Skip to content

Commit 2ccf3ee

Browse files
committed
Enable source maps for Emscripten debug builds
1 parent 9a38d59 commit 2ccf3ee

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

run

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ if test -z "$nobuild"; then
166166
# Single project: build and install just that project.
167167
make preset="$preset" "$project"
168168
cmake --install "$cmakedir" --component "$project"/web --config Debug
169+
cmake --install "$cmakedir" --component generic/web --config Debug
169170
else
170171
# Otherwise, build and install everything.
171172
make preset="$preset" install

source/ham_executable.cmake

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,13 @@ function(HamSandwich_add_executable target_name)
187187

188188
target_link_libraries("${target_name}" idbfs.js)
189189
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
190-
target_link_options("${target_name}" PRIVATE --emrun)
190+
target_link_options("${target_name}" PRIVATE --emrun -gsource-map)
191+
install(
192+
FILES
193+
"${CMAKE_CURRENT_BINARY_DIR}/${target_name}.wasm.map"
194+
DESTINATION "."
195+
COMPONENT "${target_name}/web"
196+
)
191197
endif()
192198

193199
install(
@@ -296,3 +302,15 @@ else()
296302
function(msvc_compile_options)
297303
endfunction()
298304
endif()
305+
306+
# Emscripten source map links
307+
if(EMSCRIPTEN AND CMAKE_BUILD_TYPE STREQUAL "Debug")
308+
install(
309+
CODE [[
310+
file(CREATE_LINK "${CMAKE_SOURCE_DIR}/source" "${CMAKE_INSTALL_PREFIX}/source" SYMBOLIC)
311+
file(CREATE_LINK "${CMAKE_SOURCE_DIR}/external" "${CMAKE_INSTALL_PREFIX}/external" SYMBOLIC)
312+
file(CREATE_LINK "${CMAKE_SOURCE_DIR}/external/emsdk/upstream" "${CMAKE_INSTALL_PREFIX}/emsdk" SYMBOLIC)
313+
]]
314+
COMPONENT generic/web
315+
)
316+
endif()

0 commit comments

Comments
 (0)