From d60e8a9702a601d6e14886fb64ca33766c16e749 Mon Sep 17 00:00:00 2001 From: Dennis Ameling Date: Mon, 22 Jun 2020 11:22:42 +0200 Subject: [PATCH 1/5] win,msi: download x64 node executable when cross-compiling for arm64 Uses x64 node executable for running .js files in arm64 cross-compilation scenarios. MSI can now be created by running `vcbuild.bat release msi arm64` Refs: https://github.com/nodejs/node/issues/25998 Refs: https://github.com/nodejs/node/issues/32582 --- .gitignore | 3 +++ vcbuild.bat | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/.gitignore b/.gitignore index 55152e1317f0ad..65caf766e9319d 100644 --- a/.gitignore +++ b/.gitignore @@ -131,6 +131,9 @@ _UpgradeReport_Files/ # Ignore dependencies fetched by deps/v8/tools/node/fetch_deps.py /deps/.cipd +# === Rules for Windows vcbuild.bat === +/temp-vcbuild + # === Global Rules === # Keep last to avoid being excluded *.pyc diff --git a/vcbuild.bat b/vcbuild.bat index eb7bc0d74ec7b9..5d5eba2d0f69b9 100644 --- a/vcbuild.bat +++ b/vcbuild.bat @@ -174,6 +174,20 @@ if defined package set stage_package=1 :: assign path to node_exe set "node_exe=%config%\node.exe" +if "%target_arch%"=="arm64" if "%PROCESSOR_ARCHITECTURE%"=="AMD64" ( + if not defined "%x64_node_exe%" set "x64_node_exe=temp-vcbuild\node-x64-cross-compiling.exe" + if not exist "%x64_node_exe%" ( + echo Downloading x64 node.exe... + if not exist "temp-vcbuild" mkdir temp-vcbuild + powershell -c "Invoke-WebRequest -Uri 'https://nodejs.org/dist/latest/win-x64/node.exe' -OutFile 'temp-vcbuild\node-x64-cross-compiling.exe'" + ) + if not exist "%x64_node_exe%" ( + echo Could not find the Node executable at the given x64_node_exe path. Aborting. + goto exit + ) + echo Using x64 Node executable because we're cross-compiling for arm64: %x64_node_exe% + set "node_exe=%x64_node_exe%" +) set "node_gyp_exe="%node_exe%" deps\npm\node_modules\node-gyp\bin\node-gyp" set "npm_exe="%~dp0%node_exe%" %~dp0deps\npm\bin\npm-cli.js" if "%target_env%"=="vs2019" set "node_gyp_exe=%node_gyp_exe% --msvs_version=2019" From aeaa450c856a97da4acf2c16e2589b2e57af21e7 Mon Sep 17 00:00:00 2001 From: Dennis Ameling Date: Mon, 22 Jun 2020 11:56:07 +0200 Subject: [PATCH 2/5] doc: update windows arm64 build instructions Updates the build instructions for Windows 10 ARM64, now that cross-compiling on a x64 host is possible. Refs: #25998 Refs: #32582 --- BUILDING.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/BUILDING.md b/BUILDING.md index 43245f1bdd1925..72a1d8a1cdc8e0 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -544,12 +544,12 @@ Optional requirements to build the MSI installer package: * The [WiX Toolset v3.11](https://wixtoolset.org/releases/) and the [Wix Toolset Visual Studio 2019 Extension](https://marketplace.visualstudio.com/items?itemName=WixToolset.WixToolsetVisualStudio2019Extension). +* The [WiX Toolset v3.14](https://wixtoolset.org/releases/) if building for Windows 10 on ARM (ARM64). Optional requirements for compiling for Windows 10 on ARM (ARM64): -* ARM64 Windows build machine - * Due to a GYP limitation, this is required to run compiled code - generation tools (like V8's builtins and mksnapshot tools) +* ARM64 or x64 Windows build machine + * ARM64 builds can be created on a x64 host by running `.\vcbuild arm64` * Visual Studio 15.9.0 or newer * Visual Studio optional components * Visual C++ compilers and libraries for ARM64 From baba3123567009010daf031f4ddf4e411f6744c9 Mon Sep 17 00:00:00 2001 From: Dennis Ameling Date: Mon, 22 Jun 2020 12:05:54 +0200 Subject: [PATCH 3/5] doc: fix linting in BUILDING.md --- BUILDING.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/BUILDING.md b/BUILDING.md index 72a1d8a1cdc8e0..9a117b11dd18e1 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -544,7 +544,8 @@ Optional requirements to build the MSI installer package: * The [WiX Toolset v3.11](https://wixtoolset.org/releases/) and the [Wix Toolset Visual Studio 2019 Extension](https://marketplace.visualstudio.com/items?itemName=WixToolset.WixToolsetVisualStudio2019Extension). -* The [WiX Toolset v3.14](https://wixtoolset.org/releases/) if building for Windows 10 on ARM (ARM64). +* The [WiX Toolset v3.14](https://wixtoolset.org/releases/) if + building for Windows 10 on ARM (ARM64). Optional requirements for compiling for Windows 10 on ARM (ARM64): From 21f392b12e80f2e6c7575c477aa76f42aa25814e Mon Sep 17 00:00:00 2001 From: Dennis Ameling Date: Sat, 8 Aug 2020 12:55:10 +0200 Subject: [PATCH 4/5] win,msi: use x64 node for license2rtf (ARM64) --- vcbuild.bat | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/vcbuild.bat b/vcbuild.bat index 5d5eba2d0f69b9..07b1a122103d1d 100644 --- a/vcbuild.bat +++ b/vcbuild.bat @@ -174,20 +174,6 @@ if defined package set stage_package=1 :: assign path to node_exe set "node_exe=%config%\node.exe" -if "%target_arch%"=="arm64" if "%PROCESSOR_ARCHITECTURE%"=="AMD64" ( - if not defined "%x64_node_exe%" set "x64_node_exe=temp-vcbuild\node-x64-cross-compiling.exe" - if not exist "%x64_node_exe%" ( - echo Downloading x64 node.exe... - if not exist "temp-vcbuild" mkdir temp-vcbuild - powershell -c "Invoke-WebRequest -Uri 'https://nodejs.org/dist/latest/win-x64/node.exe' -OutFile 'temp-vcbuild\node-x64-cross-compiling.exe'" - ) - if not exist "%x64_node_exe%" ( - echo Could not find the Node executable at the given x64_node_exe path. Aborting. - goto exit - ) - echo Using x64 Node executable because we're cross-compiling for arm64: %x64_node_exe% - set "node_exe=%x64_node_exe%" -) set "node_gyp_exe="%node_exe%" deps\npm\node_modules\node-gyp\bin\node-gyp" set "npm_exe="%~dp0%node_exe%" %~dp0deps\npm\bin\npm-cli.js" if "%target_env%"=="vs2019" set "node_gyp_exe=%node_gyp_exe% --msvs_version=2019" @@ -376,7 +362,24 @@ if errorlevel 1 echo Failed to sign exe&goto exit @rem Skip license.rtf generation if not requested. if not defined licensertf goto stage_package -%node_exe% tools\license2rtf.js < LICENSE > %config%\license.rtf +if "%target_arch%"=="arm64" if "%PROCESSOR_ARCHITECTURE%"=="AMD64" ( + echo Cross-compilation to ARM64 detected. We'll use the x64 Node executable for license2rtf. + if not defined "%x64_node_exe%" set "x64_node_exe=temp-vcbuild\node-x64-cross-compiling.exe" + if not exist "%x64_node_exe%" ( + echo Downloading x64 node.exe... + if not exist "temp-vcbuild" mkdir temp-vcbuild + powershell -c "Invoke-WebRequest -Uri 'https://nodejs.org/dist/latest/win-x64/node.exe' -OutFile 'temp-vcbuild\node-x64-cross-compiling.exe'" + ) + if not exist "%x64_node_exe%" ( + echo Could not find the Node executable at the given x64_node_exe path. Aborting. + set exit_code=1 + goto exit + ) + %x64_node_exe% tools\license2rtf.js < LICENSE > %config%\license.rtf +) else ( + %node_exe% tools\license2rtf.js < LICENSE > %config%\license.rtf +) + if errorlevel 1 echo Failed to generate license.rtf&goto exit :stage_package From d9b0d279051ed8520a0206c5733d6e55aa056539 Mon Sep 17 00:00:00 2001 From: Dennis Ameling Date: Tue, 11 Aug 2020 11:55:44 +0200 Subject: [PATCH 5/5] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: João Reis --- BUILDING.md | 2 -- vcbuild.bat | 4 +++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/BUILDING.md b/BUILDING.md index 9a117b11dd18e1..8455cc46351d0b 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -549,8 +549,6 @@ Optional requirements to build the MSI installer package: Optional requirements for compiling for Windows 10 on ARM (ARM64): -* ARM64 or x64 Windows build machine - * ARM64 builds can be created on a x64 host by running `.\vcbuild arm64` * Visual Studio 15.9.0 or newer * Visual Studio optional components * Visual C++ compilers and libraries for ARM64 diff --git a/vcbuild.bat b/vcbuild.bat index 07b1a122103d1d..527de7ee39664e 100644 --- a/vcbuild.bat +++ b/vcbuild.bat @@ -362,7 +362,9 @@ if errorlevel 1 echo Failed to sign exe&goto exit @rem Skip license.rtf generation if not requested. if not defined licensertf goto stage_package -if "%target_arch%"=="arm64" if "%PROCESSOR_ARCHITECTURE%"=="AMD64" ( +set "use_x64_node_exe=false" +if "%target_arch%"=="arm64" if "%PROCESSOR_ARCHITECTURE%"=="AMD64" set "use_x64_node_exe=true" +if "%use_x64_node_exe%"=="true" ( echo Cross-compilation to ARM64 detected. We'll use the x64 Node executable for license2rtf. if not defined "%x64_node_exe%" set "x64_node_exe=temp-vcbuild\node-x64-cross-compiling.exe" if not exist "%x64_node_exe%" (