@@ -3,29 +3,26 @@ import { cpus } from "node:os";
33import fs from "node:fs/promises" ;
44import { spawn } from "node:child_process" ;
55
6- let CC = process . env . CC ;
7- let CXX = process . env . CXX ;
8- let ARCH = process . env . ARCH ;
9- if ( ! CC ) CC = "gcc" ;
10- if ( ! CXX ) CXX = "g++" ;
11- if ( ! ARCH ) ARCH = "amd64" ;
6+ let OS = process . env . OS ;
7+ const ARCH = process . env . ARCH == "amd64" ? "x64" : "arm64" ;
128
139const coreCount = cpus ( ) . length ;
1410const threadCount = coreCount * 2 ;
15- const arch = ARCH == "amd64" ? "x64" : "arm64" ;
16- let os ;
11+ let current_os ;
1712switch ( process . platform ) {
1813 case "darwin" :
19- os = "mac" ;
14+ current_os = "mac" ;
2015 break ;
2116 case "win32" :
22- os = "win" ;
17+ current_os = "win" ;
2318 break ;
2419 default :
25- os = "linux" ;
20+ current_os = "linux" ;
2621 break ;
2722}
2823
24+ if ( ! OS ) OS = current_os ;
25+
2926const nodejsGithubRepo = "https://github.com/nodejs/node" ;
3027const removeTheVCharacter = ( str ) => str . replace ( "v" , "" ) ;
3128
@@ -55,11 +52,11 @@ const isANewerVersion = (oldVer, newVer) => {
5552 return false ;
5653} ;
5754
58- const spawnAsync = ( program , args , cwd ) =>
55+ const spawnAsync = ( program , args ) =>
5956 new Promise ( ( resolve , reject ) => {
60- console . log ( [ program , ...args ] . join ( " " ) ) ;
57+ console . log ( "Running:" , [ program , ...args ] . join ( " " ) ) ;
6158
62- const child = spawn ( program , args , cwd ? { cwd } : { } ) ;
59+ const child = spawn ( program , args , { } ) ;
6360
6461 child . stdout . on ( "data" , ( chunk ) => console . log ( chunk . toString ( ) ) ) ;
6562 child . stderr . on ( "data" , ( chunk ) => console . error ( chunk . toString ( ) ) ) ;
@@ -85,17 +82,31 @@ if (!syncFs.existsSync("node")) {
8582 `v${ latestNodeVersion } ` ,
8683 "--depth=1" ,
8784 ] ,
88- undefined
85+ undefined ,
86+ { }
8987 ) ;
9088}
9189
90+ process . chdir ( "node" ) ;
91+
92+ let extraArgs = [ ] ;
9293if ( process . platform == "win32" ) {
93- await spawnAsync ( "vcbuild.bat" , [ arch , "dll" ] , "node" ) ;
94+ await spawnAsync ( ".\\ vcbuild.bat" , [ ARCH , "dll" , "openssl-no-asm" ] ) ;
9495} else {
95- await spawnAsync (
96- "./configure" ,
97- [ "--ninja" , "--shared" , "--dest-cpu" , arch , "--dest-os" , os ] ,
98- "node"
99- ) ;
100- await spawnAsync ( "make" , [ `-j${ threadCount } ` ] , "node" ) ;
96+ if ( ARCH === "arm64" ) {
97+ extraArgs . push ( "--with-arm-float-abi" ) ;
98+ extraArgs . push ( "hard" ) ;
99+ extraArgs . push ( "--with-arm-fpu" ) ;
100+ extraArgs . push ( "neon" ) ;
101+ }
102+
103+ await spawnAsync ( "./configure" , [
104+ "--shared" ,
105+ "--dest-cpu" ,
106+ ARCH ,
107+ "--dest-os" ,
108+ OS ,
109+ ...extraArgs ,
110+ ] ) ;
111+ await spawnAsync ( "make" , [ `-j${ threadCount } ` ] ) ;
101112}
0 commit comments