Skip to content

Commit

Permalink
Improve output from build scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
peaBerberian committed Aug 28, 2024
1 parent 043d123 commit a3d1944
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 19 deletions.
34 changes: 21 additions & 13 deletions scripts/build_wasm_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,21 @@
# TODO documentation

print_toolchain_installation_notice() {
echo " +----------------------------------------------------------------------------------+"
echo " | A rust toolchain will be installed locally in a temporary directory (./tmp). |"
echo " | |"
echo " | If you intend to develop on the RxPlayer regularly, it is recommended that you |"
echo " | install globally rustup (with the \"wasm32-unknown-unknown\" target) as well as |"
echo " | binaryen. Once done, please remove this \"tmp\" directory. |"
echo " +----------------------------------------------------------------------------------+"
echo ""
echo ""
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~ RxPlayer building Info ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo ""
echo " A Rust toolchain is needed to build some components of the RxPlayer."
echo " We will thus now install one locally in the following temporary directory:"
echo " $(pwd)/tmp "
echo ""
echo " If you intend to develop or build the RxPlayer regularly, you can install rustup or"
echo " cargo globally (with the \"wasm32-unknown-unknown\" target) as well as binaryen."
echo " Once done, this \"tmp\" directory can be removed."
echo ""
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo ""
echo ""
}

has_local_cargo=false
Expand Down Expand Up @@ -47,18 +55,18 @@ fi

# Move to MPD parser directory
cd ./src/parsers/manifest/dash/wasm-parser
echo "Building mpd-parser WebAssembly file with Cargo..."
echo " 🦀 Building mpd-parser WebAssembly file with Cargo..."
if $has_local_cargo; then
echo "⚠️ NOTE ⚠️ : Relying on local cargo in ./tmp/cargo/bin/cargo"
echo "NOTE: Relying on local cargo in ./tmp/cargo/bin/cargo"
. ../../../../../tmp/cargo/env
../../../../../tmp/cargo/bin/cargo build --target wasm32-unknown-unknown --release
../../../../../tmp/cargo/bin/cargo build --target wasm32-unknown-unknown --release -q
else
cargo build --target wasm32-unknown-unknown --release
cargo build --target wasm32-unknown-unknown --release -q
fi

echo "Optimizing mpd-parser WebAssembly build..."
echo " 🪚 Optimizing mpd-parser WebAssembly build..."
if $has_local_wasmopt; then
echo "⚠️ NOTE ⚠️ : Relying on local wasm-opt in ./tmp/binaryen/bin/wasm-opt"
echo "NOTE: Relying on local wasm-opt in ./tmp/binaryen/bin/wasm-opt"
../../../../../tmp/binaryen/bin/wasm-opt target/wasm32-unknown-unknown/release/mpd_node_parser.wasm --signext-lowering --strip-dwarf -O4 -o ../../../../../dist/mpd-parser.wasm
else
wasm-opt target/wasm32-unknown-unknown/release/mpd_node_parser.wasm --signext-lowering --strip-dwarf -O4 -o ../../../../../dist/mpd-parser.wasm
Expand Down
4 changes: 2 additions & 2 deletions scripts/generate_build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ if (import.meta.url === pathToFileURL(process.argv[1]).href) {
* @param {Object|undefined} options
* @returns {Promise}
*/
async function generateBuild(options = {}) {
export default async function generateBuild(options = {}) {
try {
const devMode = options.devMode === true;
console.log(" 🧹 Removing previous build artefacts...");
Expand All @@ -70,7 +70,7 @@ async function generateBuild(options = {}) {
if (!fs.existsSync(dashWasmDir)) {
console.log(" 🏭 Generating WebAssembly file...");
await spawnProm(
"npm run " + (devMode ? "build:wasm:debug" : "build:wasm:release"),
"npm run --silent " + (devMode ? "build:wasm:debug" : "build:wasm:release"),
[],
(code) => new Error(`WebAssembly compilation process exited with code ${code}`),
);
Expand Down
9 changes: 5 additions & 4 deletions scripts/install_rust_toolchain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# Log a line to stdout, prefixing it with the name of this script
log() {
printf 'install_rust_toolchain: %s\n' "$1"
printf 'rx-player > install_rust_toolchain: %s\n' "$1"
}

# Log a line to sterr, prefixing it with the name of this script
Expand Down Expand Up @@ -32,7 +32,8 @@ ensure() {
fi
}

log "This script will only install dependencies locally in a ./tmp directory"
log "This script will install Rust dependencies locally in the following directory: $(pwd)/tmp"
log "A lot of logs may be produced by this installation, they can mostly be ignored."

requires_cmd curl
requires_cmd tar
Expand Down Expand Up @@ -143,5 +144,5 @@ if ! [ -f tmp/binaryen/bin/wasm-opt ]; then
err "Error after installing binaryen: wasm-opt not available in ./tmp/binaryen/bin/wasm-opt"
fi

echo ""
echo "All dependencies have been installed with success!"
log "All Rust dependencies have been installed"
log "Exiting the current script with success!"

0 comments on commit a3d1944

Please sign in to comment.