Unverified Commit 3b1b0d89 authored by Cecylia Bocovich's avatar Cecylia Bocovich 💬 Committed by boklm
Browse files

Bug 40852: Compile lox library to wasm

parent 5380e131
Loading
Loading
Loading
Loading
+3 −0
Changes for Makefile: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -615,6 +615,9 @@ 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-lox: submodule-update
	$(rbm) build lox-wasm --step cargo_vendor --target nightly --target torbrowser-linux-x86_64

go_vendor-snowflake-alpha: submodule-update
	$(rbm) build snowflake --step go_vendor --target alpha --target torbrowser-linux-x86_64

+39 −0
Changes for projects/lox-wasm/build: 39 added lines, 0 removed lines.
Original line number Diff line number Diff line
#!/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.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
[% c('tar', {
        tar_src => [ project ],
        tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'),
    }) %]
+25 −0
Changes for projects/lox-wasm/config: 25 added lines, 0 removed lines.
Original line number Diff line number Diff line
# 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