Skip to content

Add node-gyp setup for NodeJS bindings #43

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

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
93 changes: 65 additions & 28 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,33 +94,70 @@ jobs:
- name: Java
run: if [ -x bindings/java/run.me ]; then bindings/java/run.me; fi

- name: Node.js
nodejs-build-swig:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: actions/cache@v2
with:
path: ~/swig
key: ${{ runner.os }}-swig-pr1746
- name: Setup SWIG
run: |
if [ ! -x ~/swig/bin/swig ]; then
( git clone -b pr/new-node-fixes https://github.com/yegorich/swig;
cd swig;
./autogen.sh;
./configure --prefix=$HOME/swig;
make;
make install;
)
fi
- name: Run.me
run: |
env PATH=~/swig/bin:$PATH SWIG_LIB=~/swig/share/swig/4.0.2 \
./bindings/node.js/run.me
- name: Upload blst_wrap.cpp
uses: actions/upload-artifact@v2
with:
name: blst_wrap.cpp
path: bindings/node.js/blst_wrap.cpp
nodejs:
needs: ["nodejs-build-swig"]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
node: [10, 12]
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: ~/swig
key: ${{ runner.os }}-swig-pr1746
- name: Setup Node.js ${{matrix.node}}
uses: actions/setup-node@v1
with:
node-version: ${{matrix.node}}
- name: Download blst_wrap.cpp
uses: actions/download-artifact@v2
with:
name: blst_wrap.cpp
path: bindings/node.js/
- name: Setup node-gyp
run: npm install --global node-gyp
- name: Build with node-gyp
shell: bash
run: |
node_js=bindings/node.js
if [ -x $node_js/run.me ]; then
if [ ! -x ~/swig/bin/swig ]; then
( git clone -b pr/new-node-fixes https://github.com/yegorich/swig;
cd swig;
./autogen.sh;
./configure --prefix=$HOME/swig;
make;
make install;
)
fi
env PATH=~/swig/bin:$PATH SWIG_LIB=~/swig/share/swig/4.0.2 \
$node_js/run.me
fi
if [ -f $node_js/binding.gyp -a -f $node_js/blst_wrap.cpp ]; then
echo ---
if which npm > /dev/null 2>&1; then
npm install --global node-gyp || true
fi
if which node-gyp > /dev/null 2>&1; then
( export PATH=~/swig/bin:$PATH SWIG_LIB=~/swig/share/swig/4.0.2;
cd $node_js;
node-gyp configure;
node-gyp build;
env NODE_PATH=build/Release: node runnable.js;
)
fi
cd bindings/node.js
if [ "$RUNNER_OS" = "Linux" ]; then
export PATH=~/swig/bin:$PATH SWIG_LIB=~/swig/share/swig/4.0.2
elif [ -f blst_wrap.cpp ]; then # rename the downloaded artefact
mv -f blst_wrap.cpp blst_wrap.v12.cpp
fi
node-gyp configure
node-gyp build
env NODE_PATH=build/Release node runnable.js
2 changes: 1 addition & 1 deletion bindings/blst.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ static const app__string_view None;
#if __cplusplus < 201103L
# ifdef __GNUG__
# define nullptr __null
# else
# elif !defined(_MSVC_LANG) || _MSVC_LANG < 201103L
# define nullptr 0
# endif
#endif
Expand Down
2 changes: 1 addition & 1 deletion bindings/node.js/blst_wrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
except OSError as e:
if e.errno != 2: # not "no such file or directory"
raise e
sys.exit(e.errno) # or do something else, say ...
# sys.exit(e.errno) # or do something else, say ...

here = re.split(r'[/\\](?=[^/\\]*$)', sys.argv[0])
if len(here) == 1:
Expand Down
Loading