@@ -48,6 +48,41 @@ suite("zeromq", { timeout: 300_000 }, async () => {
4848 test ( "cmake-ts legacy nativeonly --logger debug" , async ( ) => {
4949 await testZeromqBuild ( "legacy" , zeromqPath , "nativeonly" , "--logger" , "debug" )
5050 } )
51+
52+ test ( "cmake-ts cross-compile cross-linux-arm64" , async ( t ) => {
53+ if ( process . platform !== "linux" || process . arch !== "x64" ) {
54+ t . skip ( )
55+ }
56+ await testZeromqBuild ( "modern" , zeromqPath , "build" , "--configs" , "cross-linux-arm64" , "--logger" , "debug" )
57+ } )
58+
59+ test ( "cmake-ts cross-compile cross-win32-ia32" , async ( t ) => {
60+ if ( process . platform !== "win32" || process . arch !== "x64" ) {
61+ t . skip ( )
62+ }
63+ await testZeromqBuild ( "modern" , zeromqPath , "build" , "--configs" , "cross-win32-ia32" , "--logger" , "debug" )
64+ } )
65+
66+ test ( "cmake-ts cross-compile cross-win32-arm64" , async ( t ) => {
67+ if ( process . platform !== "win32" || process . arch !== "x64" ) {
68+ t . skip ( )
69+ }
70+ await testZeromqBuild ( "modern" , zeromqPath , "build" , "--configs" , "cross-win32-arm64" , "--logger" , "debug" )
71+ } )
72+
73+ test ( "cmake-ts cross-compile cross-darwin-x64" , async ( t ) => {
74+ if ( process . platform !== "darwin" || process . arch !== "arm64" ) {
75+ t . skip ( )
76+ }
77+ await testZeromqBuild ( "modern" , zeromqPath , "build" , "--configs" , "cross-darwin-x64" , "--logger" , "debug" )
78+ } )
79+
80+ test ( "cmake-ts cross-compile cross-darwin-arm64" , async ( t ) => {
81+ if ( process . platform !== "darwin" || process . arch !== "x64" ) {
82+ t . skip ( )
83+ }
84+ await testZeromqBuild ( "modern" , zeromqPath , "build" , "--configs" , "cross-darwin-arm64" , "--logger" , "debug" )
85+ } )
5186} )
5287
5388async function testZeromqBuild ( bundle : string , zeromqPath : string , ...args : string [ ] ) {
@@ -66,15 +101,20 @@ async function testZeromqBuild(bundle: string, zeromqPath: string, ...args: stri
66101 const configKey = JSON . parse ( Object . keys ( manifest ) [ 0 ] ) as BuildConfiguration
67102 const configValue = manifest [ JSON . stringify ( configKey ) ]
68103
104+ const crossConfig = args . find ( ( arg ) => arg . includes ( "cross" ) )
105+ const os = ( crossConfig ?. split ( "-" ) [ 1 ] as NodeJS . Platform | undefined ) ?? process . platform
106+ const arch = ( crossConfig ?. split ( "-" ) [ 2 ] as NodeJS . Architecture | undefined ) ?? process . arch
107+
69108 const expectedConfig : BuildConfiguration = {
70109 name : "" ,
71110 dev : false ,
72- os : process . platform ,
73- arch : process . arch ,
111+ os,
112+ arch,
74113 runtime : "node" ,
75114 runtimeVersion : process . versions . node ,
76- buildType : args . includes ( "Debug" ) ? "Debug" : "Release" ,
115+ buildType : args . includes ( "Debug" ) || args . some ( ( arg ) => arg . includes ( "-debug" ) ) ? "Debug" : "Release" ,
77116 packageDirectory : "" ,
117+ cross : crossConfig !== undefined ,
78118 projectName : "addon" ,
79119 nodeAPI : "node-addon-api" ,
80120 targetDirectory : "build" ,
@@ -91,10 +131,10 @@ async function testZeromqBuild(bundle: string, zeromqPath: string, ...args: stri
91131
92132 expect ( configKey . abi ) . toBeDefined ( )
93133 const addonPath = join (
94- process . platform ,
95- process . arch ,
134+ expectedConfig . os ,
135+ expectedConfig . arch ,
96136 "node" ,
97- `${ configKey . libc } -${ configKey . abi } -${ configKey . buildType } ` ,
137+ `${ expectedConfig . libc } -${ expectedConfig . abi } -${ expectedConfig . buildType } ` ,
98138 "addon.node" ,
99139 )
100140
0 commit comments