Skip to content

Commit c1fc11e

Browse files
committed
fix(cpp.js): run ranlib for ios static libs before creating xcframework
fix(cpp.js): drop arm64e support for ios simulator fix(cpp.js): update ios-cmake toolchain file - no longer used fix(gdal): update native version to 3.10.3 fix(gdal): build with cmake-xcode instead of ios-cmake toolchain fix(geos): update native version to 3.13.1 fix(geotiff): update native version to 1.7.4 fix(proj): update native version to 9.6.0 fix(sqlite3): update native version to 4.49.1
1 parent d35fb82 commit c1fc11e

File tree

13 files changed

+68
-26
lines changed

13 files changed

+68
-26
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"build:samples:lib:ios": "pnpm --filter=@cpp.js/sample-lib-* run build:ios",
1010
"build:samples:wasm": "pnpm --filter=@cpp.js/sample-web-* run build && pnpm --filter=@cpp.js/sample-cloud-* run build && pnpm --filter=@cpp.js/sample-backend-* run build && pnpm run build:samples:lib:wasm",
1111
"build:website": "pnpm --filter=@cpp.js/website run build",
12-
"build:": "pnpm run build:packages; pnpm run build:samples;",
12+
"build": "pnpm run build:packages; pnpm run build:samples;",
1313
"clear:cache": "find packages -name \".cppjs\" -type d -maxdepth 2 -exec rm -rf {} +",
1414
"clear:cache:samples": "find packages -name \".cppjs\" -path \"*cppjs-sample-*\" -type d -maxdepth 2 -exec rm -rf {} +",
1515
"clear:cache:packages": "find packages -name \".cppjs\" -path \"*cppjs-package-*\" -type d -maxdepth 2 -exec rm -rf {} +",

packages/cpp.js/src/actions/createXCFramework.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ import upath from 'upath';
33
import { execFileSync } from 'node:child_process';
44
import state from '../state/index.js';
55

