@@ -21,45 +21,67 @@ pub use fetch::load_default_npm_version;
2121pub use resolve:: resolve;
2222
2323cfg_if ! {
24- if #[ cfg( target_os = "windows" ) ] {
25- /// The OS component of a Node distro's filename.
24+ if #[ cfg( all ( target_os = "windows" , target_arch = "x86" ) ) ] {
25+ /// The OS component of a Node distro filename
2626 pub const NODE_DISTRO_OS : & str = "win" ;
27- } else if #[ cfg( target_os = "macos" ) ] {
28- /// The OS component of a Node distro's filename.
27+ /// The architecture component of a Node distro filename
28+ pub const NODE_DISTRO_ARCH : & str = "x86" ;
29+ /// The extension for Node distro files
30+ pub const NODE_DISTRO_EXTENSION : & str = "zip" ;
31+ /// The file identifier in the Node index `files` array
32+ pub const NODE_DISTRO_IDENTIFIER : & str = "win-x86-zip" ;
33+ } else if #[ cfg( all( target_os = "windows" , target_arch = "x86_64" ) ) ] {
34+ /// The OS component of a Node distro filename
35+ pub const NODE_DISTRO_OS : & str = "win" ;
36+ /// The architecture component of a Node distro filename
37+ pub const NODE_DISTRO_ARCH : & str = "x64" ;
38+ /// The extension for Node distro files
39+ pub const NODE_DISTRO_EXTENSION : & str = "zip" ;
40+ /// The file identifier in the Node index `files` array
41+ pub const NODE_DISTRO_IDENTIFIER : & str = "win-x64-zip" ;
42+ } else if #[ cfg( all( target_os = "macos" , any( target_arch = "x86_64" , target_arch = "aarch64" ) ) ) ] {
43+ // NOTE: Currently, Node does not provide prebuilt binaries for Apple M1 machines, so we
44+ // fall back to using the x64 binaries through Rosetta 2. When Node starts shipping M1
45+ // binaries, then we will need to adjust our logic to search for those first and only fall
46+ // back if they aren't found
47+
48+ /// The OS component of a Node distro filename
2949 pub const NODE_DISTRO_OS : & str = "darwin" ;
30- } else if #[ cfg( target_os = "linux" ) ] {
31- /// The OS component of a Node distro's filename.
50+ /// The architecture component of a Node distro filename
51+ pub const NODE_DISTRO_ARCH : & str = "x64" ;
52+ /// The extension for Node distro files
53+ pub const NODE_DISTRO_EXTENSION : & str = "tar.gz" ;
54+ /// The file identifier in the Node index `files` array
55+ pub const NODE_DISTRO_IDENTIFIER : & str = "osx-x64-tar" ;
56+ } else if #[ cfg( all( target_os = "linux" , target_arch = "x86_64" ) ) ] {
57+ /// The OS component of a Node distro filename
3258 pub const NODE_DISTRO_OS : & str = "linux" ;
33- } else {
34- compile_error!( "Unsupported operating system (expected Windows, macOS, or Linux)." ) ;
35- }
36- }
37-
38- cfg_if ! {
39- if #[ cfg( target_arch = "x86" ) ] {
40- /// The system architecture component of a Node distro's name.
41- pub const NODE_DISTRO_ARCH : & str = "x86" ;
42- } else if #[ cfg( target_arch = "x86_64" ) ] {
43- /// The system architecture component of a Node distro's name.
59+ /// The architecture component of a Node distro filename
4460 pub const NODE_DISTRO_ARCH : & str = "x64" ;
45- } else if #[ cfg( target_arch = "aarch64" ) ] {
46- /// The system architecture component of a Node distro's name.
61+ /// The extension for Node distro files
62+ pub const NODE_DISTRO_EXTENSION : & str = "tar.gz" ;
63+ /// The file identifier in the Node index `files` array
64+ pub const NODE_DISTRO_IDENTIFIER : & str = "linux-x64" ;
65+ } else if #[ cfg( all( target_os = "linux" , target_arch = "aarch64" ) ) ] {
66+ /// The OS component of a Node distro filename
67+ pub const NODE_DISTRO_OS : & str = "linux" ;
68+ /// The architecture component of a Node distro filename
4769 pub const NODE_DISTRO_ARCH : & str = "arm64" ;
48- } else if #[ cfg( target_arch = "arm" ) ] {
49- /// The system architecture component of a Node distro's name.
70+ /// The extension for Node distro files
71+ pub const NODE_DISTRO_EXTENSION : & str = "tar.gz" ;
72+ /// The file identifier in the Node index `files` array
73+ pub const NODE_DISTRO_IDENTIFIER : & str = "linux-arm64" ;
74+ } else if #[ cfg( all( target_os = "linux" , target_arch = "arm" ) ) ] {
75+ /// The OS component of a Node distro filename
76+ pub const NODE_DISTRO_OS : & str = "linux" ;
77+ /// The architecture component of a Node distro filename
5078 pub const NODE_DISTRO_ARCH : & str = "armv7l" ;
51- } else {
52- compile_error!( "Unsupported target_arch variant (expected 'x86', 'x64', or 'aarch64')." ) ;
53- }
54- }
55-
56- cfg_if ! {
57- if #[ cfg( target_os = "windows" ) ] {
58- /// Filename extension for Node distro files.
59- pub const NODE_DISTRO_EXTENSION : & str = "zip" ;
60- } else {
61- /// Filename extension for Node distro files.
79+ /// The extension for Node distro files
6280 pub const NODE_DISTRO_EXTENSION : & str = "tar.gz" ;
81+ /// The file identifier in the Node index `files` array
82+ pub const NODE_DISTRO_IDENTIFIER : & str = "linux-armv7l" ;
83+ } else {
84+ compile_error!( "Unsuppored operating system + architecture combination" ) ;
6385 }
6486}
6587
0 commit comments