@@ -19,14 +19,9 @@ FetchContent_MakeAvailable(sqlite3)
1919
2020file (DOWNLOAD https://raw.githubusercontent.com/sqlite/sqlite/master/src/test_vfstrace.c "${CMAKE_BINARY_DIR} /vfstrace.c" )
2121
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} " )
3025
3126# Generate symbols we need to export from the sqlite3.wasm build
3227add_custom_command (
@@ -47,7 +42,6 @@ macro(base_sqlite3_target name debug)
4742 ${CMAKE_CURRENT_SOURCE_DIR} /os_web.c
4843 ${CMAKE_CURRENT_SOURCE_DIR} /helpers.c
4944 ${sqlite3_SOURCE_DIR} /sqlite3.c
50- ${RS_RELEASE_EXTENSION_OUT}
5145 )
5246 set (flags -Wall -Wextra -Wno-unused-parameter -Wno-unused-function)
5347
@@ -71,6 +65,7 @@ macro(base_sqlite3_target name debug)
7165 -Wl,--import-memory
7266 --sysroot ${wasi_sysroot}
7367 ${sources}
68+ ${POWERSYNC_A}
7469 @${CMAKE_CURRENT_BINARY_DIR} /required_symbols.txt
7570 DEPENDS ${sources} required_symbols
7671 VERBATIM
@@ -97,31 +92,10 @@ macro(base_sqlite3_target name debug)
9792 add_custom_target (${name} DEPENDS ${output} )
9893endmacro ()
9994
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-
11895base_sqlite3_target(sqlite3_debug true )
11996base_sqlite3_target(sqlite3_opt false )
12097
121- add_dependencies (sqlite3_opt powersync_core_bytecode)
122- add_dependencies (sqlite3_debug powersync_core_bytecode)
123-
12498add_custom_target (output )
12599add_custom_command (TARGET output COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR} /sqlite3_opt.wasm ${PROJECT_SOURCE_DIR} /../../example/web/sqlite3.wasm)
126100add_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