Skip to content

Commit

Permalink
Merge pull request #930 from qw-ctf/json-validation
Browse files Browse the repository at this point in the history
CMAKE: JSON validation and fixup.
  • Loading branch information
dsvensson committed Sep 4, 2024
2 parents c776593 + 9040775 commit ef1e9b9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 8 additions & 0 deletions cmake/AddResources.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
# };
# const unsigned int blabla_len = 581;

find_program(JQ_EXECUTABLE jq)

macro(add_resources target_var)
add_library(${target_var} OBJECT)
set(RESOURCE_COMPILER "${PROJECT_SOURCE_DIR}/cmake/ResourceCompiler.cmake")
Expand All @@ -24,8 +26,14 @@ macro(add_resources target_var)
get_filename_component(source_file_name "${source_file}" NAME)
set(generated_file_name "${generated_directory}/${source_file_name}.c")

get_filename_component(source_ext "${source_file}" EXT)
if (source_ext STREQUAL ".json" AND JQ_EXECUTABLE)
set(validation_command ${JQ_EXECUTABLE} empty "${source_file}")
endif()

add_custom_command(
OUTPUT ${generated_file_name}
COMMAND ${validation_command}
COMMAND ${CMAKE_COMMAND} -P ${RESOURCE_COMPILER} "${source_file}" "${generated_file_name}"
WORKING_DIRECTORY "${source_file_dir}"
DEPENDS ${source_file} ${RESOURCE_COMPILER}
Expand Down
4 changes: 2 additions & 2 deletions help_commands.json
Original file line number Diff line number Diff line change
Expand Up @@ -1749,8 +1749,8 @@
"svadmin": {
"system-generated": true
},
"sys_forget_sandbox" {
"description": "Clears the currently selected sandbox directory. On the next restart, ezQuake will prompt you to select a directory again."
"sys_forget_sandbox": {
"description": "Clears the currently selected sandbox directory. On the next restart, ezQuake will prompt you to select a directory again.",
"remarks": "macOS only"
},
"tcl_eval": {
Expand Down

0 comments on commit ef1e9b9

Please sign in to comment.