Skip to content

Commit 170f5ad

Browse files
committed
Overhaul bindings generation and introduce a CLI tool
This is a pretty large patch containing a whole bunch of changes. They're not really all related, but are hard to disentangle now, after being introduced while I worked on enabling debugging of componentize-js output. The key changes are: ## Two new CLI tools The embedding splicer now has a native Rust CLI for both splicing and stubbing. This isn't currently all that useful, but helped debug the changes to bindings generation and splicing. I plan on building on this in the future. Additionally, the full componentization has gained a CLI as an alternative to `jco componentize`, so running `npx componentize-js` will work and provide a reasonable interface. ## Support for unbundled JS A key goal of the changes here was to no longer rewrite the input source code, because that messes up debugging using StarlingMonkey's debugger. As part of implementing this, we got support for loading other JS modules at initialization time "for free", so that works now, too. ## No more treeshaking A regrettable change is that we don't support any kind of treeshaking anymore. This is much harder to implement without requiring bundled code (see the previous item). Additionally, it only worked for functions (not methods, or anything related to resources) before, and was thus of very limited value. We can in principle, with a decent amount of effort, reintroduce at least what we had before, but I think ultimately the right approach here is to make sure that the targeted runtime environment supports the full WIT world provided during componentization. ## Small stuff Aside from these larger items, there's a bunch of small changes, and fairly sizable refactorings.
1 parent b31032c commit 170f5ad

File tree

29 files changed

+1116
-890
lines changed

29 files changed

+1116
-890
lines changed

CMakeLists.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ project(ComponentizeJS)
2121

2222
set(RAW_WASM ${CMAKE_CURRENT_BINARY_DIR}/starling-raw.wasm/starling-raw.wasm)
2323

24+
set(EMBEDDING_DEP "starling-raw.wasm")
25+
2426
# Define output filenames based on build configuration
2527
set(OUTPUT_NAME_RELEASE "starlingmonkey_embedding.wasm")
2628
set(OUTPUT_NAME_DEBUG "starlingmonkey_embedding.debug.wasm")
@@ -31,24 +33,23 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInf
3133
set(OUTPUT_FILENAME ${OUTPUT_NAME_DEBUG})
3234
elseif(WEVAL)
3335
set(OUTPUT_FILENAME ${OUTPUT_NAME_WEVAL})
36+
set(EMBEDDING_DEP "starling-ics.wevalcache")
3437
else()
3538
set(OUTPUT_FILENAME ${OUTPUT_NAME_RELEASE})
3639
endif()
3740

3841
set(OUTPUT_FILENAME ${CMAKE_CURRENT_SOURCE_DIR}/lib/${OUTPUT_FILENAME})
3942

4043
add_custom_target(starlingmonkey_embedding
41-
DEPENDS starling-raw.wasm
44+
DEPENDS ${EMBEDDING_DEP}
4245
COMMAND ${CMAKE_COMMAND} -E copy
4346
${CMAKE_CURRENT_BINARY_DIR}/starling-raw.wasm/starling-raw.wasm
4447
${OUTPUT_FILENAME}
4548
)
4649

47-
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
50+
if(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
4851
add_custom_command(TARGET starlingmonkey_embedding POST_BUILD
4952
COMMAND ${WASM_TOOLS_BIN} strip ${OUTPUT_FILENAME} -d ".debug_(info|loc|ranges|abbrev|line|str)" -o ${OUTPUT_FILENAME}
50-
COMMENT "Stripping debug info from ${OUTPUT_FILENAME}"
5153
VERBATIM
5254
)
5355
endif()
54-
message(STATUS "Output file: ${OUTPUT_FILENAME}, wasm tools: ${WASM_TOOLS_BIN}")

0 commit comments

Comments
 (0)