Skip to content

Commit a31d9ea

Browse files
committed
compile rule preprocessor in release mode
1 parent 14af89b commit a31d9ea

2 files changed

Lines changed: 13 additions & 10 deletions

File tree

CMakeLists.txt

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,8 @@ add_custom_command(
185185
OUTPUT ${rust_rules_ir_outputs}
186186
COMMAND cargo +${RUST_STABLE_VERSION} build --release --manifest-path "${PROJECT_SOURCE_DIR}/rules/Cargo.toml"
187187
COMMAND ${CMAKE_COMMAND} -E env
188-
CARGO_TARGET_DIR="${CMAKE_CURRENT_BINARY_DIR}/target_preprocessor"
189-
cargo +${RUST_NIGHTLY_VERSION} run --manifest-path "${PROJECT_SOURCE_DIR}/rule-preprocessor/Cargo.toml"
188+
CARGO_TARGET_DIR=${CMAKE_BINARY_DIR}/target_preprocessor
189+
cargo +${RUST_NIGHTLY_VERSION} run --release --manifest-path "${PROJECT_SOURCE_DIR}/rule-preprocessor/Cargo.toml"
190190
DEPENDS ${rust_rules_inputs} ${rule_preprocessor_sources} "${RUST_STAMP_FILE}"
191191
VERBATIM
192192
)
@@ -195,13 +195,11 @@ add_custom_target("preprocess-rust-rules" ALL
195195
DEPENDS ${rust_rules_ir_outputs})
196196

197197
add_custom_target("check-rules"
198-
COMMAND find ${PROJECT_SOURCE_DIR}/rules -name "ir_unsafe.json" -delete
199-
COMMAND find ${PROJECT_SOURCE_DIR}/rules -name "ir_refcount.json" -delete
200-
COMMAND find ${PROJECT_SOURCE_DIR}/rules -name "ir_src.json" -delete
201-
COMMAND ${CMAKE_COMMAND} --build --release ${CMAKE_BINARY_DIR} --target preprocess-cpp-rules
202-
COMMAND ${CMAKE_COMMAND} --build --release ${CMAKE_BINARY_DIR} --target preprocess-rust-rules
203-
COMMAND ${CMAKE_COMMAND} -E chdir ${PROJECT_SOURCE_DIR}
204-
git diff --exit-code -- rules/
198+
COMMAND find rules "\\(" -name ir_unsafe.json -o -name ir_refcount.json -o -name ir_src.json "\\)" -delete
199+
COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target preprocess-cpp-rules
200+
COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target preprocess-rust-rules
201+
COMMAND git diff --exit-code -- rules/
202+
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
205203
)
206204

207205
add_custom_target("check-all"

rule-preprocessor/src/semantic.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,12 @@ fn get_sysroot() -> PathBuf {
7070

7171
fn find_deps_dir() -> PathBuf {
7272
let target_dir = std::env::var("CARGO_TARGET_DIR").expect("CARGO_TARGET_DIR must be set");
73-
PathBuf::from(target_dir).join("debug").join("deps")
73+
let profile = if cfg!(debug_assertions) {
74+
"debug"
75+
} else {
76+
"release"
77+
};
78+
PathBuf::from(target_dir).join(profile).join("deps")
7479
}
7580

7681
fn find_rlib(deps_dir: &Path, crate_name: &str) -> Option<PathBuf> {

0 commit comments

Comments
 (0)