@@ -19,14 +19,9 @@ FetchContent_MakeAvailable(sqlite3)
19
19
20
20
file (DOWNLOAD https://raw.githubusercontent.com/sqlite/sqlite/master/src/test_vfstrace.c "${CMAKE_BINARY_DIR} /vfstrace.c" )
21
21
22
- get_filename_component (RS_LIB_DIR "${CMAKE_BINARY_DIR} /../../powersync-sqlite-core/" ABSOLUTE )
23
- set (RS_LIB "powersync" )
24
- set (RS_WASM_TGT "wasm32-wasi" )
25
- set (RS_WASM_TGT_DIR "${RS_LIB_DIR} /target/${RS_WASM_TGT} " )
26
-
27
- set (RS_RELEASE_OUT "${RS_WASM_TGT_DIR} /wasm/" )
28
- set (RS_RELEASE_OUT_DEPS "${RS_WASM_TGT_DIR} /wasm/deps" )
29
- set (RS_RELEASE_EXTENSION_OUT "${RS_RELEASE_OUT} /powersync-extension.o" )
22
+ set (POWERSYNC_VERSION "0.3.0" )
23
+ set (POWERSYNC_A "${CMAKE_BINARY_DIR} /libpowersync-wasm.a" )
24
+ file (DOWNLOAD "https://github.com/powersync-ja/powersync-sqlite-core/releases/download/v${POWERSYNC_VERSION} /libpowersync-wasm.a" "${POWERSYNC_A} " )
30
25
31
26
# Generate symbols we need to export from the sqlite3.wasm build
32
27
add_custom_command (
@@ -47,7 +42,6 @@ macro(base_sqlite3_target name debug)
47
42
${CMAKE_CURRENT_SOURCE_DIR} /os_web.c
48
43
${CMAKE_CURRENT_SOURCE_DIR} /helpers.c
49
44
${sqlite3_SOURCE_DIR} /sqlite3.c
50
- ${RS_RELEASE_EXTENSION_OUT}
51
45
)
52
46
set (flags -Wall -Wextra -Wno-unused-parameter -Wno-unused-function)
53
47
@@ -71,6 +65,7 @@ macro(base_sqlite3_target name debug)
71
65
-Wl,--import-memory
72
66
--sysroot ${wasi_sysroot}
73
67
${sources}
68
+ ${POWERSYNC_A}
74
69
@${CMAKE_CURRENT_BINARY_DIR} /required_symbols.txt
75
70
DEPENDS ${sources} required_symbols
76
71
VERBATIM
@@ -97,31 +92,10 @@ macro(base_sqlite3_target name debug)
97
92
add_custom_target (${name} DEPENDS ${output} )
98
93
endmacro ()
99
94
100
- # Script to use llc to get object code from bytecode
101
- set (objectcode_script "${CMAKE_CURRENT_BINARY_DIR} /loop_objectcode_script.sh" )
102
- file (WRITE ${objectcode_script}
103
- "cd ${RS_RELEASE_OUT_DEPS} \n "
104
- "for filename in *.bc; do llc -march=wasm32 -filetype=obj $filename -o $filename.o; done\n "
105
- "wasm-ld -relocatable *.o -o ../powersync-extension.o"
106
- )
107
-
108
- add_custom_target (
109
- powersync_core_bytecode
110
- COMMAND ${CMAKE_COMMAND} -E env
111
- "RUSTFLAGS=--emit=llvm-bc -C linker=true"
112
- cargo build -p powersync_loadable --profile wasm --no -default-features --features \"powersync_core/static powersync_core/omit_load_extension sqlite_nostd/static sqlite_nostd/omit_load_extension\" -Z build -std=panic_abort,core,alloc --target ${RS_WASM_TGT}
113
- WORKING_DIRECTORY ${RS_LIB_DIR}
114
- # Converts bytecode to wasm object files
115
- COMMAND sh ${objectcode_script}
116
- )
117
-
118
95
base_sqlite3_target(sqlite3_debug true )
119
96
base_sqlite3_target(sqlite3_opt false )
120
97
121
- add_dependencies (sqlite3_opt powersync_core_bytecode)
122
- add_dependencies (sqlite3_debug powersync_core_bytecode)
123
-
124
98
add_custom_target (output )
125
99
add_custom_command (TARGET output COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR} /sqlite3_opt.wasm ${PROJECT_SOURCE_DIR} /../../example/web/sqlite3.wasm)
126
100
add_custom_command (TARGET output COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR} /sqlite3_debug.init.wasm ${PROJECT_SOURCE_DIR} /../../example/web/sqlite3.debug.wasm)
127
- add_dependencies (output sqlite3_debug sqlite3_opt powersync_core_bytecode )
101
+ add_dependencies (output sqlite3_debug sqlite3_opt)
0 commit comments