-
Notifications
You must be signed in to change notification settings - Fork 297
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Provide cross compile to cjs. (#2566)
The loadModule solution didn't get much love. Maybe this cross-compile helps.
- Loading branch information
1 parent
458a4fe
commit 47d0d37
Showing
25 changed files
with
131 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
^barretenberg/.*\\.(cpp|cc|cxx|c\\+\\+|h|hpp|hxx|h\\+\\+|c|h|inl|inc|ipp|tpp|cmake)$ | ||
^barretenberg/.*CMakeLists\\.txt$ | ||
^barretenberg/.*Dockerfile.*$ | ||
^barretenberg/cpp/.*\\.(cpp|cc|cxx|c\\+\\+|h|hpp|hxx|h\\+\\+|c|h|inl|inc|ipp|tpp|cmake)$ | ||
^barretenberg/cpp/.*CMakeLists\\.txt$ | ||
^barretenberg/cpp/.*Dockerfile.*$ | ||
^barretenberg/cpp/scripts/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,4 @@ node_modules | |
Dockerfile | ||
.yarn | ||
!.yarn/releases | ||
.tsbuildinfo | ||
.tsbuildinfo* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/sh | ||
set -eu | ||
|
||
if [ -z "$SKIP_CPP_BUILD" ]; then | ||
# Build the wasms and strip debug symbols. | ||
cd ../cpp | ||
cmake --preset wasm-threads && cmake --build --preset wasm-threads | ||
cmake --preset wasm && cmake --build --preset wasm | ||
./scripts/strip-wasm.sh | ||
cd ../ts | ||
fi | ||
|
||
# Copy the wasm to its home in the bb.js dest folder. | ||
# We only need the threads wasm, as node always uses threads. | ||
# We need to take two copies for both esm and cjs builds. You can't use symlinks when publishing. | ||
# This probably isn't a big deal however due to compression. | ||
# When building the the browser bundle, both wasms are inlined directly. | ||
mkdir -p ./dest/node/barretenberg_wasm | ||
mkdir -p ./dest/node-cjs/barretenberg_wasm | ||
cp ../cpp/build-wasm-threads/bin/barretenberg.wasm ./dest/node/barretenberg_wasm/barretenberg-threads.wasm | ||
cp ../cpp/build-wasm-threads/bin/barretenberg.wasm ./dest/node-cjs/barretenberg_wasm/barretenberg-threads.wasm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/sh | ||
cat >dest/node-cjs/package.json <<!EOF | ||
{ | ||
"type": "commonjs" | ||
} | ||
!EOF | ||
|
||
DIR="./dest/node-cjs" | ||
|
||
# Iterate over all .js files in the directory | ||
for FILE in $(find "$DIR" -name "*.js"); do | ||
# Use sed to replace 'import.meta.url' with '""' | ||
sed -i 's/import\.meta\.url/""/g' "$FILE" | ||
done |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
barretenberg/ts/src/barretenberg_wasm/barretenberg-threads.wasm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../cpp/build-wasm-threads/bin/barretenberg.wasm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../cpp/build-wasm/bin/barretenberg.wasm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
barretenberg/ts/src/barretenberg_wasm/fetch_code/browser/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* eslint-disable camelcase */ | ||
export const acvmInfoJson = { | ||
language: { | ||
name: 'PLONK-CSAT', | ||
width: 3, | ||
}, | ||
opcodes_supported: ['arithmetic', 'directive', 'brillig', 'memory_init', 'memory_op'], | ||
black_box_functions_supported: [ | ||
'and', | ||
'xor', | ||
'range', | ||
'sha256', | ||
'blake2s', | ||
'keccak256', | ||
'schnorr_verify', | ||
'pedersen', | ||
'hash_to_field_128_security', | ||
'ecdsa_secp256k1', | ||
'ecdsa_secp256r1', | ||
'fixed_base_scalar_mul', | ||
'recursive_aggregation', | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"module": "CommonJS", | ||
"outDir": "dest/node-cjs", | ||
"tsBuildInfoFile": ".tsbuildinfo.cjs" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,5 +17,5 @@ | |
"rootDir": "src", | ||
"tsBuildInfoFile": ".tsbuildinfo" | ||
}, | ||
"include": ["src", "src/info.json"] | ||
"include": ["src"] | ||
} |