Skip to content

Commit bb76021

Browse files
dennisamelingStefanStojanovic
authored andcommitted
feat: add support for native windows arm64 build tools
Visual Studio 2022 17.4 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://devblogs.microsoft.com/visualstudio/arm64-visual-studio-is-officially-here/ Signed-off-by: Dennis Ameling <[email protected]>
1 parent 6f3c2d3 commit bb76021

File tree

4 files changed

+646
-5
lines changed

4 files changed

+646
-5
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ Install tools and configuration manually:
5656

5757
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.
5858

59-
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".
59+
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".
60+
61+
To use the native ARM64 C++ compiler on Windows on ARM, ensure that you have Visual Studio 2022 [17.4 or later](https://devblogs.microsoft.com/visualstudio/arm64-visual-studio-is-officially-here/) installed.
6062

6163
### Configuring Python Dependency
6264

lib/find-visualstudio.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,10 +266,15 @@ VisualStudioFinder.prototype = {
266266
return {}
267267
},
268268

269+
msBuildPathExists: function msBuildPathExists (path) {
270+
return fs.existsSync(path)
271+
},
272+
269273
// Helper - process MSBuild information
270274
getMSBuild: function getMSBuild (info, versionYear) {
271275
const pkg = 'Microsoft.VisualStudio.VC.MSBuild.Base'
272276
const msbuildPath = path.join(info.path, 'MSBuild', 'Current', 'Bin', 'MSBuild.exe')
277+
const msbuildPathArm64 = path.join(info.path, 'MSBuild', 'Current', 'Bin', 'arm64', 'MSBuild.exe')
273278
if (info.packages.indexOf(pkg) !== -1) {
274279
this.log.silly('- found VC.MSBuild.Base')
275280
if (versionYear === 2017) {
@@ -279,8 +284,14 @@ VisualStudioFinder.prototype = {
279284
return msbuildPath
280285
}
281286
}
282-
// visual studio 2022 don't has msbuild pkg
283-
if (fs.existsSync(msbuildPath)) {
287+
/**
288+
* Visual Studio 2022 doesn't have the MSBuild package.
289+
* Support for compiling _on_ ARM64 was added in MSVC 14.32.31326,
290+
* so let's leverage it if the user has an ARM64 device.
291+
*/
292+
if (process.arch === 'arm64' && this.msBuildPathExists(msbuildPathArm64)) {
293+
return msbuildPathArm64
294+
} else if (this.msBuildPathExists(msbuildPath)) {
284295
return msbuildPath
285296
}
286297
return null

0 commit comments

Comments
 (0)