6+
const iOSDevPath = '/Applications/Xcode.app/Contents/Developer';
7+
const iosBinPath = `${iOSDevPath}/Toolchains/XcodeDefault.xctoolchain/usr/bin`;
8+
const iosRanLibBin = `${iosBinPath}/ranlib`;
9+
610
export default function createXCFramework(overrideConfig = null) {
711
if (process.platform !== 'darwin') {
812
return;
@@ -26,6 +30,8 @@ export default function createXCFramework(overrideConfig = null) {
2630

2731
libName.forEach((fileName) => {
2832
if (!fs.existsSync(`${projectPath}/${fileName}.xcframework`)) {
33+
execFileSync(iosRanLibBin, [`${relativeOutput}/prebuilt/iOS-iphoneos/lib/lib${fileName}.a`], options);
34+
execFileSync(iosRanLibBin, [`${relativeOutput}/prebuilt/iOS-iphonesimulator/lib/lib${fileName}.a`], options);
2935
const params = [
3036
'-create-xcframework',
3137
'-library', `${relativeOutput}/prebuilt/iOS-iphoneos/lib/lib${fileName}.a`,

packages/cpp.js/src/actions/run.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const androidParamsX86_64 = [
4141
];
4242

4343
const IOS_HOST_FLAGS = `-arch arm64 -arch arm64e -isysroot ${iosSdkPath} -fembed-bitcode`;
44-
const IOS_SIM_HOST_FLAGS = `-arch x86_64 -arch arm64 -arch arm64e -isysroot ${iosSimSdkPath} -fembed-bitcode`;
44+
const IOS_SIM_HOST_FLAGS = `-arch x86_64 -arch arm64 -isysroot ${iosSimSdkPath} -fembed-bitcode`;
4545
const IOS_IPHONE_PARAMS = [
4646
'-e', `CFLAGS="${IOS_HOST_FLAGS}"`,
4747
'-e', `CXXFLAGS="${IOS_HOST_FLAGS}"`,
@@ -130,7 +130,7 @@ export default function run(program, params = [], platformPrefix = null, platfor
130130
`-DMACOSX_FRAMEWORK_IDENTIFIER=org.js.cpp.${state.config.general.name}`,
131131
`-DCMAKE_XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER=org.js.cpp.${state.config.general.name}`,
132132
`-DCMAKE_OSX_SYSROOT='${arch[0] === 'iphoneos' ? iosSdkPath : iosSimSdkPath}'`,
133-
`-DCMAKE_OSX_ARCHITECTURES=${arch[0] === 'iphoneos' ? 'arm64;arm64e' : 'arm64;arm64e;x86_64'}`,
133+
`-DCMAKE_OSX_ARCHITECTURES=${arch[0] === 'iphoneos' ? 'arm64;arm64e' : 'arm64;x86_64'}`,
134134
`-DCMAKE_C_FLAGS=${arch[0] === 'iphoneos' ? '-fembed-bitcode' : '-fembed-bitcode-marker'}`,
135135
`-DCMAKE_CXX_FLAGS=${arch[0] === 'iphoneos' ? '-fembed-bitcode' : '-fembed-bitcode-marker'}`,
136136
'-DCMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY=\'iPhone Developer\'',
@@ -145,7 +145,7 @@ export default function run(program, params = [], platformPrefix = null, platfor
145145
...dParams,
146146
`-DCMAKE_TOOLCHAIN_FILE='${state.config.paths.cli}/assets/ios.toolchain.cmake'`,
147147
`-DPLATFORM=${arch[0] === 'iphoneos' ? 'OS64' : 'SIMULATORARM64'}`,
148-
`-DARCHS=${arch[0] === 'iphoneos' ? 'arm64;arm64e' : 'arm64;arm64e;x86_64'}`,
148+
`-DARCHS=${arch[0] === 'iphoneos' ? 'arm64;arm64e' : 'arm64;x86_64'}`,
149149
'-DENABLE_BITCODE=TRUE',
150150
'-DBUILD_SHARED_LIBS=OFF',
151151
'-DFRAMEWORK=TRUE',
@@ -154,7 +154,7 @@ export default function run(program, params = [], platformPrefix = null, platfor
154154
`-DMACOSX_FRAMEWORK_IDENTIFIER=org.js.cpp.${state.config.general.name}`,
155155
`-DCMAKE_XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER=org.js.cpp.${state.config.general.name}`,
156156
`-DCMAKE_OSX_SYSROOT='${arch[0] === 'iphoneos' ? iosSdkPath : iosSimSdkPath}'`,
157-
`-DCMAKE_OSX_ARCHITECTURES=${arch[0] === 'iphoneos' ? 'arm64;arm64e' : 'arm64;arm64e;x86_64'}`,
157+
`-DCMAKE_OSX_ARCHITECTURES=${arch[0] === 'iphoneos' ? 'arm64;arm64e' : 'arm64;x86_64'}`,
158158
`-DCMAKE_C_FLAGS=${arch[0] === 'iphoneos' ? '-fembed-bitcode' : '-fembed-bitcode-marker'}`,
159159
`-DCMAKE_CXX_FLAGS=${arch[0] === 'iphoneos' ? '-fembed-bitcode' : '-fembed-bitcode-marker'}`,
160160
'-DCMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY=\'iPhone Developer\'',

packages/cpp.js/src/assets/ios.toolchain.cmake

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
# WATCHOSCOMBINED = Build for armv7k arm64_32 x86_64 watchOS + watchOS Simulator. Combined into FAT STATIC lib (only supported on 3.14+ of CMake with "-G Xcode" argument in combination with the "cmake --install" CMake build step)
7575
# SIMULATOR_WATCHOS = Build for x86_64 for watchOS Simulator.
7676
# SIMULATORARM64_WATCHOS = Build for arm64 for watchOS Simulator.
77+
# SIMULATOR_WATCHOSCOMBINED = Build for arm64 x86_64 for watchOS Simulator. Combined into FAT STATIC lib (supported on 3.14+ of CMakewith "-G Xcode" argument ONLY)
7778
# MAC = Build for x86_64 macOS.
7879
# MAC_ARM64 = Build for Apple Silicon macOS.
7980
# MAC_UNIVERSAL = Combined build for x86_64 and Apple Silicon on macOS.
@@ -166,7 +167,7 @@ set(ENV{_IOS_TOOLCHAIN_HAS_RUN} true)
166167
list(APPEND _supported_platforms
167168
"OS" "OS64" "OS64COMBINED" "SIMULATOR" "SIMULATOR64" "SIMULATORARM64" "SIMULATOR64COMBINED"
168169
"TVOS" "TVOSCOMBINED" "SIMULATOR_TVOS" "SIMULATORARM64_TVOS"
169-
"WATCHOS" "WATCHOSCOMBINED" "SIMULATOR_WATCHOS" "SIMULATORARM64_WATCHOS"
170+
"WATCHOS" "WATCHOSCOMBINED" "SIMULATOR_WATCHOS" "SIMULATORARM64_WATCHOS" "SIMULATOR_WATCHOSCOMBINED"
170171
"MAC" "MAC_ARM64" "MAC_UNIVERSAL"
171172
"VISIONOS" "SIMULATOR_VISIONOS" "VISIONOSCOMBINED"
172173
"MAC_CATALYST" "MAC_CATALYST_ARM64" "MAC_CATALYST_UNIVERSAL")
@@ -461,12 +462,12 @@ elseif(PLATFORM_INT STREQUAL "WATCHOSCOMBINED")
461462
if(MODERN_CMAKE)
462463
if(NOT ARCHS)
463464
if (XCODE_VERSION_INT VERSION_GREATER 10.0)
464-
set(ARCHS armv7k arm64_32 i386)
465-
set(APPLE_TARGET_TRIPLE_INT arm64_32-i386-apple-watchos${DEPLOYMENT_TARGET})
465+
set(ARCHS armv7k arm64_32 x86_64)
466+
set(APPLE_TARGET_TRIPLE_INT arm64_32-x86_64-apple-watchos${DEPLOYMENT_TARGET})
466467
set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=watchos*] "armv7k arm64_32")
467-
set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=watchsimulator*] "i386")
468+
set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=watchsimulator*] "x86_64")
468469
set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=watchos*] "armv7k arm64_32")
469-
set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=watchsimulator*] "i386")
470+
set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=watchsimulator*] "x86_64")
470471
else()
471472
set(ARCHS armv7k i386)
472473
set(APPLE_TARGET_TRIPLE_INT arm-i386-apple-watchos${DEPLOYMENT_TARGET})
@@ -484,8 +485,13 @@ elseif(PLATFORM_INT STREQUAL "WATCHOSCOMBINED")
484485
elseif(PLATFORM_INT STREQUAL "SIMULATOR_WATCHOS")
485486
set(SDK_NAME watchsimulator)
486487
if(NOT ARCHS)
487-
set(ARCHS i386)
488-
set(APPLE_TARGET_TRIPLE_INT i386-apple-watchos${DEPLOYMENT_TARGET}-simulator)
488+
if (XCODE_VERSION_INT VERSION_GREATER 10.0)
489+
set(ARCHS x86_64)
490+
set(APPLE_TARGET_TRIPLE_INT x86_64-apple-watchos${DEPLOYMENT_TARGET}-simulator)
491+
else()
492+
set(ARCHS i386)
493+
set(APPLE_TARGET_TRIPLE_INT i386-apple-watchos${DEPLOYMENT_TARGET}-simulator)
494+
endif()
489495
else()
490496
set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-watchos${DEPLOYMENT_TARGET}-simulator)
491497
endif()
@@ -497,6 +503,31 @@ elseif(PLATFORM_INT STREQUAL "SIMULATORARM64_WATCHOS")
497503
else()
498504
set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-watchos${DEPLOYMENT_TARGET}-simulator)
499505
endif()
506+
elseif(PLATFORM_INT STREQUAL "SIMULATOR_WATCHOSCOMBINED")
507+
set(SDK_NAME watchsimulator)
508+
if(MODERN_CMAKE)
509+
if(NOT ARCHS)
510+
if (XCODE_VERSION_INT VERSION_GREATER 12.0)
511+
set(ARCHS arm64 x86_64)
512+
set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=watchos*] "")
513+
set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=watchsimulator*] "arm64 x86_64")
514+
set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=watchos*] "")
515+
set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=watchsimulator*] "arm64 x86_64")
516+
set(APPLE_TARGET_TRIPLE_INT arm64_x86_64-apple-watchos${DEPLOYMENT_TARGET}-simulator)
517+
else()
518+
set(ARCHS arm64 i386)
519+
set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=watchos*] "")
520+
set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=watchsimulator*] "i386")
521+
set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=watchos*] "")
522+
set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=watchsimulator*] "i386")
523+
set(APPLE_TARGET_TRIPLE_INT arm64_i386-apple-watchos${DEPLOYMENT_TARGET}-simulator)
524+
endif()
525+
else()
526+
set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-watchos${DEPLOYMENT_TARGET}-simulator)
527+
endif()
528+
else()
529+
message(FATAL_ERROR "Please make sure that you are running CMake 3.14+ to make the SIMULATOR_WATCHOSCOMBINED setting work")
530+
endif()
500531
elseif(PLATFORM_INT STREQUAL "SIMULATOR_VISIONOS")
501532
set(SDK_NAME xrsimulator)
502533
if(NOT ARCHS)

