From bd81946b8bc905ced6d0f6845a18d913053de3b0 Mon Sep 17 00:00:00 2001 From: LongYinan Date: Sat, 20 Feb 2021 14:58:33 +0800 Subject: [PATCH] Reduce Node.js addon binary size --- .github/workflows/publish-node.yml | 46 +++++++++++++++--------------- Cargo.toml | 3 ++ macros/string_enum/src/lib.rs | 2 +- rust-toolchain | 2 +- 4 files changed, 28 insertions(+), 25 deletions(-) diff --git a/.github/workflows/publish-node.yml b/.github/workflows/publish-node.yml index 45c82a673556..b16c71a7509f 100644 --- a/.github/workflows/publish-node.yml +++ b/.github/workflows/publish-node.yml @@ -13,6 +13,7 @@ env: jobs: build: strategy: + fail-fast: false matrix: os: [ubuntu-latest, macos-latest, windows-latest] @@ -25,6 +26,12 @@ jobs: uses: actions/setup-node@v2 with: node-version: 14 + + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + profile: minimal + override: true - name: Install node dependencies run: npm i @@ -57,6 +64,7 @@ jobs: run: | choco install nodejs-lts --x86 -y --force refreshenv + - name: Set 32bit NodeJS path run: | echo "C:\\Program Files (x86)\\nodejs" >> $GITHUB_PATH @@ -65,15 +73,12 @@ jobs: - name: NodeJS arch run: node -e "console.log(process.arch)" - - name: Install + - name: Install Rust uses: actions-rs/toolchain@v1 with: - toolchain: stable profile: minimal override: true - - - name: Install i686 toolchain - run: rustup target add i686-pc-windows-msvc + target: i686-pc-windows-msvc - name: Install node dependencies run: npm i @@ -117,6 +122,7 @@ jobs: run: | docker pull docker.pkg.github.com/napi-rs/napi-rs/nodejs-rust:10-alpine docker tag docker.pkg.github.com/napi-rs/napi-rs/nodejs-rust:10-alpine builder + - name: "Install dependencies" run: npm i @@ -142,15 +148,12 @@ jobs: with: node-version: 14 - - name: Install + - name: Install Rust uses: actions-rs/toolchain@v1 with: - toolchain: stable profile: minimal override: true - - - name: Install aarch64 toolchain - run: rustup target add aarch64-apple-darwin + target: aarch64-apple-darwin - name: Cache uses: actions/cache@v2 @@ -185,15 +188,12 @@ jobs: with: node-version: 14 - - name: Install + - name: Install Rust uses: actions-rs/toolchain@v1 with: - toolchain: stable profile: minimal override: true - - - name: Install aarch64 toolchain - run: rustup target add aarch64-unknown-linux-gnu + target: aarch64-unknown-linux-gnu - name: Cache uses: actions/cache@v2 @@ -202,7 +202,6 @@ jobs: target/ key: aarch64-linux-gnu-publish-integration - - name: Install cross compile toolchain run: | sudo apt-get update @@ -234,15 +233,12 @@ jobs: with: node-version: 14 - - name: Install + - name: Install Rust uses: actions-rs/toolchain@v1 with: - toolchain: stable profile: minimal override: true - - - name: Install aarch64 toolchain - run: rustup target add armv7-unknown-linux-gnueabihf + target: armv7-unknown-linux-gnueabihf - name: Cache uses: actions/cache@v2 @@ -279,8 +275,12 @@ jobs: with: node-version: 14 - - name: Install aarch64 toolchain - run: rustup target add aarch64-linux-android + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + profile: minimal + override: true + target: aarch64-linux-android - name: Install node dependencies run: npm i diff --git a/Cargo.toml b/Cargo.toml index cad93123ca93..af0c134440df 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,3 +1,5 @@ +cargo-features = ["strip"] + [workspace] members = ["ecmascript", "ecmascript/jsdoc", "native", "spack", "wasm"] @@ -55,6 +57,7 @@ name = "usage" [profile.release] codegen-units = 1 lto = true +strip = 'symbols' # debug = true # opt-level = 'z' diff --git a/macros/string_enum/src/lib.rs b/macros/string_enum/src/lib.rs index ae51801db0be..ace2bc4679f7 100644 --- a/macros/string_enum/src/lib.rs +++ b/macros/string_enum/src/lib.rs @@ -219,7 +219,7 @@ fn make_as_str(i: &DeriveInput) -> ItemImpl { })), _ => Box::new( Quote::new(def_site::()) - .quote_with(smart_quote!(Vars { qual_name }, { qual_name{..} })) + .quote_with(smart_quote!(Vars { qual_name }, { qual_name { .. } })) .parse(), ), }; diff --git a/rust-toolchain b/rust-toolchain index ed4dad9a3814..3e90e47f03c8 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-11-24 +nightly-2021-02-19 \ No newline at end of file