diff --git a/bindings/c/Makefile b/bindings/c/Makefile index 3a6e060da8..3d34e8d462 100644 --- a/bindings/c/Makefile +++ b/bindings/c/Makefile @@ -3,12 +3,11 @@ CFLAGS := -Iinclude LDFLAGS := -lm 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 +IOS_LIB_FILE = libsql_experimental.dylib +IOS_FINAL_LIB_FILE = libsql_experimental +LIB_FILE = libsql_experimental.so +XCFRAMEWORK = libsql_experimental.xcframework HEADER = libsql.h -XCFRAMEWORK = libsql.xcframework - -# Set LIBSQL_PATH to the default path if not provided -LIBSQL_EXPERIMENTAL_PATH ?= ../../target/release/libsql_experimental.a ifeq ($(OS),Darwin) CFLAGS += -framework Security -framework CoreServices @@ -21,6 +20,57 @@ all: example example: example.c $(CC) -o $@ $(CFLAGS) $< $(LIBSQL_EXPERIMENTAL_PATH) $(LDFLAGS) +notify: + osascript -e 'display notification "Build completed" with title "libsql"' + echo "🟢 Build Completed!" + +lint: + cargo clippy --all-features --all-targets -- --no-deps -D warnings + +fix: + cargo clippy --all-targets --all-features --fix --allow-dirty --allow-staged + cargo fmt --all + +nuke: + rm -rf ./target + +ios: clean ios-build package-dylibs notify + +clean: + rm -rf generated/$(XCFRAMEWORK) + +package-dylibs: + mkdir -p generated +# Delete old files + rm -rf generated/libsql*.xcframework + +# Reset the .xcframeworks from the templates + cp -r templates/libsql*.xcframework generated + +# Pack device dylibs + cp ../../target/aarch64-apple-ios/release/$(IOS_LIB_FILE) generated/$(IOS_FINAL_LIB_FILE) + + cp generated/$(IOS_FINAL_LIB_FILE) generated/libsql_experimental.xcframework/ios-arm64/libsql_experimental.framework/ + install_name_tool -id @rpath/libsql_experimental.framework/$(IOS_FINAL_LIB_FILE) generated/libsql_experimental.xcframework/ios-arm64/libsql_experimental.framework/$(IOS_FINAL_LIB_FILE) + codesign -f -s - --identifier com.turso.libsql-experimental generated/libsql_experimental.xcframework/ios-arm64/libsql_experimental.framework/$(IOS_FINAL_LIB_FILE) + + mkdir -p generated/libsql_experimental.xcframework/ios-arm64/libsql_experimental.framework/Headers + cp include/$(HEADER) generated/libsql_experimental.xcframework/ios-arm64/libsql_experimental.framework/Headers/ + +# Pack simulator dylibs + cp ../../target/aarch64-apple-ios-sim/release/$(IOS_LIB_FILE) generated/$(IOS_FINAL_LIB_FILE) + + cp generated/$(IOS_FINAL_LIB_FILE) generated/libsql_experimental.xcframework/ios-arm64-simulator/libsql_experimental.framework/ + install_name_tool -id @rpath/libsql_experimental.framework/$(IOS_FINAL_LIB_FILE) generated/libsql_experimental.xcframework/ios-arm64-simulator/libsql_experimental.framework/$(IOS_FINAL_LIB_FILE) + codesign -f -s - --identifier com.turso.libsql-experimental generated/libsql_experimental.xcframework/ios-arm64-simulator/libsql_experimental.framework/$(IOS_FINAL_LIB_FILE) + + mkdir -p generated/libsql_experimental.xcframework/ios-arm64-simulator/libsql_experimental.framework/Headers + cp include/$(HEADER) generated/libsql_experimental.xcframework/ios-arm64-simulator/libsql_experimental.framework/Headers/ + +ios-build: + cargo build --release --target aarch64-apple-ios + cargo build --release --target aarch64-apple-ios-sim + android: $(ARCHS_ANDROID) rm -rf generated mkdir -p generated/jniLibs @@ -28,33 +78,13 @@ android: $(ARCHS_ANDROID) mkdir -p generated/jniLibs/armeabi-v7a mkdir -p generated/jniLibs/x86_64 mkdir -p generated/jniLibs/x86 + mkdir -p generated/jniLibs/include - cp ../../target/aarch64-linux-android/release/$(LIB) generated/jniLibs/arm64-v8a/$(LIB) - cp ../../target/armv7-linux-androideabi/release/$(LIB) generated/jniLibs/armeabi-v7a/$(LIB) - cp ../../target/x86_64-linux-android/release/$(LIB) generated/jniLibs/x86_64/$(LIB) - cp ../../target/i686-linux-android/release/$(LIB) generated/jniLibs/x86/$(LIB) + cp ../../target/aarch64-linux-android/release/$(LIB_FILE) generated/jniLibs/arm64-v8a/$(LIB_FILE) + cp ../../target/armv7-linux-androideabi/release/$(LIB_FILE) generated/jniLibs/armeabi-v7a/$(LIB_FILE) + cp ../../target/x86_64-linux-android/release/$(LIB_FILE) generated/jniLibs/x86_64/$(LIB_FILE) + cp ../../target/i686-linux-android/release/$(LIB_FILE) generated/jniLibs/x86/$(LIB_FILE) + cp include/$(HEADER) generated/jniLibs/include/ $(ARCHS_ANDROID): %: cargo ndk --target $@ --platform 31 build --release - -ios: $(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 $@ diff --git a/bindings/c/templates/libsql_experimental.xcframework/Info.plist b/bindings/c/templates/libsql_experimental.xcframework/Info.plist new file mode 100644 index 0000000000..94cbfdcc8d --- /dev/null +++ b/bindings/c/templates/libsql_experimental.xcframework/Info.plist @@ -0,0 +1,43 @@ + + + + + AvailableLibraries + + + LibraryIdentifier + ios-arm64 + LibraryPath + libsql_experimental.framework + SupportedArchitectures + + arm64 + + SupportedPlatform + ios + + + LibraryIdentifier + ios-arm64-simulator + LibraryPath + libsql_experimental.framework + SupportedArchitectures + + arm64 + + SupportedPlatform + ios + SupportedPlatformVariant + simulator + + + CFBundlePackageType + XFWK + XCFrameworkFormatVersion + 1.0 + CFBundleVersion + 1.0.0 + CFBundleShortVersionString + 1.0.0 + + \ No newline at end of file diff --git a/bindings/c/templates/libsql_experimental.xcframework/ios-arm64-simulator/libsql_experimental.framework/Info.plist b/bindings/c/templates/libsql_experimental.xcframework/ios-arm64-simulator/libsql_experimental.framework/Info.plist new file mode 100644 index 0000000000..46a43f7e81 --- /dev/null +++ b/bindings/c/templates/libsql_experimental.xcframework/ios-arm64-simulator/libsql_experimental.framework/Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + libsql_experimental + CFBundleIdentifier + com.turso.libsql-experimental + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + FMWK + CFBundleSignature + ???? + CFBundleVersion + 1.0.0 + CFBundleShortVersionString + 1.0.0 + MinimumOSVersion + 13.0 + + \ No newline at end of file diff --git a/bindings/c/templates/libsql_experimental.xcframework/ios-arm64/libsql_experimental.framework/Info.plist b/bindings/c/templates/libsql_experimental.xcframework/ios-arm64/libsql_experimental.framework/Info.plist new file mode 100644 index 0000000000..46a43f7e81 --- /dev/null +++ b/bindings/c/templates/libsql_experimental.xcframework/ios-arm64/libsql_experimental.framework/Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + libsql_experimental + CFBundleIdentifier + com.turso.libsql-experimental + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + FMWK + CFBundleSignature + ???? + CFBundleVersion + 1.0.0 + CFBundleShortVersionString + 1.0.0 + MinimumOSVersion + 13.0 + + \ No newline at end of file diff --git a/libsql-ffi/build.rs b/libsql-ffi/build.rs index ea95d1ed28..ceda2a6794 100644 --- a/libsql-ffi/build.rs +++ b/libsql-ffi/build.rs @@ -504,7 +504,7 @@ fn build_multiple_ciphers(out_path: &Path) -> PathBuf { } let target = env::var("TARGET").unwrap(); - if target.ends_with("apple-ios") { + if target.ends_with("apple-ios") || target.contains("android") { config.define("SQLITE3MC_OMIT_AES_HARDWARE_SUPPORT", "ON"); }