Skip to content

recipes_emscripten: add ngspice #453

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
20 changes: 20 additions & 0 deletions recipes/recipes_emscripten/ngspice/build.sh
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably need to do smth like

# CLI
... -DCMAKE_PROJECT_INCLUDE=overwriteProp.cmake
# overwriteProp.cmake
set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE)
set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-s SIDE_MODULE=1")
set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "-s SIDE_MODULE=1")
set(CMAKE_STRIP FALSE)  # used by default in pybind11 on .so modules

See emscripten-core/emscripten#15276 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

otherwise cmake refused to build shared libraries with emscripten

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

set -x
set -e

# Used by autotools AX_PROG_CC_FOR_BUILD
export CC_FOR_BUILD=${CC}

./autogen.sh

configure_args=(
--prefix=${PREFIX}
--disable-debug
--disable-dependency-tracking
--disable-openmp
)

emconfigure ./configure "${configure_args[@]}" --with-ngshared LDFLAGS="${LDFLAGS}"
emmake make -j${CPU_COUNT}
emmake make install
5 changes: 5 additions & 0 deletions recipes/recipes_emscripten/ngspice/overwriteProp.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# overwriteProp.cmake
set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE)
set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-s SIDE_MODULE=1")
set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "-s SIDE_MODULE=1")
set(CMAKE_STRIP FALSE) # used by default in pybind11 on .so modules
56 changes: 56 additions & 0 deletions recipes/recipes_emscripten/ngspice/recipe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
context:
version: "44.2"

package:
name: ngspice-lib
version: '${{ version }}'

source:
url: 'https://downloads.sourceforge.net/project/ngspice/ng-spice-rework/${{ version }}/ngspice-${{ version }}.tar.gz'
sha256: 'e7dadfb7bd5474fd22409c1e5a67acdec19f77e597df68e17c5549bc1390d7fd'

build:
number: 0

requirements:
build:
- autoconf
- automake
- libtool
- make
- bison
- "${{ compiler('c') }}"
- "${{ compiler('cxx') }}"

tests:
- package_contents:
lib:
- libngspice.so

about:
homepage: http://ngspice.sourceforge.net
license: BSD-3-Clause
license_file: COPYING
summary: The open source spice simulator for electric and electronic circuits
description: |
ngspice is the open source spice simulator for electric and electronic circuits.

Such a circuit may comprise of JFETs, bipolar and MOS transistors, passive elements
like R, L, or C, diodes, transmission lines and other devices, all interconnected
in a netlist. Digital circuits are simulated as well, event driven and fast, from
single gates to complex circuits. And you may enter the combination of both analog
and digital as a mixed-signal circuit.

ngspice offers a wealth of device models for active, passive, analog, and digital
elements. Model parameters are provided by the semiconductor manufacturers.
The user add her circuits as a netlist, and the output is one or more graphs of
currents, voltages and other electrical quantities or is saved in a data file.

Note:
This build was configured with `--enable-xspice --enable-cider --enable=openmp`
See the [build script](https://git.io/JfVZX) for more specifics.

extra:
recipe-maintainers:
- proppy
- stuarteberg
Loading