Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically generate launch.json #665

Merged
merged 1 commit into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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})
Loading