Skip to content

Commit 40554dc

Browse files
authored
Merge pull request #1 from journeyapps/pod
podspec
2 parents b35c772 + 847872a commit 40554dc

30 files changed

+524
-140
lines changed

.cargo/config

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# On Linux, if we don't link to gcc_eh, we get can get this error when loading the loadable extension:
2+
# undefined symbol: _Unwind_Resume
3+
# This adds around 29KB to the loadable extension.
4+
# It may also be an option to just define _Unwind_Resume, but it causes crashes on errors on e.g. iOS, so rather avoid it.
5+
6+
[target.x86_64-unknown-linux-gnu]
7+
rustflags = [
8+
"-C", "link-arg=-lgcc_eh",
9+
]
10+
11+
[target.i686-linux-unknown-linux-gnu]
12+
rustflags = [
13+
"-C", "link-arg=-lgcc_eh",
14+
]
15+
16+
[target.aarch64-linux-unknown-linux-gnu]
17+
rustflags = [
18+
"-C", "link-arg=-lgcc_eh",
19+
]
20+
21+
22+
# For iOS and macOS, we need to specify the minimum/target version.
23+
# This must match the versions in the podspec file.
24+
[target.aarch64-apple-ios]
25+
rustflags = [
26+
"-C", "link-arg=-mios-version-min=11.0",
27+
]
28+
29+
[target.aarch64-apple-ios-sim]
30+
rustflags = [
31+
"-C", "link-arg=-miphonesimulator-version-min=11.0",
32+
]
33+
34+
[target.x86_64-apple-ios]
35+
rustflags = [
36+
"-C", "link-arg=-miphonesimulator-version-min=11.0",
37+
]
38+
39+
40+
[target.x86_64-apple-darwin]
41+
rustflags = [
42+
"-C", "link-arg=-mmacosx-version-min=10.13",
43+
]
44+
45+
[target.aarch64-apple-darwin]
46+
rustflags = [
47+
"-C", "link-arg=-mmacosx-version-min=10.13",
48+
]
49+

.github/workflows/android.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
on:
22
push:
33
pull_request:
4-
name: "rs-android"
4+
name: "android"
55
jobs:
66
build:
77
name: Building Android on ${{ matrix.os }}
@@ -30,6 +30,6 @@ jobs:
3030
i686-linux-android
3131
cargo install cargo-ndk
3232
33-
- name: Build Android
33+
- name: Build for Android
3434
run: |
3535
cargo ndk -t armeabi-v7a -t arm64-v8a -o ./jniLibs build --release -Zbuild-std -p powersync_loadable

.github/workflows/ios.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
on:
2+
push:
3+
pull_request:
4+
name: "ios"
5+
jobs:
6+
build:
7+
name: Building iOS on ${{ matrix.os }}
8+
runs-on: ${{ matrix.os }}
9+
strategy:
10+
matrix:
11+
include:
12+
- os: macos-latest
13+
steps:
14+
- uses: actions/checkout@v3
15+
with:
16+
submodules: true
17+
18+
- name: Setup
19+
run: |
20+
rustup toolchain install nightly-2023-08-28-x86_64-apple-darwin
21+
rustup component add rust-src --toolchain nightly-2023-08-28-x86_64-apple-darwin
22+
rustup target add \
23+
x86_64-apple-darwin \
24+
aarch64-apple-darwin \
25+
aarch64-apple-ios \
26+
aarch64-apple-ios-sim \
27+
x86_64-apple-ios
28+
29+
- name: setup-cocoapods
30+
uses: maxim-lobanov/setup-cocoapods@v1
31+
with:
32+
version: 1.12.1
33+
34+
- name: Build iOS & macOS xcframework
35+
run: |
36+
./build-pod.sh
37+
38+
- name: Lint pod
39+
run: |
40+
pod lib lint

