Skip to content

podspec #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Sep 5, 2023
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
49 changes: 49 additions & 0 deletions .cargo/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# On Linux, if we don't link to gcc_eh, we get can get this error when loading the loadable extension:
# undefined symbol: _Unwind_Resume
# This adds around 29KB to the loadable extension.
# 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.

[target.x86_64-unknown-linux-gnu]
rustflags = [
"-C", "link-arg=-lgcc_eh",
]

[target.i686-linux-unknown-linux-gnu]
rustflags = [
"-C", "link-arg=-lgcc_eh",
]

[target.aarch64-linux-unknown-linux-gnu]
rustflags = [
"-C", "link-arg=-lgcc_eh",
]


# For iOS and macOS, we need to specify the minimum/target version.
# This must match the versions in the podspec file.
[target.aarch64-apple-ios]
rustflags = [
"-C", "link-arg=-mios-version-min=11.0",
]

[target.aarch64-apple-ios-sim]
rustflags = [
"-C", "link-arg=-miphonesimulator-version-min=11.0",
]

[target.x86_64-apple-ios]
rustflags = [
"-C", "link-arg=-miphonesimulator-version-min=11.0",
]


[target.x86_64-apple-darwin]
rustflags = [
"-C", "link-arg=-mmacosx-version-min=10.13",
]

[target.aarch64-apple-darwin]
rustflags = [
"-C", "link-arg=-mmacosx-version-min=10.13",
]

4 changes: 2 additions & 2 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
on:
push:
pull_request:
name: "rs-android"
name: "android"
jobs:
build:
name: Building Android on ${{ matrix.os }}
Expand Down Expand Up @@ -30,6 +30,6 @@ jobs:
i686-linux-android
cargo install cargo-ndk

- name: Build Android
- name: Build for Android
run: |
cargo ndk -t armeabi-v7a -t arm64-v8a -o ./jniLibs build --release -Zbuild-std -p powersync_loadable
40 changes: 40 additions & 0 deletions .github/workflows/ios.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
on:
push:
pull_request:
name: "ios"
jobs:
build:
name: Building iOS on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: macos-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true

- name: Setup
run: |
rustup toolchain install nightly-2023-08-28-x86_64-apple-darwin
rustup component add rust-src --toolchain nightly-2023-08-28-x86_64-apple-darwin
rustup target add \
x86_64-apple-darwin \
aarch64-apple-darwin \
aarch64-apple-ios \
aarch64-apple-ios-sim \
x86_64-apple-ios

- name: setup-cocoapods
uses: maxim-lobanov/setup-cocoapods@v1
with:
version: 1.12.1

- name: Build iOS & macOS xcframework
run: |
./build-pod.sh

- name: Lint pod
run: |
pod lib lint
12 changes: 11 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
on:
push:
name: "rs-tests"
name: "tests"
jobs:
build:
name: Testing on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
Expand All @@ -23,7 +24,16 @@ jobs:
run: |
cargo build -p powersync_core --release --features static
cargo build -p powersync_sqlite --release
cargo build -p sqlite3 --release

- name: Test powersync
run: |
cargo test -p powersync_core --features loadable_extension

- name: Check shell
run: |
./target/release/powersync_sqlite ":memory:" "select powersync_rs_version()"

- name: Check loadable extension
run: |
./target/release/sqlite3 ":memory:" ".load ./target/release/libpowersync" "select powersync_rs_version()"
2 changes: 1 addition & 1 deletion .github/workflows/valgrind.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
on:
push:
pull_request:
name: "rs-valgrind"
name: "valgrind"
jobs:
build:
name: Testing on ${{ matrix.os }}
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ dist/
build/
target/
.idea
*.xcframework
*.tar.gz
*.tar.xz
13 changes: 10 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ members = [
]
resolver = "2"
# We cannot build shell and lodable and the same time
default-members = ["crates/shell"]
default-members = ["crates/shell", "crates/sqlite"]

[profile.dev]
panic = "abort"
Expand All @@ -25,7 +25,7 @@ inherits = "release"
lto = false

