diff --git a/.github/workflows/nexe-ci.yml b/.github/workflows/nexe-ci.yml index 24595bd..20c0871 100644 --- a/.github/workflows/nexe-ci.yml +++ b/.github/workflows/nexe-ci.yml @@ -21,7 +21,11 @@ jobs: # TODO: Bump to windows-latest once it can be solved how to install Python2 # such that the Node.js build system can detect it. os: [ubuntu-latest, windows-2019, macos-latest] - node_version: ['14.16.0', '14.18.0', '14.18.1', '16.11.0', '16.13.0', '16.13.1', '16.19.0', '18.14.0'] + node_version: ['18.14.0'] # ['14.16.0', '14.18.0', '14.18.1', '16.11.0', '16.13.0', '16.13.1', '16.19.0', '18.14.0'] + node_arch: [x64] + include: + - { os: macos-latest, node_version: '16.19.0', node_arch: arm64 } + #- { os: macos-latest, node_version: '18.14.0', node_arch: arm64 } steps: - uses: actions/checkout@v3 @@ -65,6 +69,7 @@ jobs: echo "build_occurred=$build_occurred" >> $GITHUB_OUTPUT env: NODE_VERSION: ${{ matrix.node_version }} + NODE_ARCH: ${{ matrix.node_arch }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} CREATE_RELEASE: "${{ github.ref == 'refs/heads/main' && 'true' || 'false' }}" diff --git a/README.md b/README.md index 97f1a2f..f324b60 100644 --- a/README.md +++ b/README.md @@ -82,9 +82,27 @@ Enjoy 🚀 1. Args: 1. Command (`build` or `build-check`) 2. Node.js version to build for. + 3. OS arch to build, options: `x64`, `arm64`. (optional) 2. Environmental Variables: None 3. Files created: 1. Nexe build artifact (`$repo_dir/dist/$os_env-$os_arch-$node_target`) 4. Exit codes: 1. `0`: Success 2. `*`: Failure + +# TMP + +https://github.com/nodejs/node/issues/40350 +https://github.com/nodejs/node-v0.x-archive/issues/5195 +https://github.com/nodejs/node/issues/37309 +https://github.com/sjitech/build-nodejs-for-android +https://github.com/briansmith/ring/issues/1442 +https://github.com/nodejs/node/issues/37441 +https://github.com/nodejs/node/issues/40302 +https://github.com/nodejs/build/issues/2474 +https://github.com/eclipse-openj9/openj9/issues/5018 +https://github.com/nodejs/node/blob/main/BUILDING.md +https://github.com/dotnet/runtime/issues/41133 +https://github.com/openssl/openssl/issues/12254 +https://embeddedartistry.com/blog/2017/10/11/demystifying-arm-floating-point-compiler-options/ +https://github.com/nodejs/gyp-next/pull/78 diff --git a/bin/build_nexe b/bin/build_nexe index 167cb1e..4b820bf 100755 --- a/bin/build_nexe +++ b/bin/build_nexe @@ -8,19 +8,24 @@ source "$script_dir/bash_utils.sh" os_env="$(get_os_type)" node_target="$2" -if [ "$os_env" = "mac" ]; then - os_arch="$(uname -m)" -else - os_arch="$(arch)" +target_arch="$3" +os_arch="" +if [ "$os_arch" = "" ]; then + if [ "$os_env" = "mac" ]; then + os_arch="$(uname -m)" + else + os_arch="$(arch)" + fi + if [ "$os_arch" = "x86_64" ]; then + os_arch="x64" + fi fi -if [ "$os_arch" = "x86_64" ]; then - os_arch="x64" -fi -if [ "$os_arch" != "x64" ]; then - echo "Error! Unsupported architecture: $os_arch" +# Validate OS arch +if [ "$target_arch" != "x64" ] && [ "$target_arch" != "arm64" ]; then + echo "Error! Unsupported architecture: $target_arch" exit 1 fi -nexe_target="${os_arch}-$node_target" +nexe_target="$target_arch-$node_target" help_text=" build_nexe @@ -101,16 +106,24 @@ function main(){ ;; esac - python2_path="$(which python2)" - python3_path="$(which python3)" + python2_path="$(command -v python2 || true)" + python3_path="$(command -v python3)" echo "python2_path=$python2_path" echo "python3_path=$python3_path" - nexe_part_1_cmd="nexe --build --verbose --no-mange --target=$nexe_target --make=-j$cpu_core_count" + nexe_part_1_cmd="nexe --build --verbose --no-mange --target=$nexe_target --make=DESTCPU=$target_arch --make=-j$cpu_core_count" + nexe_part_2_cmd="--configure=--openssl-no-asm --configure=--without-snapshot --configure=--without-inspector --configure=--without-intl --configure=--with-arm-fpu=neon --configure=--with-arm-float-abi=hard --configure=--cross-compiling" + # if [ "$target_arch" != "$os_arch"] ; then + # nexe_part_2_cmd="$nexe_part_2_cmd --configure=--cross-compiling" + # fi nexe_part_3_cmd="-o $nexe_no_mangle_path '$repo_dir/index.js'" - echo "console.log('TEST NEXE SCRIPT'); console.log(process.version); var os = require('os'); console.log('os.userInfo() =', os.userInfo());" > "$repo_dir/index.js" + echo "console.log('TEST NEXE SCRIPT'); console.log(process.version); var os = require('os'); console.log('os.arch() =', os.arch()); console.log('os.userInfo() =', os.userInfo());" > "$repo_dir/index.js" echo "Building $nexe_no_mangle_name (python 3)" - nexe_cmd="$nexe_part_1_cmd --python=$python3_path $nexe_part_3_cmd" + + export NEON32_CFLAGS="-march=armv7-a -mfloat-abi=hard -mfpu=neon" + export NEON64_CFLAGS="-march=armv8-a -mfloat-abi=hard" + + nexe_cmd="$nexe_part_1_cmd --python=$python3_path $nexe_part_2_cmd $nexe_part_3_cmd" echo " $nexe_cmd" set +e time npx $nexe_cmd || build_failed="true" diff --git a/bin/check_asset b/bin/check_asset index 7ddbcf3..675b13b 100755 --- a/bin/check_asset +++ b/bin/check_asset @@ -24,10 +24,10 @@ const osNameMap = { 'win32': 'windows', }; const archNameMap = { + 'arm64': 'arm64', 'x64': 'x64', 'x32': 'x86', }; -const osArch = os.arch(); async function main() { try { @@ -42,8 +42,12 @@ async function main() { console.log("Please provide target repo commit for release as second arg (use `git rev-parse HEAD`)"); process.exit(1); } - if (myArgs.length === 3) { - assert(myArgs[2] === '--no-create-release', `Invalid flag given: ${myArgs[2]}`); + if (myArgs.length === 2) { + console.log("Please provide target OS for release as third arg (options: x64, arm64)"); + process.exit(1); + } + if (myArgs.length === 4) { + assert(myArgs[3] === '--no-create-release', `Invalid flag given: ${myArgs[3]}`); doCreate = false; } const apiToken = process.env.GITHUB_TOKEN; @@ -51,12 +55,14 @@ async function main() { console.log("Please provide github API token via env. var. GITHUB_TOKEN"); process.exit(1); } + const targetNodeVersion = myArgs[0]; + const releaseCommitish = myArgs[1]; + const osArch = myArgs[2]; assert(Object.keys(osNameMap).includes(process.platform), `Unsupported platform: ${process.platform}`); assert(Object.keys(archNameMap).includes(osArch), `Unsupported architecture: ${osArch}`); const targetOs = osNameMap[process.platform]; const targetArch = archNameMap[osArch]; - const targetNodeVersion = myArgs[0]; - const releaseCommitish = myArgs[1]; + const nexeAssetName = `${targetOs}-${targetArch}-${targetNodeVersion}`; const packageData = getPackgeData(); const nexeVersion = packageData.dependencies.nexe.replace('^',''); diff --git a/bin/run_cd b/bin/run_cd index b072477..d5f0bad 100755 --- a/bin/run_cd +++ b/bin/run_cd @@ -7,11 +7,13 @@ script_dir="$repo_dir/bin" source "$script_dir/bash_utils.sh" os_env="$(get_os_type)" +NODE_ARCH="${NODE_ARCH:-x64}" if [ "$NODE_VERSION" = "" ]; then echo "Please set NODE_VERSION env. var." exit 1 else echo "NODE_VERSION=$NODE_VERSION" + echo "NODE_ARCH=$NODE_ARCH" fi if [ "$GITHUB_TOKEN" = "" ]; then @@ -69,7 +71,7 @@ fi echo "Running: bin/check_asset" set +e -$script_dir/check_asset "$NODE_VERSION" "$GIT_COMMIT" $check_asset_flags +$script_dir/check_asset "$NODE_VERSION" "$GIT_COMMIT" "$NODE_ARCH" $check_asset_flags exit_code="$?" set -e @@ -81,9 +83,9 @@ case "$exit_code" in "10") echo "Running: bin/install_dependencies" $script_dir/install_dependencies || exit 2 - echo "Running: bin/build_nexe build $NODE_VERSION" - $script_dir/build_nexe build "$NODE_VERSION" || exit 3 - echo "Finished: bin/build_nexe build $NODE_VERSION" + echo "Running: bin/build_nexe build $NODE_VERSION $NODE_ARCH" + $script_dir/build_nexe build "$NODE_VERSION" "$NODE_ARCH" || exit 3 + echo "Finished: bin/build_nexe build $NODE_VERSION $NODE_ARCH" ;; *) echo "Error exit code detected ($exit_code) from check_asset script! Crashing."