-
Notifications
You must be signed in to change notification settings - Fork 4
Parse src.cpp rules at build time #61
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
Changes from all commits
c4aaf1e
0ace318
27fa149
e0fd798
9e6fca1
fc7121f
46178e3
a0a8802
07c6e58
38399ac
76dfedd
93f0a3c
18a318d
c7f3e96
237edde
bb37798
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -135,18 +135,57 @@ add_custom_target("check" | |
| DEPENDS check-libcc2rs check-unit | ||
| ) | ||
|
|
||
| file(GLOB rule_src_files ${PROJECT_SOURCE_DIR}/rules/*/src.cpp) | ||
| set(cpp_rules_ir_outputs) | ||
| set(rust_rules_ir_outputs) | ||
| set(rust_rules_inputs) | ||
| foreach(_src IN LISTS rule_src_files) | ||
| get_filename_component(_rule_dir ${_src} DIRECTORY) | ||
| set(_out ${_rule_dir}/ir_src.json) | ||
| add_custom_command( | ||
| OUTPUT ${_out} | ||
| COMMAND $<TARGET_FILE:cpp-rule-preprocessor> --file ${_src} | ||
| DEPENDS ${_src} cpp-rule-preprocessor | ||
| VERBATIM | ||
| ) | ||
| list(APPEND cpp_rules_ir_outputs ${_out}) | ||
| if(EXISTS ${_rule_dir}/tgt_unsafe.rs) | ||
| list(APPEND rust_rules_ir_outputs ${_rule_dir}/ir_unsafe.json) | ||
| list(APPEND rust_rules_inputs ${_rule_dir}/tgt_unsafe.rs) | ||
| endif() | ||
| if(EXISTS ${_rule_dir}/tgt_refcount.rs) | ||
| list(APPEND rust_rules_ir_outputs ${_rule_dir}/ir_refcount.json) | ||
| list(APPEND rust_rules_inputs ${_rule_dir}/tgt_refcount.rs) | ||
| endif() | ||
| endforeach() | ||
|
|
||
| add_custom_target("preprocess-cpp-rules" ALL DEPENDS ${cpp_rules_ir_outputs}) | ||
|
|
||
| file(GLOB_RECURSE rule_preprocessor_sources | ||
| ${PROJECT_SOURCE_DIR}/rule-preprocessor/src/*.rs) | ||
|
|
||
| add_custom_command( | ||
| OUTPUT ${rust_rules_ir_outputs} | ||
| COMMAND cargo build | ||
| COMMAND ${CMAKE_COMMAND} -E chdir ${PROJECT_SOURCE_DIR}/rule-preprocessor | ||
| ${CMAKE_COMMAND} -E env | ||
| CARGO_TARGET_DIR=${PROJECT_SOURCE_DIR}/rule-preprocessor/target | ||
| cargo run | ||
| WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/rules" | ||
| DEPENDS ${rust_rules_inputs} ${rule_preprocessor_sources} | ||
| VERBATIM | ||
| ) | ||
|
|
||
| add_custom_target("preprocess-rust-rules" ALL | ||
| DEPENDS ${rust_rules_ir_outputs} install-rust-toolchain) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. doesn't seem like it needs the rust toolchain here. |
||
|
|
||
| add_custom_target("check-rules" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. move the delete here and call preprocess & then diff.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. check-rules now contains deltee + call preprocess rust/cpp + diff |
||
| COMMAND find ${PROJECT_SOURCE_DIR}/rules -name "ir*.json" -delete | ||
| COMMAND cargo build | ||
| COMMAND ${CMAKE_COMMAND} -E chdir ${PROJECT_SOURCE_DIR}/rule-preprocessor | ||
| ${CMAKE_COMMAND} -E env | ||
| CARGO_TARGET_DIR=${PROJECT_SOURCE_DIR}/rule-preprocessor/target | ||
| cargo run | ||
| COMMAND find ${PROJECT_SOURCE_DIR}/rules -name "ir_unsafe.json" -delete | ||
| COMMAND find ${PROJECT_SOURCE_DIR}/rules -name "ir_refcount.json" -delete | ||
| COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target preprocess-cpp-rules | ||
| COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target preprocess-rust-rules | ||
| COMMAND ${CMAKE_COMMAND} -E chdir ${PROJECT_SOURCE_DIR} | ||
| git diff --exit-code -- rules/ | ||
| WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/rules" | ||
| DEPENDS install-rust-toolchain | ||
| USES_TERMINAL | ||
| ) | ||
|
|
||
| add_custom_target("check-all" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this change is weird.
ninjashould regen the files.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I will make the change to regen the files on
ninjaHowever, I think it's better to run
check-rulesbefore unit tests because it's cheaper and catches the rules errors earlyThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that we run preprocess-{rust,cpp}-rules in ALL, check-rules does not need to delete then re-run preprocess-{rust,cpp}-rules, it can only do git diff