2020-09-10 21:42:46 -04:00
|
|
|
#!/bin/bash
|
|
|
|
|
# This script will update emsdk/bazel/WORKSPACE to the latest version of
|
2021-08-25 17:21:40 -07:00
|
|
|
# emscripten. It reads emsdk/emscripten-releases-tags.json to get the latest
|
2020-09-10 21:42:46 -04:00
|
|
|
# version number. Then, it downloads the prebuilts for that version and computes
|
|
|
|
|
# the sha256sum for the archive. It then puts all this information into the
|
|
|
|
|
# emsdk/bazel/WORKSPACE file.
|
|
|
|
|
|
|
|
|
|
ERR=0
|
|
|
|
|
# Attempt to change to the emsdk root directory
|
|
|
|
|
cd $(dirname $0)/..
|
|
|
|
|
|
|
|
|
|
# If the previous command succeeded. We are in the emsdk root. Check to make
|
|
|
|
|
# sure the files and directories we need are present.
|
|
|
|
|
if [[ $? = 0 ]]; then
|
2021-08-25 17:21:40 -07:00
|
|
|
if [[ ! -f emscripten-releases-tags.json ]]; then
|
|
|
|
|
echo "Cannot find emscripten-releases-tags.json."
|
2020-09-10 21:42:46 -04:00
|
|
|
ERR=1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [[ ! -d bazel ]]; then
|
|
|
|
|
echo "Cannot find the bazel directory."
|
|
|
|
|
ERR=1
|
|
|
|
|
elif [[ ! -f bazel/WORKSPACE ]]; then
|
|
|
|
|
echo "Cannot find bazel/WORKSPACE."
|
|
|
|
|
ERR=1
|
|
|
|
|
fi
|
|
|
|
|
else
|
|
|
|
|
ERR=1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [[ $ERR = 1 ]]; then
|
|
|
|
|
echo "Unable to cd into the emsdk root directory."
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
2021-03-25 00:50:44 +01:00
|
|
|
URL1=https://storage.googleapis.com/webassembly/emscripten-releases-builds/
|
2022-02-11 11:18:16 -08:00
|
|
|
URL2=/wasm-binaries
|
2020-09-10 21:42:46 -04:00
|
|
|
|
2021-03-25 00:50:44 +01:00
|
|
|
# Get commit hash for $1 version
|
|
|
|
|
get_hash () {
|
2022-02-11 11:18:16 -08:00
|
|
|
echo $(grep "$1" emscripten-releases-tags.json | grep -v latest | grep -v asserts | cut -f4 -d\")
|
2021-03-25 00:50:44 +01:00
|
|
|
}
|
|
|
|
|
|
2022-02-11 11:18:16 -08:00
|
|
|
# Get sha256 for $1 os $2 extname $3 hash $4 architecture
|
2021-03-25 00:50:44 +01:00
|
|
|
get_sha () {
|
2022-02-11 11:18:16 -08:00
|
|
|
echo $(curl "${URL1}$1/$3${URL2}$4.$2" 2>/dev/null | sha256sum | awk '{print $1}')
|
2021-03-25 00:50:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Assemble dictionary line
|
|
|
|
|
revisions_item () {
|
|
|
|
|
hash=$(get_hash $1)
|
|
|
|
|
echo \
|
2021-10-19 15:56:55 -04:00
|
|
|
"\ \"$1\": struct(\n" \
|
2021-03-25 00:50:44 +01:00
|
|
|
"\ hash = \"$(get_hash ${hash})\",\n" \
|
2021-12-20 11:24:56 -08:00
|
|
|
"\ sha_linux = \"$(get_sha linux tbz2 ${hash})\",\n" \
|
|
|
|
|
"\ sha_mac = \"$(get_sha mac tbz2 ${hash})\",\n" \
|
2022-02-11 11:18:16 -08:00
|
|
|
"\ sha_mac_arm64 = \"$(get_sha mac tbz2 ${hash} -arm64)\",\n" \
|
2021-12-20 11:24:56 -08:00
|
|
|
"\ sha_win = \"$(get_sha win zip ${hash})\",\n" \
|
2021-03-25 00:50:44 +01:00
|
|
|
"\ ),"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
append_revision () {
|
|
|
|
|
sed -i "5 i $(revisions_item $1)" bazel/revisions.bzl
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-25 17:21:40 -07:00
|
|
|
# Get the latest version number from emscripten-releases-tag.json.
|
2020-09-10 21:42:46 -04:00
|
|
|
VER=$(grep -oP '(?<=latest\": \")([\d\.]+)(?=\")' \
|
2021-08-25 17:21:40 -07:00
|
|
|
emscripten-releases-tags.json \
|
2020-09-10 21:42:46 -04:00
|
|
|
| sed --expression "s/\./\\\./g")
|
2021-03-25 00:50:44 +01:00
|
|
|
|
|
|
|
|
append_revision ${VER}
|
2020-09-10 21:42:46 -04:00
|
|
|
|
|
|
|
|
echo "Done!"
|