Skip to content

Commit

Permalink
Automatically generate launch.json
Browse files Browse the repository at this point in the history
This adds a CMake option to automatically generate the launch.json file for vscode that runs everything in the testsuite.
  • Loading branch information
mjp41 committed Apr 11, 2024
1 parent 6679897 commit a3dcf48
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ set(CMAKE_CXX_STANDARD 20)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(TRIESTE_BUILD_SAMPLES OFF)

option(VERONA_GENERATE_LAUNCH_JSON "Generate a launch.json file for debugging in VSCode" OFF)

FetchContent_Declare(
trieste
GIT_REPOSITORY https://github.com/microsoft/trieste
Expand Down
30 changes: 30 additions & 0 deletions testsuite/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,23 @@ foreach(TOOL ${TOOL_FOLDERS})
set_source_files_properties(${test_path} PROPERTIES SYMBOLIC "true")
list(APPEND test_set ${test_path})

# Make json for debugging.
toolinvoke(launch_json_args ${VERONA_LOCAL_DIST} ${test_file} ${output_dir})
list(POP_FRONT launch_json_args launch_json_prog)
# Convert to a json format list.
string(REPLACE "\"" "\\\"" launch_json_args "${launch_json_args}")
string(REPLACE ";" "\", \"" launch_json_args "${launch_json_args}")
list(APPEND LAUNCH_JSON
" {
\"name\": \"${test_path}\",
\"type\": \"cppdbg\",
\"request\": \"launch\",
\"program\": \"${launch_json_prog}\",
\"args\": [\"${launch_json_args}\"],
\"stopAtEntry\": false,
\"cwd\": \"${TOOL_FOLDER}/${test_dir}\",
},")

# Add output comparison for each golden / output file
set (golden_dir ${CMAKE_CURRENT_SOURCE_DIR}/${test_path}${GOLDEN_DIR_SUFFIX} )
file (GLOB_RECURSE results CONFIGURE_DEPENDS RELATIVE ${golden_dir} ${golden_dir}/*)
Expand Down Expand Up @@ -147,4 +164,17 @@ foreach(TOOL ${TOOL_FOLDERS})
list(APPEND UPDATE_DUMPS_TARGETS "update-dump-${TOOL}")
endforeach()

string(REPLACE ";" "\n" LAUNCH_JSON "${LAUNCH_JSON}")

if (VERONA_GENERATE_LAUNCH_JSON)
file(WRITE ${CMAKE_SOURCE_DIR}/.vscode/launch.json
"{
\"version\": \"0.2.0\",
\"configurations\": [
${LAUNCH_JSON}
]
}")
endif()


add_custom_target(update-dump DEPENDS ${UPDATE_DUMPS_TARGETS})

0 comments on commit a3dcf48

Please sign in to comment.