Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit 301d44d

Browse files
committed
Refactor build scripts.
1 parent 9266a49 commit 301d44d

File tree

14 files changed

+96
-55
lines changed

14 files changed

+96
-55
lines changed

.travis.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,8 @@ matrix:
1414
script:
1515
- cargo test --all
1616
- cargo clean
17-
- ./publish-wasm.sh
17+
- ./init.sh
18+
- ./build.sh
19+
- if [ "$TRAVIS_PULL_REQUEST" != "true" ] && [ "$TRAVIS_BRANCH" == "master" ]; then
20+
./publish-wasm.sh;
21+
fi

build.sh

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,27 @@
1-
#!/bin/sh
1+
#!/bin/bash
22

3-
# NOTE `cargo install wasm-gc` before running this script.
4-
# NOTE `cargo install --git https://github.com/pepyakin/wasm-export-table.git`
3+
# This script assumes that all pre-requisites are installed.
54

65
set -e
6+
7+
source `dirname "$0"`/common.sh
8+
79
export CARGO_INCREMENTAL=0
810

9-
cd demo/runtime/wasm && ./build.sh && cd ../../..
10-
cd substrate/executor/wasm && ./build.sh && cd ../../..
11-
cd substrate/test-runtime/wasm && ./build.sh && cd ../../..
12-
cd polkadot/runtime/wasm && ./build.sh && cd ../../..
13-
cd polkadot/parachain/test-chains && ./build.sh && cd ../../..
11+
# Save current directory.
12+
pushd .
13+
14+
cd $ROOT
15+
16+
for SRC in "${SRCS[@]}"
17+
do
18+
echo "*** Building wasm binaries in $SRC"
19+
cd $SRC
20+
21+
./build.sh
22+
23+
cd - >> /dev/null
24+
done
25+
26+
# Restore initial directory.
27+
popd

common.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
ROOT=`dirname "$0"`
4+
5+
# A list of directories which contain wasm projects.
6+
SRCS=(
7+
"polkadot/runtime/wasm"
8+
"substrate/executor/wasm"
9+
"demo/runtime/wasm"
10+
"substrate/test-runtime/wasm"
11+
"polkadot/parachain/test-chains/basic_add"
12+
)
13+
14+
# Make pushd/popd silent.
15+
16+
pushd () {
17+
command pushd "$@" > /dev/null
18+
}
19+
20+
popd () {
21+
command popd "$@" > /dev/null
22+
}

demo/runtime/wasm/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/bin/bash
22
set -e
33

44
cargo +nightly build --target=wasm32-unknown-unknown --release

demo/runtime/wasm/init.sh

Lines changed: 0 additions & 7 deletions
This file was deleted.

init.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
echo "*** Initilising WASM build environment"
6+
7+
rustup update nightly
8+
rustup target add wasm32-unknown-unknown --toolchain nightly
9+
rustup update stable
10+
11+
# Install wasm-gc. It's useful for stripping slimming down wasm binaries.
12+
command -v wasm-gc || \
13+
cargo +nightly install --git https://github.com/alexcrichton/wasm-gc
14+
15+
# At the moment of writing, rustc still uses LLD 6 which produces wasm binaries
16+
# that don't export a table. Meanwhile, we are waiting for LLD 7 to come
17+
# in rustc we could use this handy little tool.
18+
command -v wasm-export-table || \
19+
cargo +nightly install --git https://github.com/pepyakin/wasm-export-table.git
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Make LLD produce a binary that imports memory from the outside environment.
5+
export RUSTFLAGS="-C link-arg=--import-memory"
6+
7+
cargo +nightly build --target=wasm32-unknown-unknown --release --no-default-features
8+
9+
for i in basic_add
10+
do
11+
wasm-gc target/wasm32-unknown-unknown/release/$i.wasm target/wasm32-unknown-unknown/release/$i.compact.wasm
12+
done

polkadot/parachain/test-chains/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/bin/bash
22
set -e
33

44
rm -rf ./target

polkadot/runtime/wasm/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/bin/bash
22
set -e
33

44
cargo +nightly build --target=wasm32-unknown-unknown --release

polkadot/runtime/wasm/init.sh

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)