Skip to content

Commit 0be30cb

Browse files
committed
Automatically generate launch.json
This adds a CMake option to automatically generate the launch.json file for vscode that runs everything in the testsuite.
1 parent 6dd1ec8 commit 0be30cb

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ set(CMAKE_CXX_STANDARD 20)
88
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
99
set(TRIESTE_BUILD_SAMPLES OFF)
1010

11+
option(VERONA_GENERATE_LAUNCH_JSON "Generate a launch.json file for debugging in VSCode" OFF)
12+
1113
FetchContent_Declare(
1214
trieste
1315
GIT_REPOSITORY https://github.com/microsoft/trieste

testsuite/CMakeLists.txt

+30
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,23 @@ foreach(TOOL ${TOOL_FOLDERS})
8585
set_source_files_properties(${test_path} PROPERTIES SYMBOLIC "true")
8686
list(APPEND test_set ${test_path})
8787

88+
# Make json for debugging.
89+
toolinvoke(launch_json_args ${VERONA_LOCAL_DIST} ${test_file} ${output_dir})
90+
list(POP_FRONT launch_json_args launch_json_prog)
91+
# Convert to a json format list.
92+
string(REPLACE "\"" "\\\"" launch_json_args "${launch_json_args}")
93+
string(REPLACE ";" "\", \"" launch_json_args "${launch_json_args}")
94+
list(APPEND LAUNCH_JSON
95+
" {
96+
\"name\": \"${test_path}\",
97+
\"type\": \"cppdbg\",
98+
\"request\": \"launch\",
99+
\"program\": \"${launch_json_prog}\",
100+
\"args\": [\"${launch_json_args}\"],
101+
\"stopAtEntry\": false,
102+
\"cwd\": \"${TOOL_FOLDER}/${test_dir}\",
103+
},")
104+
88105
# Add output comparison for each golden / output file
89106
set (golden_dir ${CMAKE_CURRENT_SOURCE_DIR}/${test_path}${GOLDEN_DIR_SUFFIX} )
90107
file (GLOB_RECURSE results CONFIGURE_DEPENDS RELATIVE ${golden_dir} ${golden_dir}/*)
@@ -147,4 +164,17 @@ foreach(TOOL ${TOOL_FOLDERS})
147164
list(APPEND UPDATE_DUMPS_TARGETS "update-dump-${TOOL}")
148165
endforeach()
149166

167+
string(REPLACE ";" "\n" LAUNCH_JSON "${LAUNCH_JSON}")
168+
169+
if (VERONA_GENERATE_LAUNCH_JSON)
170+
file(WRITE ${CMAKE_SOURCE_DIR}/.vscode/launch.json
171+
"{
172+
\"version\": \"0.2.0\",
173+
\"configurations\": [
174+
${LAUNCH_JSON}
175+
]
176+
}")
177+
endif()
178+
179+
150180
add_custom_target(update-dump DEPENDS ${UPDATE_DUMPS_TARGETS})

0 commit comments

Comments
 (0)