1-
21fn 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}
0 commit comments