packages/cpp.js/src/state/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function setAllDependecyPaths() {
5757
if (platform === 'iOS-iphoneos') {
5858
xcRoot = `${d.paths.project}/${name}.xcframework/ios-arm64_arm64e`;
5959
} else if (platform === 'iOS-iphonesimulator') {
60-
xcRoot = `${d.paths.project}/${name}.xcframework/ios-arm64_arm64e_x86_64-simulator`;
60+
xcRoot = `${d.paths.project}/${name}.xcframework/ios-arm64_x86_64-simulator`;
6161
}
6262
dep.header = `${xcRoot}/Headers`;
6363
dep.libPath = xcRoot;

packages/cppjs-package-gdal/assets/gdal_empty_file.cpp

Whitespace-only changes.

packages/cppjs-package-gdal/cppjs.build.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const platformCmake = {
66

77
export default {
88
getURL: (version) => `https://github.com/OSGeo/gdal/releases/download/v${version}/gdal-${version}.tar.gz`,
9+
copyToSource: { 'assets/gdal_empty_file.cpp': 'gcore/gdal_empty_file.cpp' },
910
replaceList: [
1011
{
1112
regex: ' iconv_open',
@@ -27,9 +28,13 @@ export default {
2728
replacement: '',
2829
paths: ['gdal.cmake'],
2930
},
31+
{
32+
regex: 'add_library\\(\\$\\{GDAL_LIB_TARGET_NAME\\} gcore/gdal.h\\)',
33+
replacement: 'add_library(${GDAL_LIB_TARGET_NAME} gcore/gdal.h gcore/gdal_empty_file.cpp)',
34+
paths: ['gdal.cmake'],
35+
},
3036
],
31-
buildType: 'cmake', // cmake, configure,
32-
useIOSCMake: true,
37+
buildType: 'cmake',
3338
getBuildParams: (platform, depPaths, ext) => [
3439
...(platformCmake[platform] || []),
3540
'-DBUILD_APPS=OFF', '-DBUILD_TESTING=OFF', '-DACCEPT_MISSING_SQLITE3_MUTEX_ALLOC=ON',

packages/cppjs-package-gdal/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@cpp.js/package-gdal",
33
"version": "1.0.0",
4-
"nativeVersion": "3.10.1",
4+
"nativeVersion": "3.10.3",
55
"description": "This package provides the precompiled GDAL, built using Cpp.js, for seamless integration into JavaScript, WebAssembly, and React Native projects. It enables advanced geospatial data processing, including raster and vector data manipulation, format conversion, and spatial analysis, ensuring high performance and cross-platform compatibility. Perfect for web, server-side, and mobile geospatial applications.",
66
"homepage": "https://github.com/bugra9/cpp.js/tree/main/packages/cppjs-package-gdal#readme",
77
"repository": "https://github.com/bugra9/cpp.js.git",

packages/cppjs-package-geos/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@cpp.js/package-geos",
33
"version": "1.0.0",
4-
"nativeVersion": "3.13.0",
4+
"nativeVersion": "3.13.1",
55
"description": "This package provides the precompiled GEOS library, built using Cpp.js, for seamless integration into JavaScript, WebAssembly, and React Native projects. It supports advanced geometry operations, including spatial analysis and topological calculations, delivering high performance and cross-platform compatibility. Perfect for web, server-side, and mobile geospatial applications.",
66
"homepage": "https://github.com/bugra9/cpp.js/tree/main/packages/cppjs-package-geos#readme",
77
"repository": "https://github.com/bugra9/cpp.js.git",

packages/cppjs-package-geotiff/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@cpp.js/package-geotiff",
33
"version": "1.0.0",
4-
"nativeVersion": "1.7.3",
4+
"nativeVersion": "1.7.4",
55
"description": "This package provides the precompiled geotiff library, built using cpp.js, for easy integration into JavaScript, WebAssembly and React Native projects. Designed for working with GeoTIFF files, offering robust support for geospatial metadata handling, ensuring high performance and cross-platform compatibility. Ideal for use in web and mobile applications.",
66
"homepage": "https://github.com/bugra9/cpp.js/tree/main/packages/cppjs-package-geotiff#readme",
77
"repository": "https://github.com/bugra9/cpp.js.git",

0 commit comments

Comments
 (0)