.github/workflows/tests.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
on:
22
push:
3-
name: "rs-tests"
3+
name: "tests"
44
jobs:
55
build:
66
name: Testing on ${{ matrix.os }}
77
runs-on: ${{ matrix.os }}
88
strategy:
9+
fail-fast: false
910
matrix:
1011
include:
1112
- os: ubuntu-latest
@@ -23,7 +24,16 @@ jobs:
2324
run: |
2425
cargo build -p powersync_core --release --features static
2526
cargo build -p powersync_sqlite --release
27+
cargo build -p sqlite3 --release
2628
2729
- name: Test powersync
2830
run: |
2931
cargo test -p powersync_core --features loadable_extension
32+
33+
- name: Check shell
34+
run: |
35+
./target/release/powersync_sqlite ":memory:" "select powersync_rs_version()"
36+
37+
- name: Check loadable extension
38+
run: |
39+
./target/release/sqlite3 ":memory:" ".load ./target/release/libpowersync" "select powersync_rs_version()"

.github/workflows/valgrind.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
on:
22
push:
33
pull_request:
4-
name: "rs-valgrind"
4+
name: "valgrind"
55
jobs:
66
build:
77
name: Testing on ${{ matrix.os }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ dist/
55
build/
66
target/
77
.idea
8+
*.xcframework
9+
*.tar.gz
10+
*.tar.xz

Cargo.lock

Lines changed: 10 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ members = [
55
]
66
resolver = "2"
77
# We cannot build shell and lodable and the same time
8-
default-members = ["crates/shell"]
8+
default-members = ["crates/shell", "crates/sqlite"]
99

1010
[profile.dev]
1111
panic = "abort"
@@ -25,7 +25,7 @@ inherits = "release"
2525
lto = false
2626

2727
[workspace.package]
28-
version = "0.1.0"
28+
version = "0.1.3"
2929
edition = "2021"
3030
authors = ["JourneyApps"]
3131
keywords = ["sqlite", "powersync"]

LICENSE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Commercial license required, contact [email protected] for info.

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# PowerSync SQLite Extension
22

3-
This extension is used by PowerSync client SDKs. The APIs here not currently,
4-
and may change in any release.
3+
This extension is used by PowerSync client SDKs.
4+
5+
The APIs here not currently stable, and may change in any release. The APIs are intended to be used by PowerSync SDKs only.
56

67
# API
78

all-ios-loadable.sh

Lines changed: 0 additions & 64 deletions
This file was deleted.

build-pod.sh

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#! /bin/bash
2+
set -e
3+
4+
# Adapted from https://github.com/vlcn-io/cr-sqlite/blob/main/core/all-ios-loadable.sh
5+
6+
7+
BUILD_DIR=./build
8+
DIST_PACKAGE_DIR=./dist
9+
10+
function createXcframework() {
11+
plist=$(cat << EOF
12+
<?xml version="1.0" encoding="UTF-8"?>
13+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
14+
<plist version="1.0">
15+
<dict>
16+
<key>CFBundleDevelopmentRegion</key>
17+
<string>en</string>
18+
<key>CFBundleExecutable</key>
19+
<string>powersync-sqlite-core</string>
20+
<key>CFBundleIdentifier</key>
21+
<string>co.powersync.sqlitecore</string>
22+
<key>CFBundleInfoDictionaryVersion</key>
23+
<string>6.0</string>
24+
<key>CFBundlePackageType</key>
25+
<string>FMWK</string>
26+
<key>CFBundleSignature</key>
27+
<string>????</string>
28+
</dict>
29+
</plist>
30+
EOF
31+
)
32+
echo "===================== create ios device framework ====================="
33+
mkdir -p "${BUILD_DIR}/ios-arm64/powersync-sqlite-core.framework"
34+
echo "${plist}" > "${BUILD_DIR}/ios-arm64/powersync-sqlite-core.framework/Info.plist"
35+
cp -f "./target/aarch64-apple-ios/release/libpowersync.dylib" "${BUILD_DIR}/ios-arm64/powersync-sqlite-core.framework/powersync-sqlite-core"
36+
install_name_tool -id "@rpath/powersync-sqlite-core.framework/powersync-sqlite-core" "${BUILD_DIR}/ios-arm64/powersync-sqlite-core.framework/powersync-sqlite-core"
37+
38+
39+
echo "===================== create ios simulator framework ====================="
40+
mkdir -p "${BUILD_DIR}/ios-arm64_x86_64-simulator/powersync-sqlite-core.framework"
41+
echo "${plist}" > "${BUILD_DIR}/ios-arm64_x86_64-simulator/powersync-sqlite-core.framework/Info.plist"
42+
lipo ./target/aarch64-apple-ios-sim/release/libpowersync.dylib ./target/x86_64-apple-ios/release/libpowersync.dylib -create -output "${BUILD_DIR}/ios-arm64_x86_64-simulator/powersync-sqlite-core.framework/powersync-sqlite-core"
43+
install_name_tool -id "@rpath/powersync-sqlite-core.framework/powersync-sqlite-core" "${BUILD_DIR}/ios-arm64_x86_64-simulator/powersync-sqlite-core.framework/powersync-sqlite-core"
44+
45+
echo "===================== create macos framework ====================="
46+
mkdir -p "${BUILD_DIR}/macos-arm64_x86_64/powersync-sqlite-core.framework"
47+
echo "${plist}" > "${BUILD_DIR}/macos-arm64_x86_64/powersync-sqlite-core.framework/Info.plist"
48+
lipo ./target/x86_64-apple-darwin/release/libpowersync.dylib ./target/aarch64-apple-darwin/release/libpowersync.dylib -create -output "${BUILD_DIR}/macos-arm64_x86_64/powersync-sqlite-core.framework/powersync-sqlite-core"
49+
install_name_tool -id "@rpath/powersync-sqlite-core.framework/powersync-sqlite-core" "${BUILD_DIR}/macos-arm64_x86_64/powersync-sqlite-core.framework/powersync-sqlite-core"
50+
51+
echo "===================== create xcframework ====================="
52+
rm -rf "${BUILD_DIR}/powersync-sqlite-core.xcframework"
53+
xcodebuild -create-xcframework \
54+
-framework "${BUILD_DIR}/ios-arm64/powersync-sqlite-core.framework" \
55+
-framework "${BUILD_DIR}/ios-arm64_x86_64-simulator/powersync-sqlite-core.framework" \
56+
-framework "${BUILD_DIR}/macos-arm64_x86_64/powersync-sqlite-core.framework" \
57+
-output "${BUILD_DIR}/powersync-sqlite-core.xcframework"
58+
59+
cp -Rf "${BUILD_DIR}/powersync-sqlite-core.xcframework" "powersync-sqlite-core.xcframework"
60+
tar -cJvf powersync-sqlite-core.xcframework.tar.xz powersync-sqlite-core.xcframework LICENSE README.md
61+
rm -rf ${BUILD_DIR}
62+
}
63+
64+
# Make all the non-simulator libs
65+
# Package into a universal ios lib
66+
67+
rm -rf powersync-sqlite-core.xcframework
68+
69+
# iOS
70+
cargo build -p powersync_loadable --release --target aarch64-apple-ios -Zbuild-std
71+
# Simulator
72+
cargo build -p powersync_loadable --release --target aarch64-apple-ios-sim -Zbuild-std
73+
cargo build -p powersync_loadable --release --target x86_64-apple-ios -Zbuild-std
74+
# macOS
75+
cargo build -p powersync_loadable --release --target aarch64-apple-darwin -Zbuild-std
76+
cargo build -p powersync_loadable --release --target x86_64-apple-darwin -Zbuild-std
77+
78+
createXcframework

0 commit comments

Comments
 (0)