Skip to content

Commit

Permalink
feat: add support for native windows arm64 build tools
Browse files Browse the repository at this point in the history
Visual Studio 2022 17.2 adds a native C++ compiler for Windows on ARM.
This allows arm64 devices to leverage native build tools, leading to
a 35% (or more) speed increase.
https://azure.microsoft.com/en-us/blog/now-in-preview-azure-virtual-machines-with-ampere-altra-armbased-processors/
  • Loading branch information
dennisameling committed May 22, 2022
1 parent 6f74c76 commit 3588133
Show file tree
Hide file tree
Showing 4 changed files with 652 additions and 5 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ Install tools and configuration manually:

If the above steps didn't work for you, please visit [Microsoft's Node.js Guidelines for Windows](https://github.com/Microsoft/nodejs-guidelines/blob/master/windows-environment.md#compiling-native-addon-modules) for additional tips.

To target native ARM64 Node.js on Windows 10 on ARM, add the components "Visual C++ compilers and libraries for ARM64" and "Visual C++ ATL for ARM64".
To target native ARM64 Node.js on Windows on ARM, add the components "Visual C++ compilers and libraries for ARM64" and "Visual C++ ATL for ARM64".

To use the native ARM64 C++ compiler on Windows on ARM, ensure that you have MSVC 14.32.31326 (Visual Studio 17.2) or later installed.

### Configuring Python Dependency

Expand Down
15 changes: 13 additions & 2 deletions lib/find-visualstudio.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,15 @@ VisualStudioFinder.prototype = {
return {}
},

msBuildPathExists: function msBuildPathExists (path) {
return fs.existsSync(path)
},

// Helper - process MSBuild information
getMSBuild: function getMSBuild (info, versionYear) {
const pkg = 'Microsoft.VisualStudio.VC.MSBuild.Base'
const msbuildPath = path.join(info.path, 'MSBuild', 'Current', 'Bin', 'MSBuild.exe')
const msbuildPathArm64 = path.join(info.path, 'MSBuild', 'Current', 'Bin', 'arm64', 'MSBuild.exe')
if (info.packages.indexOf(pkg) !== -1) {
this.log.silly('- found VC.MSBuild.Base')
if (versionYear === 2017) {
Expand All @@ -279,8 +284,14 @@ VisualStudioFinder.prototype = {
return msbuildPath
}
}
// visual studio 2022 don't has msbuild pkg
if (fs.existsSync(msbuildPath)) {
/**
* Visual Studio 2022 doesn't have the MSBuild package.
* Support for compiling _on_ ARM64 was added in MSVC 14.32.31326,
* so let's leverage it if the user has an ARM64 device.
*/
if (process.arch === 'arm64' && this.msBuildPathExists(msbuildPathArm64)) {
return msbuildPathArm64
} else if (this.msBuildPathExists(msbuildPath)) {
return msbuildPath
}
return null
Expand Down
Loading

0 comments on commit 3588133

Please sign in to comment.