File tree Expand file tree Collapse file tree 3 files changed +55
-3
lines changed
node-addon-examples/scripts
react-native-node-api-modules Expand file tree Collapse file tree 3 files changed +55
-3
lines changed Original file line number Diff line number Diff line change 11import { execSync } from "node:child_process" ;
2+ import { platform } from "node:os" ;
23
34import { findCMakeProjects } from "./cmake-projects.mjs" ;
45
56const projectDirectories = findCMakeProjects ( ) ;
67
8+ // Platform-specific build command
9+ let buildCommand : string ;
10+ switch ( platform ( ) ) {
11+ case "darwin" :
12+ // macOS: build for both Android and Apple
13+ buildCommand = "react-native-node-api-cmake --android --apple" ;
14+ break ;
15+ case "win32" :
16+ case "linux" :
17+ // Windows and Linux: only Android
18+ buildCommand = "react-native-node-api-cmake --android" ;
19+ break ;
20+ default :
21+ console . error ( `Unsupported platform: ${ platform ( ) } ` ) ;
22+ process . exit ( 1 ) ;
23+ }
24+
725for ( const projectDirectory of projectDirectories ) {
8- console . log ( `Running "react-native-node-api-cmake " in ${ projectDirectory } ` ) ;
26+ console . log ( `Running "${ buildCommand } " in ${ projectDirectory } ` ) ;
927 execSync (
10- "react-native-node-api-cmake --android --apple" ,
28+ buildCommand ,
1129 // "react-native-node-api-cmake --triplet aarch64-linux-android --triplet arm64-apple-ios-sim",
1230 {
1331 cwd : projectDirectory ,
Original file line number Diff line number Diff line change 4343 "copy-node-api-headers" : " tsx scripts/copy-node-api-headers.ts" ,
4444 "generate-weak-node-api" : " tsx scripts/generate-weak-node-api.ts" ,
4545 "generate-weak-node-api-injector" : " tsx scripts/generate-weak-node-api-injector.ts" ,
46- "build-weak-node-api" : " npm run generate -weak-node-api && react-native-node-api-cmake --android --apple --no-auto-link --no-weak-node-api-linkage --xcframework-extension --source ./weak-node-api " ,
46+ "build-weak-node-api" : " tsx scripts/build -weak-node-api.ts " ,
4747 "test" : " tsx --test src/node/**/*.test.ts src/node/*.test.ts"
4848 },
4949 "keywords" : [
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env tsx
2+
3+ import { execSync } from "node:child_process" ;
4+ import { platform } from "node:os" ;
5+
6+ // First generate the weak node API
7+ execSync ( "npm run generate-weak-node-api" , { stdio : "inherit" } ) ;
8+
9+ // Build command with common flags
10+ const baseCommand = "react-native-node-api-cmake --no-auto-link --no-weak-node-api-linkage --source ./weak-node-api" ;
11+
12+ // Platform-specific flags
13+ let platformFlags = "" ;
14+ switch ( platform ( ) ) {
15+ case "darwin" :
16+ // macOS: build for both Android and Apple
17+ platformFlags = "--android --apple --xcframework-extension" ;
18+ break ;
19+ case "win32" :
20+ // Windows: only Android (no Apple/Xcode support)
21+ platformFlags = "--android" ;
22+ break ;
23+ case "linux" :
24+ // Linux: only Android
25+ platformFlags = "--android" ;
26+ break ;
27+ default :
28+ console . error ( `Unsupported platform: ${ platform ( ) } ` ) ;
29+ process . exit ( 1 ) ;
30+ }
31+
32+ const fullCommand = `${ baseCommand } ${ platformFlags } ` ;
33+ console . log ( `Running: ${ fullCommand } ` ) ;
34+ execSync ( fullCommand , { stdio : "inherit" } ) ;
You can’t perform that action at this time.
0 commit comments