Skip to content

Commit e3eb0f5

Browse files
zifeosimolus3
authored andcommitted
feat: add watchos support
1 parent 3285e39 commit e3eb0f5

File tree

11 files changed

+182
-31
lines changed

11 files changed

+182
-31
lines changed

.cargo/config.toml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
# Previously we added this to rustflags for all linux builds:
32
# "-C", "link-arg=-lgcc_eh"
43
# It was to fix this error when loading the loadable extension:
@@ -86,3 +85,18 @@ rustflags = [
8685
rustflags = [
8786
"-C", "link-arg=-Wl,-soname,libpowersync.so",
8887
]
88+
89+
[target.aarch64-apple-watchos]
90+
rustflags = [
91+
"-C", "link-arg=-mwatchos-version-min=7.0",
92+
]
93+
94+
[target.aarch64-apple-watchos-sim]
95+
rustflags = [
96+
"-C", "link-arg=-mwatchsimulator-version-min=7.0",
97+
]
98+
99+
[target.x86_64-apple-watchos]
100+
rustflags = [
101+
"-C", "link-arg=-mwatchos-version-min=7.0",
102+
]

.github/workflows/ios.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ jobs:
2121
aarch64-apple-darwin \
2222
aarch64-apple-ios \
2323
aarch64-apple-ios-sim \
24-
x86_64-apple-ios
25-
24+
x86_64-apple-ios \
25+
aarch64-apple-watchos \
26+
aarch64-apple-watchos-sim \
27+
x86_64-apple-watchos
2628
- name: setup-cocoapods
2729
uses: maxim-lobanov/setup-cocoapods@v1
2830
with:

.github/workflows/release.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,10 @@ jobs:
9191
aarch64-apple-darwin \
9292
aarch64-apple-ios \
9393
aarch64-apple-ios-sim \
94-
x86_64-apple-ios
95-
94+
x86_64-apple-ios \
95+
aarch64-apple-watchos \
96+
aarch64-apple-watchos-sim \
97+
x86_64-apple-watchos
9698
- name: setup-cocoapods
9799
uses: maxim-lobanov/setup-cocoapods@v1
98100
with:

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,4 @@ repository = "https://github.com/powersync-ja/powersync-sqlite-core"
3838

3939
[workspace.dependencies]
4040
sqlite_nostd = { path="./sqlite-rs-embedded/sqlite_nostd" }
41+

crates/shell/Cargo.toml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,23 @@ license.workspace = true
88
authors.workspace = true
99
keywords.workspace = true
1010

11+
[lib]
12+
name = "powersync_sqlite"
13+
path = "src/main.rs"
14+
crate-type = ["staticlib"]
15+
16+
[[bin]]
17+
name = "powersync_sqlite"
18+
path = "src/main.rs"
19+
required-features = ["shell"]
20+
1121
[dependencies]
12-
powersync_core = { path="../core" }
13-
sqlite_nostd = { workspace=true }
22+
powersync_core = { path="../core", default-features = false, features = ["static", "omit_load_extension"] }
23+
sqlite_nostd = { workspace=true, features = ["static", "omit_load_extension"] }
1424

1525
[features]
16-
default = ["powersync_core/static", "powersync_core/omit_load_extension", "sqlite_nostd/static", "sqlite_nostd/omit_load_extension"]
26+
default = []
27+
shell = []
1728

1829
[build-dependencies]
1930
cc = "1.0.46"

crates/shell/build.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
21
fn main() {
32
let mut cfg = cc::Build::new();
3+
let target = std::env::var("TARGET").unwrap();
4+
let is_watchos = target.contains("watchos") || target.contains("watchsimulator");
45

56
// Compile the SQLite source
67
cfg.file("../sqlite/sqlite/sqlite3.c");
7-
cfg.file("../sqlite/sqlite/shell.c");
88
cfg.include("../sqlite/sqlite");
99

1010
// General SQLite options
@@ -14,15 +14,22 @@ fn main() {
1414
// Call core_init() in main.rs
1515
cfg.define("SQLITE_EXTRA_INIT", Some("core_init"));
1616

17-
// Compile with readline support (also requires -lreadline / cargo:rustc-link-lib=readline below)
18-
cfg.define("HAVE_READLINE", Some("1"));
17+
if is_watchos {
18+
// For watchOS, don't build the shell and disable readline
19+
cfg.define("HAVE_READLINE", Some("0"));
20+
cfg.define("HAVE_EDITLINE", Some("0"));
21+
cfg.define("SQLITE_OMIT_SYSTEM", Some("1"));
22+
} else {
23+
// For other platforms, build the shell with readline
24+
cfg.file("../sqlite/sqlite/shell.c");
25+
cfg.define("HAVE_READLINE", Some("1"));
26+
println!("cargo:rustc-link-lib=readline");
27+
}
1928

2029
// Silence warnings generated for SQLite
2130
cfg.flag("-Wno-implicit-fallthrough");
2231
cfg.flag("-Wno-unused-parameter");
2332
cfg.flag("-Wno-null-pointer-subtraction");
2433

2534
cfg.compile("sqlite-ps");
26-
27-
println!("cargo:rustc-link-lib=readline");
2835
}

crates/shell/src/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ fn panic(_info: &core::panic::PanicInfo) -> ! {
2828
#[lang = "eh_personality"]
2929
extern "C" fn eh_personality() {}
3030

31-
3231
#[no_mangle]
3332
pub extern "C" fn core_init(_dummy: *mut c_char) -> c_int {
3433
powersync_init_static()

crates/sqlite/Cargo.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,21 @@ license.workspace = true
88
authors.workspace = true
99
keywords.workspace = true
1010

11+
[lib]
12+
name = "sqlite3"
13+
path = "src/main.rs"
14+
crate-type = ["staticlib"]
15+
16+
[[bin]]
17+
name = "sqlite3"
18+
path = "src/main.rs"
19+
required-features = ["shell"]
20+
1121
[dependencies]
1222

1323
[features]
24+
default = []
25+
shell = []
1426

1527
[build-dependencies]
1628
cc = "1.0.46"

crates/sqlite/build.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,32 @@
11
fn main() {
22
let mut cfg = cc::Build::new();
3+
let target = std::env::var("TARGET").unwrap();
4+
let is_watchos = target.contains("watchos") || target.contains("watchsimulator");
35

46
// Compile the SQLite source
57
cfg.file("./sqlite/sqlite3.c");
6-
cfg.file("./sqlite/shell.c");
78
cfg.include("./sqlite");
89

910
// General SQLite options
1011
cfg.define("SQLITE_THREADSAFE", Some("0"));
1112
cfg.define("SQLITE_ENABLE_BYTECODE_VTAB", Some("1"));
1213

13-
// Compile with readline support (also requires -lreadline / cargo:rustc-link-lib=readline below)
14-
cfg.define("HAVE_READLINE", Some("1"));
14+
if is_watchos {
15+
// For watchOS, don't build the shell and disable readline
16+
cfg.define("HAVE_READLINE", Some("0"));
17+
cfg.define("HAVE_EDITLINE", Some("0"));
18+
cfg.define("SQLITE_OMIT_SYSTEM", Some("1"));
19+
} else {
20+
// For other platforms, build the shell with readline
21+
cfg.file("./sqlite/shell.c");
22+
cfg.define("HAVE_READLINE", Some("1"));
23+
println!("cargo:rustc-link-lib=readline");
24+
}
1525

1626
// Silence warnings generated for SQLite
1727
cfg.flag("-Wno-implicit-fallthrough");
1828
cfg.flag("-Wno-unused-parameter");
1929
cfg.flag("-Wno-null-pointer-subtraction");
2030

2131
cfg.compile("sqlite");
22-
23-
println!("cargo:rustc-link-lib=readline");
2432
}

powersync-sqlite-core.podspec

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ PowerSync extension for SQLite.
1313
s.source = { :http => "https://github.com/powersync-ja/powersync-sqlite-core/releases/download/v#{s.version}/powersync-sqlite-core.xcframework.zip" }
1414
s.vendored_frameworks = 'powersync-sqlite-core.xcframework'
1515

16-
1716
s.ios.deployment_target = '11.0'
1817
s.osx.deployment_target = '10.13'
18+
s.watchos.deployment_target = '7.0'
19+
20+
# Ensure no asset catalogs are included for watchOS
21+
s.watchos.resource_bundles = {}
22+
s.watchos.resources = []
1923
end

0 commit comments

Comments
 (0)