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
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 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,19 @@
#!/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
)

emconfigure ./configure "${configure_args[@]}" --with-ngshared LDFLAGS="${LDFLAGS}"
emmake make -j${CPU_COUNT}
emmake make install
60 changes: 60 additions & 0 deletions recipes/recipes_emscripten/ngspice/recipe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
context:
version: "40"

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

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

build:
number: 0

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

test:
commands:
- test -f $PREFIX/lib/libngspice{{ SHLIB_EXT }}

about:
home: http://ngspice.sourceforge.net
doc_url: http://ngspice.sourceforge.net/docs.html
dev_url: http://ngspice.sourceforge.net/devel.html

license: BSD-3-Clause
license_family: BSD
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