Skip to content

Commit 93c9397

Browse files
committed
Run preprocess-rust-rules and preprocess-cpp-rules in parallel
1 parent 168a43e commit 93c9397

1 file changed

Lines changed: 27 additions & 7 deletions

File tree

CMakeLists.txt

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -135,22 +135,42 @@ add_custom_target("check"
135135
DEPENDS check-libcc2rs check-unit
136136
)
137137

138-
add_custom_target("check-rules"
139-
COMMAND find ${PROJECT_SOURCE_DIR}/rules -name "ir*.json" -delete
138+
file(GLOB rule_src_files ${PROJECT_SOURCE_DIR}/rules/*/src.cpp)
139+
set(cpp_rules_ir_outputs)
140+
foreach(_src IN LISTS rule_src_files)
141+
get_filename_component(_rule_dir ${_src} DIRECTORY)
142+
set(_out ${_rule_dir}/ir_src.json)
143+
add_custom_command(
144+
OUTPUT ${_out}
145+
COMMAND $<TARGET_FILE:cpp-rule-preprocessor> --file ${_src}
146+
DEPENDS ${_src} cpp-rule-preprocessor
147+
VERBATIM
148+
)
149+
list(APPEND cpp_rules_ir_outputs ${_out})
150+
endforeach()
151+
152+
add_custom_target("preprocess-cpp-rules" DEPENDS ${cpp_rules_ir_outputs})
153+
154+
add_custom_target("preprocess-rust-rules"
155+
COMMAND find ${PROJECT_SOURCE_DIR}/rules
156+
\( -name "ir_unsafe.json" -o -name "ir_refcount.json" \)
157+
-delete
140158
COMMAND cargo build
141159
COMMAND ${CMAKE_COMMAND} -E chdir ${PROJECT_SOURCE_DIR}/rule-preprocessor
142160
${CMAKE_COMMAND} -E env
143161
CARGO_TARGET_DIR=${PROJECT_SOURCE_DIR}/rule-preprocessor/target
144162
cargo run
145-
COMMAND $<TARGET_FILE:cpp-rule-preprocessor>
146-
--rules ${PROJECT_SOURCE_DIR}/rules
147-
COMMAND ${CMAKE_COMMAND} -E chdir ${PROJECT_SOURCE_DIR}
148-
git diff --exit-code -- rules/
149163
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/rules"
150-
DEPENDS install-rust-toolchain cpp-rule-preprocessor
164+
DEPENDS install-rust-toolchain
151165
USES_TERMINAL
152166
)
153167

168+
add_custom_target("check-rules"
169+
COMMAND ${CMAKE_COMMAND} -E chdir ${PROJECT_SOURCE_DIR}
170+
git diff --exit-code -- rules/
171+
DEPENDS preprocess-cpp-rules preprocess-rust-rules
172+
)
173+
154174
add_custom_target("check-all"
155175
DEPENDS check-libcc2rs check-rules check-unit check-benchmarks
156176
)

0 commit comments

Comments
 (0)