From ee9cd71d02bc6908ff3579cd17e6353b00021c6f Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Mon, 24 Apr 2023 19:32:38 +0100 Subject: [PATCH 001/142] wip --- .github/workflows/wasm.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 938fa0aa181..17a71004db7 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -27,3 +27,20 @@ jobs: - name: Build wasm crate working-directory: ./crates/wasm run: ./build-wasm + + - name: Checkout noir-wasm-testing + uses: actions/checkout@v3 + with: + repository: aztecprotocol/noir-wasm-testing + path: noir-wasm-testing + + - name: Inject built wasm into noir-wasm-testing + run: | + cp -r ./crates/wasm/pkg ./noir-wasm-testing/noir_wasm + echo "noir_wasm@file:./noir_wasm" >> ./noir-wasm-testing/package.json + + - name: Install dependencies and run tests + working-directory: ./noir-wasm-testing + run: | + npm ci + npm test From 9aa82e11bed68e9e3b9ae9dc543cd1096f91d8bd Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Mon, 24 Apr 2023 19:46:39 +0100 Subject: [PATCH 002/142] Change repo link --- .github/workflows/wasm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 17a71004db7..c25cdd0247f 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -31,7 +31,7 @@ jobs: - name: Checkout noir-wasm-testing uses: actions/checkout@v3 with: - repository: aztecprotocol/noir-wasm-testing + repository: noir-lang/noir-wasm-testing path: noir-wasm-testing - name: Inject built wasm into noir-wasm-testing From 718673b10df84bba1ab8ef8008109baf4028e2ed Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Tue, 25 Apr 2023 18:49:58 +0100 Subject: [PATCH 003/142] Update workflow --- .github/workflows/wasm.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index c25cdd0247f..b8ac3b932c7 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -42,5 +42,5 @@ jobs: - name: Install dependencies and run tests working-directory: ./noir-wasm-testing run: | - npm ci - npm test + yarn install --frozen-lockfile + yarn test From 285d6ea5cb778314d3e37d661ee27ee2602ca6b1 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Tue, 25 Apr 2023 19:05:05 +0100 Subject: [PATCH 004/142] Use jq --- .github/workflows/wasm.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index b8ac3b932c7..1032d29ac48 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -2,7 +2,6 @@ name: Wasm on: [push, pull_request] -# This will cancel previous runs when a branch or PR is updated concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.ref || github.run_id }} cancel-in-progress: true @@ -34,10 +33,14 @@ jobs: repository: noir-lang/noir-wasm-testing path: noir-wasm-testing + - name: Install jq + run: sudo apt-get install -y jq + - name: Inject built wasm into noir-wasm-testing run: | cp -r ./crates/wasm/pkg ./noir-wasm-testing/noir_wasm - echo "noir_wasm@file:./noir_wasm" >> ./noir-wasm-testing/package.json + jq '.dependencies.noir_wasm = "file:./noir_wasm"' ./noir-wasm-testing/package.json > ./noir-wasm-testing/package.json.tmp + mv ./noir-wasm-testing/package.json.tmp ./noir-wasm-testing/package.json - name: Install dependencies and run tests working-directory: ./noir-wasm-testing From 309efb9f0990ded70be84686d48f44030641a203 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Wed, 26 Apr 2023 10:33:42 +0100 Subject: [PATCH 005/142] Fix yarn --- .github/workflows/wasm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 1032d29ac48..a3a198185f7 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -45,5 +45,5 @@ jobs: - name: Install dependencies and run tests working-directory: ./noir-wasm-testing run: | - yarn install --frozen-lockfile + yarn install yarn test From d555fbc6006f111f83d7fe8e7a9147c2741fc779 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Wed, 26 Apr 2023 10:56:11 +0100 Subject: [PATCH 006/142] Dependency test --- .github/workflows/wasm.yml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index a3a198185f7..d455591d372 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -42,8 +42,18 @@ jobs: jq '.dependencies.noir_wasm = "file:./noir_wasm"' ./noir-wasm-testing/package.json > ./noir-wasm-testing/package.json.tmp mv ./noir-wasm-testing/package.json.tmp ./noir-wasm-testing/package.json - - name: Install dependencies and run tests + - name: Install dependencies + working-directory: ./noir-wasm-testing + run: yarn install + + - name: Log package information working-directory: ./noir-wasm-testing run: | - yarn install - yarn test + echo "Directory contents:" + ls -la + echo "package.json contents:" + cat package.json + + - name: Run tests + working-directory: ./noir-wasm-testing + run: yarn test From 2a4355c1b3daeecdbbf7e03aa22e20a95d4b0286 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Wed, 26 Apr 2023 11:57:55 +0100 Subject: [PATCH 007/142] Create noir-script.json --- .github/workflows/wasm.yml | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index d455591d372..d5f2e836118 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -42,9 +42,16 @@ jobs: jq '.dependencies.noir_wasm = "file:./noir_wasm"' ./noir-wasm-testing/package.json > ./noir-wasm-testing/package.json.tmp mv ./noir-wasm-testing/package.json.tmp ./noir-wasm-testing/package.json + # Could probably be switched to just run update.yml on noir-wasm-testing? + - name: Run build.sh in noir-wasm-testing + working-directory: ./noir-wasm-testing + run: | + chmod +x build.sh + ./build.sh + - name: Install dependencies working-directory: ./noir-wasm-testing - run: yarn install + run: npm install - name: Log package information working-directory: ./noir-wasm-testing @@ -53,7 +60,13 @@ jobs: ls -la echo "package.json contents:" cat package.json + echo "Checking if noir-script.json exists:" + if [ -f "./src/noir-script/target/noir-script.json" ]; then + echo "File exists." + else + echo "File does not exist." + fi - name: Run tests working-directory: ./noir-wasm-testing - run: yarn test + run: npm test From ec3a04e6ac06ac852feb87fa20a91db26bd27c96 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Wed, 26 Apr 2023 12:18:30 +0100 Subject: [PATCH 008/142] Implement nix/cachix --- .github/workflows/wasm.yml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index d5f2e836118..8b535c8aec6 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -15,17 +15,15 @@ jobs: - name: Checkout sources uses: actions/checkout@v3 - - name: Setup rust toolchain - uses: dtolnay/rust-toolchain@master + - name: Setup Nix + uses: cachix/install-nix-action@v20 with: - toolchain: 1.66.0 + nix_path: nixpkgs=channel:nixos-22.11 + github_access_token: ${{ secrets.GITHUB_TOKEN }} - - name: Install wasm-pack - run: cargo install wasm-pack - - - name: Build wasm crate + - name: Build wasm crate with Nix working-directory: ./crates/wasm - run: ./build-wasm + run: nix-build wasm.nix - name: Checkout noir-wasm-testing uses: actions/checkout@v3 From f97ba8ce4dde1835a6c296075253388b3793a001 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Wed, 26 Apr 2023 12:21:30 +0100 Subject: [PATCH 009/142] Update path --- .github/workflows/wasm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 8b535c8aec6..a2d19ded08a 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -36,7 +36,7 @@ jobs: - name: Inject built wasm into noir-wasm-testing run: | - cp -r ./crates/wasm/pkg ./noir-wasm-testing/noir_wasm + cp -r ./crates/wasm/result/pkg ./noir-wasm-testing/noir_wasm jq '.dependencies.noir_wasm = "file:./noir_wasm"' ./noir-wasm-testing/package.json > ./noir-wasm-testing/package.json.tmp mv ./noir-wasm-testing/package.json.tmp ./noir-wasm-testing/package.json From f26e552d36a9b5d2a391b82489d197b6ab0a9e20 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Wed, 26 Apr 2023 12:25:41 +0100 Subject: [PATCH 010/142] Fix path --- .github/workflows/wasm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index a2d19ded08a..14bf092ccd2 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -36,7 +36,7 @@ jobs: - name: Inject built wasm into noir-wasm-testing run: | - cp -r ./crates/wasm/result/pkg ./noir-wasm-testing/noir_wasm + cp -r ./crates/wasm/result ./noir-wasm-testing/noir_wasm jq '.dependencies.noir_wasm = "file:./noir_wasm"' ./noir-wasm-testing/package.json > ./noir-wasm-testing/package.json.tmp mv ./noir-wasm-testing/package.json.tmp ./noir-wasm-testing/package.json From 65eb5d5e038bf2a8824c14c1d1997fc61660fa3d Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Wed, 26 Apr 2023 12:43:29 +0100 Subject: [PATCH 011/142] Change branch for noir-wasm-testing --- .github/workflows/wasm.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 14bf092ccd2..71d0d8ca7ac 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -30,6 +30,7 @@ jobs: with: repository: noir-lang/noir-wasm-testing path: noir-wasm-testing + ref: jb/workflow-integration - name: Install jq run: sudo apt-get install -y jq From 69bbfda6b7805d8787fc43c47aab65eceaf88804 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Wed, 26 Apr 2023 14:06:59 +0100 Subject: [PATCH 012/142] Update workflow --- .github/workflows/wasm.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 71d0d8ca7ac..61264dee4e3 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -30,7 +30,6 @@ jobs: with: repository: noir-lang/noir-wasm-testing path: noir-wasm-testing - ref: jb/workflow-integration - name: Install jq run: sudo apt-get install -y jq @@ -41,7 +40,7 @@ jobs: jq '.dependencies.noir_wasm = "file:./noir_wasm"' ./noir-wasm-testing/package.json > ./noir-wasm-testing/package.json.tmp mv ./noir-wasm-testing/package.json.tmp ./noir-wasm-testing/package.json - # Could probably be switched to just run update.yml on noir-wasm-testing? + # Could probably be switched to just run test.yml on noir-wasm-testing? - name: Run build.sh in noir-wasm-testing working-directory: ./noir-wasm-testing run: | From da7eef4f46ad8f3c8f1c3e167947a7686d181752 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Wed, 26 Apr 2023 14:43:46 +0100 Subject: [PATCH 013/142] Remove comment --- .github/workflows/wasm.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 61264dee4e3..41885aed144 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -40,7 +40,6 @@ jobs: jq '.dependencies.noir_wasm = "file:./noir_wasm"' ./noir-wasm-testing/package.json > ./noir-wasm-testing/package.json.tmp mv ./noir-wasm-testing/package.json.tmp ./noir-wasm-testing/package.json - # Could probably be switched to just run test.yml on noir-wasm-testing? - name: Run build.sh in noir-wasm-testing working-directory: ./noir-wasm-testing run: | From 29bd1e20cb3e498aff779357c8bf5d1ed1f6bb29 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Thu, 27 Apr 2023 12:20:37 +0100 Subject: [PATCH 014/142] Fix import --- .github/workflows/wasm.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 41885aed144..170ad2b470f 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -36,8 +36,8 @@ jobs: - name: Inject built wasm into noir-wasm-testing run: | - cp -r ./crates/wasm/result ./noir-wasm-testing/noir_wasm - jq '.dependencies.noir_wasm = "file:./noir_wasm"' ./noir-wasm-testing/package.json > ./noir-wasm-testing/package.json.tmp + cp -r ./crates/wasm/result ./noir-wasm-testing/@noir-lang_noir_wasm + jq '.dependencies["@noir-lang/noir_wasm"] = "file:./@noir-lang_noir_wasm"' ./noir-wasm-testing/package.json > ./noir-wasm-testing/package.json.tmp mv ./noir-wasm-testing/package.json.tmp ./noir-wasm-testing/package.json - name: Run build.sh in noir-wasm-testing From 47c5d4015e79395b566a53cbcc349e1114b98890 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Thu, 27 Apr 2023 12:25:20 +0100 Subject: [PATCH 015/142] Symlink --- .github/workflows/wasm.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 170ad2b470f..8127b8a9adb 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -37,7 +37,8 @@ jobs: - name: Inject built wasm into noir-wasm-testing run: | cp -r ./crates/wasm/result ./noir-wasm-testing/@noir-lang_noir_wasm - jq '.dependencies["@noir-lang/noir_wasm"] = "file:./@noir-lang_noir_wasm"' ./noir-wasm-testing/package.json > ./noir-wasm-testing/package.json.tmp + ln -s ./@noir-lang_noir_wasm ./noir-wasm-testing/node_modules/@noir-lang/noir_wasm + jq '.dependencies["@noir-lang/noir_wasm"] = "file:./node_modules/@noir-lang/noir_wasm"' ./noir-wasm-testing/package.json > ./noir-wasm-testing/package.json.tmp mv ./noir-wasm-testing/package.json.tmp ./noir-wasm-testing/package.json - name: Run build.sh in noir-wasm-testing From 8320455142fddd4303c460fb1574fba24a90b1bc Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Thu, 27 Apr 2023 12:28:31 +0100 Subject: [PATCH 016/142] Test fix --- .github/workflows/wasm.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 8127b8a9adb..435a0391034 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -36,8 +36,9 @@ jobs: - name: Inject built wasm into noir-wasm-testing run: | + mkdir -p ./noir-wasm-testing/node_modules/@noir-lang cp -r ./crates/wasm/result ./noir-wasm-testing/@noir-lang_noir_wasm - ln -s ./@noir-lang_noir_wasm ./noir-wasm-testing/node_modules/@noir-lang/noir_wasm + ln -s ../../@noir-lang_noir_wasm ./noir-wasm-testing/node_modules/@noir-lang/noir_wasm jq '.dependencies["@noir-lang/noir_wasm"] = "file:./node_modules/@noir-lang/noir_wasm"' ./noir-wasm-testing/package.json > ./noir-wasm-testing/package.json.tmp mv ./noir-wasm-testing/package.json.tmp ./noir-wasm-testing/package.json From 4a14b682550209382277fa4ad949ec562c2261b2 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Thu, 27 Apr 2023 12:32:57 +0100 Subject: [PATCH 017/142] Output nix result --- .github/workflows/wasm.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 435a0391034..81ab4610791 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -34,6 +34,10 @@ jobs: - name: Install jq run: sudo apt-get install -y jq + - name: Log out wasm output + working-directory: ./crates/wasm/result + run: ls -la + - name: Inject built wasm into noir-wasm-testing run: | mkdir -p ./noir-wasm-testing/node_modules/@noir-lang From d4f18d08187dcf716dd708a959a05c870fc49c88 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Thu, 27 Apr 2023 12:37:52 +0100 Subject: [PATCH 018/142] Revert and build wasm with build-wasm --- .github/workflows/wasm.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 81ab4610791..de00a4105de 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -21,9 +21,16 @@ jobs: nix_path: nixpkgs=channel:nixos-22.11 github_access_token: ${{ secrets.GITHUB_TOKEN }} - - name: Build wasm crate with Nix + # - name: Build wasm crate with Nix + # working-directory: ./crates/wasm + # run: nix-build wasm.nix + + - name: Install wasm-pack + run: cargo install wasm-pack + + - name: Build wasm crate working-directory: ./crates/wasm - run: nix-build wasm.nix + run: ./build-wasm - name: Checkout noir-wasm-testing uses: actions/checkout@v3 From d1f414813d4a92bf5d357e7ce4317d07a1dca358 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Thu, 27 Apr 2023 13:51:28 +0100 Subject: [PATCH 019/142] Fix path --- .github/workflows/wasm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index de00a4105de..b264efae6ce 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -42,7 +42,7 @@ jobs: run: sudo apt-get install -y jq - name: Log out wasm output - working-directory: ./crates/wasm/result + working-directory: crates/wasm/result run: ls -la - name: Inject built wasm into noir-wasm-testing From e181a3de691842274e84235d81e7bf625e34381e Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Thu, 27 Apr 2023 13:57:50 +0100 Subject: [PATCH 020/142] Debug --- .github/workflows/wasm.yml | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index b264efae6ce..e835ceb8cf5 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -41,31 +41,17 @@ jobs: - name: Install jq run: sudo apt-get install -y jq - - name: Log out wasm output - working-directory: crates/wasm/result - run: ls -la - - name: Inject built wasm into noir-wasm-testing run: | - mkdir -p ./noir-wasm-testing/node_modules/@noir-lang cp -r ./crates/wasm/result ./noir-wasm-testing/@noir-lang_noir_wasm - ln -s ../../@noir-lang_noir_wasm ./noir-wasm-testing/node_modules/@noir-lang/noir_wasm jq '.dependencies["@noir-lang/noir_wasm"] = "file:./node_modules/@noir-lang/noir_wasm"' ./noir-wasm-testing/package.json > ./noir-wasm-testing/package.json.tmp mv ./noir-wasm-testing/package.json.tmp ./noir-wasm-testing/package.json - - name: Run build.sh in noir-wasm-testing - working-directory: ./noir-wasm-testing - run: | - chmod +x build.sh - ./build.sh - - - name: Install dependencies - working-directory: ./noir-wasm-testing - run: npm install - - name: Log package information working-directory: ./noir-wasm-testing run: | + echo "Wasm contents:" + ls -la ./@noir-lang_noir_wasm echo "Directory contents:" ls -la echo "package.json contents:" @@ -77,6 +63,16 @@ jobs: echo "File does not exist." fi + - name: Run build.sh in noir-wasm-testing + working-directory: ./noir-wasm-testing + run: | + chmod +x build.sh + ./build.sh + + - name: Install dependencies + working-directory: ./noir-wasm-testing + run: npm install + - name: Run tests working-directory: ./noir-wasm-testing run: npm test From 27e9ac689dac41806ed0eafdca8d58f01994fcf6 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Thu, 27 Apr 2023 14:50:19 +0100 Subject: [PATCH 021/142] Test flake --- .github/workflows/wasm.yml | 16 +++++++++++----- flake.nix | 21 +++++++++++++++++++++ 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index e835ceb8cf5..209dd280935 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -21,16 +21,22 @@ jobs: nix_path: nixpkgs=channel:nixos-22.11 github_access_token: ${{ secrets.GITHUB_TOKEN }} + - name: Build noir_wasm with Nix + run: | + nix build .#wasm + echo "Build result:" + ls -la result/pkg + # - name: Build wasm crate with Nix # working-directory: ./crates/wasm # run: nix-build wasm.nix - - name: Install wasm-pack - run: cargo install wasm-pack + # - name: Install wasm-pack + # run: cargo install wasm-pack - - name: Build wasm crate - working-directory: ./crates/wasm - run: ./build-wasm + # - name: Build wasm crate + # working-directory: ./crates/wasm + # run: ./build-wasm - name: Checkout noir-wasm-testing uses: actions/checkout@v3 diff --git a/flake.nix b/flake.nix index 28859ebb2b9..014c5d7d3e8 100644 --- a/flake.nix +++ b/flake.nix @@ -187,11 +187,32 @@ nil nixpkgs-fmt llvmPackages.lldb # This ensures the right lldb is in the environment for running rust-lldb + wasm-pack ]; shellHook = '' eval "$(starship init bash)" ''; }); + + packages.wasm = pkgs.stdenv.mkDerivation rec { + pname = "noir_wasm"; + version = "1.0.0"; + + src = ./.; + + nativeBuildInputs = [ wasmPack ]; + + buildPhase = '' + wasm-pack build --scope noir-lang --target nodejs --out-dir pkg/nodejs + wasm-pack build --scope noir-lang --target web --out-dir pkg/web + ''; + + installPhase = '' + mkdir -p $out/pkg + cp -r pkg/* $out/pkg/ + ''; + }; + # packages.noir-wasm-testing = noirWasmTestingPackage; }); } From 3f5b5d23058896cdc73a69b18d57da56ca6acabe Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Thu, 27 Apr 2023 14:59:09 +0100 Subject: [PATCH 022/142] Fix package --- flake.nix | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index 014c5d7d3e8..361a2ad0ad2 100644 --- a/flake.nix +++ b/flake.nix @@ -201,7 +201,7 @@ src = ./.; - nativeBuildInputs = [ wasmPack ]; + nativeBuildInputs = [ pkgs.wasm-pack ]; buildPhase = '' wasm-pack build --scope noir-lang --target nodejs --out-dir pkg/nodejs @@ -213,6 +213,5 @@ cp -r pkg/* $out/pkg/ ''; }; - # packages.noir-wasm-testing = noirWasmTestingPackage; }); } From 541e96f147596e61e4c402d7662055798630089c Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Thu, 27 Apr 2023 15:33:32 +0100 Subject: [PATCH 023/142] implements nix to build-wasm, testing --- .github/workflows/wasm.yml | 18 +++++++-------- crates/wasm/build-wasm | 46 ++++++++++++++++++++++++++++++++------ 2 files changed, 48 insertions(+), 16 deletions(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 209dd280935..2c22f0f05d9 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -21,15 +21,15 @@ jobs: nix_path: nixpkgs=channel:nixos-22.11 github_access_token: ${{ secrets.GITHUB_TOKEN }} - - name: Build noir_wasm with Nix - run: | - nix build .#wasm - echo "Build result:" - ls -la result/pkg - - # - name: Build wasm crate with Nix - # working-directory: ./crates/wasm - # run: nix-build wasm.nix + # - name: Build noir_wasm with Nix + # run: | + # nix build .#wasm + # echo "Build result:" + # ls -la result/pkg + + - name: Build wasm crate with Nix + working-directory: ./crates/wasm + run: nix-build wasm.nix # - name: Install wasm-pack # run: cargo install wasm-pack diff --git a/crates/wasm/build-wasm b/crates/wasm/build-wasm index 6b574b71d03..a8f85e58635 100755 --- a/crates/wasm/build-wasm +++ b/crates/wasm/build-wasm @@ -1,14 +1,15 @@ #!/usr/bin/env bash -# Clear out the existing build artifacts as these aren't automatically removed by wasm-pack. +# Clear out the existing build artifacts as these aren't automatically removed. if [ -d ./pkg/ ]; then rm -rf ./pkg/ fi -# Build the new wasm package -wasm-pack build --scope noir-lang --target nodejs --out-dir pkg/nodejs +# Build the wasm crate using Nix +nix-build wasm.nix -wasm-pack build --scope noir-lang --target web --out-dir pkg/web +# Copy the built wasm to the pkg directory +cp -r ./result pkg COMMIT_SHORT=$(git rev-parse --short HEAD) VERSION_APPENDIX="" @@ -18,8 +19,39 @@ else VERSION_APPENDIX="-NOGIT" fi -jq -s '.[0] * .[1]' pkg/nodejs/package.json pkg/web/package.json | jq '.files = ["nodejs", "web", "package.json"]' | jq ".version += \"$VERSION_APPENDIX\"" | jq '.main = "./nodejs/" + .main | .module = "./web/" + .module | .types = "./web/" + .types | .peerDependencies = { "@noir-lang/noir-source-resolver": "1.1.2" }' | tee ./pkg/package.json +# Generate the package.json file +jq -n \ + --arg version_appendix "$VERSION_APPENDIX" \ + --arg main "./nodejs/noir_wasm.js" \ + --arg module "./web/noir_wasm.js", \ + --arg types "./web/noir_wasm.d.ts" + '{ + "name": "@noir-lang/noir_wasm", + "collaborators": [ + "The Noir Team " + ], + "version": "0.4.1" + $version_appendix, + "main": $main, + "module": $module, + "types": $types, + "files": [ + "nodejs", + "web", + "package.json" + ], + "peerDependencies": { + "@noir-lang/noir-source-resolver": "1.1.2" + }, + "repository": { + "type": "git", + "url": "https://github.com/noir-lang/noir_wasm.git" + }, + }' > ./pkg/package.json -rm pkg/nodejs/package.json pkg/nodejs/README.md pkg/nodejs/.gitignore +# Log the contents of the pkg directory +echo "Contents of pkg directory:" +ls -la ./pkg -rm pkg/web/package.json pkg/web/README.md pkg/web/.gitignore \ No newline at end of file +# Log the contents of the generated package.json file +echo "Contents of package.json:" +cat ./pkg/package.json \ No newline at end of file From dfc34409092068805a650631fde4be9fdaee7594 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Thu, 27 Apr 2023 15:36:19 +0100 Subject: [PATCH 024/142] Run build-wasm --- .github/workflows/wasm.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 2c22f0f05d9..30eb3355aa5 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -27,16 +27,16 @@ jobs: # echo "Build result:" # ls -la result/pkg - - name: Build wasm crate with Nix - working-directory: ./crates/wasm - run: nix-build wasm.nix + # - name: Build wasm crate with Nix + # working-directory: ./crates/wasm + # run: nix-build wasm.nix # - name: Install wasm-pack # run: cargo install wasm-pack - # - name: Build wasm crate - # working-directory: ./crates/wasm - # run: ./build-wasm + - name: Build wasm + working-directory: ./crates/wasm + run: ./build-wasm - name: Checkout noir-wasm-testing uses: actions/checkout@v3 From b7abfee1119ef47a6ba98b5b63281aaf6e9e53df Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Thu, 27 Apr 2023 15:41:21 +0100 Subject: [PATCH 025/142] Change path --- crates/wasm/build-wasm | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/crates/wasm/build-wasm b/crates/wasm/build-wasm index a8f85e58635..b16dc2608dc 100755 --- a/crates/wasm/build-wasm +++ b/crates/wasm/build-wasm @@ -1,15 +1,18 @@ #!/usr/bin/env bash # Clear out the existing build artifacts as these aren't automatically removed. -if [ -d ./pkg/ ]; then - rm -rf ./pkg/ +if [ -d ./pkg_output/ ]; then + rm -rf ./pkg_output/ fi # Build the wasm crate using Nix nix-build wasm.nix -# Copy the built wasm to the pkg directory -cp -r ./result pkg +# Create the pkg_output directory +mkdir -p pkg_output + +# Copy the built wasm to the pkg_output directory +cp -r ./result pkg_output COMMIT_SHORT=$(git rev-parse --short HEAD) VERSION_APPENDIX="" @@ -46,12 +49,12 @@ jq -n \ "type": "git", "url": "https://github.com/noir-lang/noir_wasm.git" }, - }' > ./pkg/package.json + }' > ./pkg_output/package.json -# Log the contents of the pkg directory -echo "Contents of pkg directory:" -ls -la ./pkg +# Log the contents of the pkg_output directory +echo "Contents of pkg_output directory:" +ls -la ./pkg_output # Log the contents of the generated package.json file echo "Contents of package.json:" -cat ./pkg/package.json \ No newline at end of file +cat ./pkg_output/package.json From 6f9711dad5a66cf7196b8db05437445f4dd6a0fa Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Thu, 27 Apr 2023 15:55:01 +0100 Subject: [PATCH 026/142] Update bash file --- crates/wasm/build-wasm | 69 +++++++++++++++--------------------------- 1 file changed, 24 insertions(+), 45 deletions(-) diff --git a/crates/wasm/build-wasm b/crates/wasm/build-wasm index b16dc2608dc..ffeec8985a1 100755 --- a/crates/wasm/build-wasm +++ b/crates/wasm/build-wasm @@ -1,18 +1,26 @@ #!/usr/bin/env bash -# Clear out the existing build artifacts as these aren't automatically removed. -if [ -d ./pkg_output/ ]; then - rm -rf ./pkg_output/ +# Clear out the existing build artifacts as these aren't automatically removed by wasm-pack. +if [ -d ./pkg/ ]; then + rm -rf ./pkg/ fi -# Build the wasm crate using Nix -nix-build wasm.nix +# Enter the nix-shell environment +nix-shell wasm.nix --run ' -# Create the pkg_output directory -mkdir -p pkg_output +# Build the new wasm package +cargo build --target wasm32-unknown-unknown --release -# Copy the built wasm to the pkg_output directory -cp -r ./result pkg_output +# Create output directories for nodejs and web +mkdir -p pkg/nodejs pkg/web + +# Copy the generated wasm to the output directories +cp target/wasm32-unknown-unknown/release/noir_wasm.wasm pkg/nodejs +cp target/wasm32-unknown-unknown/release/noir_wasm.wasm pkg/web + +# Generate the respective package.json files using wasm-bindgen +wasm-bindgen --out-dir pkg/nodejs --target nodejs target/wasm32-unknown-unknown/release/noir_wasm.wasm +wasm-bindgen --out-dir pkg/web --target web target/wasm32-unknown-unknown/release/noir_wasm.wasm COMMIT_SHORT=$(git rev-parse --short HEAD) VERSION_APPENDIX="" @@ -22,39 +30,10 @@ else VERSION_APPENDIX="-NOGIT" fi -# Generate the package.json file -jq -n \ - --arg version_appendix "$VERSION_APPENDIX" \ - --arg main "./nodejs/noir_wasm.js" \ - --arg module "./web/noir_wasm.js", \ - --arg types "./web/noir_wasm.d.ts" - '{ - "name": "@noir-lang/noir_wasm", - "collaborators": [ - "The Noir Team " - ], - "version": "0.4.1" + $version_appendix, - "main": $main, - "module": $module, - "types": $types, - "files": [ - "nodejs", - "web", - "package.json" - ], - "peerDependencies": { - "@noir-lang/noir-source-resolver": "1.1.2" - }, - "repository": { - "type": "git", - "url": "https://github.com/noir-lang/noir_wasm.git" - }, - }' > ./pkg_output/package.json - -# Log the contents of the pkg_output directory -echo "Contents of pkg_output directory:" -ls -la ./pkg_output - -# Log the contents of the generated package.json file -echo "Contents of package.json:" -cat ./pkg_output/package.json +jq -s ".[0] * .[1]" pkg/nodejs/package.json pkg/web/package.json | jq ".files = [\"nodejs\", \"web\", \"package.json\"]" | jq ".version += \"$VERSION_APPENDIX\"" | jq ".main = \"./nodejs/\" + .main | .module = \"./web/\" + .module | .types = \"./web/\" + .types | .peerDependencies = { \"@noir-lang/noir-source-resolver\": \"1.1.2\" }" | tee ./pkg/package.json + +rm pkg/nodejs/package.json pkg/nodejs/README.md pkg/nodejs/.gitignore + +rm pkg/web/package.json pkg/web/README.md pkg/web/.gitignore +' + From 318dac69acb85560504c990ad47c1d1d8a35fd4f Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Thu, 27 Apr 2023 15:56:23 +0100 Subject: [PATCH 027/142] Output contents --- crates/wasm/build-wasm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crates/wasm/build-wasm b/crates/wasm/build-wasm index ffeec8985a1..cadd72484b5 100755 --- a/crates/wasm/build-wasm +++ b/crates/wasm/build-wasm @@ -37,3 +37,11 @@ rm pkg/nodejs/package.json pkg/nodejs/README.md pkg/nodejs/.gitignore rm pkg/web/package.json pkg/web/README.md pkg/web/.gitignore ' + +# Log the contents of the pkg directory +echo "Contents of pkg directory:" +ls -la ./pkg + +# Log the contents of the generated package.json file +echo "Contents of package.json:" +cat ./pkg/package.json \ No newline at end of file From 0c5a7c6afa12b71ab636dac7a8321aafe88da00e Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Thu, 27 Apr 2023 16:22:48 +0100 Subject: [PATCH 028/142] Use wasm-pack again --- crates/wasm/build-wasm | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/crates/wasm/build-wasm b/crates/wasm/build-wasm index cadd72484b5..3666d078c45 100755 --- a/crates/wasm/build-wasm +++ b/crates/wasm/build-wasm @@ -9,18 +9,8 @@ fi nix-shell wasm.nix --run ' # Build the new wasm package -cargo build --target wasm32-unknown-unknown --release - -# Create output directories for nodejs and web -mkdir -p pkg/nodejs pkg/web - -# Copy the generated wasm to the output directories -cp target/wasm32-unknown-unknown/release/noir_wasm.wasm pkg/nodejs -cp target/wasm32-unknown-unknown/release/noir_wasm.wasm pkg/web - -# Generate the respective package.json files using wasm-bindgen -wasm-bindgen --out-dir pkg/nodejs --target nodejs target/wasm32-unknown-unknown/release/noir_wasm.wasm -wasm-bindgen --out-dir pkg/web --target web target/wasm32-unknown-unknown/release/noir_wasm.wasm +wasm-pack build --scope noir-lang --target nodejs --out-dir pkg/nodejs +wasm-pack build --scope noir-lang --target web --out-dir pkg/web COMMIT_SHORT=$(git rev-parse --short HEAD) VERSION_APPENDIX="" @@ -30,14 +20,13 @@ else VERSION_APPENDIX="-NOGIT" fi -jq -s ".[0] * .[1]" pkg/nodejs/package.json pkg/web/package.json | jq ".files = [\"nodejs\", \"web\", \"package.json\"]" | jq ".version += \"$VERSION_APPENDIX\"" | jq ".main = \"./nodejs/\" + .main | .module = \"./web/\" + .module | .types = \"./web/\" + .types | .peerDependencies = { \"@noir-lang/noir-source-resolver\": \"1.1.2\" }" | tee ./pkg/package.json +jq -s ".[0] * .[1]" pkg/nodejs/package.json pkg/web/package.json | jq ".files = [\"nodejs\", \"web\", \"package.json\"]" | jq ".version += \"$VERSION_APPENDIX\"" | jq ".main = \"./nodejs/noir_wasm.js\" | .module = \"./web/noir_wasm.js\" | .types = \"./web/noir_wasm.d.ts\" | .peerDependencies = { \"@noir-lang/noir-source-resolver\": \"1.1.2\" }" | tee ./pkg/package.json rm pkg/nodejs/package.json pkg/nodejs/README.md pkg/nodejs/.gitignore rm pkg/web/package.json pkg/web/README.md pkg/web/.gitignore ' - # Log the contents of the pkg directory echo "Contents of pkg directory:" ls -la ./pkg From a60c94cd40539b5a8b09bde521aa6c3c9a2842a1 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Thu, 27 Apr 2023 16:32:08 +0100 Subject: [PATCH 029/142] Change quotes --- crates/wasm/build-wasm | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/crates/wasm/build-wasm b/crates/wasm/build-wasm index 3666d078c45..fdba94728f7 100755 --- a/crates/wasm/build-wasm +++ b/crates/wasm/build-wasm @@ -6,26 +6,26 @@ if [ -d ./pkg/ ]; then fi # Enter the nix-shell environment -nix-shell wasm.nix --run ' +nix-shell wasm.nix --run " # Build the new wasm package wasm-pack build --scope noir-lang --target nodejs --out-dir pkg/nodejs wasm-pack build --scope noir-lang --target web --out-dir pkg/web COMMIT_SHORT=$(git rev-parse --short HEAD) -VERSION_APPENDIX="" -if [ -n "$COMMIT_SHORT" ]; then - VERSION_APPENDIX="-$COMMIT_SHORT" +VERSION_APPENDIX='' +if [ -n \"$COMMIT_SHORT\" ]; then + VERSION_APPENDIX=\"-$COMMIT_SHORT\" else - VERSION_APPENDIX="-NOGIT" + VERSION_APPENDIX=\"-NOGIT\" fi -jq -s ".[0] * .[1]" pkg/nodejs/package.json pkg/web/package.json | jq ".files = [\"nodejs\", \"web\", \"package.json\"]" | jq ".version += \"$VERSION_APPENDIX\"" | jq ".main = \"./nodejs/noir_wasm.js\" | .module = \"./web/noir_wasm.js\" | .types = \"./web/noir_wasm.d.ts\" | .peerDependencies = { \"@noir-lang/noir-source-resolver\": \"1.1.2\" }" | tee ./pkg/package.json +jq -s '.[0] * .[1]' pkg/nodejs/package.json pkg/web/package.json | jq '.files = [\"nodejs\", \"web\", \"package.json\"]' | jq \".version += \\\"$VERSION_APPENDIX\\\"\" | jq '.main = \"./nodejs/noir_wasm.js\" | .module = \"./web/noir_wasm.js\" | .types = \"./web/noir_wasm.d.ts\" | .peerDependencies = { \"@noir-lang/noir-source-resolver\": \"1.1.2\" }' | tee ./pkg/package.json rm pkg/nodejs/package.json pkg/nodejs/README.md pkg/nodejs/.gitignore rm pkg/web/package.json pkg/web/README.md pkg/web/.gitignore -' +" # Log the contents of the pkg directory echo "Contents of pkg directory:" @@ -33,4 +33,4 @@ ls -la ./pkg # Log the contents of the generated package.json file echo "Contents of package.json:" -cat ./pkg/package.json \ No newline at end of file +cat ./pkg/package.json From ad318b17e7fefb1d1d5f637eec7016e8127c5f72 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Thu, 27 Apr 2023 16:40:49 +0100 Subject: [PATCH 030/142] Revert build-wasm --- crates/wasm/build-wasm | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/crates/wasm/build-wasm b/crates/wasm/build-wasm index fdba94728f7..6b574b71d03 100755 --- a/crates/wasm/build-wasm +++ b/crates/wasm/build-wasm @@ -5,32 +5,21 @@ if [ -d ./pkg/ ]; then rm -rf ./pkg/ fi -# Enter the nix-shell environment -nix-shell wasm.nix --run " - # Build the new wasm package wasm-pack build --scope noir-lang --target nodejs --out-dir pkg/nodejs + wasm-pack build --scope noir-lang --target web --out-dir pkg/web COMMIT_SHORT=$(git rev-parse --short HEAD) -VERSION_APPENDIX='' -if [ -n \"$COMMIT_SHORT\" ]; then - VERSION_APPENDIX=\"-$COMMIT_SHORT\" +VERSION_APPENDIX="" +if [ -n "$COMMIT_SHORT" ]; then + VERSION_APPENDIX="-$COMMIT_SHORT" else - VERSION_APPENDIX=\"-NOGIT\" + VERSION_APPENDIX="-NOGIT" fi -jq -s '.[0] * .[1]' pkg/nodejs/package.json pkg/web/package.json | jq '.files = [\"nodejs\", \"web\", \"package.json\"]' | jq \".version += \\\"$VERSION_APPENDIX\\\"\" | jq '.main = \"./nodejs/noir_wasm.js\" | .module = \"./web/noir_wasm.js\" | .types = \"./web/noir_wasm.d.ts\" | .peerDependencies = { \"@noir-lang/noir-source-resolver\": \"1.1.2\" }' | tee ./pkg/package.json +jq -s '.[0] * .[1]' pkg/nodejs/package.json pkg/web/package.json | jq '.files = ["nodejs", "web", "package.json"]' | jq ".version += \"$VERSION_APPENDIX\"" | jq '.main = "./nodejs/" + .main | .module = "./web/" + .module | .types = "./web/" + .types | .peerDependencies = { "@noir-lang/noir-source-resolver": "1.1.2" }' | tee ./pkg/package.json rm pkg/nodejs/package.json pkg/nodejs/README.md pkg/nodejs/.gitignore -rm pkg/web/package.json pkg/web/README.md pkg/web/.gitignore -" - -# Log the contents of the pkg directory -echo "Contents of pkg directory:" -ls -la ./pkg - -# Log the contents of the generated package.json file -echo "Contents of package.json:" -cat ./pkg/package.json +rm pkg/web/package.json pkg/web/README.md pkg/web/.gitignore \ No newline at end of file From 352f1dccfc7be9e04cdd8be39ae918c755d01446 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Thu, 27 Apr 2023 16:46:55 +0100 Subject: [PATCH 031/142] Update yml to use flake --- .github/workflows/wasm.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 30eb3355aa5..fa90af4c842 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -34,9 +34,19 @@ jobs: # - name: Install wasm-pack # run: cargo install wasm-pack - - name: Build wasm + # - name: Build wasm + # working-directory: ./crates/wasm + # run: ./build-wasm + + - name: Build noir_wasm with Nix flakes + run: | + nix build .#wasm + echo "Build result:" + ls -la result/pkg + + - name: Copy wasm build result working-directory: ./crates/wasm - run: ./build-wasm + run: cp -r ./result ./pkg - name: Checkout noir-wasm-testing uses: actions/checkout@v3 From e571cd3e5ecfae433a7d3ccebe02a91f5a551372 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Tue, 9 May 2023 10:30:10 +0100 Subject: [PATCH 032/142] Fix relative path --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 361a2ad0ad2..893b70f970b 100644 --- a/flake.nix +++ b/flake.nix @@ -199,7 +199,7 @@ pname = "noir_wasm"; version = "1.0.0"; - src = ./.; + src = ./crates/wasm; nativeBuildInputs = [ pkgs.wasm-pack ]; From 706e47aef0ff0a5e71ad3a1b82388df516559d44 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Tue, 9 May 2023 10:33:20 +0100 Subject: [PATCH 033/142] Print directory --- flake.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/flake.nix b/flake.nix index 893b70f970b..069bf2647aa 100644 --- a/flake.nix +++ b/flake.nix @@ -204,6 +204,10 @@ nativeBuildInputs = [ pkgs.wasm-pack ]; buildPhase = '' + echo "Current working directory:" + pwd + echo "Contents of the source directory:" + ls -la wasm-pack build --scope noir-lang --target nodejs --out-dir pkg/nodejs wasm-pack build --scope noir-lang --target web --out-dir pkg/web ''; From 9db36dac508de48c66e1e949e0cf7d3f07a02ea7 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Tue, 9 May 2023 10:35:49 +0100 Subject: [PATCH 034/142] Update path for wasm-pack --- flake.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index 069bf2647aa..d4ad73fc0a1 100644 --- a/flake.nix +++ b/flake.nix @@ -208,8 +208,8 @@ pwd echo "Contents of the source directory:" ls -la - wasm-pack build --scope noir-lang --target nodejs --out-dir pkg/nodejs - wasm-pack build --scope noir-lang --target web --out-dir pkg/web + wasm-pack build --scope noir-lang --target nodejs --out-dir $PWD/pkg/nodejs + wasm-pack build --scope noir-lang --target web --out-dir $PWD/pkg/web ''; installPhase = '' From f82a5627cf96308c400d1e245ce00db44b8050a9 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Tue, 9 May 2023 10:45:26 +0100 Subject: [PATCH 035/142] Add chmod --- .github/workflows/wasm.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index fa90af4c842..bb39bfa76c5 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -40,6 +40,7 @@ jobs: - name: Build noir_wasm with Nix flakes run: | + chmod +x ./crates/wasm/build-wasm nix build .#wasm echo "Build result:" ls -la result/pkg From cdf3fee71968f27245289414c239ff3b7d8113c2 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Tue, 9 May 2023 10:48:01 +0100 Subject: [PATCH 036/142] Update buildPhase --- .github/workflows/wasm.yml | 4 +++- flake.nix | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index bb39bfa76c5..2e7a3f5f7fa 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -38,9 +38,11 @@ jobs: # working-directory: ./crates/wasm # run: ./build-wasm + - name: Make build-wasm script executable + run: chmod +x ./crates/wasm/build-wasm + - name: Build noir_wasm with Nix flakes run: | - chmod +x ./crates/wasm/build-wasm nix build .#wasm echo "Build result:" ls -la result/pkg diff --git a/flake.nix b/flake.nix index d4ad73fc0a1..278f13b1bf4 100644 --- a/flake.nix +++ b/flake.nix @@ -208,8 +208,7 @@ pwd echo "Contents of the source directory:" ls -la - wasm-pack build --scope noir-lang --target nodejs --out-dir $PWD/pkg/nodejs - wasm-pack build --scope noir-lang --target web --out-dir $PWD/pkg/web + ./build-wasm ''; installPhase = '' From a9753f0e8c2da694bcadd4f1ed4345e57e693d1b Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Tue, 9 May 2023 10:53:16 +0100 Subject: [PATCH 037/142] Try to fix path --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 278f13b1bf4..7911da61b25 100644 --- a/flake.nix +++ b/flake.nix @@ -208,7 +208,7 @@ pwd echo "Contents of the source directory:" ls -la - ./build-wasm + ${pkgs.bash}/bin/bash ./build-wasm ''; installPhase = '' From 3b4d8100b92fcd01e9be3838ba093582c3b1e3c8 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Tue, 9 May 2023 11:06:37 +0100 Subject: [PATCH 038/142] Fix jq path --- crates/wasm/build-wasm | 4 ++-- crates/wasm/wasm.nix | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/crates/wasm/build-wasm b/crates/wasm/build-wasm index 6b574b71d03..6739c6d3c9d 100755 --- a/crates/wasm/build-wasm +++ b/crates/wasm/build-wasm @@ -18,8 +18,8 @@ else VERSION_APPENDIX="-NOGIT" fi -jq -s '.[0] * .[1]' pkg/nodejs/package.json pkg/web/package.json | jq '.files = ["nodejs", "web", "package.json"]' | jq ".version += \"$VERSION_APPENDIX\"" | jq '.main = "./nodejs/" + .main | .module = "./web/" + .module | .types = "./web/" + .types | .peerDependencies = { "@noir-lang/noir-source-resolver": "1.1.2" }' | tee ./pkg/package.json +${JQ_PATH} -s '.[0] * .[1]' pkg/nodejs/package.json pkg/web/package.json | ${JQ_PATH} '.files = ["nodejs", "web", "package.json"]' | ${JQ_PATH} ".version += \"$VERSION_APPENDIX\"" | ${JQ_PATH} '.main = "./nodejs/" + .main | .module = "./web/" + .module | .types = "./web/" + .types | .peerDependencies = { "@noir-lang/noir-source-resolver": "1.1.2" }' | tee ./pkg/package.json rm pkg/nodejs/package.json pkg/nodejs/README.md pkg/nodejs/.gitignore -rm pkg/web/package.json pkg/web/README.md pkg/web/.gitignore \ No newline at end of file +rm pkg/web/package.json pkg/web/README.md pkg/web/.gitignore diff --git a/crates/wasm/wasm.nix b/crates/wasm/wasm.nix index 332db3de0cc..1a918fe76f9 100644 --- a/crates/wasm/wasm.nix +++ b/crates/wasm/wasm.nix @@ -6,7 +6,6 @@ let # NixOS 22.05 pinnedPkgs = fetchTarball "https://github.com/NixOS/nixpkgs/archive/0938d73bb143f4ae037143572f11f4338c7b2d1c.tar.gz"; - pkgs = import pinnedPkgs { overlays = [ (import rustOverlay) ]; @@ -18,10 +17,11 @@ let }; in pkgs.mkShell.override { stdenv = llvm11stdenv;} { - + nativeBuildInputs = with pkgs; [ binaryen jq + coreutils ]; buildInputs = with pkgs; [ @@ -30,4 +30,8 @@ pkgs.mkShell.override { stdenv = llvm11stdenv;} { wasm-pack ]; -} \ No newline at end of file + shellHook = '' + export JQ_PATH="${pkgs.jq}/bin/jq" + ''; + +} From b9a7278f3e4dfce8724f4d0f74c5c18058b8e430 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Tue, 9 May 2023 11:15:09 +0100 Subject: [PATCH 039/142] Fix jq --- crates/wasm/build-wasm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/wasm/build-wasm b/crates/wasm/build-wasm index 6739c6d3c9d..5cbda1fec0f 100755 --- a/crates/wasm/build-wasm +++ b/crates/wasm/build-wasm @@ -18,7 +18,7 @@ else VERSION_APPENDIX="-NOGIT" fi -${JQ_PATH} -s '.[0] * .[1]' pkg/nodejs/package.json pkg/web/package.json | ${JQ_PATH} '.files = ["nodejs", "web", "package.json"]' | ${JQ_PATH} ".version += \"$VERSION_APPENDIX\"" | ${JQ_PATH} '.main = "./nodejs/" + .main | .module = "./web/" + .module | .types = "./web/" + .types | .peerDependencies = { "@noir-lang/noir-source-resolver": "1.1.2" }' | tee ./pkg/package.json +${JQ_PATH} -s '.[0] * .[1]' pkg/nodejs/package.json pkg/web/package.json | ${JQ_PATH} --argjson version_appendix "\"$VERSION_APPENDIX\"" '. * { version: .version + $version_appendix, files: ["nodejs", "web", "package.json"], main: "./nodejs/" + .main, module: "./web/" + .module, types: "./web/" + .types, peerDependencies: { "@noir-lang/noir-source-resolver": "1.1.2" }}' | tee ./pkg/package.json rm pkg/nodejs/package.json pkg/nodejs/README.md pkg/nodejs/.gitignore From 3eb51346cf51ebcbacf5c409f112cf5070f40fb5 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Tue, 9 May 2023 11:17:39 +0100 Subject: [PATCH 040/142] Fix missing commands --- crates/wasm/build-wasm | 2 +- crates/wasm/wasm.nix | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/crates/wasm/build-wasm b/crates/wasm/build-wasm index 5cbda1fec0f..47d8f0cf16b 100755 --- a/crates/wasm/build-wasm +++ b/crates/wasm/build-wasm @@ -18,7 +18,7 @@ else VERSION_APPENDIX="-NOGIT" fi -${JQ_PATH} -s '.[0] * .[1]' pkg/nodejs/package.json pkg/web/package.json | ${JQ_PATH} --argjson version_appendix "\"$VERSION_APPENDIX\"" '. * { version: .version + $version_appendix, files: ["nodejs", "web", "package.json"], main: "./nodejs/" + .main, module: "./web/" + .module, types: "./web/" + .types, peerDependencies: { "@noir-lang/noir-source-resolver": "1.1.2" }}' | tee ./pkg/package.json +jq -s '.[0] * .[1]' pkg/nodejs/package.json pkg/web/package.json | jq --argjson version_appendix "\"$VERSION_APPENDIX\"" '. * { version: .version + $version_appendix, files: ["nodejs", "web", "package.json"], main: "./nodejs/" + .main, module: "./web/" + .module, types: "./web/" + .types, peerDependencies: { "@noir-lang/noir-source-resolver": "1.1.2" }}' | tee ./pkg/package.json rm pkg/nodejs/package.json pkg/nodejs/README.md pkg/nodejs/.gitignore diff --git a/crates/wasm/wasm.nix b/crates/wasm/wasm.nix index 1a918fe76f9..1357f40245a 100644 --- a/crates/wasm/wasm.nix +++ b/crates/wasm/wasm.nix @@ -4,7 +4,6 @@ let rustOverlay = builtins.fetchTarball "https://github.com/oxalica/rust-overlay/archive/master.tar.gz"; llvm11stdenv = pkgs.llvmPackages_10.stdenv; - # NixOS 22.05 pinnedPkgs = fetchTarball "https://github.com/NixOS/nixpkgs/archive/0938d73bb143f4ae037143572f11f4338c7b2d1c.tar.gz"; pkgs = import pinnedPkgs { @@ -17,11 +16,11 @@ let }; in pkgs.mkShell.override { stdenv = llvm11stdenv;} { - + nativeBuildInputs = with pkgs; [ binaryen jq - coreutils + git ]; buildInputs = with pkgs; [ @@ -30,8 +29,4 @@ pkgs.mkShell.override { stdenv = llvm11stdenv;} { wasm-pack ]; - shellHook = '' - export JQ_PATH="${pkgs.jq}/bin/jq" - ''; - } From 8baf91f1b1973999659db024c3aa34b52af575cb Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Tue, 9 May 2023 11:19:35 +0100 Subject: [PATCH 041/142] Change buildInputs --- crates/wasm/wasm.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/wasm/wasm.nix b/crates/wasm/wasm.nix index 1357f40245a..57ed8168d13 100644 --- a/crates/wasm/wasm.nix +++ b/crates/wasm/wasm.nix @@ -19,14 +19,14 @@ pkgs.mkShell.override { stdenv = llvm11stdenv;} { nativeBuildInputs = with pkgs; [ binaryen - jq - git ]; buildInputs = with pkgs; [ pkg-config rustbin wasm-pack + git + jq ]; } From 0d5f80a021006359663b7e51289f85456fda2250 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Tue, 9 May 2023 11:24:51 +0100 Subject: [PATCH 042/142] Fix missing improts --- crates/wasm/wasm.nix | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/crates/wasm/wasm.nix b/crates/wasm/wasm.nix index 57ed8168d13..462b722bd3d 100644 --- a/crates/wasm/wasm.nix +++ b/crates/wasm/wasm.nix @@ -15,13 +15,10 @@ let targets = [ "wasm32-unknown-unknown" ]; }; in -pkgs.mkShell.override { stdenv = llvm11stdenv;} { - - nativeBuildInputs = with pkgs; [ - binaryen - ]; +(pkgs.mkShell.override { stdenv = llvm11stdenv;}).overrideAttrs(oldAttrs: { buildInputs = with pkgs; [ + binaryen pkg-config rustbin wasm-pack @@ -29,4 +26,4 @@ pkgs.mkShell.override { stdenv = llvm11stdenv;} { jq ]; -} +}) From ec20f093d1017dabae03bc7a7e5dacea7f6fa317 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Tue, 9 May 2023 11:27:31 +0100 Subject: [PATCH 043/142] Install jq --- .github/workflows/wasm.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 2e7a3f5f7fa..f56a798a82b 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -38,6 +38,9 @@ jobs: # working-directory: ./crates/wasm # run: ./build-wasm + - name: Install jq + run: sudo apt-get install -y jq + - name: Make build-wasm script executable run: chmod +x ./crates/wasm/build-wasm @@ -57,9 +60,6 @@ jobs: repository: noir-lang/noir-wasm-testing path: noir-wasm-testing - - name: Install jq - run: sudo apt-get install -y jq - - name: Inject built wasm into noir-wasm-testing run: | cp -r ./crates/wasm/result ./noir-wasm-testing/@noir-lang_noir_wasm From 1af678a8ce524c676c315dc8e568d5e97e721979 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Tue, 9 May 2023 14:13:21 +0100 Subject: [PATCH 044/142] Fix imports --- crates/wasm/wasm.nix | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/crates/wasm/wasm.nix b/crates/wasm/wasm.nix index 462b722bd3d..8dcd487a98f 100644 --- a/crates/wasm/wasm.nix +++ b/crates/wasm/wasm.nix @@ -15,15 +15,14 @@ let targets = [ "wasm32-unknown-unknown" ]; }; in -(pkgs.mkShell.override { stdenv = llvm11stdenv;}).overrideAttrs(oldAttrs: { - - buildInputs = with pkgs; [ - binaryen +pkgs.mkShell.overrideAttrs (oldAttrs: { + buildInputs = with pkgs; oldAttrs.buildInputs ++ [ pkg-config rustbin wasm-pack + binaryen git jq ]; - + stdenv = llvm11stdenv; }) From 96d55ee02960b20c53ff2a0fa1d8c24163f13cf9 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Tue, 9 May 2023 14:35:03 +0100 Subject: [PATCH 045/142] Add dependencies to flake nix file --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 7911da61b25..0ed55bc2122 100644 --- a/flake.nix +++ b/flake.nix @@ -201,7 +201,7 @@ src = ./crates/wasm; - nativeBuildInputs = [ pkgs.wasm-pack ]; + nativeBuildInputs = [ pkgs.wasm-pack pkgs.git pkgs.jq ]; buildPhase = '' echo "Current working directory:" From be4ca190bb5397999c5fc5eba99f9418e79df35d Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Tue, 9 May 2023 14:38:33 +0100 Subject: [PATCH 046/142] Debug errors --- crates/wasm/build-wasm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/wasm/build-wasm b/crates/wasm/build-wasm index 47d8f0cf16b..88103b94df5 100755 --- a/crates/wasm/build-wasm +++ b/crates/wasm/build-wasm @@ -7,8 +7,12 @@ fi # Build the new wasm package wasm-pack build --scope noir-lang --target nodejs --out-dir pkg/nodejs +echo "NodeJS build complete. Directory contents:" +ls -la pkg/nodejs wasm-pack build --scope noir-lang --target web --out-dir pkg/web +echo "Web build complete. Directory contents:" +ls -la pkg/web COMMIT_SHORT=$(git rev-parse --short HEAD) VERSION_APPENDIX="" From 54e62936775bc4e1e71b001c506ed2c953bcbc1e Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Tue, 9 May 2023 14:41:08 +0100 Subject: [PATCH 047/142] Debugging wip --- crates/wasm/build-wasm | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/crates/wasm/build-wasm b/crates/wasm/build-wasm index 88103b94df5..f44161e3c20 100755 --- a/crates/wasm/build-wasm +++ b/crates/wasm/build-wasm @@ -10,20 +10,20 @@ wasm-pack build --scope noir-lang --target nodejs --out-dir pkg/nodejs echo "NodeJS build complete. Directory contents:" ls -la pkg/nodejs -wasm-pack build --scope noir-lang --target web --out-dir pkg/web -echo "Web build complete. Directory contents:" -ls -la pkg/web +# wasm-pack build --scope noir-lang --target web --out-dir pkg/web +# echo "Web build complete. Directory contents:" +# ls -la pkg/web -COMMIT_SHORT=$(git rev-parse --short HEAD) -VERSION_APPENDIX="" -if [ -n "$COMMIT_SHORT" ]; then - VERSION_APPENDIX="-$COMMIT_SHORT" -else - VERSION_APPENDIX="-NOGIT" -fi +# COMMIT_SHORT=$(git rev-parse --short HEAD) +# VERSION_APPENDIX="" +# if [ -n "$COMMIT_SHORT" ]; then +# VERSION_APPENDIX="-$COMMIT_SHORT" +# else +# VERSION_APPENDIX="-NOGIT" +# fi -jq -s '.[0] * .[1]' pkg/nodejs/package.json pkg/web/package.json | jq --argjson version_appendix "\"$VERSION_APPENDIX\"" '. * { version: .version + $version_appendix, files: ["nodejs", "web", "package.json"], main: "./nodejs/" + .main, module: "./web/" + .module, types: "./web/" + .types, peerDependencies: { "@noir-lang/noir-source-resolver": "1.1.2" }}' | tee ./pkg/package.json +# jq -s '.[0] * .[1]' pkg/nodejs/package.json pkg/web/package.json | jq --argjson version_appendix "\"$VERSION_APPENDIX\"" '. * { version: .version + $version_appendix, files: ["nodejs", "web", "package.json"], main: "./nodejs/" + .main, module: "./web/" + .module, types: "./web/" + .types, peerDependencies: { "@noir-lang/noir-source-resolver": "1.1.2" }}' | tee ./pkg/package.json -rm pkg/nodejs/package.json pkg/nodejs/README.md pkg/nodejs/.gitignore +# rm pkg/nodejs/package.json pkg/nodejs/README.md pkg/nodejs/.gitignore -rm pkg/web/package.json pkg/web/README.md pkg/web/.gitignore +# rm pkg/web/package.json pkg/web/README.md pkg/web/.gitignore From 9cdf4500b5e83548dfd463a80aeda87c9b9c7663 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Tue, 9 May 2023 14:43:57 +0100 Subject: [PATCH 048/142] Add install wasm step --- .github/workflows/wasm.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index f56a798a82b..e4523f99d08 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -31,8 +31,8 @@ jobs: # working-directory: ./crates/wasm # run: nix-build wasm.nix - # - name: Install wasm-pack - # run: cargo install wasm-pack + - name: Install wasm-pack + run: cargo install wasm-pack # - name: Build wasm # working-directory: ./crates/wasm From b43a9668e1c9ae89b7e6c8f8e2532177acca5c01 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Tue, 9 May 2023 14:56:42 +0100 Subject: [PATCH 049/142] Debugging --- crates/wasm/build-wasm | 26 +++++++++++++------------- flake.nix | 4 ++++ 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/crates/wasm/build-wasm b/crates/wasm/build-wasm index f44161e3c20..88103b94df5 100755 --- a/crates/wasm/build-wasm +++ b/crates/wasm/build-wasm @@ -10,20 +10,20 @@ wasm-pack build --scope noir-lang --target nodejs --out-dir pkg/nodejs echo "NodeJS build complete. Directory contents:" ls -la pkg/nodejs -# wasm-pack build --scope noir-lang --target web --out-dir pkg/web -# echo "Web build complete. Directory contents:" -# ls -la pkg/web +wasm-pack build --scope noir-lang --target web --out-dir pkg/web +echo "Web build complete. Directory contents:" +ls -la pkg/web -# COMMIT_SHORT=$(git rev-parse --short HEAD) -# VERSION_APPENDIX="" -# if [ -n "$COMMIT_SHORT" ]; then -# VERSION_APPENDIX="-$COMMIT_SHORT" -# else -# VERSION_APPENDIX="-NOGIT" -# fi +COMMIT_SHORT=$(git rev-parse --short HEAD) +VERSION_APPENDIX="" +if [ -n "$COMMIT_SHORT" ]; then + VERSION_APPENDIX="-$COMMIT_SHORT" +else + VERSION_APPENDIX="-NOGIT" +fi -# jq -s '.[0] * .[1]' pkg/nodejs/package.json pkg/web/package.json | jq --argjson version_appendix "\"$VERSION_APPENDIX\"" '. * { version: .version + $version_appendix, files: ["nodejs", "web", "package.json"], main: "./nodejs/" + .main, module: "./web/" + .module, types: "./web/" + .types, peerDependencies: { "@noir-lang/noir-source-resolver": "1.1.2" }}' | tee ./pkg/package.json +jq -s '.[0] * .[1]' pkg/nodejs/package.json pkg/web/package.json | jq --argjson version_appendix "\"$VERSION_APPENDIX\"" '. * { version: .version + $version_appendix, files: ["nodejs", "web", "package.json"], main: "./nodejs/" + .main, module: "./web/" + .module, types: "./web/" + .types, peerDependencies: { "@noir-lang/noir-source-resolver": "1.1.2" }}' | tee ./pkg/package.json -# rm pkg/nodejs/package.json pkg/nodejs/README.md pkg/nodejs/.gitignore +rm pkg/nodejs/package.json pkg/nodejs/README.md pkg/nodejs/.gitignore -# rm pkg/web/package.json pkg/web/README.md pkg/web/.gitignore +rm pkg/web/package.json pkg/web/README.md pkg/web/.gitignore diff --git a/flake.nix b/flake.nix index 0ed55bc2122..83a7c7c6e9f 100644 --- a/flake.nix +++ b/flake.nix @@ -204,11 +204,15 @@ nativeBuildInputs = [ pkgs.wasm-pack pkgs.git pkgs.jq ]; buildPhase = '' + echo "Contents of the build-wasm script:" + cat ./build-wasm echo "Current working directory:" pwd echo "Contents of the source directory:" ls -la ${pkgs.bash}/bin/bash ./build-wasm + echo "Contents of the pkg directory after running build-wasm:" + ls -la pkg ''; installPhase = '' From b9f3ebbf07dcbd60a63d640226f5c5ccf2c8f07b Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Tue, 9 May 2023 14:58:33 +0100 Subject: [PATCH 050/142] Remove wasm-pack installation on workflow --- .github/workflows/wasm.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index e4523f99d08..b09b2c8864b 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -31,8 +31,8 @@ jobs: # working-directory: ./crates/wasm # run: nix-build wasm.nix - - name: Install wasm-pack - run: cargo install wasm-pack + # - name: Install wasm-pack + # run: cargo install wasm-pack # - name: Build wasm # working-directory: ./crates/wasm From f81d0a944dcceb847c1c979e951614b8f6f77ab4 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Tue, 9 May 2023 15:04:39 +0100 Subject: [PATCH 051/142] Ensure logging --- flake.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/flake.nix b/flake.nix index 83a7c7c6e9f..80ee67ca5b7 100644 --- a/flake.nix +++ b/flake.nix @@ -204,6 +204,7 @@ nativeBuildInputs = [ pkgs.wasm-pack pkgs.git pkgs.jq ]; buildPhase = '' + set -x echo "Contents of the build-wasm script:" cat ./build-wasm echo "Current working directory:" From b8838ff5a13ad9bf1f391a7c34b027f1fb6a23a3 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Tue, 9 May 2023 15:16:42 +0100 Subject: [PATCH 052/142] Output full logs to a file --- .github/workflows/wasm.yml | 7 +++++-- flake.nix | 19 +++++++++---------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index b09b2c8864b..8208c5bab39 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -38,8 +38,8 @@ jobs: # working-directory: ./crates/wasm # run: ./build-wasm - - name: Install jq - run: sudo apt-get install -y jq + # - name: Install jq + # run: sudo apt-get install -y jq - name: Make build-wasm script executable run: chmod +x ./crates/wasm/build-wasm @@ -50,6 +50,9 @@ jobs: echo "Build result:" ls -la result/pkg + - name: Print build log + run: cat result/build.log + - name: Copy wasm build result working-directory: ./crates/wasm run: cp -r ./result ./pkg diff --git a/flake.nix b/flake.nix index 80ee67ca5b7..f6ae7a81995 100644 --- a/flake.nix +++ b/flake.nix @@ -202,23 +202,22 @@ src = ./crates/wasm; nativeBuildInputs = [ pkgs.wasm-pack pkgs.git pkgs.jq ]; - + buildPhase = '' set -x - echo "Contents of the build-wasm script:" - cat ./build-wasm - echo "Current working directory:" - pwd - echo "Contents of the source directory:" - ls -la - ${pkgs.bash}/bin/bash ./build-wasm - echo "Contents of the pkg directory after running build-wasm:" - ls -la pkg + echo "Contents of the build-wasm script:" >&2 + cat ./build-wasm >&2 + echo "Current working directory:" >&2 + pwd >&2 + echo "Contents of the source directory:" >&2 + ls -la >&2 + ${pkgs.bash}/bin/bash ./build-wasm 2>&1 | tee build.log ''; installPhase = '' mkdir -p $out/pkg cp -r pkg/* $out/pkg/ + cp build.log $out/ ''; }; }); From 93f92424bb7bfc9815eead2b7eba0f110c8e7f4b Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Tue, 9 May 2023 15:52:30 +0100 Subject: [PATCH 053/142] Log when failure happens --- .github/workflows/wasm.yml | 5 +++-- flake.nix | 7 ++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 8208c5bab39..f63176cd477 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -50,8 +50,9 @@ jobs: echo "Build result:" ls -la result/pkg - - name: Print build log - run: cat result/build.log + - name: Print build log if build failed + if: ${{ failure() }} + run: cat $(nix-build --no-link -A packages.wasm.default)./build.log || true - name: Copy wasm build result working-directory: ./crates/wasm diff --git a/flake.nix b/flake.nix index f6ae7a81995..518b472bc67 100644 --- a/flake.nix +++ b/flake.nix @@ -211,7 +211,12 @@ pwd >&2 echo "Contents of the source directory:" >&2 ls -la >&2 - ${pkgs.bash}/bin/bash ./build-wasm 2>&1 | tee build.log + + if ! ${pkgs.bash}/bin/bash ./build-wasm 2>&1 | tee build.log; then + echo "Build failed. Copying build.log before exiting." >&2 + cp build.log $out/ + exit 1 + fi ''; installPhase = '' From 762d01004be2dcaa883865812567161f8eabc815 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Tue, 9 May 2023 15:54:24 +0100 Subject: [PATCH 054/142] Typo --- .github/workflows/wasm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index f63176cd477..1380a6c5bc4 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -52,7 +52,7 @@ jobs: - name: Print build log if build failed if: ${{ failure() }} - run: cat $(nix-build --no-link -A packages.wasm.default)./build.log || true + run: cat $(nix-build --no-link -A packages.default.wasm)./build.log || true - name: Copy wasm build result working-directory: ./crates/wasm From ec1a13376291e48741efa40a8daa10b2ac4683e1 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Tue, 9 May 2023 15:56:15 +0100 Subject: [PATCH 055/142] Fix logging --- .github/workflows/wasm.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 1380a6c5bc4..751247f7d6f 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -51,8 +51,10 @@ jobs: ls -la result/pkg - name: Print build log if build failed - if: ${{ failure() }} - run: cat $(nix-build --no-link -A packages.default.wasm)./build.log || true + if: ${{ failure() }} + run: | + system=$(nix eval --raw nixpkgs#localSystem.system) + cat $(nix-build --no-link -A packages.$system.wasm)./build.log || true - name: Copy wasm build result working-directory: ./crates/wasm From 78ec81e7ab928f267597582a091d9564fa99ccbc Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Tue, 9 May 2023 16:22:07 +0100 Subject: [PATCH 056/142] Remove workflow step --- .github/workflows/wasm.yml | 6 ------ flake.nix | 9 ++++----- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 751247f7d6f..116530b8703 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -50,12 +50,6 @@ jobs: echo "Build result:" ls -la result/pkg - - name: Print build log if build failed - if: ${{ failure() }} - run: | - system=$(nix eval --raw nixpkgs#localSystem.system) - cat $(nix-build --no-link -A packages.$system.wasm)./build.log || true - - name: Copy wasm build result working-directory: ./crates/wasm run: cp -r ./result ./pkg diff --git a/flake.nix b/flake.nix index 518b472bc67..6c3c90a9def 100644 --- a/flake.nix +++ b/flake.nix @@ -202,7 +202,7 @@ src = ./crates/wasm; nativeBuildInputs = [ pkgs.wasm-pack pkgs.git pkgs.jq ]; - + buildPhase = '' set -x echo "Contents of the build-wasm script:" >&2 @@ -211,10 +211,10 @@ pwd >&2 echo "Contents of the source directory:" >&2 ls -la >&2 - + if ! ${pkgs.bash}/bin/bash ./build-wasm 2>&1 | tee build.log; then - echo "Build failed. Copying build.log before exiting." >&2 - cp build.log $out/ + echo "Build failed. Printing build.log:" + cat build.log exit 1 fi ''; @@ -222,7 +222,6 @@ installPhase = '' mkdir -p $out/pkg cp -r pkg/* $out/pkg/ - cp build.log $out/ ''; }; }); From f6db72fbe7230ccb4b4fc30cc8046690ad29b869 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Tue, 9 May 2023 19:27:12 +0100 Subject: [PATCH 057/142] Debug wip --- .github/workflows/wasm.yml | 10 +++++----- flake.nix | 22 +++++++++------------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 116530b8703..a53092fd8b8 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -44,11 +44,11 @@ jobs: - name: Make build-wasm script executable run: chmod +x ./crates/wasm/build-wasm - - name: Build noir_wasm with Nix flakes - run: | - nix build .#wasm - echo "Build result:" - ls -la result/pkg + - name: Build wasm package + run: nix build .#packages.wasm --keep-failed || true + + - name: Print build log if build failed + run: cat ./result-build/log/builder.log || true - name: Copy wasm build result working-directory: ./crates/wasm diff --git a/flake.nix b/flake.nix index 6c3c90a9def..7df650ea32e 100644 --- a/flake.nix +++ b/flake.nix @@ -203,20 +203,16 @@ nativeBuildInputs = [ pkgs.wasm-pack pkgs.git pkgs.jq ]; - buildPhase = '' + buildPhase = '' set -x - echo "Contents of the build-wasm script:" >&2 - cat ./build-wasm >&2 - echo "Current working directory:" >&2 - pwd >&2 - echo "Contents of the source directory:" >&2 - ls -la >&2 - - if ! ${pkgs.bash}/bin/bash ./build-wasm 2>&1 | tee build.log; then - echo "Build failed. Printing build.log:" - cat build.log - exit 1 - fi + echo "Contents of the build-wasm script:" + cat ./build-wasm + echo "Current working directory:" + pwd + echo "Contents of the source directory:" + ls -la + + ${pkgs.bash}/bin/bash ./build-wasm 2>&1 | tee build.log ''; installPhase = '' From 0135edb1644cf209f45e1959dc607553e30cc05e Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Tue, 9 May 2023 20:31:58 +0100 Subject: [PATCH 058/142] Debug wip --- .github/workflows/wasm.yml | 3 --- flake.nix | 23 ++++++++++++++--------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index a53092fd8b8..595a825b07c 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -47,9 +47,6 @@ jobs: - name: Build wasm package run: nix build .#packages.wasm --keep-failed || true - - name: Print build log if build failed - run: cat ./result-build/log/builder.log || true - - name: Copy wasm build result working-directory: ./crates/wasm run: cp -r ./result ./pkg diff --git a/flake.nix b/flake.nix index 7df650ea32e..1ce1a5f7172 100644 --- a/flake.nix +++ b/flake.nix @@ -203,21 +203,26 @@ nativeBuildInputs = [ pkgs.wasm-pack pkgs.git pkgs.jq ]; - buildPhase = '' + buildPhase = '' set -x - echo "Contents of the build-wasm script:" - cat ./build-wasm - echo "Current working directory:" - pwd - echo "Contents of the source directory:" - ls -la - - ${pkgs.bash}/bin/bash ./build-wasm 2>&1 | tee build.log + echo "Contents of the build-wasm script:" >&2 + cat ./build-wasm >&2 + echo "Current working directory:" >&2 + pwd >&2 + echo "Contents of the source directory:" >&2 + ls -la >&2 + + ${pkgs.bash}/bin/bash ./build-wasm 2>&1 | tee build.log || { + echo "Build failed, printing build.log:"; + cat build.log; + exit 1; + } ''; installPhase = '' mkdir -p $out/pkg cp -r pkg/* $out/pkg/ + cp build.log $out/ ''; }; }); From 990fef42e0dfa1ad8a4f66477d42a68629131c94 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Tue, 9 May 2023 20:32:40 +0100 Subject: [PATCH 059/142] Stop on failure --- .github/workflows/wasm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 595a825b07c..e95d93c1316 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -45,7 +45,7 @@ jobs: run: chmod +x ./crates/wasm/build-wasm - name: Build wasm package - run: nix build .#packages.wasm --keep-failed || true + run: nix build .#packages.wasm --keep-failed - name: Copy wasm build result working-directory: ./crates/wasm From 8207a499a2055e2fe69d6a61568dc9365de42356 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Tue, 9 May 2023 20:36:15 +0100 Subject: [PATCH 060/142] Trying to output debug information --- .github/workflows/wasm.yml | 113 +++++++++++++++++-------------------- 1 file changed, 51 insertions(+), 62 deletions(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index e95d93c1316..88481c76da5 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -21,74 +21,63 @@ jobs: nix_path: nixpkgs=channel:nixos-22.11 github_access_token: ${{ secrets.GITHUB_TOKEN }} - # - name: Build noir_wasm with Nix - # run: | - # nix build .#wasm - # echo "Build result:" - # ls -la result/pkg + - name: Build wasm package + run: nix build .#packages.wasm || true - # - name: Build wasm crate with Nix - # working-directory: ./crates/wasm - # run: nix-build wasm.nix + - name: Print build.log if build failed + run: | + if [ -d result ]; then + echo "Build successful." + else + echo "Build failed. Printing build.log:" + cat ./result/build.log || true + fi - # - name: Install wasm-pack - # run: cargo install wasm-pack + # - name: Build wasm package + # run: nix build .#packages.wasm --keep-failed - # - name: Build wasm + # - name: Copy wasm build result # working-directory: ./crates/wasm - # run: ./build-wasm - - # - name: Install jq - # run: sudo apt-get install -y jq - - - name: Make build-wasm script executable - run: chmod +x ./crates/wasm/build-wasm - - - name: Build wasm package - run: nix build .#packages.wasm --keep-failed - - - name: Copy wasm build result - working-directory: ./crates/wasm - run: cp -r ./result ./pkg + # run: cp -r ./result ./pkg - - name: Checkout noir-wasm-testing - uses: actions/checkout@v3 - with: - repository: noir-lang/noir-wasm-testing - path: noir-wasm-testing - - - name: Inject built wasm into noir-wasm-testing - run: | - cp -r ./crates/wasm/result ./noir-wasm-testing/@noir-lang_noir_wasm - jq '.dependencies["@noir-lang/noir_wasm"] = "file:./node_modules/@noir-lang/noir_wasm"' ./noir-wasm-testing/package.json > ./noir-wasm-testing/package.json.tmp - mv ./noir-wasm-testing/package.json.tmp ./noir-wasm-testing/package.json + # - name: Checkout noir-wasm-testing + # uses: actions/checkout@v3 + # with: + # repository: noir-lang/noir-wasm-testing + # path: noir-wasm-testing - - name: Log package information - working-directory: ./noir-wasm-testing - run: | - echo "Wasm contents:" - ls -la ./@noir-lang_noir_wasm - echo "Directory contents:" - ls -la - echo "package.json contents:" - cat package.json - echo "Checking if noir-script.json exists:" - if [ -f "./src/noir-script/target/noir-script.json" ]; then - echo "File exists." - else - echo "File does not exist." - fi + # - name: Inject built wasm into noir-wasm-testing + # run: | + # cp -r ./crates/wasm/result ./noir-wasm-testing/@noir-lang_noir_wasm + # jq '.dependencies["@noir-lang/noir_wasm"] = "file:./node_modules/@noir-lang/noir_wasm"' ./noir-wasm-testing/package.json > ./noir-wasm-testing/package.json.tmp + # mv ./noir-wasm-testing/package.json.tmp ./noir-wasm-testing/package.json - - name: Run build.sh in noir-wasm-testing - working-directory: ./noir-wasm-testing - run: | - chmod +x build.sh - ./build.sh + # - name: Log package information + # working-directory: ./noir-wasm-testing + # run: | + # echo "Wasm contents:" + # ls -la ./@noir-lang_noir_wasm + # echo "Directory contents:" + # ls -la + # echo "package.json contents:" + # cat package.json + # echo "Checking if noir-script.json exists:" + # if [ -f "./src/noir-script/target/noir-script.json" ]; then + # echo "File exists." + # else + # echo "File does not exist." + # fi + + # - name: Run build.sh in noir-wasm-testing + # working-directory: ./noir-wasm-testing + # run: | + # chmod +x build.sh + # ./build.sh - - name: Install dependencies - working-directory: ./noir-wasm-testing - run: npm install + # - name: Install dependencies + # working-directory: ./noir-wasm-testing + # run: npm install - - name: Run tests - working-directory: ./noir-wasm-testing - run: npm test + # - name: Run tests + # working-directory: ./noir-wasm-testing + # run: npm test From 87ed37f1489986e81bab58c48c8d7604a7edbc53 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Tue, 9 May 2023 20:37:48 +0100 Subject: [PATCH 061/142] Fix path --- .github/workflows/wasm.yml | 2 +- flake.nix | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 88481c76da5..21737b17d0d 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -30,7 +30,7 @@ jobs: echo "Build successful." else echo "Build failed. Printing build.log:" - cat ./result/build.log || true + cat ./result-dev-shell/build.log || true fi # - name: Build wasm package diff --git a/flake.nix b/flake.nix index 1ce1a5f7172..8f9b4be6c64 100644 --- a/flake.nix +++ b/flake.nix @@ -212,11 +212,7 @@ echo "Contents of the source directory:" >&2 ls -la >&2 - ${pkgs.bash}/bin/bash ./build-wasm 2>&1 | tee build.log || { - echo "Build failed, printing build.log:"; - cat build.log; - exit 1; - } + ${pkgs.bash}/bin/bash ./build-wasm 2>&1 | tee $out/build.log ''; installPhase = '' From 275cbb3f073b13487d6f003989ad35b5facae7eb Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Tue, 9 May 2023 20:39:52 +0100 Subject: [PATCH 062/142] Fix output file --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 8f9b4be6c64..2c04b615ccf 100644 --- a/flake.nix +++ b/flake.nix @@ -212,7 +212,7 @@ echo "Contents of the source directory:" >&2 ls -la >&2 - ${pkgs.bash}/bin/bash ./build-wasm 2>&1 | tee $out/build.log + ${pkgs.bash}/bin/bash ./build-wasm 2>&1 | tee build.log ''; installPhase = '' From 3174bdf300b3555142adbfee764fc9b7a8303fbe Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Tue, 9 May 2023 20:49:20 +0100 Subject: [PATCH 063/142] Fix --- .github/workflows/wasm.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 21737b17d0d..222ccfb7a4b 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -29,8 +29,10 @@ jobs: if [ -d result ]; then echo "Build successful." else - echo "Build failed. Printing build.log:" - cat ./result-dev-shell/build.log || true + echo "Build failed. Trying to locate build.log:" + find . -name build.log + echo "Printing the build.log (if found):" + find . -name build.log -exec cat {} \; || true fi # - name: Build wasm package From bb2e50f0acc29f76fdc8271d280143ae524aba97 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Tue, 9 May 2023 20:51:40 +0100 Subject: [PATCH 064/142] Use xtracefd flag --- flake.nix | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/flake.nix b/flake.nix index 2c04b615ccf..83b27500ce9 100644 --- a/flake.nix +++ b/flake.nix @@ -204,7 +204,10 @@ nativeBuildInputs = [ pkgs.wasm-pack pkgs.git pkgs.jq ]; buildPhase = '' + BASH_XTRACEFD=19 set -x + exec 19>build.log + echo "Contents of the build-wasm script:" >&2 cat ./build-wasm >&2 echo "Current working directory:" >&2 @@ -212,13 +215,10 @@ echo "Contents of the source directory:" >&2 ls -la >&2 - ${pkgs.bash}/bin/bash ./build-wasm 2>&1 | tee build.log - ''; + ${pkgs.bash}/bin/bash ./build-wasm - installPhase = '' - mkdir -p $out/pkg - cp -r pkg/* $out/pkg/ - cp build.log $out/ + set +x + exec 19>&- ''; }; }); From e81792fdb11ac9a8cb42316c0cb3407113d473f9 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Tue, 9 May 2023 20:53:24 +0100 Subject: [PATCH 065/142] Accidentally removed installPhase --- flake.nix | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 83b27500ce9..5278d45345d 100644 --- a/flake.nix +++ b/flake.nix @@ -206,7 +206,7 @@ buildPhase = '' BASH_XTRACEFD=19 set -x - exec 19>build.log + exec 19>${src}/build.log echo "Contents of the build-wasm script:" >&2 cat ./build-wasm >&2 @@ -220,6 +220,12 @@ set +x exec 19>&- ''; + + installPhase = '' + mkdir -p $out/pkg + cp -r pkg/* $out/pkg/ + cp build.log $out/ + ''; }; }); } From 8ffcf7baed7168ed494dfb98379b8d9b11967a6c Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Tue, 9 May 2023 20:54:57 +0100 Subject: [PATCH 066/142] Change workflow --- .github/workflows/wasm.yml | 6 ++---- flake.nix | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 222ccfb7a4b..2cf947b59f3 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -29,10 +29,8 @@ jobs: if [ -d result ]; then echo "Build successful." else - echo "Build failed. Trying to locate build.log:" - find . -name build.log - echo "Printing the build.log (if found):" - find . -name build.log -exec cat {} \; || true + echo "Build failed. Printing build.log:" + cat crates/wasm/build.log || true fi # - name: Build wasm package diff --git a/flake.nix b/flake.nix index 5278d45345d..05de9a254fe 100644 --- a/flake.nix +++ b/flake.nix @@ -202,7 +202,7 @@ src = ./crates/wasm; nativeBuildInputs = [ pkgs.wasm-pack pkgs.git pkgs.jq ]; - + buildPhase = '' BASH_XTRACEFD=19 set -x @@ -220,7 +220,7 @@ set +x exec 19>&- ''; - + installPhase = '' mkdir -p $out/pkg cp -r pkg/* $out/pkg/ From ad3bae9a283af4fb12e199a6844ea53128e1d22f Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Tue, 9 May 2023 20:56:32 +0100 Subject: [PATCH 067/142] Print from flake --- .github/workflows/wasm.yml | 9 --------- flake.nix | 4 ++-- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 2cf947b59f3..b2a3eef8385 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -24,15 +24,6 @@ jobs: - name: Build wasm package run: nix build .#packages.wasm || true - - name: Print build.log if build failed - run: | - if [ -d result ]; then - echo "Build successful." - else - echo "Build failed. Printing build.log:" - cat crates/wasm/build.log || true - fi - # - name: Build wasm package # run: nix build .#packages.wasm --keep-failed diff --git a/flake.nix b/flake.nix index 05de9a254fe..0f6c85f2298 100644 --- a/flake.nix +++ b/flake.nix @@ -202,7 +202,7 @@ src = ./crates/wasm; nativeBuildInputs = [ pkgs.wasm-pack pkgs.git pkgs.jq ]; - + buildPhase = '' BASH_XTRACEFD=19 set -x @@ -215,7 +215,7 @@ echo "Contents of the source directory:" >&2 ls -la >&2 - ${pkgs.bash}/bin/bash ./build-wasm + ${pkgs.bash}/bin/bash ./build-wasm || (cat ${src}/build.log && exit 1) set +x exec 19>&- From 3d0102390e0ce3f124ab4811e9e429df40415ffa Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Tue, 9 May 2023 21:01:48 +0100 Subject: [PATCH 068/142] Revert build stage --- .github/workflows/wasm.yml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index b2a3eef8385..68e83bd2c5a 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -21,8 +21,20 @@ jobs: nix_path: nixpkgs=channel:nixos-22.11 github_access_token: ${{ secrets.GITHUB_TOKEN }} - - name: Build wasm package - run: nix build .#packages.wasm || true + - name: Build noir_wasm with Nix flakes + run: | + nix build .#wasm || true + echo "Build result:" + ls -la result/pkg + + - name: Print build.log if build failed + run: | + if [ -d result ]; then + echo "Build successful." + else + echo "Build failed. Printing build.log:" + cat crates/wasm/build.log || true + fi # - name: Build wasm package # run: nix build .#packages.wasm --keep-failed From 49561a7a63883a4a4280a2418441a29a2145bbba Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Tue, 9 May 2023 21:03:13 +0100 Subject: [PATCH 069/142] Remove output from noir_wasm build stage --- .github/workflows/wasm.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 68e83bd2c5a..822139e7b6a 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -24,8 +24,6 @@ jobs: - name: Build noir_wasm with Nix flakes run: | nix build .#wasm || true - echo "Build result:" - ls -la result/pkg - name: Print build.log if build failed run: | From 0a91470c393ebbe425ca9ec98beba17744d994af Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Tue, 9 May 2023 21:04:50 +0100 Subject: [PATCH 070/142] Revert logging --- .github/workflows/wasm.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 822139e7b6a..5482722c817 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -30,8 +30,10 @@ jobs: if [ -d result ]; then echo "Build successful." else - echo "Build failed. Printing build.log:" - cat crates/wasm/build.log || true + echo "Build failed. Trying to locate build.log:" + find . -name build.log + echo "Printing the build.log (if found):" + find . -name build.log -exec cat {} \; || true fi # - name: Build wasm package From 6bad6e0adf85d2366c81428950c051b0f6dcb9af Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Wed, 10 May 2023 10:27:42 +0100 Subject: [PATCH 071/142] Further logging tests --- .github/workflows/wasm.yml | 4 ++++ flake.nix | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 5482722c817..6570cfae567 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -24,6 +24,10 @@ jobs: - name: Build noir_wasm with Nix flakes run: | nix build .#wasm || true + extra_nix_config: | + experimental-features = nix-command flakes + access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} + max-log-lines = 100 - name: Print build.log if build failed run: | diff --git a/flake.nix b/flake.nix index 0f6c85f2298..02db36821ac 100644 --- a/flake.nix +++ b/flake.nix @@ -203,7 +203,7 @@ nativeBuildInputs = [ pkgs.wasm-pack pkgs.git pkgs.jq ]; - buildPhase = '' + buildPhase = '' BASH_XTRACEFD=19 set -x exec 19>${src}/build.log @@ -217,6 +217,12 @@ ${pkgs.bash}/bin/bash ./build-wasm || (cat ${src}/build.log && exit 1) + # Check if build.log is present and not empty + if [ ! -s ${src}/build.log ]; then + echo "Error: build.log not found or empty" >&2 + exit 1 + fi + set +x exec 19>&- ''; From 6128843785cf4fc2c36704d90ba66edac7dc566a Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Wed, 10 May 2023 10:31:02 +0100 Subject: [PATCH 072/142] Trying experimental features --- .github/workflows/wasm.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 6570cfae567..6917a4d6e70 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -23,11 +23,10 @@ jobs: - name: Build noir_wasm with Nix flakes run: | - nix build .#wasm || true - extra_nix_config: | - experimental-features = nix-command flakes - access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} - max-log-lines = 100 + echo 'experimental-features = nix-command flakes' | sudo tee -a /etc/nix/nix.conf + echo 'access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}' > nix-tokens.conf + echo 'max-log-lines = 100' | sudo tee -a /etc/nix/nix.conf + sudo env NIX_CONF_DIR=$(pwd) nix build .#wasm || true - name: Print build.log if build failed run: | From d654235ffafbfbe2e5648f5d3a8b8ecbef025087 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Wed, 10 May 2023 10:32:59 +0100 Subject: [PATCH 073/142] Other config --- .github/workflows/wasm.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 6917a4d6e70..ecf80d4c8a5 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -20,13 +20,14 @@ jobs: with: nix_path: nixpkgs=channel:nixos-22.11 github_access_token: ${{ secrets.GITHUB_TOKEN }} + extra_nix_config: | + experimental-features = nix-command flakes + access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} + max-log-lines = 100 - - name: Build noir_wasm with Nix flakes + - name: Build and output the log run: | - echo 'experimental-features = nix-command flakes' | sudo tee -a /etc/nix/nix.conf - echo 'access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}' > nix-tokens.conf - echo 'max-log-lines = 100' | sudo tee -a /etc/nix/nix.conf - sudo env NIX_CONF_DIR=$(pwd) nix build .#wasm || true + nix build .#wasm || true - name: Print build.log if build failed run: | From 595d4e57a44880fcd4d3d442d2ceb90b300e3466 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Wed, 10 May 2023 10:34:52 +0100 Subject: [PATCH 074/142] Remove experimental config --- .github/workflows/wasm.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index ecf80d4c8a5..24657d64dd1 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -20,10 +20,6 @@ jobs: with: nix_path: nixpkgs=channel:nixos-22.11 github_access_token: ${{ secrets.GITHUB_TOKEN }} - extra_nix_config: | - experimental-features = nix-command flakes - access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} - max-log-lines = 100 - name: Build and output the log run: | From 54f4dd544749735f08096d91fb629585a1907dba Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Wed, 10 May 2023 10:39:04 +0100 Subject: [PATCH 075/142] Remove logs --- crates/wasm/build-wasm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/wasm/build-wasm b/crates/wasm/build-wasm index 88103b94df5..90b3079107b 100755 --- a/crates/wasm/build-wasm +++ b/crates/wasm/build-wasm @@ -8,11 +8,11 @@ fi # Build the new wasm package wasm-pack build --scope noir-lang --target nodejs --out-dir pkg/nodejs echo "NodeJS build complete. Directory contents:" -ls -la pkg/nodejs +# ls -la pkg/nodejs wasm-pack build --scope noir-lang --target web --out-dir pkg/web echo "Web build complete. Directory contents:" -ls -la pkg/web +# ls -la pkg/web COMMIT_SHORT=$(git rev-parse --short HEAD) VERSION_APPENDIX="" From 9c9b40bab97d2db86686bb539249ab885f9e6f0a Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Wed, 10 May 2023 10:43:26 +0100 Subject: [PATCH 076/142] Output build log file location --- .github/workflows/wasm.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 24657d64dd1..c41a7c2a90e 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -25,6 +25,15 @@ jobs: run: | nix build .#wasm || true + - name: Output build.log location + run: | + BUILD_LOG_PATH=$(find . -name build.log) + if [ -n "$BUILD_LOG_PATH" ]; then + echo "Found build.log at $BUILD_LOG_PATH" + else + echo "build.log not found" + fi + - name: Print build.log if build failed run: | if [ -d result ]; then From 3b24c5b3166fd83b9a03ffbb9a4216413d3444e6 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Wed, 10 May 2023 10:49:19 +0100 Subject: [PATCH 077/142] Log out Hello World file from nix to workflow --- .github/workflows/wasm.yml | 41 +++++++++++++++++++++++--------------- flake.nix | 40 ++++++++++++++++--------------------- 2 files changed, 42 insertions(+), 39 deletions(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index c41a7c2a90e..0d0575f3535 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -25,25 +25,34 @@ jobs: run: | nix build .#wasm || true - - name: Output build.log location + - name: Output hello_world.txt run: | - BUILD_LOG_PATH=$(find . -name build.log) - if [ -n "$BUILD_LOG_PATH" ]; then - echo "Found build.log at $BUILD_LOG_PATH" - else - echo "build.log not found" + HELLO_WORLD_PATH=$(find . -name hello_world.txt) + if [ -n "$HELLO_WORLD_PATH" ]; then + echo "Printing hello_world.txt:" + cat $HELLO_WORLD_PATH fi - - name: Print build.log if build failed - run: | - if [ -d result ]; then - echo "Build successful." - else - echo "Build failed. Trying to locate build.log:" - find . -name build.log - echo "Printing the build.log (if found):" - find . -name build.log -exec cat {} \; || true - fi + # - name: Output build.log location + # run: | + # BUILD_LOG_PATH=$(find . -name build.log) + # echo "path is $BUILD_LOG_PATH" + # if [ -n "$BUILD_LOG_PATH" ]; then + # echo "Found build.log at $BUILD_LOG_PATH" + # else + # echo "build.log not found" + # fi + + # - name: Print build.log if build failed + # run: | + # if [ -d result ]; then + # echo "Build successful." + # else + # echo "Build failed. Trying to locate build.log:" + # find . -name build.log + # echo "Printing the build.log (if found):" + # find . -name build.log -exec cat {} \; || true + # fi # - name: Build wasm package # run: nix build .#packages.wasm --keep-failed diff --git a/flake.nix b/flake.nix index 02db36821ac..39652ac85c7 100644 --- a/flake.nix +++ b/flake.nix @@ -203,30 +203,24 @@ nativeBuildInputs = [ pkgs.wasm-pack pkgs.git pkgs.jq ]; - buildPhase = '' - BASH_XTRACEFD=19 - set -x - exec 19>${src}/build.log - - echo "Contents of the build-wasm script:" >&2 - cat ./build-wasm >&2 - echo "Current working directory:" >&2 - pwd >&2 - echo "Contents of the source directory:" >&2 - ls -la >&2 - - ${pkgs.bash}/bin/bash ./build-wasm || (cat ${src}/build.log && exit 1) - - # Check if build.log is present and not empty - if [ ! -s ${src}/build.log ]; then - echo "Error: build.log not found or empty" >&2 - exit 1 - fi - - set +x - exec 19>&- + buildPhase = '' + echo "hello world" > hello_world.txt + # set -x + # echo "Contents of the build-wasm script:" >&2 + # cat ./build-wasm >&2 + # echo "Current working directory:" >&2 + # pwd >&2 + # echo "Contents of the source directory:" >&2 + # ls -la >&2 + + # ${pkgs.bash}/bin/bash ./build-wasm 2>&1 | tee build.log + # BUILD_RESULT=$? + # if [ $BUILD_RESULT -ne 0 ]; then + # touch BUILD_FAILED + # fi + # exit $BUILD_RESULT ''; - + installPhase = '' mkdir -p $out/pkg cp -r pkg/* $out/pkg/ From 56d55c6ac163a6ce0e2f396be1d6bdf16e737612 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Wed, 10 May 2023 10:52:35 +0100 Subject: [PATCH 078/142] Output hello_world.txt --- flake.nix | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/flake.nix b/flake.nix index 39652ac85c7..21f64672126 100644 --- a/flake.nix +++ b/flake.nix @@ -222,9 +222,10 @@ ''; installPhase = '' - mkdir -p $out/pkg - cp -r pkg/* $out/pkg/ - cp build.log $out/ + mkdir -p $out + cp hello_world.txt $out/ + # cp -r pkg/* $out/pkg/ + # cp build.log $out/ ''; }; }); From 904fb094d0570fb204df753252e33282c5334796 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Wed, 10 May 2023 10:55:08 +0100 Subject: [PATCH 079/142] Add else --- .github/workflows/wasm.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 0d0575f3535..3dad6629142 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -31,6 +31,8 @@ jobs: if [ -n "$HELLO_WORLD_PATH" ]; then echo "Printing hello_world.txt:" cat $HELLO_WORLD_PATH + else + echo "Couldnt find hello_world.txt" fi # - name: Output build.log location From a358696a0b126f529e8b3f27e36912c170ef6fdc Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Wed, 10 May 2023 11:00:56 +0100 Subject: [PATCH 080/142] Copy file from nix to workflow --- .github/workflows/wasm.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 3dad6629142..e4041bedf67 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -21,9 +21,10 @@ jobs: nix_path: nixpkgs=channel:nixos-22.11 github_access_token: ${{ secrets.GITHUB_TOKEN }} - - name: Build and output the log + - name: Copy hello_world.txt to workspace run: | - nix build .#wasm || true + cp $(nix-build --no-link -A wasm)./hello_world.txt $GITHUB_WORKSPACE + shell: bash - name: Output hello_world.txt run: | From 8922c4d0f7a93b368cbd86d5f21ffe9abc86449f Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Wed, 10 May 2023 11:03:57 +0100 Subject: [PATCH 081/142] Fix flake run --- .github/workflows/wasm.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index e4041bedf67..4f152171b1b 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -23,7 +23,7 @@ jobs: - name: Copy hello_world.txt to workspace run: | - cp $(nix-build --no-link -A wasm)./hello_world.txt $GITHUB_WORKSPACE + cp $(nix-build --no-link -A packages.x86_64-linux.wasm)/hello_world.txt $GITHUB_WORKSPACE shell: bash - name: Output hello_world.txt @@ -33,7 +33,7 @@ jobs: echo "Printing hello_world.txt:" cat $HELLO_WORLD_PATH else - echo "Couldnt find hello_world.txt" + echo "Couldn't find hello_world.txt" fi # - name: Output build.log location From a551992ea847e1127b98b36defd6102dcda6add0 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Wed, 10 May 2023 11:11:00 +0100 Subject: [PATCH 082/142] Change hello world to build log --- .github/workflows/wasm.yml | 31 +++++++++++++++++++++++-------- flake.nix | 29 +++++++++++++++-------------- 2 files changed, 38 insertions(+), 22 deletions(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 4f152171b1b..649982039cd 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -21,21 +21,36 @@ jobs: nix_path: nixpkgs=channel:nixos-22.11 github_access_token: ${{ secrets.GITHUB_TOKEN }} - - name: Copy hello_world.txt to workspace + - name: Copy build.log to workspace run: | - cp $(nix-build --no-link -A packages.x86_64-linux.wasm)/hello_world.txt $GITHUB_WORKSPACE + cp $(nix-build --no-link -A packages.x86_64-linux.wasm)/build.log $GITHUB_WORKSPACE shell: bash - - name: Output hello_world.txt + - name: Output build.log run: | - HELLO_WORLD_PATH=$(find . -name hello_world.txt) - if [ -n "$HELLO_WORLD_PATH" ]; then - echo "Printing hello_world.txt:" - cat $HELLO_WORLD_PATH + BUILD_LOG_PATH=$(find . -name build.log) + if [ -n "$BUILD_LOG_PATH" ]; then + echo "Printing build.log:" + cat $BUILD_LOG_PATH else - echo "Couldn't find hello_world.txt" + echo "Couldn't find build.log" fi + # - name: Copy hello_world.txt to workspace + # run: | + # cp $(nix-build --no-link -A packages.x86_64-linux.wasm)/hello_world.txt $GITHUB_WORKSPACE + # shell: bash + + # - name: Output hello_world.txt + # run: | + # HELLO_WORLD_PATH=$(find . -name hello_world.txt) + # if [ -n "$HELLO_WORLD_PATH" ]; then + # echo "Printing hello_world.txt:" + # cat $HELLO_WORLD_PATH + # else + # echo "Couldn't find hello_world.txt" + # fi + # - name: Output build.log location # run: | # BUILD_LOG_PATH=$(find . -name build.log) diff --git a/flake.nix b/flake.nix index 21f64672126..b24e3386a88 100644 --- a/flake.nix +++ b/flake.nix @@ -205,27 +205,28 @@ buildPhase = '' echo "hello world" > hello_world.txt - # set -x - # echo "Contents of the build-wasm script:" >&2 - # cat ./build-wasm >&2 - # echo "Current working directory:" >&2 - # pwd >&2 - # echo "Contents of the source directory:" >&2 - # ls -la >&2 + + set -x + echo "Contents of the build-wasm script:" >&2 + cat ./build-wasm >&2 + echo "Current working directory:" >&2 + pwd >&2 + echo "Contents of the source directory:" >&2 + ls -la >&2 - # ${pkgs.bash}/bin/bash ./build-wasm 2>&1 | tee build.log - # BUILD_RESULT=$? - # if [ $BUILD_RESULT -ne 0 ]; then - # touch BUILD_FAILED - # fi - # exit $BUILD_RESULT + ${pkgs.bash}/bin/bash ./build-wasm 2>&1 | tee build.log + BUILD_RESULT=$? + if [ $BUILD_RESULT -ne 0 ]; then + touch BUILD_FAILED + fi + exit $BUILD_RESULT ''; installPhase = '' mkdir -p $out cp hello_world.txt $out/ + cp build.log $out/ # cp -r pkg/* $out/pkg/ - # cp build.log $out/ ''; }; }); From 74ea3c3dd3269af42d64ba19d5d273078bd1e405 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Wed, 10 May 2023 11:29:07 +0100 Subject: [PATCH 083/142] Revert build-wasm --- crates/wasm/build-wasm | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/crates/wasm/build-wasm b/crates/wasm/build-wasm index 90b3079107b..6b574b71d03 100755 --- a/crates/wasm/build-wasm +++ b/crates/wasm/build-wasm @@ -7,12 +7,8 @@ fi # Build the new wasm package wasm-pack build --scope noir-lang --target nodejs --out-dir pkg/nodejs -echo "NodeJS build complete. Directory contents:" -# ls -la pkg/nodejs wasm-pack build --scope noir-lang --target web --out-dir pkg/web -echo "Web build complete. Directory contents:" -# ls -la pkg/web COMMIT_SHORT=$(git rev-parse --short HEAD) VERSION_APPENDIX="" @@ -22,8 +18,8 @@ else VERSION_APPENDIX="-NOGIT" fi -jq -s '.[0] * .[1]' pkg/nodejs/package.json pkg/web/package.json | jq --argjson version_appendix "\"$VERSION_APPENDIX\"" '. * { version: .version + $version_appendix, files: ["nodejs", "web", "package.json"], main: "./nodejs/" + .main, module: "./web/" + .module, types: "./web/" + .types, peerDependencies: { "@noir-lang/noir-source-resolver": "1.1.2" }}' | tee ./pkg/package.json +jq -s '.[0] * .[1]' pkg/nodejs/package.json pkg/web/package.json | jq '.files = ["nodejs", "web", "package.json"]' | jq ".version += \"$VERSION_APPENDIX\"" | jq '.main = "./nodejs/" + .main | .module = "./web/" + .module | .types = "./web/" + .types | .peerDependencies = { "@noir-lang/noir-source-resolver": "1.1.2" }' | tee ./pkg/package.json rm pkg/nodejs/package.json pkg/nodejs/README.md pkg/nodejs/.gitignore -rm pkg/web/package.json pkg/web/README.md pkg/web/.gitignore +rm pkg/web/package.json pkg/web/README.md pkg/web/.gitignore \ No newline at end of file From d1b03b68e285e4222983e51be4b09c5126ba0a0b Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Wed, 10 May 2023 11:34:02 +0100 Subject: [PATCH 084/142] Output build-wasm build --- crates/wasm/build-wasm | 4 ++++ flake.nix | 14 +++++--------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/crates/wasm/build-wasm b/crates/wasm/build-wasm index 6b574b71d03..90182f4b0d7 100755 --- a/crates/wasm/build-wasm +++ b/crates/wasm/build-wasm @@ -7,8 +7,12 @@ fi # Build the new wasm package wasm-pack build --scope noir-lang --target nodejs --out-dir pkg/nodejs +echo "NodeJS build complete. Directory contents:" +ls -la pkg/nodejs wasm-pack build --scope noir-lang --target web --out-dir pkg/web +echo "Web build complete. Directory contents:" +ls -la pkg/web COMMIT_SHORT=$(git rev-parse --short HEAD) VERSION_APPENDIX="" diff --git a/flake.nix b/flake.nix index b24e3386a88..b415c54ac39 100644 --- a/flake.nix +++ b/flake.nix @@ -199,20 +199,16 @@ pname = "noir_wasm"; version = "1.0.0"; - src = ./crates/wasm; + src = ./crates/wasm; nativeBuildInputs = [ pkgs.wasm-pack pkgs.git pkgs.jq ]; buildPhase = '' - echo "hello world" > hello_world.txt + # echo "hello world" > hello_world.txt set -x - echo "Contents of the build-wasm script:" >&2 - cat ./build-wasm >&2 - echo "Current working directory:" >&2 - pwd >&2 - echo "Contents of the source directory:" >&2 - ls -la >&2 + # echo "Contents of the source directory:" >&2 + # ls -la >&2 ${pkgs.bash}/bin/bash ./build-wasm 2>&1 | tee build.log BUILD_RESULT=$? @@ -224,8 +220,8 @@ installPhase = '' mkdir -p $out - cp hello_world.txt $out/ cp build.log $out/ + # cp hello_world.txt $out/ # cp -r pkg/* $out/pkg/ ''; }; From 1bf71fd6bf04af5cd7202a3516e0430fc1553724 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Wed, 10 May 2023 11:36:29 +0100 Subject: [PATCH 085/142] Print all files in build-wasm --- crates/wasm/build-wasm | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/wasm/build-wasm b/crates/wasm/build-wasm index 90182f4b0d7..02d5a6fbf8b 100755 --- a/crates/wasm/build-wasm +++ b/crates/wasm/build-wasm @@ -5,6 +5,7 @@ if [ -d ./pkg/ ]; then rm -rf ./pkg/ fi + # Build the new wasm package wasm-pack build --scope noir-lang --target nodejs --out-dir pkg/nodejs echo "NodeJS build complete. Directory contents:" @@ -14,6 +15,12 @@ wasm-pack build --scope noir-lang --target web --out-dir pkg/web echo "Web build complete. Directory contents:" ls -la pkg/web +echo "Pkg directory contents:" +ls -la pkg + +echo "Current directory contents:" +ls -la + COMMIT_SHORT=$(git rev-parse --short HEAD) VERSION_APPENDIX="" if [ -n "$COMMIT_SHORT" ]; then From 8e4996a36c24d6b5e1e0a08fef24da0aaca42499 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Wed, 10 May 2023 11:41:18 +0100 Subject: [PATCH 086/142] Add verbose on wasm-pack --- crates/wasm/build-wasm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/wasm/build-wasm b/crates/wasm/build-wasm index 02d5a6fbf8b..b2427d00c7e 100755 --- a/crates/wasm/build-wasm +++ b/crates/wasm/build-wasm @@ -7,11 +7,11 @@ fi # Build the new wasm package -wasm-pack build --scope noir-lang --target nodejs --out-dir pkg/nodejs +wasm-pack build --scope noir-lang --target nodejs --out-dir pkg/nodejs --verbose echo "NodeJS build complete. Directory contents:" ls -la pkg/nodejs -wasm-pack build --scope noir-lang --target web --out-dir pkg/web +wasm-pack build --scope noir-lang --target web --out-dir pkg/web --verbose echo "Web build complete. Directory contents:" ls -la pkg/web From c3db93632244c8ea176758db400a2a43cb302d25 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Wed, 10 May 2023 11:44:46 +0100 Subject: [PATCH 087/142] Add which wasm-pack --- crates/wasm/build-wasm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/wasm/build-wasm b/crates/wasm/build-wasm index b2427d00c7e..9201695fdf3 100755 --- a/crates/wasm/build-wasm +++ b/crates/wasm/build-wasm @@ -5,6 +5,8 @@ if [ -d ./pkg/ ]; then rm -rf ./pkg/ fi +echo "Which wasm-pack" +which wasm-pack # Build the new wasm package wasm-pack build --scope noir-lang --target nodejs --out-dir pkg/nodejs --verbose From 58db2cff0c2a16f4e15b9bf51ddf57c88cc00c68 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Wed, 10 May 2023 11:47:02 +0100 Subject: [PATCH 088/142] Replace which with command -v --- crates/wasm/build-wasm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/wasm/build-wasm b/crates/wasm/build-wasm index 9201695fdf3..c8fe90e6b61 100755 --- a/crates/wasm/build-wasm +++ b/crates/wasm/build-wasm @@ -6,7 +6,7 @@ if [ -d ./pkg/ ]; then fi echo "Which wasm-pack" -which wasm-pack +command -v wasm-pack # Build the new wasm package wasm-pack build --scope noir-lang --target nodejs --out-dir pkg/nodejs --verbose From 41bdfabefc243537b2bc91d456611d8034a9f8dd Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Wed, 10 May 2023 11:57:16 +0100 Subject: [PATCH 089/142] Manually generate output folders --- crates/wasm/build-wasm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/wasm/build-wasm b/crates/wasm/build-wasm index c8fe90e6b61..9661b472167 100755 --- a/crates/wasm/build-wasm +++ b/crates/wasm/build-wasm @@ -5,9 +5,15 @@ if [ -d ./pkg/ ]; then rm -rf ./pkg/ fi -echo "Which wasm-pack" +echo "Checking if wasm-pack is ready" command -v wasm-pack +mkdir -p pkg/nodejs +chmod 755 pkg/nodejs + +mkdir -p pkg/web +chmod 755 pkg/web + # Build the new wasm package wasm-pack build --scope noir-lang --target nodejs --out-dir pkg/nodejs --verbose echo "NodeJS build complete. Directory contents:" @@ -23,6 +29,9 @@ ls -la pkg echo "Current directory contents:" ls -la +echo "Current working directory:" +pwd + COMMIT_SHORT=$(git rev-parse --short HEAD) VERSION_APPENDIX="" if [ -n "$COMMIT_SHORT" ]; then From 09603655faf2b76a2c0aae06668ba4722640853a Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Wed, 10 May 2023 13:49:15 +0100 Subject: [PATCH 090/142] Add debug flag --- crates/wasm/build-wasm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/wasm/build-wasm b/crates/wasm/build-wasm index 9661b472167..301945decf3 100755 --- a/crates/wasm/build-wasm +++ b/crates/wasm/build-wasm @@ -15,11 +15,11 @@ mkdir -p pkg/web chmod 755 pkg/web # Build the new wasm package -wasm-pack build --scope noir-lang --target nodejs --out-dir pkg/nodejs --verbose +wasm-pack build --scope noir-lang --target nodejs --out-dir pkg/nodejs --verbose --debug echo "NodeJS build complete. Directory contents:" ls -la pkg/nodejs -wasm-pack build --scope noir-lang --target web --out-dir pkg/web --verbose +wasm-pack build --scope noir-lang --target web --out-dir pkg/web --verbose --debug echo "Web build complete. Directory contents:" ls -la pkg/web From b55da9b0f222217df811b1d2a9f252c4235f35d5 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Wed, 10 May 2023 13:49:31 +0100 Subject: [PATCH 091/142] Remove further comments --- flake.nix | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/flake.nix b/flake.nix index b415c54ac39..3af3305f593 100644 --- a/flake.nix +++ b/flake.nix @@ -203,12 +203,8 @@ nativeBuildInputs = [ pkgs.wasm-pack pkgs.git pkgs.jq ]; - buildPhase = '' - # echo "hello world" > hello_world.txt - + buildPhase = '' set -x - # echo "Contents of the source directory:" >&2 - # ls -la >&2 ${pkgs.bash}/bin/bash ./build-wasm 2>&1 | tee build.log BUILD_RESULT=$? @@ -221,7 +217,6 @@ installPhase = '' mkdir -p $out cp build.log $out/ - # cp hello_world.txt $out/ # cp -r pkg/* $out/pkg/ ''; }; From 07aa43ec750004c5f42b0d2e6bd93f1c0d7a2a3e Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Wed, 10 May 2023 13:52:51 +0100 Subject: [PATCH 092/142] Output wasm-pack version --- crates/wasm/build-wasm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/wasm/build-wasm b/crates/wasm/build-wasm index 301945decf3..d1fb3f85932 100755 --- a/crates/wasm/build-wasm +++ b/crates/wasm/build-wasm @@ -5,6 +5,9 @@ if [ -d ./pkg/ ]; then rm -rf ./pkg/ fi +echo "wasm-pack version" +wasm-pack -V + echo "Checking if wasm-pack is ready" command -v wasm-pack From b2bdf6819f03be9bbcae7274ba069cfc4143226a Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Wed, 10 May 2023 13:54:54 +0100 Subject: [PATCH 093/142] Output rustc version --- crates/wasm/build-wasm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/wasm/build-wasm b/crates/wasm/build-wasm index d1fb3f85932..d524f78d36e 100755 --- a/crates/wasm/build-wasm +++ b/crates/wasm/build-wasm @@ -7,9 +7,8 @@ fi echo "wasm-pack version" wasm-pack -V - -echo "Checking if wasm-pack is ready" -command -v wasm-pack +echo "rustc version" +rustc -V mkdir -p pkg/nodejs chmod 755 pkg/nodejs From 7b2f5b650c7b6177342eee466cdd387c5cb92f96 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Wed, 10 May 2023 14:01:12 +0100 Subject: [PATCH 094/142] Add rustc to build inputs --- flake.nix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 3af3305f593..c697d87c5fc 100644 --- a/flake.nix +++ b/flake.nix @@ -201,7 +201,12 @@ src = ./crates/wasm; - nativeBuildInputs = [ pkgs.wasm-pack pkgs.git pkgs.jq ]; + nativeBuildInputs = with pkgs; [ + wasm-pack + rustc + jq + git + ]; buildPhase = '' set -x From b162da44ab7bd29a0c99eb6554d4aa5aa43b8909 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Wed, 10 May 2023 14:04:14 +0100 Subject: [PATCH 095/142] Set up dev flag --- crates/wasm/build-wasm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/wasm/build-wasm b/crates/wasm/build-wasm index d524f78d36e..0a98a66e675 100755 --- a/crates/wasm/build-wasm +++ b/crates/wasm/build-wasm @@ -17,11 +17,11 @@ mkdir -p pkg/web chmod 755 pkg/web # Build the new wasm package -wasm-pack build --scope noir-lang --target nodejs --out-dir pkg/nodejs --verbose --debug +wasm-pack build --scope noir-lang --target nodejs --out-dir pkg/nodejs --dev echo "NodeJS build complete. Directory contents:" ls -la pkg/nodejs -wasm-pack build --scope noir-lang --target web --out-dir pkg/web --verbose --debug +wasm-pack build --scope noir-lang --target web --out-dir pkg/web --dev echo "Web build complete. Directory contents:" ls -la pkg/web From 3f3ec2c52236c978cf33eff17fbe62fd49d1c46a Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Wed, 10 May 2023 19:28:18 +0100 Subject: [PATCH 096/142] Fix src path --- flake.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index c697d87c5fc..5b6c6ede1f9 100644 --- a/flake.nix +++ b/flake.nix @@ -199,7 +199,7 @@ pname = "noir_wasm"; version = "1.0.0"; - src = ./crates/wasm; + src = ./.; nativeBuildInputs = with pkgs; [ wasm-pack @@ -211,7 +211,7 @@ buildPhase = '' set -x - ${pkgs.bash}/bin/bash ./build-wasm 2>&1 | tee build.log + ${pkgs.bash}/bin/bash ./crates/wasm/build-wasm 2>&1 | tee build.log BUILD_RESULT=$? if [ $BUILD_RESULT -ne 0 ]; then touch BUILD_FAILED From 0b20fac223b354a2697f9bc15bcc9d81f628e00e Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Wed, 10 May 2023 11:59:05 -0700 Subject: [PATCH 097/142] add wasm32 target --- flake.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 5b6c6ede1f9..fe5361f3637 100644 --- a/flake.nix +++ b/flake.nix @@ -64,6 +64,7 @@ # We include rust-src to ensure rust-analyzer works. # See https://discourse.nixos.org/t/rust-src-not-found-and-other-misadventures-of-developing-rust-on-nixos/11570/4 extensions = [ "rust-src" ]; + targets = [ "wasm32-unknown-unknown" ]; }; craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain; @@ -203,7 +204,7 @@ nativeBuildInputs = with pkgs; [ wasm-pack - rustc + rustToolchain jq git ]; From 1f18b147b643a06fe91fd592b5759a096e9b0cbe Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Mon, 15 May 2023 11:02:36 +0100 Subject: [PATCH 098/142] wip - fix for section too large error --- crates/wasm/Cargo.toml | 4 ++++ flake.nix | 24 +++++++++++------------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/crates/wasm/Cargo.toml b/crates/wasm/Cargo.toml index bbcabe12e0a..c972f1be433 100644 --- a/crates/wasm/Cargo.toml +++ b/crates/wasm/Cargo.toml @@ -24,3 +24,7 @@ gloo-utils = { version = "0.1", features = ["serde"] } [build-dependencies] build-data = "0.1.3" + +# added to strip the sections +[profile.release] +strip = true \ No newline at end of file diff --git a/flake.nix b/flake.nix index fe5361f3637..3ec5a2eb6fb 100644 --- a/flake.nix +++ b/flake.nix @@ -64,6 +64,8 @@ # We include rust-src to ensure rust-analyzer works. # See https://discourse.nixos.org/t/rust-src-not-found-and-other-misadventures-of-developing-rust-on-nixos/11570/4 extensions = [ "rust-src" ]; + # possible fix for "section too large" + # targets = [ "aarch64-apple-darwin" "wasm32-unknown-unknown" ]; targets = [ "wasm32-unknown-unknown" ]; }; @@ -196,11 +198,16 @@ ''; }); - packages.wasm = pkgs.stdenv.mkDerivation rec { + # throws failed to get '"acvm" as a dependency of package noirc_evaluator v0.4.1' + # packages.wasm = pkgs.stdenv.mkDerivation rec { + + # throws "error: failed to build archive: section too large" + packages.wasm = craneLib.buildPackage rec { pname = "noir_wasm"; version = "1.0.0"; - src = ./.; + # src = ./.; + src = craneLib.cleanCargoSource (craneLib.path ./.); nativeBuildInputs = with pkgs; [ wasm-pack @@ -209,21 +216,12 @@ git ]; - buildPhase = '' - set -x - - ${pkgs.bash}/bin/bash ./crates/wasm/build-wasm 2>&1 | tee build.log - BUILD_RESULT=$? - if [ $BUILD_RESULT -ne 0 ]; then - touch BUILD_FAILED - fi - exit $BUILD_RESULT + buildPhase = '' + wasm-pack build crates/wasm --scope noir-lang --target web --out-dir pkg/web --release ''; installPhase = '' mkdir -p $out - cp build.log $out/ - # cp -r pkg/* $out/pkg/ ''; }; }); From fc936b18d1943238639daf5ec8442ecdef9a4976 Mon Sep 17 00:00:00 2001 From: kobyhallx Date: Tue, 16 May 2023 10:38:12 +0000 Subject: [PATCH 099/142] progress: build with wasm-pack --- flake.nix | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/flake.nix b/flake.nix index 3ec5a2eb6fb..aca7ec2dc0b 100644 --- a/flake.nix +++ b/flake.nix @@ -200,29 +200,40 @@ # throws failed to get '"acvm" as a dependency of package noirc_evaluator v0.4.1' # packages.wasm = pkgs.stdenv.mkDerivation rec { - + # throws "error: failed to build archive: section too large" - packages.wasm = craneLib.buildPackage rec { + packages.wasm = craneLib.mkCargoDerivation rec { pname = "noir_wasm"; version = "1.0.0"; - # src = ./.; + inherit cargoArtifacts; + inherit GIT_COMMIT; + inherit GIT_DIRTY; + + # src = ./.; src = craneLib.cleanCargoSource (craneLib.path ./.); nativeBuildInputs = with pkgs; [ - wasm-pack - rustToolchain - jq + which git + jq + rustToolchain + wasm-bindgen-cli + wasm-pack ]; - buildPhase = '' - wasm-pack build crates/wasm --scope noir-lang --target web --out-dir pkg/web --release + buildPhaseCargoCommand = '' + echo About to Wasm-Pack + echo $(which wasm-bindgen) + RUST_LOG="debug" + wasm-pack build crates/wasm --mode normal --scope noir-lang --target web --out-dir pkg/web --release ''; - + installPhase = '' - mkdir -p $out + mkdir - p $out ''; + }; }); } + From 5b106ecf1ee13b210610a1bfd71f60d9a42f8090 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Fri, 19 May 2023 14:20:14 +0100 Subject: [PATCH 100/142] Downgrade wasm-bindgen - wip --- flake.nix | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/flake.nix b/flake.nix index aca7ec2dc0b..5ed25fce2f6 100644 --- a/flake.nix +++ b/flake.nix @@ -49,7 +49,12 @@ }; outputs = - { self, nixpkgs, crane, flake-utils, rust-overlay, barretenberg, ... }: + { self, nixpkgs, crane, flake-utils, rust-overlay, barretenberg, ... }: let + wasm-bindgen-cli-src = builtins.fetchGit { + url = "https://github.com/rustwasm/wasm-bindgen.git"; + rev = "4caa98165c65984e3eba3dd7825f3bf44955d127"; + }; + in flake-utils.lib.eachDefaultSystem (system: let pkgs = import nixpkgs { @@ -147,6 +152,17 @@ noir = craneLib.buildPackage (commonArgs // { inherit cargoArtifacts; }); + + wasm-bindgen-cli = pkgs.rustPlatform.buildRustPackage rec { + pname = "wasm-bindgen-cli"; + version = "0.2.74"; + src = wasm-bindgen-cli-src; + cargoSha256 = "0000000000000000000000000000000000000000000000000000"; + + postInstall = '' + ln -s $out/bin/wasm-bindgen $out/bin/wasm-bindgen-cli + ''; + }; in rec { checks = { @@ -223,10 +239,11 @@ ]; buildPhaseCargoCommand = '' - echo About to Wasm-Pack - echo $(which wasm-bindgen) + echo "wasm-bindgen version: $(wasm-bindgen --version)" + echo "===========" RUST_LOG="debug" - wasm-pack build crates/wasm --mode normal --scope noir-lang --target web --out-dir pkg/web --release + # wasm-pack build crates/wasm --scope noir-lang --target nodejs --out-dir pkg/nodejs --dev + # wasm-pack build crates/wasm --mode no-install --dev ''; installPhase = '' From 6eaeadead23fc6d9732a2154bc05f21d3e3a6ba3 Mon Sep 17 00:00:00 2001 From: kobyhallx Date: Tue, 23 May 2023 08:35:30 +0000 Subject: [PATCH 101/142] chore: building with correct versions --- flake.lock | 18 +++++++++--------- flake.nix | 4 +++- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/flake.lock b/flake.lock index 7c01326f86d..797e05fa66c 100644 --- a/flake.lock +++ b/flake.lock @@ -39,11 +39,11 @@ ] }, "locked": { - "lastModified": 1681177078, - "narHash": "sha256-ZNIjBDou2GOabcpctiQykEQVkI8BDwk7TyvlWlI4myE=", + "lastModified": 1684468982, + "narHash": "sha256-EoC1N5sFdmjuAP3UOkyQujSOT6EdcXTnRw8hPjJkEgc=", "owner": "ipetkov", "repo": "crane", - "rev": "0c9f468ff00576577d83f5019a66c557ede5acf6", + "rev": "99de890b6ef4b4aab031582125b6056b792a4a30", "type": "github" }, "original": { @@ -88,11 +88,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1681269223, - "narHash": "sha256-i6OeI2f7qGvmLfD07l1Az5iBL+bFeP0RHixisWtpUGo=", + "lastModified": 1684580438, + "narHash": "sha256-LUPswmDn6fXP3lEBJFA2Id8PkcYDgzUilevWackYVvQ=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "87edbd74246ccdfa64503f334ed86fa04010bab9", + "rev": "7dc71aef32e8faf065cb171700792cf8a65c152d", "type": "github" }, "original": { @@ -122,11 +122,11 @@ ] }, "locked": { - "lastModified": 1681352318, - "narHash": "sha256-+kwy7bTsuW8GYrRqWRQ8T5hg6duZb5IJiHlKo1J+v9g=", + "lastModified": 1684808436, + "narHash": "sha256-WG5LgB1+Oguj4H4Bpqr5GoLSc382LyGlaToiOw5xhwA=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "aeaa11c65a5c5cebaa51652353ab3c497b9a7bbf", + "rev": "a227d4571dd1f948138a40ea8b0d0c413eefb44b", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index aca7ec2dc0b..1b759f44a04 100644 --- a/flake.nix +++ b/flake.nix @@ -190,10 +190,12 @@ nil nixpkgs-fmt llvmPackages.lldb # This ensures the right lldb is in the environment for running rust-lldb + wasm-bindgen-cli wasm-pack ]; shellHook = '' + echo which wasm-bindgen $(which wasm-bindgen) eval "$(starship init bash)" ''; }); @@ -226,7 +228,7 @@ echo About to Wasm-Pack echo $(which wasm-bindgen) RUST_LOG="debug" - wasm-pack build crates/wasm --mode normal --scope noir-lang --target web --out-dir pkg/web --release + wasm-pack build crates/wasm --mode no-install --scope noir-lang --target web --out-dir pkg/web --release ''; installPhase = '' From 704be6f9e019999da9cfc7f0230aa687f873eefe Mon Sep 17 00:00:00 2001 From: kobyhallx Date: Tue, 23 May 2023 12:42:46 +0000 Subject: [PATCH 102/142] choir: rely on stock wasm-binden-cli --- flake.nix | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/flake.nix b/flake.nix index be9e281e958..1fa7c8c877b 100644 --- a/flake.nix +++ b/flake.nix @@ -153,16 +153,16 @@ inherit cargoArtifacts; }); - wasm-bindgen-cli = pkgs.rustPlatform.buildRustPackage rec { - pname = "wasm-bindgen-cli"; - version = "0.2.74"; - src = wasm-bindgen-cli-src; - cargoSha256 = "0000000000000000000000000000000000000000000000000000"; - - postInstall = '' - ln -s $out/bin/wasm-bindgen $out/bin/wasm-bindgen-cli - ''; - }; + # wasm-bindgen-cli = pkgs.rustPlatform.buildRustPackage rec { + # pname = "wasm-bindgen-cli"; + # version = "0.2.74"; + # src = wasm-bindgen-cli-src; + # cargoSha256 = "0000000000000000000000000000000000000000000000000000"; + + # postInstall = '' + # ln -s $out/bin/wasm-bindgen $out/bin/wasm-bindgen-cli + # ''; + # }; in rec { checks = { From 9c9734d69f75e509f79eae49f3ad3886d350b8f1 Mon Sep 17 00:00:00 2001 From: jonybur Date: Wed, 24 May 2023 10:54:53 +0000 Subject: [PATCH 103/142] Cleanup, implement build on flake file --- crates/wasm/build-wasm | 43 ------------------------------------------ flake.nix | 43 +++++++++++++++++++++++------------------- 2 files changed, 24 insertions(+), 62 deletions(-) diff --git a/crates/wasm/build-wasm b/crates/wasm/build-wasm index 0a98a66e675..98b655db45d 100755 --- a/crates/wasm/build-wasm +++ b/crates/wasm/build-wasm @@ -1,46 +1,3 @@ -#!/usr/bin/env bash - -# Clear out the existing build artifacts as these aren't automatically removed by wasm-pack. -if [ -d ./pkg/ ]; then - rm -rf ./pkg/ -fi - -echo "wasm-pack version" -wasm-pack -V -echo "rustc version" -rustc -V - -mkdir -p pkg/nodejs -chmod 755 pkg/nodejs - -mkdir -p pkg/web -chmod 755 pkg/web - -# Build the new wasm package -wasm-pack build --scope noir-lang --target nodejs --out-dir pkg/nodejs --dev -echo "NodeJS build complete. Directory contents:" -ls -la pkg/nodejs - -wasm-pack build --scope noir-lang --target web --out-dir pkg/web --dev -echo "Web build complete. Directory contents:" -ls -la pkg/web - -echo "Pkg directory contents:" -ls -la pkg - -echo "Current directory contents:" -ls -la - -echo "Current working directory:" -pwd - -COMMIT_SHORT=$(git rev-parse --short HEAD) -VERSION_APPENDIX="" -if [ -n "$COMMIT_SHORT" ]; then - VERSION_APPENDIX="-$COMMIT_SHORT" -else - VERSION_APPENDIX="-NOGIT" -fi jq -s '.[0] * .[1]' pkg/nodejs/package.json pkg/web/package.json | jq '.files = ["nodejs", "web", "package.json"]' | jq ".version += \"$VERSION_APPENDIX\"" | jq '.main = "./nodejs/" + .main | .module = "./web/" + .module | .types = "./web/" + .types | .peerDependencies = { "@noir-lang/noir-source-resolver": "1.1.2" }' | tee ./pkg/package.json diff --git a/flake.nix b/flake.nix index 1fa7c8c877b..b92c6d6e73b 100644 --- a/flake.nix +++ b/flake.nix @@ -152,17 +152,6 @@ noir = craneLib.buildPackage (commonArgs // { inherit cargoArtifacts; }); - - # wasm-bindgen-cli = pkgs.rustPlatform.buildRustPackage rec { - # pname = "wasm-bindgen-cli"; - # version = "0.2.74"; - # src = wasm-bindgen-cli-src; - # cargoSha256 = "0000000000000000000000000000000000000000000000000000"; - - # postInstall = '' - # ln -s $out/bin/wasm-bindgen $out/bin/wasm-bindgen-cli - # ''; - # }; in rec { checks = { @@ -216,10 +205,6 @@ ''; }); - # throws failed to get '"acvm" as a dependency of package noirc_evaluator v0.4.1' - # packages.wasm = pkgs.stdenv.mkDerivation rec { - - # throws "error: failed to build archive: section too large" packages.wasm = craneLib.mkCargoDerivation rec { pname = "noir_wasm"; version = "1.0.0"; @@ -228,7 +213,9 @@ inherit GIT_COMMIT; inherit GIT_DIRTY; - # src = ./.; + COMMIT_SHORT = builtins.substring 0 7 GIT_COMMIT; + VERSION_APPENDIX = if GIT_DIRTY == "true" then "-dirty" else ""; + src = craneLib.cleanCargoSource (craneLib.path ./.); nativeBuildInputs = with pkgs; [ @@ -241,10 +228,28 @@ ]; buildPhaseCargoCommand = '' - echo "wasm-bindgen version: $(wasm-bindgen --version)" - echo "===========" RUST_LOG="debug" - wasm-pack build crates/wasm --mode no-install --scope noir-lang --target web --out-dir pkg/web --release + PKG_PATH="crates/wasm/pkg" + + if [ -d $PKG_PATH ]; then + rm -rf $PKG_PATH + fi + + # wasm-pack build crates/wasm --mode no-install --scope noir-lang --target web --out-dir pkg/web --release + # echo "NodeJS build complete. Directory contents:" + # ls -la $PKG_PATH/web + + # wasm-pack build crates/wasm --mode no-install --scope noir-lang --target nodejs --out-dir pkg/nodejs --release + # echo "Web build complete. Directory contents:" + # ls -la $PKG_PATH/nodejs + + if [ -n "$COMMIT_SHORT" ]; then + VERSION_APPENDIX="-$COMMIT_SHORT" + else + VERSION_APPENDIX="-NOGIT" + fi + + echo "VERSION_APPENDIX = ${VERSION_APPENDIX}" ''; installPhase = '' From 3444feb0b6757169f2045080a6fcd4edaca6720e Mon Sep 17 00:00:00 2001 From: jonybur Date: Wed, 24 May 2023 10:57:13 +0000 Subject: [PATCH 104/142] Fix conditional --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index b92c6d6e73b..c51aa238555 100644 --- a/flake.nix +++ b/flake.nix @@ -243,7 +243,7 @@ # echo "Web build complete. Directory contents:" # ls -la $PKG_PATH/nodejs - if [ -n "$COMMIT_SHORT" ]; then + if [ -n $COMMIT_SHORT ]; then VERSION_APPENDIX="-$COMMIT_SHORT" else VERSION_APPENDIX="-NOGIT" From 0df80bdf3c623778aeec288bd92759a9f70a9bd5 Mon Sep 17 00:00:00 2001 From: jonybur Date: Wed, 24 May 2023 13:56:37 +0000 Subject: [PATCH 105/142] Test workflow --- .github/workflows/wasm.yml | 62 +++++--------------------------------- crates/wasm/build-wasm | 6 ---- flake.nix | 29 +++++++++++------- 3 files changed, 25 insertions(+), 72 deletions(-) delete mode 100755 crates/wasm/build-wasm diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 649982039cd..7f8722ef85c 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -21,63 +21,15 @@ jobs: nix_path: nixpkgs=channel:nixos-22.11 github_access_token: ${{ secrets.GITHUB_TOKEN }} - - name: Copy build.log to workspace - run: | - cp $(nix-build --no-link -A packages.x86_64-linux.wasm)/build.log $GITHUB_WORKSPACE - shell: bash + - name: Build wasm package + run: nix build -L .#wasm --extra-experimental-features nix-command --extra-experimental-features flakes - - name: Output build.log - run: | - BUILD_LOG_PATH=$(find . -name build.log) - if [ -n "$BUILD_LOG_PATH" ]; then - echo "Printing build.log:" - cat $BUILD_LOG_PATH - else - echo "Couldn't find build.log" - fi + - name: Copy wasm build result + working-directory: ./crates/wasm + run: cp -r ./result ./pkg - # - name: Copy hello_world.txt to workspace - # run: | - # cp $(nix-build --no-link -A packages.x86_64-linux.wasm)/hello_world.txt $GITHUB_WORKSPACE - # shell: bash - - # - name: Output hello_world.txt - # run: | - # HELLO_WORLD_PATH=$(find . -name hello_world.txt) - # if [ -n "$HELLO_WORLD_PATH" ]; then - # echo "Printing hello_world.txt:" - # cat $HELLO_WORLD_PATH - # else - # echo "Couldn't find hello_world.txt" - # fi - - # - name: Output build.log location - # run: | - # BUILD_LOG_PATH=$(find . -name build.log) - # echo "path is $BUILD_LOG_PATH" - # if [ -n "$BUILD_LOG_PATH" ]; then - # echo "Found build.log at $BUILD_LOG_PATH" - # else - # echo "build.log not found" - # fi - - # - name: Print build.log if build failed - # run: | - # if [ -d result ]; then - # echo "Build successful." - # else - # echo "Build failed. Trying to locate build.log:" - # find . -name build.log - # echo "Printing the build.log (if found):" - # find . -name build.log -exec cat {} \; || true - # fi - - # - name: Build wasm package - # run: nix build .#packages.wasm --keep-failed - - # - name: Copy wasm build result - # working-directory: ./crates/wasm - # run: cp -r ./result ./pkg + - name: Output results + run: ls -la ./result # - name: Checkout noir-wasm-testing # uses: actions/checkout@v3 diff --git a/crates/wasm/build-wasm b/crates/wasm/build-wasm deleted file mode 100755 index 98b655db45d..00000000000 --- a/crates/wasm/build-wasm +++ /dev/null @@ -1,6 +0,0 @@ - -jq -s '.[0] * .[1]' pkg/nodejs/package.json pkg/web/package.json | jq '.files = ["nodejs", "web", "package.json"]' | jq ".version += \"$VERSION_APPENDIX\"" | jq '.main = "./nodejs/" + .main | .module = "./web/" + .module | .types = "./web/" + .types | .peerDependencies = { "@noir-lang/noir-source-resolver": "1.1.2" }' | tee ./pkg/package.json - -rm pkg/nodejs/package.json pkg/nodejs/README.md pkg/nodejs/.gitignore - -rm pkg/web/package.json pkg/web/README.md pkg/web/.gitignore \ No newline at end of file diff --git a/flake.nix b/flake.nix index c51aa238555..0a919eb06c6 100644 --- a/flake.nix +++ b/flake.nix @@ -215,6 +215,7 @@ COMMIT_SHORT = builtins.substring 0 7 GIT_COMMIT; VERSION_APPENDIX = if GIT_DIRTY == "true" then "-dirty" else ""; + PKG_PATH = "crates/wasm/pkg"; src = craneLib.cleanCargoSource (craneLib.path ./.); @@ -229,27 +230,33 @@ buildPhaseCargoCommand = '' RUST_LOG="debug" - PKG_PATH="crates/wasm/pkg" - if [ -d $PKG_PATH ]; then - rm -rf $PKG_PATH + if [ -d ${PKG_PATH} ]; then + rm -rf ${PKG_PATH} fi - # wasm-pack build crates/wasm --mode no-install --scope noir-lang --target web --out-dir pkg/web --release - # echo "NodeJS build complete. Directory contents:" - # ls -la $PKG_PATH/web + wasm-pack build crates/wasm --mode no-install --scope noir-lang --target web --out-dir pkg/web --release + echo "NodeJS build complete. Directory contents:" + ls -la ${PKG_PATH}/web - # wasm-pack build crates/wasm --mode no-install --scope noir-lang --target nodejs --out-dir pkg/nodejs --release - # echo "Web build complete. Directory contents:" - # ls -la $PKG_PATH/nodejs + wasm-pack build crates/wasm --mode no-install --scope noir-lang --target nodejs --out-dir pkg/nodejs --release + echo "Web build complete. Directory contents:" + ls -la ${PKG_PATH}/nodejs - if [ -n $COMMIT_SHORT ]; then - VERSION_APPENDIX="-$COMMIT_SHORT" + if [ -n ${COMMIT_SHORT} ]; then + VERSION_APPENDIX="-${COMMIT_SHORT}" else VERSION_APPENDIX="-NOGIT" fi + # NOTE: This is not working echo "VERSION_APPENDIX = ${VERSION_APPENDIX}" + + jq -s '.[0] * .[1]' ${PKG_PATH}/nodejs/package.json ${PKG_PATH}/web/package.json | jq '.files = ["nodejs", "web", "package.json"]' | jq ".version += \"${VERSION_APPENDIX}\"" | jq '.main = "./nodejs/" + .main | .module = "./web/" + .module | .types = "./web/" + .types | .peerDependencies = { "@noir-lang/noir-source-resolver": "1.1.2" }' | tee ${PKG_PATH}/package.json + + rm ${PKG_PATH}/nodejs/package.json ${PKG_PATH}/nodejs/.gitignore + rm ${PKG_PATH}/web/package.json ${PKG_PATH}/web/.gitignore + cat ${PKG_PATH}/package.json ''; installPhase = '' From eb924be5c790f39b703c533501dbfeb2ae3e9797 Mon Sep 17 00:00:00 2001 From: jonybur Date: Wed, 24 May 2023 14:38:44 +0000 Subject: [PATCH 106/142] Edit workflow --- .github/workflows/wasm.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 7f8722ef85c..361ba09fcf4 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -22,14 +22,16 @@ jobs: github_access_token: ${{ secrets.GITHUB_TOKEN }} - name: Build wasm package - run: nix build -L .#wasm --extra-experimental-features nix-command --extra-experimental-features flakes + run: | + nix build -L .#wasm --extra-experimental-features nix-command --extra-experimental-features flakes + ls -la - name: Copy wasm build result working-directory: ./crates/wasm - run: cp -r ./result ./pkg + run: cp -r ./pkg ./result - name: Output results - run: ls -la ./result + run: ls -la ./pkg # - name: Checkout noir-wasm-testing # uses: actions/checkout@v3 From 8f243ff53e7cb188a1b223fe778e07b6ec842ddd Mon Sep 17 00:00:00 2001 From: jonybur Date: Wed, 24 May 2023 15:21:31 +0000 Subject: [PATCH 107/142] Fix workflow --- .github/workflows/wasm.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 361ba09fcf4..23e93612f76 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -27,11 +27,12 @@ jobs: ls -la - name: Copy wasm build result - working-directory: ./crates/wasm - run: cp -r ./pkg ./result + run: | + mkdir -p ./pkg + cp -r ./result/* ./pkg - name: Output results - run: ls -la ./pkg + run: ls -la ./result # - name: Checkout noir-wasm-testing # uses: actions/checkout@v3 From 3a9b4db32e8bbfff533cb548d0740e6b408bba55 Mon Sep 17 00:00:00 2001 From: jonybur Date: Wed, 24 May 2023 16:50:09 +0000 Subject: [PATCH 108/142] Test fix --- .github/workflows/wasm.yml | 1 + flake.nix | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 23e93612f76..1b2923958f4 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -29,6 +29,7 @@ jobs: - name: Copy wasm build result run: | mkdir -p ./pkg + ls -la cp -r ./result/* ./pkg - name: Output results diff --git a/flake.nix b/flake.nix index 0a919eb06c6..c0d7c806ab4 100644 --- a/flake.nix +++ b/flake.nix @@ -239,9 +239,9 @@ echo "NodeJS build complete. Directory contents:" ls -la ${PKG_PATH}/web - wasm-pack build crates/wasm --mode no-install --scope noir-lang --target nodejs --out-dir pkg/nodejs --release - echo "Web build complete. Directory contents:" - ls -la ${PKG_PATH}/nodejs + # wasm-pack build crates/wasm --mode no-install --scope noir-lang --target nodejs --out-dir pkg/nodejs --release + # echo "Web build complete. Directory contents:" + # ls -la ${PKG_PATH}/nodejs if [ -n ${COMMIT_SHORT} ]; then VERSION_APPENDIX="-${COMMIT_SHORT}" From 5ba85251230c862af8fc1ef8dc24be961766e48b Mon Sep 17 00:00:00 2001 From: jonybur Date: Thu, 25 May 2023 14:41:46 +0000 Subject: [PATCH 109/142] Clone nodejs --- flake.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/flake.nix b/flake.nix index c0d7c806ab4..0573dd128e5 100644 --- a/flake.nix +++ b/flake.nix @@ -242,6 +242,7 @@ # wasm-pack build crates/wasm --mode no-install --scope noir-lang --target nodejs --out-dir pkg/nodejs --release # echo "Web build complete. Directory contents:" # ls -la ${PKG_PATH}/nodejs + cp -R /nodejs /web if [ -n ${COMMIT_SHORT} ]; then VERSION_APPENDIX="-${COMMIT_SHORT}" From 5f71604945eb4757d64ce5b03301ae348a4e5948 Mon Sep 17 00:00:00 2001 From: jonybur Date: Fri, 26 May 2023 00:42:45 +0000 Subject: [PATCH 110/142] Fix copy --- flake.nix | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/flake.nix b/flake.nix index 0573dd128e5..ebcfedd23b6 100644 --- a/flake.nix +++ b/flake.nix @@ -236,13 +236,14 @@ fi wasm-pack build crates/wasm --mode no-install --scope noir-lang --target web --out-dir pkg/web --release - echo "NodeJS build complete. Directory contents:" + echo "Web build complete. Directory contents:" ls -la ${PKG_PATH}/web # wasm-pack build crates/wasm --mode no-install --scope noir-lang --target nodejs --out-dir pkg/nodejs --release - # echo "Web build complete. Directory contents:" + # echo "NodeJS build complete. Directory contents:" # ls -la ${PKG_PATH}/nodejs - cp -R /nodejs /web + + cp -R ${PKG_PATH}/web ${PKG_PATH}/nodejs if [ -n ${COMMIT_SHORT} ]; then VERSION_APPENDIX="-${COMMIT_SHORT}" From bbaada816c0fbaeaa5b3896b2d47cafe88a4c4b2 Mon Sep 17 00:00:00 2001 From: jonybur Date: Fri, 26 May 2023 01:43:58 +0000 Subject: [PATCH 111/142] Add recursive step to copy --- .github/workflows/wasm.yml | 2 +- flake.nix | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 1b2923958f4..75d547ee52e 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -30,7 +30,7 @@ jobs: run: | mkdir -p ./pkg ls -la - cp -r ./result/* ./pkg + cp -r -L ./result/* ./pkg - name: Output results run: ls -la ./result diff --git a/flake.nix b/flake.nix index ebcfedd23b6..dbd1b22f4bb 100644 --- a/flake.nix +++ b/flake.nix @@ -239,11 +239,9 @@ echo "Web build complete. Directory contents:" ls -la ${PKG_PATH}/web - # wasm-pack build crates/wasm --mode no-install --scope noir-lang --target nodejs --out-dir pkg/nodejs --release - # echo "NodeJS build complete. Directory contents:" - # ls -la ${PKG_PATH}/nodejs - - cp -R ${PKG_PATH}/web ${PKG_PATH}/nodejs + wasm-pack build crates/wasm --mode no-install --scope noir-lang --target nodejs --out-dir pkg/nodejs --release + echo "NodeJS build complete. Directory contents:" + ls -la ${PKG_PATH}/nodejs if [ -n ${COMMIT_SHORT} ]; then VERSION_APPENDIX="-${COMMIT_SHORT}" From ba2e86c853239b2a12d36b0a5863bcad870b688d Mon Sep 17 00:00:00 2001 From: jonybur Date: Tue, 30 May 2023 17:04:24 +0000 Subject: [PATCH 112/142] Fix output --- flake.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index dbd1b22f4bb..c30ec376a67 100644 --- a/flake.nix +++ b/flake.nix @@ -260,7 +260,8 @@ ''; installPhase = '' - mkdir - p $out + mkdir -p $out + cp -r ${PKG_PATH}/* $out ''; }; From a915cf2c595fd061191ee18c5fea187cce68bd9a Mon Sep 17 00:00:00 2001 From: jonybur Date: Wed, 31 May 2023 14:52:28 +0000 Subject: [PATCH 113/142] Remove noir_wasm publish step --- .github/workflows/release.yml | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f242f10d971..ed9ca7020fb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,7 +3,7 @@ name: Release on: push: branches: - - master + - jb-nix-flake jobs: release-please: @@ -73,8 +73,8 @@ jobs: token: ${{ secrets.NOIR_REPO_TOKEN }} inputs: '{ "noir-ref": "${{ needs.release-please.outputs.tag-name }}", "publish": true }' - publish-wasm: - name: Publish noir_wasm package + dispatch-noir_wasm: + name: Dispatch to noir_wasm needs: [release-please] if: ${{ needs.release-please.outputs.tag-name }} runs-on: ubuntu-latest @@ -84,6 +84,21 @@ jobs: with: workflow: update.yml repo: noir-lang/noir_wasm - ref: master - token: ${{ secrets.NOIR_REPO_TOKEN }} + ref: jb-nix-flake + token: ${{ secrets.NOIR_RELEASES_TOKEN }} inputs: '{ "noir-ref": "${{ needs.release-please.outputs.tag-name }}" }' + + # publish-wasm: + # name: Publish noir_wasm package + # needs: [release-please] + # if: ${{ needs.release-please.outputs.tag-name }} + # runs-on: ubuntu-latest + # steps: + # - name: Dispatch to noir_wasm + # uses: benc-uk/workflow-dispatch@v1 + # with: + # workflow: update.yml + # repo: noir-lang/noir_wasm + # ref: master + # token: ${{ secrets.NOIR_REPO_TOKEN }} + # inputs: '{ "noir-ref": "${{ needs.release-please.outputs.tag-name }}" }' From cc62a3ae96fd2f74dcd9abae296a49269a0e1147 Mon Sep 17 00:00:00 2001 From: jonybur Date: Thu, 1 Jun 2023 09:55:25 +0000 Subject: [PATCH 114/142] Fix branch name --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ed9ca7020fb..54c75fcf02e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,7 +3,7 @@ name: Release on: push: branches: - - jb-nix-flake + - jb/noir-wasm-workflow jobs: release-please: From 7b6fa8ca3d4cebf4b106bd0c7b50d13821eb7c99 Mon Sep 17 00:00:00 2001 From: jonybur Date: Fri, 2 Jun 2023 13:38:45 +0000 Subject: [PATCH 115/142] Remove condition on dispatch-noir_wasm --- .github/workflows/release.yml | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 54c75fcf02e..bde69ce0dd4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -31,7 +31,7 @@ jobs: update-lockfile: name: Update lockfile needs: [release-please] - if: ${{ needs.release-please.outputs.release-pr }} + # if: ${{ needs.release-please.outputs.release-pr }} runs-on: ubuntu-latest steps: - name: Checkout release branch @@ -58,25 +58,25 @@ jobs: git commit -m 'chore: Update lockfile' git push - build-binaries: - name: Build binaries - needs: [release-please] - if: ${{ needs.release-please.outputs.tag-name }} - runs-on: ubuntu-latest - steps: - - name: Dispatch to build-nargo - uses: benc-uk/workflow-dispatch@v1 - with: - workflow: publish.yml - repo: noir-lang/build-nargo - ref: master - token: ${{ secrets.NOIR_REPO_TOKEN }} - inputs: '{ "noir-ref": "${{ needs.release-please.outputs.tag-name }}", "publish": true }' + # build-binaries: + # name: Build binaries + # needs: [release-please] + # if: ${{ needs.release-please.outputs.tag-name }} + # runs-on: ubuntu-latest + # steps: + # - name: Dispatch to build-nargo + # uses: benc-uk/workflow-dispatch@v1 + # with: + # workflow: publish.yml + # repo: noir-lang/build-nargo + # ref: master + # token: ${{ secrets.NOIR_REPO_TOKEN }} + # inputs: '{ "noir-ref": "${{ needs.release-please.outputs.tag-name }}", "publish": true }' dispatch-noir_wasm: name: Dispatch to noir_wasm needs: [release-please] - if: ${{ needs.release-please.outputs.tag-name }} + # if: ${{ needs.release-please.outputs.tag-name }} runs-on: ubuntu-latest steps: - name: Dispatch to noir_wasm From 0637a8c267e65334e90199b94e43526a3851a3e3 Mon Sep 17 00:00:00 2001 From: jonybur Date: Fri, 2 Jun 2023 15:35:56 +0000 Subject: [PATCH 116/142] Update cargoArtifacts name --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 4d8734d1696..4364fdc10f8 100644 --- a/flake.nix +++ b/flake.nix @@ -275,7 +275,7 @@ pname = "noir_wasm"; version = "1.0.0"; - inherit cargoArtifacts; + cargoArtifacts = native-cargo-artifacts; inherit GIT_COMMIT; inherit GIT_DIRTY; From 623209103879c538fad45ceca36a254a63e939a0 Mon Sep 17 00:00:00 2001 From: jonybur Date: Sat, 3 Jun 2023 00:21:30 +0000 Subject: [PATCH 117/142] Remove wasm workflow, now noir_wasm runs the flake --- .github/workflows/wasm.yml | 78 -------------------------------------- 1 file changed, 78 deletions(-) delete mode 100644 .github/workflows/wasm.yml diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml deleted file mode 100644 index 75d547ee52e..00000000000 --- a/.github/workflows/wasm.yml +++ /dev/null @@ -1,78 +0,0 @@ -name: Wasm - -on: [push, pull_request] - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.ref || github.run_id }} - cancel-in-progress: true - -jobs: - build: - name: Build Wasm - runs-on: ubuntu-latest - - steps: - - name: Checkout sources - uses: actions/checkout@v3 - - - name: Setup Nix - uses: cachix/install-nix-action@v20 - with: - nix_path: nixpkgs=channel:nixos-22.11 - github_access_token: ${{ secrets.GITHUB_TOKEN }} - - - name: Build wasm package - run: | - nix build -L .#wasm --extra-experimental-features nix-command --extra-experimental-features flakes - ls -la - - - name: Copy wasm build result - run: | - mkdir -p ./pkg - ls -la - cp -r -L ./result/* ./pkg - - - name: Output results - run: ls -la ./result - - # - name: Checkout noir-wasm-testing - # uses: actions/checkout@v3 - # with: - # repository: noir-lang/noir-wasm-testing - # path: noir-wasm-testing - - # - name: Inject built wasm into noir-wasm-testing - # run: | - # cp -r ./crates/wasm/result ./noir-wasm-testing/@noir-lang_noir_wasm - # jq '.dependencies["@noir-lang/noir_wasm"] = "file:./node_modules/@noir-lang/noir_wasm"' ./noir-wasm-testing/package.json > ./noir-wasm-testing/package.json.tmp - # mv ./noir-wasm-testing/package.json.tmp ./noir-wasm-testing/package.json - - # - name: Log package information - # working-directory: ./noir-wasm-testing - # run: | - # echo "Wasm contents:" - # ls -la ./@noir-lang_noir_wasm - # echo "Directory contents:" - # ls -la - # echo "package.json contents:" - # cat package.json - # echo "Checking if noir-script.json exists:" - # if [ -f "./src/noir-script/target/noir-script.json" ]; then - # echo "File exists." - # else - # echo "File does not exist." - # fi - - # - name: Run build.sh in noir-wasm-testing - # working-directory: ./noir-wasm-testing - # run: | - # chmod +x build.sh - # ./build.sh - - # - name: Install dependencies - # working-directory: ./noir-wasm-testing - # run: npm install - - # - name: Run tests - # working-directory: ./noir-wasm-testing - # run: npm test From 9dc67f04c1734b640fd1c3f33063ba6bb2e3ebcb Mon Sep 17 00:00:00 2001 From: jonybur Date: Sat, 3 Jun 2023 00:29:39 +0000 Subject: [PATCH 118/142] Comment all the release workflow except for the dispatch --- .github/workflows/release.yml | 109 +++++++++++++++------------------- 1 file changed, 47 insertions(+), 62 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bde69ce0dd4..817f45ad0e2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,57 +6,57 @@ on: - jb/noir-wasm-workflow jobs: - release-please: - name: Create Release - outputs: - release-pr: ${{ steps.release.outputs.pr }} - tag-name: ${{ steps.release.outputs.tag_name }} - runs-on: ubuntu-latest - steps: - - name: Run release-please - id: release - uses: google-github-actions/release-please-action@v3 - with: - token: ${{ secrets.NOIR_RELEASES_TOKEN }} - release-type: simple - package-name: noir - bump-minor-pre-major: true - bump-patch-for-minor-pre-major: true - prerelease: true # Marks GitHub Releases for 0.x.x versions as "Pre-release" - pull-request-title-pattern: "chore(noir): Release ${version}" - extra-files: | - Cargo.toml - flake.nix + # release-please: + # name: Create Release + # outputs: + # release-pr: ${{ steps.release.outputs.pr }} + # tag-name: ${{ steps.release.outputs.tag_name }} + # runs-on: ubuntu-latest + # steps: + # - name: Run release-please + # id: release + # uses: google-github-actions/release-please-action@v3 + # with: + # token: ${{ secrets.NOIR_RELEASES_TOKEN }} + # release-type: simple + # package-name: noir + # bump-minor-pre-major: true + # bump-patch-for-minor-pre-major: true + # prerelease: true # Marks GitHub Releases for 0.x.x versions as "Pre-release" + # pull-request-title-pattern: "chore(noir): Release ${version}" + # extra-files: | + # Cargo.toml + # flake.nix - update-lockfile: - name: Update lockfile - needs: [release-please] - # if: ${{ needs.release-please.outputs.release-pr }} - runs-on: ubuntu-latest - steps: - - name: Checkout release branch - uses: actions/checkout@v3 - with: - ref: ${{ fromJSON(needs.release-please.outputs.release-pr).headBranchName }} - token: ${{ secrets.NOIR_RELEASES_TOKEN }} + # update-lockfile: + # name: Update lockfile + # needs: [release-please] + # if: ${{ needs.release-please.outputs.release-pr }} + # runs-on: ubuntu-latest + # steps: + # - name: Checkout release branch + # uses: actions/checkout@v3 + # with: + # ref: ${{ fromJSON(needs.release-please.outputs.release-pr).headBranchName }} + # token: ${{ secrets.NOIR_RELEASES_TOKEN }} - - name: Setup toolchain - uses: dtolnay/rust-toolchain@1.65.0 + # - name: Setup toolchain + # uses: dtolnay/rust-toolchain@1.65.0 - - name: Update lockfile - run: | - cargo update --workspace + # - name: Update lockfile + # run: | + # cargo update --workspace - - name: Configure git - run: | - git config user.name kevaundray - git config user.email kevtheappdev@gmail.com + # - name: Configure git + # run: | + # git config user.name kevaundray + # git config user.email kevtheappdev@gmail.com - - name: Commit updates - run: | - git add Cargo.lock - git commit -m 'chore: Update lockfile' - git push + # - name: Commit updates + # run: | + # git add Cargo.lock + # git commit -m 'chore: Update lockfile' + # git push # build-binaries: # name: Build binaries @@ -75,7 +75,7 @@ jobs: dispatch-noir_wasm: name: Dispatch to noir_wasm - needs: [release-please] + # needs: [release-please] # if: ${{ needs.release-please.outputs.tag-name }} runs-on: ubuntu-latest steps: @@ -87,18 +87,3 @@ jobs: ref: jb-nix-flake token: ${{ secrets.NOIR_RELEASES_TOKEN }} inputs: '{ "noir-ref": "${{ needs.release-please.outputs.tag-name }}" }' - - # publish-wasm: - # name: Publish noir_wasm package - # needs: [release-please] - # if: ${{ needs.release-please.outputs.tag-name }} - # runs-on: ubuntu-latest - # steps: - # - name: Dispatch to noir_wasm - # uses: benc-uk/workflow-dispatch@v1 - # with: - # workflow: update.yml - # repo: noir-lang/noir_wasm - # ref: master - # token: ${{ secrets.NOIR_REPO_TOKEN }} - # inputs: '{ "noir-ref": "${{ needs.release-please.outputs.tag-name }}" }' From 8d268669bf53e3881942729467df3c736fd27fc7 Mon Sep 17 00:00:00 2001 From: jonybur Date: Sat, 3 Jun 2023 01:09:41 +0000 Subject: [PATCH 119/142] Readd wasm workflow --- .github/workflows/wasm.yml | 76 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 .github/workflows/wasm.yml diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml new file mode 100644 index 00000000000..25ddc0c601d --- /dev/null +++ b/.github/workflows/wasm.yml @@ -0,0 +1,76 @@ +name: Wasm + +on: [push, pull_request] + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.ref || github.run_id }} + cancel-in-progress: true + +jobs: + build: + name: Build Wasm + runs-on: ubuntu-latest + + steps: + - name: Checkout sources + uses: actions/checkout@v3 + + - name: Setup Nix + uses: cachix/install-nix-action@v20 + with: + nix_path: nixpkgs=channel:nixos-22.11 + github_access_token: ${{ secrets.GITHUB_TOKEN }} + + - name: Build wasm package + run: | + nix build -L .#wasm --extra-experimental-features nix-command --extra-experimental-features flakes + ls -la + - name: Copy wasm build result + run: | + mkdir -p ./pkg + ls -la + cp -r -L ./result/* ./pkg + - name: Output results + run: ls -la ./result + + # - name: Checkout noir-wasm-testing + # uses: actions/checkout@v3 + # with: + # repository: noir-lang/noir-wasm-testing + # path: noir-wasm-testing + + # - name: Inject built wasm into noir-wasm-testing + # run: | + # cp -r ./crates/wasm/result ./noir-wasm-testing/@noir-lang_noir_wasm + # jq '.dependencies["@noir-lang/noir_wasm"] = "file:./node_modules/@noir-lang/noir_wasm"' ./noir-wasm-testing/package.json > ./noir-wasm-testing/package.json.tmp + # mv ./noir-wasm-testing/package.json.tmp ./noir-wasm-testing/package.json + + # - name: Log package information + # working-directory: ./noir-wasm-testing + # run: | + # echo "Wasm contents:" + # ls -la ./@noir-lang_noir_wasm + # echo "Directory contents:" + # ls -la + # echo "package.json contents:" + # cat package.json + # echo "Checking if noir-script.json exists:" + # if [ -f "./src/noir-script/target/noir-script.json" ]; then + # echo "File exists." + # else + # echo "File does not exist." + # fi + + # - name: Run build.sh in noir-wasm-testing + # working-directory: ./noir-wasm-testing + # run: | + # chmod +x build.sh + # ./build.sh + + # - name: Install dependencies + # working-directory: ./noir-wasm-testing + # run: npm install + + # - name: Run tests + # working-directory: ./noir-wasm-testing + # run: npm test From ef3a1f7adbaf229a9103ee9cd304f4c055445310 Mon Sep 17 00:00:00 2001 From: jonybur Date: Sat, 3 Jun 2023 01:10:18 +0000 Subject: [PATCH 120/142] Typo --- .github/workflows/wasm.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 25ddc0c601d..75d547ee52e 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -25,11 +25,13 @@ jobs: run: | nix build -L .#wasm --extra-experimental-features nix-command --extra-experimental-features flakes ls -la + - name: Copy wasm build result run: | mkdir -p ./pkg ls -la cp -r -L ./result/* ./pkg + - name: Output results run: ls -la ./result From 5023d894e2517db965b8c6ee6ced74e755dc09f3 Mon Sep 17 00:00:00 2001 From: jonybur Date: Mon, 5 Jun 2023 14:42:25 +0000 Subject: [PATCH 121/142] Remove wasm-pack --- buildPhaseCargoCommand.sh | 34 ++++++++++++++++++++++++++++++++ crates/wasm/README.md | 3 --- crates/wasm/wasm.nix | 28 -------------------------- flake.nix | 41 +++++++++++++-------------------------- installPhase.sh | 2 ++ 5 files changed, 49 insertions(+), 59 deletions(-) create mode 100644 buildPhaseCargoCommand.sh delete mode 100644 crates/wasm/wasm.nix create mode 100644 installPhase.sh diff --git a/buildPhaseCargoCommand.sh b/buildPhaseCargoCommand.sh new file mode 100644 index 00000000000..0d81ac1d3f0 --- /dev/null +++ b/buildPhaseCargoCommand.sh @@ -0,0 +1,34 @@ +RUST_LOG="debug" + +if [ -d ${PKG_PATH} ]; then + rm -rf ${PKG_PATH} +fi + +cargo build --lib --release --target wasm32-unknown-unknown +wasm-bindgen ./target/wasm32-unknown-unknown/release/acvm_simulator.wasm --out-dir ./pkg/nodejs --typescript --target nodejs +wasm-bindgen ./target/wasm32-unknown-unknown/release/acvm_simulator.wasm --out-dir ./pkg/web --typescript --target web +wasm-opt ./pkg/nodejs/acvm_simulator_bg.wasm -o ./pkg/nodejs/acvm_simulator_bg.wasm -O +wasm-opt ./pkg/web/acvm_simulator_bg.wasm -o ./pkg/web/acvm_simulator_bg.wasm -O + +# wasm-pack build crates/wasm --mode no-install --scope noir-lang --target web --out-dir pkg/web --release +# echo "Web build complete. Directory contents:" +# ls -la ${PKG_PATH}/web + +# wasm-pack build crates/wasm --mode no-install --scope noir-lang --target nodejs --out-dir pkg/nodejs --release +# echo "NodeJS build complete. Directory contents:" +# ls -la ${PKG_PATH}/nodejs + +if [ -n ${COMMIT_SHORT} ]; then + VERSION_APPENDIX="-${COMMIT_SHORT}" +else + VERSION_APPENDIX="-NOGIT" +fi + +# NOTE: This is not working +echo "VERSION_APPENDIX = ${VERSION_APPENDIX}" + +jq -s '.[0] * .[1]' ${PKG_PATH}/nodejs/package.json ${PKG_PATH}/web/package.json | jq '.files = ["nodejs", "web", "package.json"]' | jq ".version += \"${VERSION_APPENDIX}\"" | jq '.main = "./nodejs/" + .main | .module = "./web/" + .module | .types = "./web/" + .types | .peerDependencies = { "@noir-lang/noir-source-resolver": "1.1.2" }' | tee ${PKG_PATH}/package.json + +rm ${PKG_PATH}/nodejs/package.json ${PKG_PATH}/nodejs/.gitignore +rm ${PKG_PATH}/web/package.json ${PKG_PATH}/web/.gitignore +cat ${PKG_PATH}/package.json \ No newline at end of file diff --git a/crates/wasm/README.md b/crates/wasm/README.md index 55c5cc4fb19..3714acd329f 100644 --- a/crates/wasm/README.md +++ b/crates/wasm/README.md @@ -4,7 +4,6 @@ In order to build the wasm package, the following must be installed: -- [wasm-pack](https://github.com/rustwasm/wasm-pack) - [jq](https://github.com/stedolan/jq) ## Build @@ -14,5 +13,3 @@ The wasm package can be built using the command below: ```bash ./build-wasm ``` - -Using `wasm-pack` directly isn't recommended as it doesn't generate a complete `package.json` file, resulting in files being omitted from the published package. diff --git a/crates/wasm/wasm.nix b/crates/wasm/wasm.nix deleted file mode 100644 index 8dcd487a98f..00000000000 --- a/crates/wasm/wasm.nix +++ /dev/null @@ -1,28 +0,0 @@ -{ nixpkgs ? import {} }: - -let - rustOverlay = builtins.fetchTarball "https://github.com/oxalica/rust-overlay/archive/master.tar.gz"; - llvm11stdenv = pkgs.llvmPackages_10.stdenv; - - pinnedPkgs = fetchTarball "https://github.com/NixOS/nixpkgs/archive/0938d73bb143f4ae037143572f11f4338c7b2d1c.tar.gz"; - - pkgs = import pinnedPkgs { - overlays = [ (import rustOverlay) ]; - }; - - rustbin = pkgs.rust-bin.stable.latest.default.override { - extensions = [ "rust-src" ]; - targets = [ "wasm32-unknown-unknown" ]; - }; -in -pkgs.mkShell.overrideAttrs (oldAttrs: { - buildInputs = with pkgs; oldAttrs.buildInputs ++ [ - pkg-config - rustbin - wasm-pack - binaryen - git - jq - ]; - stdenv = llvm11stdenv; -}) diff --git a/flake.nix b/flake.nix index 4364fdc10f8..53686a42ab6 100644 --- a/flake.nix +++ b/flake.nix @@ -262,7 +262,6 @@ nixpkgs-fmt llvmPackages.lldb # This ensures the right lldb is in the environment for running rust-lldb wasm-bindgen-cli - wasm-pack ]; shellHook = '' @@ -271,7 +270,7 @@ ''; }); - packages.wasm = craneLib.mkCargoDerivation rec { + packages.wasm = craneLib.mkCargoDerivation (wasmArgs // rec { pname = "noir_wasm"; version = "1.0.0"; @@ -283,7 +282,7 @@ VERSION_APPENDIX = if GIT_DIRTY == "true" then "-dirty" else ""; PKG_PATH = "crates/wasm/pkg"; - src = craneLib.cleanCargoSource (craneLib.path ./.); + src = ./.; nativeBuildInputs = with pkgs; [ which @@ -291,46 +290,32 @@ jq rustToolchain wasm-bindgen-cli - wasm-pack ]; buildPhaseCargoCommand = '' - RUST_LOG="debug" + # bash ./buildPhaseCargoCommand.sh + RUST_LOG="debug" + if [ -d ${PKG_PATH} ]; then rm -rf ${PKG_PATH} fi - wasm-pack build crates/wasm --mode no-install --scope noir-lang --target web --out-dir pkg/web --release - echo "Web build complete. Directory contents:" - ls -la ${PKG_PATH}/web - - wasm-pack build crates/wasm --mode no-install --scope noir-lang --target nodejs --out-dir pkg/nodejs --release - echo "NodeJS build complete. Directory contents:" - ls -la ${PKG_PATH}/nodejs - - if [ -n ${COMMIT_SHORT} ]; then - VERSION_APPENDIX="-${COMMIT_SHORT}" - else - VERSION_APPENDIX="-NOGIT" - fi - - # NOTE: This is not working - echo "VERSION_APPENDIX = ${VERSION_APPENDIX}" - - jq -s '.[0] * .[1]' ${PKG_PATH}/nodejs/package.json ${PKG_PATH}/web/package.json | jq '.files = ["nodejs", "web", "package.json"]' | jq ".version += \"${VERSION_APPENDIX}\"" | jq '.main = "./nodejs/" + .main | .module = "./web/" + .module | .types = "./web/" + .types | .peerDependencies = { "@noir-lang/noir-source-resolver": "1.1.2" }' | tee ${PKG_PATH}/package.json - - rm ${PKG_PATH}/nodejs/package.json ${PKG_PATH}/nodejs/.gitignore - rm ${PKG_PATH}/web/package.json ${PKG_PATH}/web/.gitignore - cat ${PKG_PATH}/package.json + cargo build --lib --release --target x86_64-unknown-linux-gnu + wasm-bindgen ./target/x86_64-unknown-linux-gnu/release/acvm_simulator.wasm --out-dir ./pkg/nodejs --typescript --target nodejs + wasm-bindgen ./target/x86_64-unknown-linux-gnu/release/acvm_simulator.wasm --out-dir ./pkg/web --typescript --target web + wasm-opt ./pkg/nodejs/acvm_simulator_bg.wasm -o ./pkg/nodejs/acvm_simulator_bg.wasm -O + wasm-opt ./pkg/web/acvm_simulator_bg.wasm -o ./pkg/web/acvm_simulator_bg.wasm -O ''; installPhase = '' + # bash ./installPhase.sh + mkdir -p $out cp -r ${PKG_PATH}/* $out ''; - }; + }); }); } diff --git a/installPhase.sh b/installPhase.sh new file mode 100644 index 00000000000..80b076c453e --- /dev/null +++ b/installPhase.sh @@ -0,0 +1,2 @@ +mkdir -p $out +cp -r ${PKG_PATH}/* $out \ No newline at end of file From 2f2c4c334b13e0d4819a0588fbd6a18ff2974979 Mon Sep 17 00:00:00 2001 From: jonybur Date: Mon, 5 Jun 2023 14:44:47 +0000 Subject: [PATCH 122/142] Update script --- flake.nix | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/flake.nix b/flake.nix index 53686a42ab6..c58bbfbff34 100644 --- a/flake.nix +++ b/flake.nix @@ -293,6 +293,7 @@ ]; buildPhaseCargoCommand = '' + # REPLACE WITH: # bash ./buildPhaseCargoCommand.sh RUST_LOG="debug" @@ -306,9 +307,25 @@ wasm-bindgen ./target/x86_64-unknown-linux-gnu/release/acvm_simulator.wasm --out-dir ./pkg/web --typescript --target web wasm-opt ./pkg/nodejs/acvm_simulator_bg.wasm -o ./pkg/nodejs/acvm_simulator_bg.wasm -O wasm-opt ./pkg/web/acvm_simulator_bg.wasm -o ./pkg/web/acvm_simulator_bg.wasm -O + + if [ -n ${COMMIT_SHORT} ]; then + VERSION_APPENDIX="-${COMMIT_SHORT}" + else + VERSION_APPENDIX="-NOGIT" + fi + + # NOTE: This is not working + echo "VERSION_APPENDIX = ${VERSION_APPENDIX}" + + jq -s '.[0] * .[1]' ${PKG_PATH}/nodejs/package.json ${PKG_PATH}/web/package.json | jq '.files = ["nodejs", "web", "package.json"]' | jq ".version += \"${VERSION_APPENDIX}\"" | jq '.main = "./nodejs/" + .main | .module = "./web/" + .module | .types = "./web/" + .types | .peerDependencies = { "@noir-lang/noir-source-resolver": "1.1.2" }' | tee ${PKG_PATH}/package.json + + rm ${PKG_PATH}/nodejs/package.json ${PKG_PATH}/nodejs/.gitignore + rm ${PKG_PATH}/web/package.json ${PKG_PATH}/web/.gitignore + cat ${PKG_PATH}/package.json ''; installPhase = '' + # REPLACE WITH: # bash ./installPhase.sh mkdir -p $out From 63abb4218c05b4d591686e1defb0b6c45e2f993b Mon Sep 17 00:00:00 2001 From: jonybur Date: Mon, 5 Jun 2023 14:51:46 +0000 Subject: [PATCH 123/142] Update script --- buildPhaseCargoCommand.sh | 18 +++++------------- flake.nix | 32 ++++++++++++++++---------------- 2 files changed, 21 insertions(+), 29 deletions(-) diff --git a/buildPhaseCargoCommand.sh b/buildPhaseCargoCommand.sh index 0d81ac1d3f0..5e7f98fb7d1 100644 --- a/buildPhaseCargoCommand.sh +++ b/buildPhaseCargoCommand.sh @@ -4,19 +4,11 @@ if [ -d ${PKG_PATH} ]; then rm -rf ${PKG_PATH} fi -cargo build --lib --release --target wasm32-unknown-unknown -wasm-bindgen ./target/wasm32-unknown-unknown/release/acvm_simulator.wasm --out-dir ./pkg/nodejs --typescript --target nodejs -wasm-bindgen ./target/wasm32-unknown-unknown/release/acvm_simulator.wasm --out-dir ./pkg/web --typescript --target web -wasm-opt ./pkg/nodejs/acvm_simulator_bg.wasm -o ./pkg/nodejs/acvm_simulator_bg.wasm -O -wasm-opt ./pkg/web/acvm_simulator_bg.wasm -o ./pkg/web/acvm_simulator_bg.wasm -O - -# wasm-pack build crates/wasm --mode no-install --scope noir-lang --target web --out-dir pkg/web --release -# echo "Web build complete. Directory contents:" -# ls -la ${PKG_PATH}/web - -# wasm-pack build crates/wasm --mode no-install --scope noir-lang --target nodejs --out-dir pkg/nodejs --release -# echo "NodeJS build complete. Directory contents:" -# ls -la ${PKG_PATH}/nodejs +cargo build --lib --release --target x86_64-unknown-linux-gnu +# wasm-bindgen ./target/x86_64-unknown-linux-gnu/release/noir.wasm --out-dir ./pkg/nodejs --typescript --target nodejs +# wasm-bindgen ./target/x86_64-unknown-linux-gnu/release/noir.wasm --out-dir ./pkg/web --typescript --target web +# wasm-opt ./pkg/nodejs/noir_wasm.wasm -o ./pkg/nodejs/noir_wasm.wasm -O +# wasm-opt ./pkg/web/noir_wasm.wasm -o ./pkg/web/noir_wasm.wasm -O if [ -n ${COMMIT_SHORT} ]; then VERSION_APPENDIX="-${COMMIT_SHORT}" diff --git a/flake.nix b/flake.nix index c58bbfbff34..6135a3352e2 100644 --- a/flake.nix +++ b/flake.nix @@ -303,25 +303,25 @@ fi cargo build --lib --release --target x86_64-unknown-linux-gnu - wasm-bindgen ./target/x86_64-unknown-linux-gnu/release/acvm_simulator.wasm --out-dir ./pkg/nodejs --typescript --target nodejs - wasm-bindgen ./target/x86_64-unknown-linux-gnu/release/acvm_simulator.wasm --out-dir ./pkg/web --typescript --target web - wasm-opt ./pkg/nodejs/acvm_simulator_bg.wasm -o ./pkg/nodejs/acvm_simulator_bg.wasm -O - wasm-opt ./pkg/web/acvm_simulator_bg.wasm -o ./pkg/web/acvm_simulator_bg.wasm -O - - if [ -n ${COMMIT_SHORT} ]; then - VERSION_APPENDIX="-${COMMIT_SHORT}" - else - VERSION_APPENDIX="-NOGIT" - fi + # wasm-bindgen ./target/x86_64-unknown-linux-gnu/release/noir.wasm --out-dir ./pkg/nodejs --typescript --target nodejs + # wasm-bindgen ./target/x86_64-unknown-linux-gnu/release/noir.wasm --out-dir ./pkg/web --typescript --target web + # wasm-opt ./pkg/nodejs/noir_wasm.wasm -o ./pkg/nodejs/noir_wasm.wasm -O + # wasm-opt ./pkg/web/noir_wasm.wasm -o ./pkg/web/noir_wasm.wasm -O + + # if [ -n ${COMMIT_SHORT} ]; then + # VERSION_APPENDIX="-${COMMIT_SHORT}" + # else + # VERSION_APPENDIX="-NOGIT" + # fi - # NOTE: This is not working - echo "VERSION_APPENDIX = ${VERSION_APPENDIX}" + # # NOTE: This is not working + # echo "VERSION_APPENDIX = ${VERSION_APPENDIX}" - jq -s '.[0] * .[1]' ${PKG_PATH}/nodejs/package.json ${PKG_PATH}/web/package.json | jq '.files = ["nodejs", "web", "package.json"]' | jq ".version += \"${VERSION_APPENDIX}\"" | jq '.main = "./nodejs/" + .main | .module = "./web/" + .module | .types = "./web/" + .types | .peerDependencies = { "@noir-lang/noir-source-resolver": "1.1.2" }' | tee ${PKG_PATH}/package.json + # jq -s '.[0] * .[1]' ${PKG_PATH}/nodejs/package.json ${PKG_PATH}/web/package.json | jq '.files = ["nodejs", "web", "package.json"]' | jq ".version += \"${VERSION_APPENDIX}\"" | jq '.main = "./nodejs/" + .main | .module = "./web/" + .module | .types = "./web/" + .types | .peerDependencies = { "@noir-lang/noir-source-resolver": "1.1.2" }' | tee ${PKG_PATH}/package.json - rm ${PKG_PATH}/nodejs/package.json ${PKG_PATH}/nodejs/.gitignore - rm ${PKG_PATH}/web/package.json ${PKG_PATH}/web/.gitignore - cat ${PKG_PATH}/package.json + # rm ${PKG_PATH}/nodejs/package.json ${PKG_PATH}/nodejs/.gitignore + # rm ${PKG_PATH}/web/package.json ${PKG_PATH}/web/.gitignore + # cat ${PKG_PATH}/package.json ''; installPhase = '' From 9363ff5ad500c16b0939cc7236451821b1fca5f0 Mon Sep 17 00:00:00 2001 From: jonybur Date: Mon, 5 Jun 2023 15:19:30 +0000 Subject: [PATCH 124/142] Update targets --- flake.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index 6135a3352e2..01bce89b2a6 100644 --- a/flake.nix +++ b/flake.nix @@ -71,7 +71,7 @@ extensions = [ "rust-src" ]; # possible fix for "section too large" # targets = [ "aarch64-apple-darwin" "wasm32-unknown-unknown" ]; - targets = [ "wasm32-unknown-unknown" ]; + targets = [ "x86_64-unknown-linux-gnu" ]; }; craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain; @@ -282,7 +282,7 @@ VERSION_APPENDIX = if GIT_DIRTY == "true" then "-dirty" else ""; PKG_PATH = "crates/wasm/pkg"; - src = ./.; + src = craneLib.cleanCargoSource (craneLib.path ./.); nativeBuildInputs = with pkgs; [ which From a28e63b321b8207764ee8e227226bd69d90fe5d3 Mon Sep 17 00:00:00 2001 From: jonybur Date: Mon, 5 Jun 2023 16:31:50 +0000 Subject: [PATCH 125/142] wip - changes to build --- flake.nix | 31 +++++++++-------------- buildPhaseCargoCommand.sh => postBuild.sh | 0 2 files changed, 12 insertions(+), 19 deletions(-) rename buildPhaseCargoCommand.sh => postBuild.sh (100%) diff --git a/flake.nix b/flake.nix index 01bce89b2a6..490807cfa80 100644 --- a/flake.nix +++ b/flake.nix @@ -71,7 +71,7 @@ extensions = [ "rust-src" ]; # possible fix for "section too large" # targets = [ "aarch64-apple-darwin" "wasm32-unknown-unknown" ]; - targets = [ "x86_64-unknown-linux-gnu" ]; + targets = [ "wasm32-unknown-unknown" ]; }; craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain; @@ -108,8 +108,9 @@ # filter to include those files in addition to usual rust/cargo source files noirFilter = path: _type: builtins.match ".*nr$" path != null; tomlFilter = path: _type: builtins.match ".*toml$" path != null; + shFilter = path: _type: builtins.match ".*sh$" path != null; sourceFilter = path: type: - (noirFilter path type) || (tomlFilter path type) || (craneLib.filterCargoSources path type); + (noirFilter path type) || (tomlFilter path type) || (shFilter path type) || (craneLib.filterCargoSources path type); # As per https://discourse.nixos.org/t/gcc11stdenv-and-clang/17734/7 since it seems that aarch64-linux uses # gcc9 instead of gcc11 for the C++ stdlib, while all other targets we support provide the correct libstdc++ @@ -270,19 +271,19 @@ ''; }); - packages.wasm = craneLib.mkCargoDerivation (wasmArgs // rec { + packages.wasm = craneLib.buildPackage rec { pname = "noir_wasm"; version = "1.0.0"; - cargoArtifacts = native-cargo-artifacts; inherit GIT_COMMIT; inherit GIT_DIRTY; + doCheck = false; COMMIT_SHORT = builtins.substring 0 7 GIT_COMMIT; VERSION_APPENDIX = if GIT_DIRTY == "true" then "-dirty" else ""; PKG_PATH = "crates/wasm/pkg"; - src = craneLib.cleanCargoSource (craneLib.path ./.); + src = ./.; nativeBuildInputs = with pkgs; [ which @@ -292,21 +293,14 @@ wasm-bindgen-cli ]; - buildPhaseCargoCommand = '' - # REPLACE WITH: - # bash ./buildPhaseCargoCommand.sh - - RUST_LOG="debug" - - if [ -d ${PKG_PATH} ]; then - rm -rf ${PKG_PATH} - fi + cargoExtraArgs = "--package noir_wasm --target wasm32-unknown-unknown"; - cargo build --lib --release --target x86_64-unknown-linux-gnu + postBuild = '' + bash ./postBuild.sh # wasm-bindgen ./target/x86_64-unknown-linux-gnu/release/noir.wasm --out-dir ./pkg/nodejs --typescript --target nodejs # wasm-bindgen ./target/x86_64-unknown-linux-gnu/release/noir.wasm --out-dir ./pkg/web --typescript --target web - # wasm-opt ./pkg/nodejs/noir_wasm.wasm -o ./pkg/nodejs/noir_wasm.wasm -O - # wasm-opt ./pkg/web/noir_wasm.wasm -o ./pkg/web/noir_wasm.wasm -O + # wasm-opt ./pkg/nodejs/noir_wasm_bg.wasm -o ./pkg/nodejs/noir_wasm_bg.wasm -O + # wasm-opt ./pkg/web/noir_wasm_bg.wasm -o ./pkg/web/noir_wasm_bg.wasm -O # if [ -n ${COMMIT_SHORT} ]; then # VERSION_APPENDIX="-${COMMIT_SHORT}" @@ -331,8 +325,7 @@ mkdir -p $out cp -r ${PKG_PATH}/* $out ''; - - }); + }; }); } diff --git a/buildPhaseCargoCommand.sh b/postBuild.sh similarity index 100% rename from buildPhaseCargoCommand.sh rename to postBuild.sh From 59c174609f0e43b9ca36da2473d49f22a701fbcd Mon Sep 17 00:00:00 2001 From: jonybur Date: Mon, 5 Jun 2023 18:15:28 +0000 Subject: [PATCH 126/142] Fix build --- flake.nix | 56 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/flake.nix b/flake.nix index 490807cfa80..0fe5e4f3b01 100644 --- a/flake.nix +++ b/flake.nix @@ -281,7 +281,7 @@ COMMIT_SHORT = builtins.substring 0 7 GIT_COMMIT; VERSION_APPENDIX = if GIT_DIRTY == "true" then "-dirty" else ""; - PKG_PATH = "crates/wasm/pkg"; + PKG_PATH = "./pkg"; src = ./.; @@ -291,39 +291,45 @@ jq rustToolchain wasm-bindgen-cli + binaryen + toml2json ]; - cargoExtraArgs = "--package noir_wasm --target wasm32-unknown-unknown"; + cargoExtraArgs = "--lib --package noir_wasm --target wasm32-unknown-unknown"; postBuild = '' - bash ./postBuild.sh - # wasm-bindgen ./target/x86_64-unknown-linux-gnu/release/noir.wasm --out-dir ./pkg/nodejs --typescript --target nodejs - # wasm-bindgen ./target/x86_64-unknown-linux-gnu/release/noir.wasm --out-dir ./pkg/web --typescript --target web - # wasm-opt ./pkg/nodejs/noir_wasm_bg.wasm -o ./pkg/nodejs/noir_wasm_bg.wasm -O - # wasm-opt ./pkg/web/noir_wasm_bg.wasm -o ./pkg/web/noir_wasm_bg.wasm -O - - # if [ -n ${COMMIT_SHORT} ]; then - # VERSION_APPENDIX="-${COMMIT_SHORT}" - # else - # VERSION_APPENDIX="-NOGIT" - # fi - - # # NOTE: This is not working - # echo "VERSION_APPENDIX = ${VERSION_APPENDIX}" - - # jq -s '.[0] * .[1]' ${PKG_PATH}/nodejs/package.json ${PKG_PATH}/web/package.json | jq '.files = ["nodejs", "web", "package.json"]' | jq ".version += \"${VERSION_APPENDIX}\"" | jq '.main = "./nodejs/" + .main | .module = "./web/" + .module | .types = "./web/" + .types | .peerDependencies = { "@noir-lang/noir-source-resolver": "1.1.2" }' | tee ${PKG_PATH}/package.json - - # rm ${PKG_PATH}/nodejs/package.json ${PKG_PATH}/nodejs/.gitignore - # rm ${PKG_PATH}/web/package.json ${PKG_PATH}/web/.gitignore - # cat ${PKG_PATH}/package.json + # Clear out the existing build artifacts as these aren't automatically removed by wasm-pack. + if [ -d ./pkg/ ]; then + rm -rf ./pkg/ + fi + wasm-bindgen ./target/wasm32-unknown-unknown/release/noir_wasm.wasm --out-dir ./pkg/nodejs --typescript --target nodejs + wasm-bindgen ./target/wasm32-unknown-unknown/release/noir_wasm.wasm --out-dir ./pkg/web --typescript --target web + wasm-opt ./pkg/nodejs/noir_wasm_bg.wasm -o ./pkg/nodejs/noir_wasm_bg.wasm -O + wasm-opt ./pkg/web/noir_wasm_bg.wasm -o ./pkg/web/noir_wasm_bg.wasm -O ''; installPhase = '' - # REPLACE WITH: - # bash ./installPhase.sh + # Extract version from Cargo.toml using toml2json + PACKAGE_VERSION=$(toml2json < Cargo.toml | jq -r .package.version) + if [ -z "$PACKAGE_VERSION" ]; then + echo "Could not extract version from Cargo.toml" + exit 1 + fi + PACKAGE_VERSION+=$VERSION_APPENDIX mkdir -p $out - cp -r ${PKG_PATH}/* $out + cp README.md $out/ + cp -r ./pkg/* $out/ + jq -n --arg ver "$PACKAGE_VERSION" \ + '{ + "version": $ver, + "repository": {"type": "git","url": "https://github.com/noir-lang/acvm-simulator-wasm.git"}, + "sideEffects": false, + "files": ["nodejs","web","package.json"], + "main": "./nodejs/noir_wasm.js", + "types": "./web/noir_wasm.d.ts", + "module": "./web/noir_wasm.js" + }' > $out/package.json ''; }; }); From 8366e5a25187fbe2f1d2e6c9e8790f11945dabb5 Mon Sep 17 00:00:00 2001 From: jonybur Date: Mon, 5 Jun 2023 18:16:09 +0000 Subject: [PATCH 127/142] Fix link --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 0fe5e4f3b01..a6fb5d91b0c 100644 --- a/flake.nix +++ b/flake.nix @@ -323,7 +323,7 @@ jq -n --arg ver "$PACKAGE_VERSION" \ '{ "version": $ver, - "repository": {"type": "git","url": "https://github.com/noir-lang/acvm-simulator-wasm.git"}, + "repository": {"type": "git","url": "https://github.com/noir-lang/noir_wasm.git"}, "sideEffects": false, "files": ["nodejs","web","package.json"], "main": "./nodejs/noir_wasm.js", From e0be03e0df2fbae2d04e0bdd519e3c049462e426 Mon Sep 17 00:00:00 2001 From: jonybur Date: Mon, 5 Jun 2023 18:20:47 +0000 Subject: [PATCH 128/142] Remove unused scripts --- installPhase.sh | 2 -- postBuild.sh | 26 -------------------------- 2 files changed, 28 deletions(-) delete mode 100644 installPhase.sh delete mode 100644 postBuild.sh diff --git a/installPhase.sh b/installPhase.sh deleted file mode 100644 index 80b076c453e..00000000000 --- a/installPhase.sh +++ /dev/null @@ -1,2 +0,0 @@ -mkdir -p $out -cp -r ${PKG_PATH}/* $out \ No newline at end of file diff --git a/postBuild.sh b/postBuild.sh deleted file mode 100644 index 5e7f98fb7d1..00000000000 --- a/postBuild.sh +++ /dev/null @@ -1,26 +0,0 @@ -RUST_LOG="debug" - -if [ -d ${PKG_PATH} ]; then - rm -rf ${PKG_PATH} -fi - -cargo build --lib --release --target x86_64-unknown-linux-gnu -# wasm-bindgen ./target/x86_64-unknown-linux-gnu/release/noir.wasm --out-dir ./pkg/nodejs --typescript --target nodejs -# wasm-bindgen ./target/x86_64-unknown-linux-gnu/release/noir.wasm --out-dir ./pkg/web --typescript --target web -# wasm-opt ./pkg/nodejs/noir_wasm.wasm -o ./pkg/nodejs/noir_wasm.wasm -O -# wasm-opt ./pkg/web/noir_wasm.wasm -o ./pkg/web/noir_wasm.wasm -O - -if [ -n ${COMMIT_SHORT} ]; then - VERSION_APPENDIX="-${COMMIT_SHORT}" -else - VERSION_APPENDIX="-NOGIT" -fi - -# NOTE: This is not working -echo "VERSION_APPENDIX = ${VERSION_APPENDIX}" - -jq -s '.[0] * .[1]' ${PKG_PATH}/nodejs/package.json ${PKG_PATH}/web/package.json | jq '.files = ["nodejs", "web", "package.json"]' | jq ".version += \"${VERSION_APPENDIX}\"" | jq '.main = "./nodejs/" + .main | .module = "./web/" + .module | .types = "./web/" + .types | .peerDependencies = { "@noir-lang/noir-source-resolver": "1.1.2" }' | tee ${PKG_PATH}/package.json - -rm ${PKG_PATH}/nodejs/package.json ${PKG_PATH}/nodejs/.gitignore -rm ${PKG_PATH}/web/package.json ${PKG_PATH}/web/.gitignore -cat ${PKG_PATH}/package.json \ No newline at end of file From 7e4bacce18dae4ab93faebbb775ace2dbba7a22d Mon Sep 17 00:00:00 2001 From: jonybur Date: Tue, 6 Jun 2023 13:50:34 +0000 Subject: [PATCH 129/142] Update Cargo.lock --- Cargo.lock | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 66dffa03c9b..deea4b5f9f0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3320,9 +3320,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.84" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" +checksum = "5bba0e8cb82ba49ff4e229459ff22a191bbe9a1cb3a341610c9c33efc27ddf73" dependencies = [ "cfg-if 1.0.0", "serde", @@ -3332,16 +3332,16 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.84" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9" +checksum = "19b04bc93f9d6bdee709f6bd2118f57dd6679cf1176a1af464fca3ab0d66d8fb" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.12", "wasm-bindgen-shared", ] @@ -3359,9 +3359,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.84" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" +checksum = "14d6b024f1a526bb0234f52840389927257beb670610081360e5a03c5df9c258" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -3369,22 +3369,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.84" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" +checksum = "e128beba882dd1eb6200e1dc92ae6c5dbaa4311aa7bb211ca035779e5efc39f8" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.12", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.84" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" +checksum = "ed9d5b4305409d1fc9482fee2d7f9bcbf24b3972bf59817ef757e23982242a93" [[package]] name = "wasm-encoder" @@ -3902,4 +3902,4 @@ dependencies = [ "quote", "syn 1.0.109", "synstructure", -] \ No newline at end of file +] From fc5f1300c184607bc083e6ddf41a95d7ff5af1e1 Mon Sep 17 00:00:00 2001 From: jonybur Date: Tue, 6 Jun 2023 13:59:50 +0000 Subject: [PATCH 130/142] Update wasm-bindgen --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index a6fb5d91b0c..eb05f23e54e 100644 --- a/flake.nix +++ b/flake.nix @@ -52,7 +52,7 @@ { self, nixpkgs, crane, flake-utils, rust-overlay, barretenberg, ... }: let wasm-bindgen-cli-src = builtins.fetchGit { url = "https://github.com/rustwasm/wasm-bindgen.git"; - rev = "4caa98165c65984e3eba3dd7825f3bf44955d127"; + rev = "2d882c97b005c7b512b364ccd0fed8280bf8f821"; }; in flake-utils.lib.eachDefaultSystem (system: From c577233e9247c04ba8d5f4f21afacaa7b6c4757c Mon Sep 17 00:00:00 2001 From: jonybur Date: Tue, 6 Jun 2023 14:11:03 +0000 Subject: [PATCH 131/142] Update flake lock --- flake.lock | 30 +++++++++++++++--------------- flake.nix | 4 ++-- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/flake.lock b/flake.lock index d2f4e2b8a6d..d4e9251b047 100644 --- a/flake.lock +++ b/flake.lock @@ -10,11 +10,11 @@ ] }, "locked": { - "lastModified": 1683909802, - "narHash": "sha256-2CL8NYKLYwwy6n0RyldvH86ULgrSvfzHrgq2Qf0ZUkE=", + "lastModified": 1685987687, + "narHash": "sha256-NSWBQsSpaQtxHn9nDtP5/T0dmaVlto03RMCf/In8jG8=", "owner": "AztecProtocol", "repo": "barretenberg", - "rev": "97c9bc72aebab850b4a647d6e6cc50085226eafb", + "rev": "871cf65d0e87d385b87d480d0d49bd6384a48bed", "type": "github" }, "original": { @@ -39,11 +39,11 @@ ] }, "locked": { - "lastModified": 1684468982, - "narHash": "sha256-EoC1N5sFdmjuAP3UOkyQujSOT6EdcXTnRw8hPjJkEgc=", + "lastModified": 1685896619, + "narHash": "sha256-6rgKAm8/GaFYOrshu+heVjUCgWTJJpzsm9YyENsYDRo=", "owner": "ipetkov", "repo": "crane", - "rev": "99de890b6ef4b4aab031582125b6056b792a4a30", + "rev": "4bdf5595ae15481b4021358dc17d6c0df8eecd7f", "type": "github" }, "original": { @@ -73,11 +73,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1681202837, - "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", + "lastModified": 1685518550, + "narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=", "owner": "numtide", "repo": "flake-utils", - "rev": "cfacdce06f30d2b68473a46042957675eebb3401", + "rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef", "type": "github" }, "original": { @@ -88,11 +88,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1684580438, - "narHash": "sha256-LUPswmDn6fXP3lEBJFA2Id8PkcYDgzUilevWackYVvQ=", + "lastModified": 1685883127, + "narHash": "sha256-zPDaPNrAtBnO24rNqjHLINHsqTdRbgWy1c/TL3EdwlM=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "7dc71aef32e8faf065cb171700792cf8a65c152d", + "rev": "d4a9ff82fc18723219b60c66fb2ccb0734c460eb", "type": "github" }, "original": { @@ -122,11 +122,11 @@ ] }, "locked": { - "lastModified": 1684808436, - "narHash": "sha256-WG5LgB1+Oguj4H4Bpqr5GoLSc382LyGlaToiOw5xhwA=", + "lastModified": 1686018793, + "narHash": "sha256-3w+6dmVbFg4wJqDMjGmy4Ki5GclJx4AhzSEfAwtu6Aw=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "a227d4571dd1f948138a40ea8b0d0c413eefb44b", + "rev": "32b17eeafe550935bd5ca1afd1717dcefcb97653", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index eb05f23e54e..f5bfcf7aae9 100644 --- a/flake.nix +++ b/flake.nix @@ -304,8 +304,8 @@ fi wasm-bindgen ./target/wasm32-unknown-unknown/release/noir_wasm.wasm --out-dir ./pkg/nodejs --typescript --target nodejs wasm-bindgen ./target/wasm32-unknown-unknown/release/noir_wasm.wasm --out-dir ./pkg/web --typescript --target web - wasm-opt ./pkg/nodejs/noir_wasm_bg.wasm -o ./pkg/nodejs/noir_wasm_bg.wasm -O - wasm-opt ./pkg/web/noir_wasm_bg.wasm -o ./pkg/web/noir_wasm_bg.wasm -O + # wasm-opt ./pkg/nodejs/noir_wasm_bg.wasm -o ./pkg/nodejs/noir_wasm_bg.wasm -O + # wasm-opt ./pkg/web/noir_wasm_bg.wasm -o ./pkg/web/noir_wasm_bg.wasm -O ''; installPhase = '' From b802a8c7ff45bc562cd801856881372a58a7a54e Mon Sep 17 00:00:00 2001 From: jonybur Date: Tue, 6 Jun 2023 16:00:42 +0000 Subject: [PATCH 132/142] Update wasm-bindgen-cli to 0.2.86 --- flake.nix | 45 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/flake.nix b/flake.nix index f5bfcf7aae9..e32c233ed8d 100644 --- a/flake.nix +++ b/flake.nix @@ -49,12 +49,7 @@ }; outputs = - { self, nixpkgs, crane, flake-utils, rust-overlay, barretenberg, ... }: let - wasm-bindgen-cli-src = builtins.fetchGit { - url = "https://github.com/rustwasm/wasm-bindgen.git"; - rev = "2d882c97b005c7b512b364ccd0fed8280bf8f821"; - }; - in + { self, nixpkgs, crane, flake-utils, rust-overlay, barretenberg, ... }: flake-utils.lib.eachDefaultSystem (system: let pkgs = import nixpkgs { @@ -108,9 +103,8 @@ # filter to include those files in addition to usual rust/cargo source files noirFilter = path: _type: builtins.match ".*nr$" path != null; tomlFilter = path: _type: builtins.match ".*toml$" path != null; - shFilter = path: _type: builtins.match ".*sh$" path != null; sourceFilter = path: type: - (noirFilter path type) || (tomlFilter path type) || (shFilter path type) || (craneLib.filterCargoSources path type); + (noirFilter path type) || (tomlFilter path type) || (craneLib.filterCargoSources path type); # As per https://discourse.nixos.org/t/gcc11stdenv-and-clang/17734/7 since it seems that aarch64-linux uses # gcc9 instead of gcc11 for the C++ stdlib, while all other targets we support provide the correct libstdc++ @@ -219,6 +213,37 @@ # We don't want to run checks or tests when just building the project doCheck = false; }); + + rustPlatform = pkgs.makeRustPlatform { + rustc = rustToolchain; + cargo = rustToolchain; + }; + + wasm-bindgen-cli = rustPlatform.buildRustPackage rec { + pname = "wasm-bindgen-cli"; + version = "0.2.86"; + + src = pkgs.fetchCrate { + inherit pname version; + sha256 = "sha256-56EOiLbdgAcoTrkyvB3t9TjtLaRvGxFUXx4haLwE2QY="; + }; + + cargoSha256 = "sha256-4CPBmz92PuPN6KeGDTdYPAf5+vTFk9EN5Cmx4QJy6yI="; + + nativeBuildInputs = [ pkgs.pkg-config ]; + + buildInputs = [ pkgs.openssl ] ++ pkgs.lib.optionals stdenv.isDarwin [ pkgs.curl pkgs.darwin.apple_sdk.frameworks.Security ]; + + doCheck = false; + + meta = with pkgs.lib; { + homepage = "https://rustwasm.github.io/docs/wasm-bindgen/"; + license = with licenses; [ asl20 /* or */ mit ]; + description = "Facilitating high-level interactions between wasm modules and JavaScript"; + maintainers = with maintainers; [ nitsky rizary ]; + mainProgram = "wasm-bindgen"; + }; + }; in rec { checks = { @@ -304,8 +329,8 @@ fi wasm-bindgen ./target/wasm32-unknown-unknown/release/noir_wasm.wasm --out-dir ./pkg/nodejs --typescript --target nodejs wasm-bindgen ./target/wasm32-unknown-unknown/release/noir_wasm.wasm --out-dir ./pkg/web --typescript --target web - # wasm-opt ./pkg/nodejs/noir_wasm_bg.wasm -o ./pkg/nodejs/noir_wasm_bg.wasm -O - # wasm-opt ./pkg/web/noir_wasm_bg.wasm -o ./pkg/web/noir_wasm_bg.wasm -O + wasm-opt ./pkg/nodejs/noir_wasm_bg.wasm -o ./pkg/nodejs/noir_wasm_bg.wasm -O + wasm-opt ./pkg/web/noir_wasm_bg.wasm -o ./pkg/web/noir_wasm_bg.wasm -O ''; installPhase = '' From 5e173ff45cb7ce4af7413dffaf017b51320dabf3 Mon Sep 17 00:00:00 2001 From: jonybur Date: Tue, 6 Jun 2023 16:19:15 +0000 Subject: [PATCH 133/142] Rollback flake.lock changes --- flake.lock | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/flake.lock b/flake.lock index d4e9251b047..535e0eefdb7 100644 --- a/flake.lock +++ b/flake.lock @@ -9,12 +9,12 @@ "nixpkgs" ] }, - "locked": { - "lastModified": 1685987687, - "narHash": "sha256-NSWBQsSpaQtxHn9nDtP5/T0dmaVlto03RMCf/In8jG8=", + "locked": { + "lastModified": 1683909802, + "narHash": "sha256-2CL8NYKLYwwy6n0RyldvH86ULgrSvfzHrgq2Qf0ZUkE=", "owner": "AztecProtocol", "repo": "barretenberg", - "rev": "871cf65d0e87d385b87d480d0d49bd6384a48bed", + "rev": "97c9bc72aebab850b4a647d6e6cc50085226eafb", "type": "github" }, "original": { @@ -39,11 +39,11 @@ ] }, "locked": { - "lastModified": 1685896619, - "narHash": "sha256-6rgKAm8/GaFYOrshu+heVjUCgWTJJpzsm9YyENsYDRo=", + "lastModified": 1684468982, + "narHash": "sha256-EoC1N5sFdmjuAP3UOkyQujSOT6EdcXTnRw8hPjJkEgc=", "owner": "ipetkov", "repo": "crane", - "rev": "4bdf5595ae15481b4021358dc17d6c0df8eecd7f", + "rev": "99de890b6ef4b4aab031582125b6056b792a4a30", "type": "github" }, "original": { @@ -73,11 +73,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1685518550, - "narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=", + "lastModified": 1681202837, + "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", "owner": "numtide", "repo": "flake-utils", - "rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef", + "rev": "cfacdce06f30d2b68473a46042957675eebb3401", "type": "github" }, "original": { @@ -88,11 +88,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1685883127, - "narHash": "sha256-zPDaPNrAtBnO24rNqjHLINHsqTdRbgWy1c/TL3EdwlM=", + "lastModified": 1684580438, + "narHash": "sha256-LUPswmDn6fXP3lEBJFA2Id8PkcYDgzUilevWackYVvQ=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "d4a9ff82fc18723219b60c66fb2ccb0734c460eb", + "rev": "7dc71aef32e8faf065cb171700792cf8a65c152d", "type": "github" }, "original": { @@ -122,11 +122,11 @@ ] }, "locked": { - "lastModified": 1686018793, - "narHash": "sha256-3w+6dmVbFg4wJqDMjGmy4Ki5GclJx4AhzSEfAwtu6Aw=", + "lastModified": 1684808436, + "narHash": "sha256-WG5LgB1+Oguj4H4Bpqr5GoLSc382LyGlaToiOw5xhwA=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "32b17eeafe550935bd5ca1afd1717dcefcb97653", + "rev": "a227d4571dd1f948138a40ea8b0d0c413eefb44b", "type": "github" }, "original": { From 054748dabb272ced3867cf233992ba3a2619f444 Mon Sep 17 00:00:00 2001 From: jonybur Date: Tue, 6 Jun 2023 16:22:32 +0000 Subject: [PATCH 134/142] Rollback Cargo.lock changes --- Cargo.lock | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index deea4b5f9f0..11764720da8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3320,9 +3320,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.86" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bba0e8cb82ba49ff4e229459ff22a191bbe9a1cb3a341610c9c33efc27ddf73" +checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" dependencies = [ "cfg-if 1.0.0", "serde", @@ -3332,16 +3332,16 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.86" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19b04bc93f9d6bdee709f6bd2118f57dd6679cf1176a1af464fca3ab0d66d8fb" +checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.12", + "syn 1.0.109", "wasm-bindgen-shared", ] @@ -3359,9 +3359,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.86" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14d6b024f1a526bb0234f52840389927257beb670610081360e5a03c5df9c258" +checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -3369,22 +3369,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.86" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e128beba882dd1eb6200e1dc92ae6c5dbaa4311aa7bb211ca035779e5efc39f8" +checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.12", + "syn 1.0.109", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.86" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed9d5b4305409d1fc9482fee2d7f9bcbf24b3972bf59817ef757e23982242a93" +checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" [[package]] name = "wasm-encoder" From c10bb3f9c1f88aa9d98f0079761e330775e8f545 Mon Sep 17 00:00:00 2001 From: jonybur Date: Tue, 6 Jun 2023 16:23:08 +0000 Subject: [PATCH 135/142] Remove space --- Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 11764720da8..66dffa03c9b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3902,4 +3902,4 @@ dependencies = [ "quote", "syn 1.0.109", "synstructure", -] +] \ No newline at end of file From 936027d4b8104757ce840dfc3a1d90bd8e419a77 Mon Sep 17 00:00:00 2001 From: jonybur Date: Tue, 6 Jun 2023 16:25:03 +0000 Subject: [PATCH 136/142] Rollback flake.lock --- flake.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/flake.lock b/flake.lock index 535e0eefdb7..53b65eb4b4f 100644 --- a/flake.lock +++ b/flake.lock @@ -9,7 +9,7 @@ "nixpkgs" ] }, - "locked": { + "locked": { "lastModified": 1683909802, "narHash": "sha256-2CL8NYKLYwwy6n0RyldvH86ULgrSvfzHrgq2Qf0ZUkE=", "owner": "AztecProtocol", @@ -39,11 +39,11 @@ ] }, "locked": { - "lastModified": 1684468982, - "narHash": "sha256-EoC1N5sFdmjuAP3UOkyQujSOT6EdcXTnRw8hPjJkEgc=", + "lastModified": 1681177078, + "narHash": "sha256-ZNIjBDou2GOabcpctiQykEQVkI8BDwk7TyvlWlI4myE=", "owner": "ipetkov", "repo": "crane", - "rev": "99de890b6ef4b4aab031582125b6056b792a4a30", + "rev": "0c9f468ff00576577d83f5019a66c557ede5acf6", "type": "github" }, "original": { @@ -88,11 +88,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1684580438, - "narHash": "sha256-LUPswmDn6fXP3lEBJFA2Id8PkcYDgzUilevWackYVvQ=", + "lastModified": 1681269223, + "narHash": "sha256-i6OeI2f7qGvmLfD07l1Az5iBL+bFeP0RHixisWtpUGo=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "7dc71aef32e8faf065cb171700792cf8a65c152d", + "rev": "87edbd74246ccdfa64503f334ed86fa04010bab9", "type": "github" }, "original": { @@ -122,11 +122,11 @@ ] }, "locked": { - "lastModified": 1684808436, - "narHash": "sha256-WG5LgB1+Oguj4H4Bpqr5GoLSc382LyGlaToiOw5xhwA=", + "lastModified": 1681352318, + "narHash": "sha256-+kwy7bTsuW8GYrRqWRQ8T5hg6duZb5IJiHlKo1J+v9g=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "a227d4571dd1f948138a40ea8b0d0c413eefb44b", + "rev": "aeaa11c65a5c5cebaa51652353ab3c497b9a7bbf", "type": "github" }, "original": { From bb31c19daf513e7d27995c8ce63e8436f3388460 Mon Sep 17 00:00:00 2001 From: jonybur Date: Tue, 6 Jun 2023 17:08:24 +0000 Subject: [PATCH 137/142] Update packages (Cargo.lock) --- Cargo.lock | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 66dffa03c9b..deea4b5f9f0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3320,9 +3320,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.84" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" +checksum = "5bba0e8cb82ba49ff4e229459ff22a191bbe9a1cb3a341610c9c33efc27ddf73" dependencies = [ "cfg-if 1.0.0", "serde", @@ -3332,16 +3332,16 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.84" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9" +checksum = "19b04bc93f9d6bdee709f6bd2118f57dd6679cf1176a1af464fca3ab0d66d8fb" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.12", "wasm-bindgen-shared", ] @@ -3359,9 +3359,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.84" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" +checksum = "14d6b024f1a526bb0234f52840389927257beb670610081360e5a03c5df9c258" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -3369,22 +3369,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.84" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" +checksum = "e128beba882dd1eb6200e1dc92ae6c5dbaa4311aa7bb211ca035779e5efc39f8" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.12", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.84" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" +checksum = "ed9d5b4305409d1fc9482fee2d7f9bcbf24b3972bf59817ef757e23982242a93" [[package]] name = "wasm-encoder" @@ -3902,4 +3902,4 @@ dependencies = [ "quote", "syn 1.0.109", "synstructure", -] \ No newline at end of file +] From 0641c223b5ee03169f3d6028f512b882ee96dab7 Mon Sep 17 00:00:00 2001 From: jonybur Date: Thu, 8 Jun 2023 13:51:19 +0000 Subject: [PATCH 138/142] Remove nix build flags --- .github/workflows/wasm.yml | 2 +- crates/wasm/Cargo.toml | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 75d547ee52e..713d6347eb2 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -23,7 +23,7 @@ jobs: - name: Build wasm package run: | - nix build -L .#wasm --extra-experimental-features nix-command --extra-experimental-features flakes + nix build -L .#wasm ls -la - name: Copy wasm build result diff --git a/crates/wasm/Cargo.toml b/crates/wasm/Cargo.toml index c972f1be433..80f86e3d966 100644 --- a/crates/wasm/Cargo.toml +++ b/crates/wasm/Cargo.toml @@ -23,8 +23,4 @@ console_error_panic_hook = "0.1.7" gloo-utils = { version = "0.1", features = ["serde"] } [build-dependencies] -build-data = "0.1.3" - -# added to strip the sections -[profile.release] -strip = true \ No newline at end of file +build-data = "0.1.3" \ No newline at end of file From b58d12f2efb4f4ef9ce7b174ed27680a21b20720 Mon Sep 17 00:00:00 2001 From: Koby Hall <102518238+kobyhallx@users.noreply.github.com> Date: Tue, 13 Jun 2023 14:46:00 +0200 Subject: [PATCH 139/142] Kh noir wasm nix flake (#1657) * chore: ignoring output dir * chore: refactor noir_wasm package build --- .gitignore | 1 + crates/wasm/build.sh | 20 +++++++++ crates/wasm/buildPhaseCargoCommand.sh | 17 ++++++++ crates/wasm/installPhase.sh | 25 +++++++++++ flake.nix | 61 ++++++++++----------------- 5 files changed, 86 insertions(+), 38 deletions(-) create mode 100755 crates/wasm/build.sh create mode 100755 crates/wasm/buildPhaseCargoCommand.sh create mode 100755 crates/wasm/installPhase.sh diff --git a/.gitignore b/.gitignore index 351f5e16a7f..9684106d30c 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ node_modules pkg/ # Nix stuff +**/outputs result .envrc.local .direnv/ diff --git a/crates/wasm/build.sh b/crates/wasm/build.sh new file mode 100755 index 00000000000..2aa0a339aa4 --- /dev/null +++ b/crates/wasm/build.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +function require_command { + if ! command -v "$1" >/dev/null 2>&1; then + echo "Error: $1 is required but not installed." >&2 + exit 1 + fi +} + +require_command toml2json +require_command jq +require_command cargo +require_command wasm-bindgen +require_command wasm-opt + +export pname=$(toml2json < Cargo.toml | jq -r .package.name) + +./buildPhaseCargoCommand.sh +./installPhase.sh + diff --git a/crates/wasm/buildPhaseCargoCommand.sh b/crates/wasm/buildPhaseCargoCommand.sh new file mode 100755 index 00000000000..a9eac8c2000 --- /dev/null +++ b/crates/wasm/buildPhaseCargoCommand.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +# Clear out the existing build artifacts as these aren't automatically removed by wasm-pack. +if [ -d ./pkg/ ]; then + rm -rf ./pkg/ +fi + +WASM_BINARY=./target/wasm32-unknown-unknown/release/${pname}.wasm +NODE_WASM=./pkg/nodejs/${pname}_bg.wasm +BROWSER_WASM=./pkg/nodejs/${pname}_bg.wasm + +# Build the new wasm package +cargo build --lib --release --package noir_wasm --target wasm32-unknown-unknown +wasm-bindgen $WASM_BINARY --out-dir ./pkg/nodejs --typescript --target nodejs +wasm-bindgen $WASM_BINARY --out-dir ./pkg/web --typescript --target web +wasm-opt $NODE_WASM -o $NODE_WASM -O +wasm-opt $BROWSER_WASM -o $BROWSER_WASM -O diff --git a/crates/wasm/installPhase.sh b/crates/wasm/installPhase.sh new file mode 100755 index 00000000000..c653111c1f3 --- /dev/null +++ b/crates/wasm/installPhase.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +# Extract version from Cargo.toml using toml2json +PACKAGE_VERSION=$(toml2json < Cargo.toml | jq -r .workspace.package.version) +if [ -z "$PACKAGE_VERSION" ]; then + echo "Could not extract version from Cargo.toml" + exit 1 +fi +PACKAGE_VERSION+=$VERSION_APPENDIX + +echo PACKAGE_VERSION=$PACKAGE_VERSION + +mkdir -p $out +cp README.md $out/ +cp -r ./pkg/* $out/ +jq -n --arg ver "$PACKAGE_VERSION" \ + '{ + "version": $ver, + "repository": {"type": "git","url": "https://github.com/noir-lang/noir_wasm.git"}, + "sideEffects": false, + "files": ["nodejs","web","package.json"], + "main": "./nodejs/noir_wasm.js", + "types": "./web/noir_wasm.d.ts", + "module": "./web/noir_wasm.js" + }' > $out/package.json diff --git a/flake.nix b/flake.nix index e32c233ed8d..de14809a885 100644 --- a/flake.nix +++ b/flake.nix @@ -167,6 +167,19 @@ buildInputs = [ ] ++ extraBuildInputs; }; + # Combine the environmnet with cargo args needed to build wasm package + noirWasmArgs = wasmEnvironment // { + pname = "noir_wasm"; + + src = ./.; + + cargoExtraArgs = "--lib --package noir_wasm --target wasm32-unknown-unknown"; + + buildInputs = [ ] ++ extraBuildInputs; + + doCheck = false; + }; + # The `port` is parameterized to support parallel test runs without colliding static servers testArgs = port: testEnvironment // { # We provide `barretenberg-transcript00` from the overlay to the tests as a URL hosted via a static server @@ -195,6 +208,7 @@ # Build *just* the cargo dependencies, so we can reuse all of that work between runs native-cargo-artifacts = craneLib.buildDepsOnly nativeArgs; wasm-cargo-artifacts = craneLib.buildDepsOnly wasmArgs; + noir-wasm-cargo-artifacts = craneLib.buildDepsOnly noirWasmArgs; noir-native = craneLib.buildPackage (nativeArgs // { inherit GIT_COMMIT GIT_DIRTY; @@ -286,6 +300,7 @@ git nil nixpkgs-fmt + toml2json llvmPackages.lldb # This ensures the right lldb is in the environment for running rust-lldb wasm-bindgen-cli ]; @@ -296,20 +311,18 @@ ''; }); - packages.wasm = craneLib.buildPackage rec { - pname = "noir_wasm"; - version = "1.0.0"; + packages.wasm = craneLib.mkCargoDerivation (noirWasmArgs // { inherit GIT_COMMIT; inherit GIT_DIRTY; doCheck = false; + cargoArtifacts = noir-wasm-cargo-artifacts; + COMMIT_SHORT = builtins.substring 0 7 GIT_COMMIT; VERSION_APPENDIX = if GIT_DIRTY == "true" then "-dirty" else ""; PKG_PATH = "./pkg"; - src = ./.; - nativeBuildInputs = with pkgs; [ which git @@ -320,43 +333,15 @@ toml2json ]; - cargoExtraArgs = "--lib --package noir_wasm --target wasm32-unknown-unknown"; - - postBuild = '' - # Clear out the existing build artifacts as these aren't automatically removed by wasm-pack. - if [ -d ./pkg/ ]; then - rm -rf ./pkg/ - fi - wasm-bindgen ./target/wasm32-unknown-unknown/release/noir_wasm.wasm --out-dir ./pkg/nodejs --typescript --target nodejs - wasm-bindgen ./target/wasm32-unknown-unknown/release/noir_wasm.wasm --out-dir ./pkg/web --typescript --target web - wasm-opt ./pkg/nodejs/noir_wasm_bg.wasm -o ./pkg/nodejs/noir_wasm_bg.wasm -O - wasm-opt ./pkg/web/noir_wasm_bg.wasm -o ./pkg/web/noir_wasm_bg.wasm -O + buildPhaseCargoCommand = '' + bash crates/wasm/buildPhaseCargoCommand.sh ''; installPhase = '' - # Extract version from Cargo.toml using toml2json - PACKAGE_VERSION=$(toml2json < Cargo.toml | jq -r .package.version) - if [ -z "$PACKAGE_VERSION" ]; then - echo "Could not extract version from Cargo.toml" - exit 1 - fi - PACKAGE_VERSION+=$VERSION_APPENDIX - - mkdir -p $out - cp README.md $out/ - cp -r ./pkg/* $out/ - jq -n --arg ver "$PACKAGE_VERSION" \ - '{ - "version": $ver, - "repository": {"type": "git","url": "https://github.com/noir-lang/noir_wasm.git"}, - "sideEffects": false, - "files": ["nodejs","web","package.json"], - "main": "./nodejs/noir_wasm.js", - "types": "./web/noir_wasm.d.ts", - "module": "./web/noir_wasm.js" - }' > $out/package.json + bash crates/wasm/installPhase.sh ''; - }; + + }); }); } From 367df3c00dd5b72e00da7ce59cc97dca45339e4d Mon Sep 17 00:00:00 2001 From: jonybur Date: Tue, 13 Jun 2023 13:00:36 +0000 Subject: [PATCH 140/142] Uncomment workflows --- .github/workflows/release.yml | 128 +++++++++++++++++----------------- .github/workflows/wasm.yml | 2 + 2 files changed, 66 insertions(+), 64 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 817f45ad0e2..5240fe092b7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,80 +3,80 @@ name: Release on: push: branches: - - jb/noir-wasm-workflow + - master jobs: - # release-please: - # name: Create Release - # outputs: - # release-pr: ${{ steps.release.outputs.pr }} - # tag-name: ${{ steps.release.outputs.tag_name }} - # runs-on: ubuntu-latest - # steps: - # - name: Run release-please - # id: release - # uses: google-github-actions/release-please-action@v3 - # with: - # token: ${{ secrets.NOIR_RELEASES_TOKEN }} - # release-type: simple - # package-name: noir - # bump-minor-pre-major: true - # bump-patch-for-minor-pre-major: true - # prerelease: true # Marks GitHub Releases for 0.x.x versions as "Pre-release" - # pull-request-title-pattern: "chore(noir): Release ${version}" - # extra-files: | - # Cargo.toml - # flake.nix + release-please: + name: Create Release + outputs: + release-pr: ${{ steps.release.outputs.pr }} + tag-name: ${{ steps.release.outputs.tag_name }} + runs-on: ubuntu-latest + steps: + - name: Run release-please + id: release + uses: google-github-actions/release-please-action@v3 + with: + token: ${{ secrets.NOIR_RELEASES_TOKEN }} + release-type: simple + package-name: noir + bump-minor-pre-major: true + bump-patch-for-minor-pre-major: true + prerelease: true # Marks GitHub Releases for 0.x.x versions as "Pre-release" + pull-request-title-pattern: "chore(noir): Release ${version}" + extra-files: | + Cargo.toml + flake.nix - # update-lockfile: - # name: Update lockfile - # needs: [release-please] - # if: ${{ needs.release-please.outputs.release-pr }} - # runs-on: ubuntu-latest - # steps: - # - name: Checkout release branch - # uses: actions/checkout@v3 - # with: - # ref: ${{ fromJSON(needs.release-please.outputs.release-pr).headBranchName }} - # token: ${{ secrets.NOIR_RELEASES_TOKEN }} + update-lockfile: + name: Update lockfile + needs: [release-please] + if: ${{ needs.release-please.outputs.release-pr }} + runs-on: ubuntu-latest + steps: + - name: Checkout release branch + uses: actions/checkout@v3 + with: + ref: ${{ fromJSON(needs.release-please.outputs.release-pr).headBranchName }} + token: ${{ secrets.NOIR_RELEASES_TOKEN }} - # - name: Setup toolchain - # uses: dtolnay/rust-toolchain@1.65.0 + - name: Setup toolchain + uses: dtolnay/rust-toolchain@1.65.0 - # - name: Update lockfile - # run: | - # cargo update --workspace + - name: Update lockfile + run: | + cargo update --workspace - # - name: Configure git - # run: | - # git config user.name kevaundray - # git config user.email kevtheappdev@gmail.com + - name: Configure git + run: | + git config user.name kevaundray + git config user.email kevtheappdev@gmail.com - # - name: Commit updates - # run: | - # git add Cargo.lock - # git commit -m 'chore: Update lockfile' - # git push + - name: Commit updates + run: | + git add Cargo.lock + git commit -m 'chore: Update lockfile' + git push - # build-binaries: - # name: Build binaries - # needs: [release-please] - # if: ${{ needs.release-please.outputs.tag-name }} - # runs-on: ubuntu-latest - # steps: - # - name: Dispatch to build-nargo - # uses: benc-uk/workflow-dispatch@v1 - # with: - # workflow: publish.yml - # repo: noir-lang/build-nargo - # ref: master - # token: ${{ secrets.NOIR_REPO_TOKEN }} - # inputs: '{ "noir-ref": "${{ needs.release-please.outputs.tag-name }}", "publish": true }' + build-binaries: + name: Build binaries + needs: [release-please] + if: ${{ needs.release-please.outputs.tag-name }} + runs-on: ubuntu-latest + steps: + - name: Dispatch to build-nargo + uses: benc-uk/workflow-dispatch@v1 + with: + workflow: publish.yml + repo: noir-lang/build-nargo + ref: master + token: ${{ secrets.NOIR_REPO_TOKEN }} + inputs: '{ "noir-ref": "${{ needs.release-please.outputs.tag-name }}", "publish": true }' dispatch-noir_wasm: name: Dispatch to noir_wasm - # needs: [release-please] - # if: ${{ needs.release-please.outputs.tag-name }} + needs: [release-please] + if: ${{ needs.release-please.outputs.tag-name }} runs-on: ubuntu-latest steps: - name: Dispatch to noir_wasm @@ -84,6 +84,6 @@ jobs: with: workflow: update.yml repo: noir-lang/noir_wasm - ref: jb-nix-flake + ref: master token: ${{ secrets.NOIR_RELEASES_TOKEN }} inputs: '{ "noir-ref": "${{ needs.release-please.outputs.tag-name }}" }' diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 713d6347eb2..09e343c57fd 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -35,6 +35,8 @@ jobs: - name: Output results run: ls -la ./result + # Todo: Enable wasm testing by injecting wasm into noir-wasm-testing + # - name: Checkout noir-wasm-testing # uses: actions/checkout@v3 # with: From 1f7dccf7fe17c820ee661a369aaa1fef57de1b13 Mon Sep 17 00:00:00 2001 From: jonybur Date: Tue, 13 Jun 2023 13:01:54 +0000 Subject: [PATCH 141/142] Revert workflow changes --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5240fe092b7..1b95c271f35 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -85,5 +85,5 @@ jobs: workflow: update.yml repo: noir-lang/noir_wasm ref: master - token: ${{ secrets.NOIR_RELEASES_TOKEN }} + token: ${{ secrets.NOIR_REPO_TOKEN }} inputs: '{ "noir-ref": "${{ needs.release-please.outputs.tag-name }}" }' From 77dbe59ef49d8fc7f2fe1b88b00bf76097da6497 Mon Sep 17 00:00:00 2001 From: jonybur Date: Tue, 13 Jun 2023 13:02:56 +0000 Subject: [PATCH 142/142] Revert workflow --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1b95c271f35..f242f10d971 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -73,8 +73,8 @@ jobs: token: ${{ secrets.NOIR_REPO_TOKEN }} inputs: '{ "noir-ref": "${{ needs.release-please.outputs.tag-name }}", "publish": true }' - dispatch-noir_wasm: - name: Dispatch to noir_wasm + publish-wasm: + name: Publish noir_wasm package needs: [release-please] if: ${{ needs.release-please.outputs.tag-name }} runs-on: ubuntu-latest