[workspace.package]
version = "0.1.0"
version = "0.1.3"
edition = "2021"
authors = ["JourneyApps"]
keywords = ["sqlite", "powersync"]
Expand Down
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Commercial license required, contact info@powersync.co for info.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# PowerSync SQLite Extension

This extension is used by PowerSync client SDKs. The APIs here not currently,
and may change in any release.
This extension is used by PowerSync client SDKs.

The APIs here not currently stable, and may change in any release. The APIs are intended to be used by PowerSync SDKs only.

# API

Expand Down
64 changes: 0 additions & 64 deletions all-ios-loadable.sh

This file was deleted.

78 changes: 78 additions & 0 deletions build-pod.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#! /bin/bash
set -e

# Adapted from https://github.com/vlcn-io/cr-sqlite/blob/main/core/all-ios-loadable.sh


BUILD_DIR=./build
DIST_PACKAGE_DIR=./dist

function createXcframework() {
plist=$(cat << EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>powersync-sqlite-core</string>
<key>CFBundleIdentifier</key>
<string>co.powersync.sqlitecore</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleSignature</key>
<string>????</string>
</dict>
</plist>
EOF
)
echo "===================== create ios device framework ====================="
mkdir -p "${BUILD_DIR}/ios-arm64/powersync-sqlite-core.framework"
echo "${plist}" > "${BUILD_DIR}/ios-arm64/powersync-sqlite-core.framework/Info.plist"
cp -f "./target/aarch64-apple-ios/release/libpowersync.dylib" "${BUILD_DIR}/ios-arm64/powersync-sqlite-core.framework/powersync-sqlite-core"
install_name_tool -id "@rpath/powersync-sqlite-core.framework/powersync-sqlite-core" "${BUILD_DIR}/ios-arm64/powersync-sqlite-core.framework/powersync-sqlite-core"


echo "===================== create ios simulator framework ====================="
mkdir -p "${BUILD_DIR}/ios-arm64_x86_64-simulator/powersync-sqlite-core.framework"
echo "${plist}" > "${BUILD_DIR}/ios-arm64_x86_64-simulator/powersync-sqlite-core.framework/Info.plist"
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"
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"

echo "===================== create macos framework ====================="
mkdir -p "${BUILD_DIR}/macos-arm64_x86_64/powersync-sqlite-core.framework"
echo "${plist}" > "${BUILD_DIR}/macos-arm64_x86_64/powersync-sqlite-core.framework/Info.plist"
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"
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"

echo "===================== create xcframework ====================="
rm -rf "${BUILD_DIR}/powersync-sqlite-core.xcframework"
xcodebuild -create-xcframework \
-framework "${BUILD_DIR}/ios-arm64/powersync-sqlite-core.framework" \
-framework "${BUILD_DIR}/ios-arm64_x86_64-simulator/powersync-sqlite-core.framework" \
-framework "${BUILD_DIR}/macos-arm64_x86_64/powersync-sqlite-core.framework" \
-output "${BUILD_DIR}/powersync-sqlite-core.xcframework"

cp -Rf "${BUILD_DIR}/powersync-sqlite-core.xcframework" "powersync-sqlite-core.xcframework"
tar -cJvf powersync-sqlite-core.xcframework.tar.xz powersync-sqlite-core.xcframework LICENSE README.md
rm -rf ${BUILD_DIR}
}

# Make all the non-simulator libs
# Package into a universal ios lib

rm -rf powersync-sqlite-core.xcframework

# iOS
cargo build -p powersync_loadable --release --target aarch64-apple-ios -Zbuild-std
# Simulator
cargo build -p powersync_loadable --release --target aarch64-apple-ios-sim -Zbuild-std
cargo build -p powersync_loadable --release --target x86_64-apple-ios -Zbuild-std
# macOS
cargo build -p powersync_loadable --release --target aarch64-apple-darwin -Zbuild-std
cargo build -p powersync_loadable --release --target x86_64-apple-darwin -Zbuild-std

createXcframework
Loading