Skip to content

Commit 0e8b824

Browse files
committed
ios: support compiling or prebuilding for iOS simulator
1 parent db89e7a commit 0e8b824

File tree

5 files changed

+39
-8
lines changed

5 files changed

+39
-8
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
#ifdef __cplusplus
3+
extern "C" {
4+
#endif
5+
6+
int node_start(int argc, char *argv[]);
7+
8+
#ifdef __cplusplus
9+
}
10+
#endif
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
framework module NodeMobile {
2+
umbrella header "NodeMobile.h"
3+
4+
export *
5+
module * { export * }
6+
}

ios/libnode/include/node/common.gypi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
'msvs_multi_core_compile': '0', # we do enable multicore compiles, but not using the V8 way
1313
'enable_pgo_generate%': '0',
1414
'enable_pgo_use%': '0',
15-
'iossim': 'false',
1615
'python%': 'python',
16+
'iossim%': 'false',
1717

1818
'node_shared%': 'false',
1919
'force_dynamic_crt%': 0,

scripts/ios-build-native-modules.sh

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,24 @@ if [ "$PLATFORM_PREFERRED_ARCH" == "arm64" ]; then
7171
else
7272
PREBUILD_ARCH="x64"
7373
fi
74+
if [ "$PLATFORM_NAME" == "iphonesimulator" ] && [ "$NATIVE_ARCH" == "arm64" ]; then
75+
SUFFIX="-simulator"
76+
PREBUILD_ARCH="arm64"
77+
else
78+
SUFFIX=""
79+
fi
7480
find -E "$NODEPROJ" \
75-
! -regex ".*/prebuilds/ios-$PREBUILD_ARCH" \
81+
! -regex ".*/prebuilds/ios-$PREBUILD_ARCH$SUFFIX" \
7682
-regex '.*/prebuilds/[^/]*$' -type d \
7783
-prune -exec rm -rf "{}" \;
7884
find -E "$NODEPROJ" \
79-
! -regex ".*/prebuilds/ios-$PREBUILD_ARCH/.*\.node$" \
85+
! -regex ".*/prebuilds/ios-$PREBUILD_ARCH$SUFFIX/.*\.node$" \
8086
-name '*.node' -type f \
8187
-exec rm "{}" \;
8288
find "$NODEPROJ" \
8389
-name "*.framework" -type d \
8490
-prune -exec rm -rf "{}" \;
85-
for DOT_NODE in `find -E "$NODEPROJ" -regex ".*/prebuilds/ios-$PREBUILD_ARCH/.*\.node$"`; do
91+
for DOT_NODE in `find -E "$NODEPROJ" -regex ".*/prebuilds/ios-$PREBUILD_ARCH$SUFFIX/.*\.node$"`; do
8692
preparePrebuiltModule "$DOT_NODE"
8793
done
8894

@@ -104,10 +110,19 @@ fi
104110
# Rebuild modules with right environment
105111
NODEJS_HEADERS_DIR="$( cd "$PROJECT_DIR" && cd ../node_modules/nodejs-mobile-react-native/ios/libnode/ && pwd )"
106112
pushd $NODEPROJ
107-
if [ "$PLATFORM_NAME" == "iphoneos" ]
108-
then
113+
if [ "$PLATFORM_NAME" == "iphoneos" ]; then
109114
GYP_DEFINES="OS=ios" \
110-
CARGO_BUILD_TARGET="aarch64-apple-ios" \
115+
CARGO_BUILD_TARGET="aarch64-apple-ios iossim=false" \
116+
NODEJS_MOBILE_GYP="$NODEJS_MOBILE_GYP_BIN_FILE" \
117+
npm_config_node_gyp="$NODEJS_MOBILE_GYP_BIN_FILE" \
118+
npm_config_nodedir="$NODEJS_HEADERS_DIR" \
119+
npm_config_platform="ios" \
120+
npm_config_format="make-ios" \
121+
npm_config_arch="arm64" \
122+
npm --verbose --foreground-scripts rebuild --build-from-source
123+
elif [ "$NATIVE_ARCH" == "arm64" ]; then
124+
GYP_DEFINES="OS=ios target_arch=arm64 iossim=true" \
125+
CARGO_BUILD_TARGET="aarch64-apple-ios-sim" \
111126
NODEJS_MOBILE_GYP="$NODEJS_MOBILE_GYP_BIN_FILE" \
112127
npm_config_node_gyp="$NODEJS_MOBILE_GYP_BIN_FILE" \
113128
npm_config_nodedir="$NODEJS_HEADERS_DIR" \
@@ -116,7 +131,7 @@ then
116131
npm_config_arch="arm64" \
117132
npm --verbose --foreground-scripts rebuild --build-from-source
118133
else
119-
GYP_DEFINES="OS=ios" \
134+
GYP_DEFINES="OS=ios target_arch=x64 iossim=true" \
120135
CARGO_BUILD_TARGET="x86_64-apple-ios" \
121136
NODEJS_MOBILE_GYP="$NODEJS_MOBILE_GYP_BIN_FILE" \
122137
npm_config_node_gyp="$NODEJS_MOBILE_GYP_BIN_FILE" \

0 commit comments

Comments
 (0)