Skip to content

Commit a457d00

Browse files
committed
bindings: create native target
1 parent 569e99c commit a457d00

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
CURRENT_DIRECTORY=$(pwd)
5+
PROOF_SYSTEMS_ROOT=$(cd ../../../proof-systems && pwd)
6+
7+
cargo build \
8+
--manifest-path "${PROOF_SYSTEMS_ROOT}/Cargo.toml" \
9+
--release \
10+
-p plonk-napi
11+
12+
TARGET_ROOT=${CARGO_TARGET_DIR:-"${PROOF_SYSTEMS_ROOT}/target"}
13+
14+
case "$(uname -s)" in
15+
Darwin*) LIB_NAME="libplonk_napi.dylib" ;;
16+
MINGW*|MSYS*|CYGWIN*) LIB_NAME="plonk_napi.dll" ;;
17+
*) LIB_NAME="libplonk_napi.so" ;;
18+
esac
19+
20+
ARTIFACT="${TARGET_ROOT}/release/${LIB_NAME}"
21+
22+
if [[ ! -f "${ARTIFACT}" ]]; then
23+
echo "Failed to locate plonk-napi artifact at ${ARTIFACT}" >&2
24+
exit 1
25+
fi
26+
27+
rm -f "${CURRENT_DIRECTORY}/plonk_napi.node"
28+
cp "${ARTIFACT}" "${CURRENT_DIRECTORY}/plonk_napi.node"
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
(library
2+
(name native_backend)
3+
(public_name bindings_js.native_backend)
4+
(js_of_ocaml
5+
(flags
6+
(:include flags.sexp))
7+
(javascript_files native_backend.js))
8+
(instrumentation
9+
(backend bisect_ppx))
10+
(preprocess
11+
(pps ppx_version js_of_ocaml-ppx)))
12+
13+
(rule
14+
(targets
15+
plonk_napi.node
16+
flags.sexp)
17+
(deps
18+
build.sh
19+
../../dune-build-root
20+
(source_tree ../../../proof-systems))
21+
(locks /cargo-lock)
22+
(action
23+
(progn
24+
(setenv
25+
CARGO_TARGET_DIR
26+
"%{read:../../dune-build-root}/cargo_kimchi_native"
27+
(run bash build.sh))
28+
(write-file flags.sexp "()"))))
29+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Provides: plonk_napi
2+
var plonk_napi = require('./plonk_napi.node');
3+
4+
module.exports = plonk_napi;

0 commit comments

Comments
 (0)