|
17 | 17 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
18 | 18 | # MA 02110-1301, USA. |
19 | 19 | # |
20 | | -set(input_dir "json") |
21 | | -set(output_dir "${CMAKE_CURRENT_SOURCE_DIR}/json") |
22 | | -set(folder "${CMAKE_CURRENT_SOURCE_DIR}/json") |
23 | | -if (WITH_JSON_VALIDATION) |
24 | | - set(files "") |
25 | 20 |
|
26 | | - file(GLOB_RECURSE files RELATIVE |
27 | | - "${CMAKE_CURRENT_SOURCE_DIR}/${input_dir}" |
28 | | - "${CMAKE_CURRENT_SOURCE_DIR}/${input_dir}/*.json") |
29 | | - |
30 | | - set(target "models.json") |
31 | | - add_custom_target(validate_${target}) |
32 | | - add_dependencies(validate_all_json validate_${target}) |
33 | | - |
34 | | - add_custom_target(indent_${target}) |
35 | | - add_dependencies(indent_all_json indent_${target}) |
36 | | - |
37 | | - foreach(file ${files}) |
38 | | - add_custom_target(validate_${file} |
39 | | - COMMENT "Validating JSON for ${target}/${file}." |
40 | | - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} |
41 | | - COMMAND ${JQ_COMMAND} . ${folder}/${file} > /dev/null) |
42 | | - add_dependencies(validate_${target} validate_${file}) |
43 | | - |
44 | | - add_custom_target(indent_${file} |
45 | | - COMMENT "Indenting JSON for ${target}/${file}." |
46 | | - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} |
47 | | - COMMAND ${JQ_COMMAND} . ${folder}/${file} > ${folder}/${file}_tmp |
48 | | - COMMAND mv ${folder}/${file}_tmp ${folder}/${file}) |
49 | | - add_dependencies(indent_${target} indent_${file}) |
50 | | - |
51 | | - endforeach() |
52 | | -endif() |
53 | | - |
54 | | -# |
55 | | -# Conversion targets |
56 | | -# |
57 | 21 | if (DOGEN_CLI_EXECUTABLE) |
58 | | - # |
59 | | - # Model conversion |
60 | | - # |
61 | | - file(GLOB models "dia/*.dia") |
62 | | - foreach(model ${models}) |
63 | | - set(model_name "") |
64 | | - get_filename_component(model_name ${model} NAME) |
65 | | - |
66 | | - set(output_dir "${CMAKE_CURRENT_SOURCE_DIR}/json") |
67 | | - set(destination_name ${output_dir}/${model_name}) |
68 | | - string(REGEX REPLACE ".dia$" ".json" destination_name |
69 | | - ${destination_name}) |
70 | | - |
71 | | - add_custom_target(convert_${model_name}_json |
72 | | - COMMENT "Converting ${model_name} to JSON." |
73 | | - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} |
74 | | - COMMAND ${DOGEN_CLI_EXECUTABLE} convert |
75 | | - --source ${model} --destination ${destination_name} |
76 | | - ${DOGEN_COMMON_OPTIONS}) |
77 | | - add_dependencies(convert_all_json convert_${model_name}_json) |
78 | | - |
79 | | - set(output_dir "${CMAKE_CURRENT_SOURCE_DIR}/org") |
80 | | - set(destination_name ${output_dir}/${model_name}) |
81 | | - string(REGEX REPLACE ".dia$" ".org" destination_name |
82 | | - ${destination_name}) |
83 | | - |
84 | | - add_custom_target(convert_${model_name}_org |
85 | | - COMMENT "Converting ${model_name} to org-mode." |
86 | | - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} |
87 | | - COMMAND ${DOGEN_CLI_EXECUTABLE} convert |
88 | | - --source ${model} --destination ${destination_name} |
89 | | - ${DOGEN_COMMON_OPTIONS}) |
90 | | - add_dependencies(convert_all_org convert_${model_name}_org) |
91 | | - endforeach() |
92 | | - |
93 | 22 | # input models |
94 | 23 | set(models cpp_ref_impl.directory_settings) |
95 | 24 | set(models ${models} cpp_ref_impl.northwind) |
@@ -122,6 +51,4 @@ if (DOGEN_CLI_EXECUTABLE) |
122 | 51 | # set(models ${models} cpp_ref_impl.out_of_sync) |
123 | 52 | endif() |
124 | 53 |
|
125 | | -add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/dia) |
126 | | -add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/json) |
127 | 54 | add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/org) |
0 commit comments