Use stable as nightly compiler (#192)
* Use stable as nightly compiler * detect stable * Apply suggestions from code review * CHANGELOG * De-dupe Rust version * Adjust script location * Script cleanups * trigger * Script location
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
5
|
||||
6
|
||||
3.2.2
|
||||
3.2.3
|
||||
3.2.4
|
||||
4.0.2
|
||||
|
||||
4.1.2
|
||||
4.1.2
|
||||
|
||||
@@ -9,6 +9,7 @@ Contributed:
|
||||
Changes:
|
||||
|
||||
- Adjust tests to align with JS coding standards
|
||||
- Allow for optional build with Rust stable bootstrap
|
||||
|
||||
|
||||
## 4.1.2 Jul 9, 2021
|
||||
|
||||
@@ -5,8 +5,7 @@
|
||||
|
||||
set -e
|
||||
|
||||
# also change in install-build-deps
|
||||
RUST_VER=nightly-2020-10-25
|
||||
source ../scripts/rust-version.sh
|
||||
|
||||
WSM=bytes/wasm_bg.wasm
|
||||
OPT=bytes/wasm_opt.wasm
|
||||
@@ -15,17 +14,18 @@ ASM=wasm-crypto-asmjs/build/cjs/data.js
|
||||
# build new via wasm-pack
|
||||
echo "*** Building Rust sources"
|
||||
cd wasm-crypto
|
||||
rustup run $RUST_VER xargo build --target wasm32-unknown-unknown --release
|
||||
# rustup run $RUST_VER cargo build --target wasm32-unknown-unknown --release -Z build-std=std,panic_abort
|
||||
if [ "$RUST_VER" == "stable" ]; then
|
||||
RUSTC_BOOTSTRAP=1 cargo build --target wasm32-unknown-unknown --release -Z build-std=std,panic_abort
|
||||
else
|
||||
rustup run $RUST_VER xargo build --target wasm32-unknown-unknown --release
|
||||
fi
|
||||
cd ..
|
||||
|
||||
echo "*** Converting to WASM"
|
||||
../bindgen/wasm-bindgen wasm-crypto/target/wasm32-unknown-unknown/release/wasm.wasm --out-dir bytes --target web
|
||||
# wasm-pack build --release --scope polkadot --target web
|
||||
|
||||
# optimise
|
||||
echo "*** Optimising WASM output"
|
||||
# ../../wabt/bin/wasm-strip $WSM
|
||||
../binaryen/bin/wasm-opt $WSM -Os -o $OPT
|
||||
|
||||
# convert wasm to base64 structure
|
||||
|
||||
@@ -5,8 +5,7 @@
|
||||
|
||||
set -e
|
||||
|
||||
# also change in build-package
|
||||
RUST_VER=nightly-2020-10-25
|
||||
source ./scripts/rust-version.sh
|
||||
|
||||
BINARYEN_REPO=https://github.com/WebAssembly/binaryen
|
||||
BINARYEN_VER=version_97
|
||||
@@ -24,7 +23,10 @@ unamestr=`uname`
|
||||
|
||||
# toolchain with rust-src (for panic overrdides) and the right wasm32 toolchain
|
||||
rustup toolchain install $RUST_VER -c rust-src -t wasm32-unknown-unknown
|
||||
cargo install xargo
|
||||
|
||||
if [ "$RUST_VER" != "stable" ]; then
|
||||
cargo install xargo
|
||||
fi
|
||||
|
||||
if [[ "$unamestr" == 'Linux' ]]; then
|
||||
echo "*** Detected Linux"
|
||||
|
||||
@@ -5,39 +5,20 @@ const fflate = require('fflate/node');
|
||||
const fs = require('fs');
|
||||
const { formatNumber } = require('@polkadot/util');
|
||||
|
||||
// const A_NAME = 'wasm-crypto-asmjs';
|
||||
const W_NAME = 'wasm-crypto-wasm';
|
||||
|
||||
function hdr (package) {
|
||||
return `// Copyright 2019-2021 @polkadot/${package} authors & contributors
|
||||
const data = fs.readFileSync('./bytes/wasm_opt.wasm');
|
||||
const compressed = Buffer.from(fflate.zlibSync(data, { level: 9 }));
|
||||
|
||||
console.log(`*** Compressed WASM: ${formatNumber(data.length)} -> ${formatNumber(compressed.length)} (${(100 * compressed.length / data.length).toFixed(2)}%)`);
|
||||
|
||||
fs.writeFileSync(`./${W_NAME}/build/cjs/bytes.js`, `// Copyright 2019-2021 @polkadot/${W_NAME} authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Generated as part of the build, do not edit
|
||||
`;
|
||||
}
|
||||
|
||||
function getWasmBuffer () {
|
||||
const data = fs.readFileSync('./bytes/wasm_opt.wasm');
|
||||
const compressed = Buffer.from(fflate.zlibSync(data, { level: 9 }));
|
||||
|
||||
console.log(`*** Compressed WASM: ${formatNumber(data.length)} -> ${formatNumber(compressed.length)} (${(100 * compressed.length / data.length).toFixed(2)}%)`);
|
||||
|
||||
return { compressed, sizeUncompressed: data.length };
|
||||
}
|
||||
|
||||
// fs.writeFileSync(`./${A_NAME}/build/data.js`, `${hdr(A_NAME)}
|
||||
// export { asmJsInit } from './data.cjs';
|
||||
// `);
|
||||
|
||||
// fs.writeFileSync(`./${W_NAME}/build/bytes.js`, `${hdr(W_NAME)}
|
||||
// export { bytes, sizeCompressed, sizeUncompressed } from './bytes.cjs';
|
||||
// `);
|
||||
|
||||
const { compressed, sizeUncompressed } = getWasmBuffer();
|
||||
|
||||
fs.writeFileSync(`./${W_NAME}/build/cjs/bytes.js`, `${hdr(W_NAME)}
|
||||
const sizeCompressed = ${compressed.length};
|
||||
const sizeUncompressed = ${sizeUncompressed};
|
||||
const sizeUncompressed = ${data.length};
|
||||
const bytes = '${compressed.toString('base64')}';
|
||||
|
||||
module.exports = { bytes, sizeCompressed, sizeUncompressed };
|
||||
|
||||
7
scripts/rust-version.sh
Executable file
7
scripts/rust-version.sh
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
# Copyright 2019-2021 @polkadot/wasm authors & contributors
|
||||
# This software may be modified and distributed under the terms
|
||||
# of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
RUST_VER=nightly-2020-10-25
|
||||
# RUST_VER=stable
|
||||
Reference in New Issue
Block a user