diff --git a/bindings/c/Cargo.toml b/bindings/c/Cargo.toml index 162fdcac1d..78f4be6689 100644 --- a/bindings/c/Cargo.toml +++ b/bindings/c/Cargo.toml @@ -19,14 +19,8 @@ tracing = "0.1.40" tracing-subscriber = "0.3.18" http = "1.1.0" anyhow = "1.0.86" - -[target.'cfg(not(any(target_os = "ios", target_os = "android")))'.dependencies] libsql = { path = "../../libsql", features = ["encryption"] } -# Disable encryption for ios and android targets -[target.'cfg(any(target_os = "ios", target_os = "android"))'.dependencies] -libsql = { path = "../../libsql"} - # The produced binaries are too large for mobiles # When compiling for iOS or Android, you should turn on symbol stripping, lto and cut debug symbols diff --git a/bindings/c/Makefile b/bindings/c/Makefile index de0974e5c3..3a6e060da8 100644 --- a/bindings/c/Makefile +++ b/bindings/c/Makefile @@ -1,7 +1,7 @@ OS := $(shell uname) CFLAGS := -Iinclude LDFLAGS := -lm -ARCHS_IOS = x86_64-apple-ios aarch64-apple-ios aarch64-apple-ios-sim +ARCHS_IOS = aarch64-apple-ios aarch64-apple-ios-sim ARCHS_ANDROID = aarch64-linux-android armv7-linux-androideabi x86_64-linux-android i686-linux-android LIB = libsql_experimental.a HEADER = libsql.h @@ -40,11 +40,21 @@ $(ARCHS_ANDROID): %: ios: $(XCFRAMEWORK) $(ARCHS_IOS): %: - cargo build --release --target $@ - -$(XCFRAMEWORK): $(ARCHS_IOS) + cargo build --release --target $@ + +x86_64-apple-ios: + SDKROOT=$$(xcrun --sdk iphonesimulator --show-sdk-path) \ + CFLAGS_x86_64_apple_ios="-target x86_64-apple-ios-simulator" \ + CXXFLAGS_x86_64_apple_ios="-target x86_64-apple-ios-simulator" \ + CC_x86_64_apple_ios=$$(xcrun --sdk iphonesimulator --find clang) \ + CXX_x86_64_apple_ios=$$(xcrun --sdk iphonesimulator --find clang++) \ + CMAKE_SYSTEM_NAME=iOS \ + CMAKE_OSX_SYSROOT=$$(xcrun --sdk iphonesimulator --show-sdk-path) \ + cargo build --release --target x86_64-apple-ios + +$(XCFRAMEWORK): $(ARCHS_IOS) x86_64-apple-ios rm -rf generated mkdir -p generated/simulator_fat rm -rf $@ lipo -create $(wildcard ../../target/x86_64-apple-ios/release/$(LIB)) $(wildcard ../../target/aarch64-apple-ios-sim/release/$(LIB)) -output generated/simulator_fat/$(LIB) - xcodebuild -create-xcframework -library $(wildcard ../../target/aarch64-apple-ios/release/$(LIB)) -headers include -library generated/simulator_fat/$(LIB) -headers include -output $@ \ No newline at end of file + xcodebuild -create-xcframework -library $(wildcard ../../target/aarch64-apple-ios/release/$(LIB)) -headers include -library generated/simulator_fat/$(LIB) -headers include -output $@ diff --git a/libsql-ffi/build.rs b/libsql-ffi/build.rs index 193e161ecd..a5aab595c4 100644 --- a/libsql-ffi/build.rs +++ b/libsql-ffi/build.rs @@ -485,6 +485,11 @@ fn build_multiple_ciphers(out_path: &Path) -> PathBuf { build.compiler(cxx); config.init_cxx_cfg(build); } + let target = env::var("TARGET").unwrap(); + + if target.ends_with("apple-ios") { + config.define("SQLITE3MC_OMIT_AES_HARDWARE_SUPPORT", "ON"); + } if cfg!(feature = "wasmtime-bindings") { config.define("LIBSQL_ENABLE_WASM_RUNTIME", "1"); @@ -496,6 +501,14 @@ fn build_multiple_ciphers(out_path: &Path) -> PathBuf { .define("SQLITE_ENABLE_SESSION", "ON"); } + if let Ok(abi) = env::var("CARGO_NDK_ANDROID_TARGET") { + config.define("ANDROID_ABI", abi); + } + + if let Ok(platform) = env::var("ANDROID_PLATFORM") { + config.define("ANDROID_PLATFORM", platform); + } + config.build() } diff --git a/libsql-ffi/bundled/SQLite3MultipleCiphers/CMakeLists.txt b/libsql-ffi/bundled/SQLite3MultipleCiphers/CMakeLists.txt index aa48e789d3..51cca45a20 100644 --- a/libsql-ffi/bundled/SQLite3MultipleCiphers/CMakeLists.txt +++ b/libsql-ffi/bundled/SQLite3MultipleCiphers/CMakeLists.txt @@ -313,11 +313,12 @@ if (CMAKE_C_COMPILER_ID STREQUAL "Clang" AND NOT ( CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "arm" + OR CMAKE_ANDROID_ARCH_ABI STREQUAL "arm64-v8a" + OR CMAKE_ANDROID_ARCH_ABI STREQUAL "armeabi-v7a" )) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.2 -maes -Wno-error=incompatible-function-pointer-types") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.2 -maes") endif() - set(_LIB_DIFINITIONS _LIB )