Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions bindings/c/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 15 additions & 5 deletions bindings/c/Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 $@
xcodebuild -create-xcframework -library $(wildcard ../../target/aarch64-apple-ios/release/$(LIB)) -headers include -library generated/simulator_fat/$(LIB) -headers include -output $@
13 changes: 13 additions & 0 deletions libsql-ffi/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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()
}

Expand Down
3 changes: 2 additions & 1 deletion libsql-ffi/bundled/SQLite3MultipleCiphers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
Loading