forked from tursodatabase/libsql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
101 lines (79 loc) · 4.27 KB
/
Makefile
File metadata and controls
101 lines (79 loc) · 4.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
OS := $(shell uname)
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
IOS_LIB_FILE = libsql_experimental.dylib
IOS_FINAL_LIB_FILE = libsql_experimental
LIB_FILE = libsql_experimental.so
XCFRAMEWORK = libsql_experimental.xcframework
HEADER = libsql.h
ifeq ($(OS),Darwin)
CFLAGS += -framework Security -framework CoreServices
endif
.PHONY: all $(ARCHS_IOS) ios $(ARCHS_ANDROID) android
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 (fat binary: arm64 + x86_64)
lipo -create \
../../target/aarch64-apple-ios-sim/release/$(IOS_LIB_FILE) \
../../target/x86_64-apple-ios/release/$(IOS_LIB_FILE) \
-output generated/$(IOS_FINAL_LIB_FILE)
cp generated/$(IOS_FINAL_LIB_FILE) generated/libsql_experimental.xcframework/ios-arm64_x86_64-simulator/libsql_experimental.framework/
install_name_tool -id @rpath/libsql_experimental.framework/$(IOS_FINAL_LIB_FILE) generated/libsql_experimental.xcframework/ios-arm64_x86_64-simulator/libsql_experimental.framework/$(IOS_FINAL_LIB_FILE)
codesign -f -s - --identifier com.turso.libsql-experimental generated/libsql_experimental.xcframework/ios-arm64_x86_64-simulator/libsql_experimental.framework/$(IOS_FINAL_LIB_FILE)
mkdir -p generated/libsql_experimental.xcframework/ios-arm64_x86_64-simulator/libsql_experimental.framework/Headers
cp include/$(HEADER) generated/libsql_experimental.xcframework/ios-arm64_x86_64-simulator/libsql_experimental.framework/Headers/
ios-build:
cargo build --release --target aarch64-apple-ios
cargo build --release --target aarch64-apple-ios-sim
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
android: $(ARCHS_ANDROID)
rm -rf generated
mkdir -p generated/jniLibs
mkdir -p generated/jniLibs/arm64-v8a
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_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