boklm pushed to branch main at The Tor Project / Applications / tor-browser-build
Commits: 3b1b0d89 by Cecylia Bocovich at 2023-10-17T15:38:41+02:00 Bug 40852: Compile lox library to wasm
- - - - - f1003d94 by Cecylia Bocovich at 2023-10-17T15:38:43+02:00 Bug 40852: Add wasm-bindgen project
- - - - - 94a3fda8 by Cecylia Bocovich at 2023-10-17T15:38:45+02:00 Bug 40852: Generate javascript bindings for lox-wasm
- - - - -
5 changed files:
- Makefile - + projects/lox-wasm/build - + projects/lox-wasm/config - + projects/wasm-bindgen/build - + projects/wasm-bindgen/config
Changes:
===================================== Makefile ===================================== @@ -615,6 +615,12 @@ cargo_vendor-application-services: submodule-update cargo_vendor-cbindgen: submodule-update $(rbm) build cbindgen --step cargo_vendor --target alpha --target torbrowser-linux-x86_64
+cargo_vendor-wasm-bindgen: submodule-update + $(rbm) build wasm-bindgen --step cargo_vendor --target alpha --target torbrowser-linux-x86_64 + +cargo_vendor-lox: submodule-update + $(rbm) build lox-wasm --step cargo_vendor --target alpha --target torbrowser-linux-x86_64 + go_vendor-snowflake-alpha: submodule-update $(rbm) build snowflake --step go_vendor --target alpha --target torbrowser-linux-x86_64
===================================== projects/lox-wasm/build ===================================== @@ -0,0 +1,43 @@ +#!/bin/bash +[% c("var/set_default_env") -%] +distdir=/var/tmp/dist +builddir=/var/tmp/build/[% project %] +mkdir -p $distdir/[% project %] +tar -C /var/tmp/dist -xf $rootdir/[% c('input_files_by_name/rust') %] +export PATH="/var/tmp/dist/rust/bin:$PATH" +tar -C /var/tmp/dist -xf $rootdir/[% c('input_files_by_name/wasm-bindgen') %] +export PATH="/var/tmp/dist/wasm-bindgen:$PATH" +[% IF c("var/linux") -%] + export LD_LIBRARY_PATH="/var/tmp/dist/rust/lib:$LD_LIBRARY_PATH" +[% END -%] +mkdir -p /var/tmp/build +tar -C /var/tmp/build -xf [% project %]-[% c('version') %].tar.gz + +# Now prepare the offline build +# Move the directory for hardcoding the path in .cargo/config +mv /var/tmp/build/[% project %]-[% c('version') %] $builddir +tar -C $builddir -xf $rootdir/[% c('input_files_by_name/cargo_vendor') %] +cd $builddir +mkdir .cargo +cat > .cargo/config << 'EOF' +[source.crates-io] +replace-with = "vendored-sources" + +[source."https://git-crysp.uwaterloo.ca/iang/lox.git"] +git = "https://git-crysp.uwaterloo.ca/iang/lox.git" +replace-with = "vendored-sources" + +[source.vendored-sources] +directory = "/var/tmp/build/lox-wasm/vendor" +EOF + +cargo build -p lox-wasm --release --frozen --target wasm32-unknown-unknown +mv target/wasm32-unknown-unknown/release/lox_wasm.wasm $distdir/[% project %] + +cd $distdir +wasm-bindgen --out-dir [% project %] --target web [% project %]/lox_wasm.wasm + +[% c('tar', { + tar_src => [ project ], + tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'), + }) %]
===================================== projects/lox-wasm/config ===================================== @@ -0,0 +1,25 @@ +# vim: filetype=yaml sw=2 +# Remember to update also the package's hash, with the version! +version: "0.1.0" +git_url: https://gitlab.torproject.org/tpo/anti-censorship/lox-rs +git_hash: 003d9c886be3cef59c4c61db03e54a90990e2e93 +container: + use_container: 1 + +steps: + build: + filename: '[% project %]-[% c("version") %]-[% c("var/build_id") %].tar.[% c("compress_tar") %]' + input_files: + - project: container-image + pkg_type: build + - project: rust + name: rust + pkg_type: build + - project: wasm-bindgen + name: wasm-bindgen + pkg_type: build + - name: cargo_vendor + project: lox-wasm + pkg_type: cargo_vendor + norec: + sha256sum: c4d31f971d406688a08414d471bca6ae2dcea4ce9507ab44a4e54324768c2b22
===================================== projects/wasm-bindgen/build ===================================== @@ -0,0 +1,44 @@ +#!/bin/bash +[% c("var/set_default_env") -%] +distdir=/var/tmp/dist +builddir=/var/tmp/build/[% project %] +mkdir -p $distdir/[% project %] +tar -C /var/tmp/dist -xf $rootdir/[% c('input_files_by_name/rust') %] +export PATH="/var/tmp/dist/rust/bin:$PATH" +[% IF c("var/linux") -%] + export LD_LIBRARY_PATH="/var/tmp/dist/rust/lib:$LD_LIBRARY_PATH" +[% END -%] +mkdir -p /var/tmp/build +tar -C /var/tmp/build -xf [% project %]-[% c('version') %].tar.[% c('compress_tar') %] + +# Now prepare the offline build +# Move the directory for hardcoding the path in .cargo/config +mv /var/tmp/build/[% project %]-[% c('version') %] $builddir +tar -C $builddir -xf $rootdir/[% c('input_files_by_name/cargo_vendor') %] +cd $builddir +cat > .cargo/config << 'EOF' +[source.crates-io] +replace-with = "vendored-sources" + +[source."git+https://github.com/alexcrichton/raytracer?branch=update-deps"] +git = "https://github.com/alexcrichton/raytracer" +branch = "update-deps" +replace-with = "vendored-sources" + +[source."git+https://github.com/rustwasm/weedle.git"] +git = "https://github.com/rustwasm/weedle.git" +replace-with = "vendored-sources" + +[source.vendored-sources] +directory = "/var/tmp/build/wasm-bindgen/vendor" +EOF + +cargo build -p wasm-bindgen-cli --release --frozen --target x86_64-unknown-linux-gnu +cd $builddir +mv target/x86_64-unknown-linux-gnu/release/wasm-bindgen $distdir/[% project %] + +cd $distdir +[% c('tar', { + tar_src => [ project ], + tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'), + }) %]
===================================== projects/wasm-bindgen/config ===================================== @@ -0,0 +1,19 @@ +# vim: filetype=yaml sw=2 +version: 0.2.86 +git_url: https://github.com/cohosh/wasm-bindgen +git_hash: ecc5ca153cda278bfcebc99c157fb4732eb75e6e +container: + use_container: 1 + +steps: + build: + filename: '[% project %]-[% c("version") %]-[% c("var/build_id") %].tar.[% c("compress_tar") %]' + input_files: + - project: container-image + - project: rust + name: rust + - name: cargo_vendor + project: wasm-bindgen + pkg_type: cargo_vendor + norec: + sha256sum: 926e938cc4eebf2f5c99f34170fddc5aa7b12445fb379d768eb51aaae3b305a3
View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser-build/-/compare/5...
tor-commits@lists.torproject.org