Skip to content

Commit 9a0e697

Browse files
committed
chore(ci): fix C API build system to manage profiles other than release
1 parent 674a697 commit 9a0e697

File tree

4 files changed

+27
-7
lines changed

4 files changed

+27
-7
lines changed

Makefile

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,16 +243,20 @@ test_boolean: install_rs_build_toolchain
243243
RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_BUILD_TOOLCHAIN) test --profile $(CARGO_PROFILE) \
244244
--features=$(TARGET_ARCH_FEATURE),boolean -p tfhe -- boolean::
245245

246-
.PHONY: test_c_api # Run the tests for the C API
247-
test_c_api: install_rs_check_toolchain
246+
.PHONY: test_c_api_rs # Run the rust tests for the C API
247+
test_c_api_rs: install_rs_check_toolchain
248248
RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_CHECK_TOOLCHAIN) test --profile $(CARGO_PROFILE) \
249249
--features=$(TARGET_ARCH_FEATURE),boolean-c-api,shortint-c-api,high-level-c-api \
250250
-p tfhe \
251251
c_api
252-
253-
"$(MAKE)" build_c_api
252+
253+
.PHONY: test_c_api_c # Run the C tests for the C API
254+
test_c_api_c: build_c_api
254255
./scripts/c_api_tests.sh
255256

257+
.PHONY: test_c_api # Run all the tests for the C API
258+
test_c_api: test_c_api_rs test_c_api_c
259+
256260
.PHONY: test_shortint_ci # Run the tests for shortint ci
257261
test_shortint_ci: install_rs_build_toolchain install_cargo_nextest
258262
BIG_TESTS_INSTANCE="$(BIG_TESTS_INSTANCE)" \

scripts/c_api_tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ mkdir -p "${TFHE_BUILD_DIR}"
4040

4141
cd "${TFHE_BUILD_DIR}"
4242

43-
cmake .. -DCMAKE_BUILD_TYPE=RELEASE
43+
cmake .. -DCMAKE_BUILD_TYPE=RELEASE -DCARGO_PROFILE="${CARGO_PROFILE}"
4444

4545
make -j
4646

tfhe/build.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,27 @@ fn gen_c_api() {
77
return;
88
}
99

10+
fn get_build_profile_name() -> String {
11+
// The profile name is always the 3rd last part of the path (with 1 based indexing).
12+
// e.g. /code/core/target/cli/build/my-build-info-9f91ba6f99d7a061/out
13+
let out_dir = std::env::var("OUT_DIR")
14+
.expect("OUT_DIR is not set, cannot determine build profile, aborting");
15+
out_dir
16+
.split(std::path::MAIN_SEPARATOR)
17+
.nth_back(3)
18+
.expect("Cannot determine build profile, aborting")
19+
.to_string()
20+
}
21+
1022
/// Find the location of the `target/` directory. Note that this may be
1123
/// overridden by `cmake`, so we also need to check the `CARGO_TARGET_DIR`
1224
/// variable.
1325
fn target_dir() -> PathBuf {
1426
if let Ok(target) = env::var("CARGO_TARGET_DIR") {
1527
PathBuf::from(target)
1628
} else {
17-
PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()).join("../target/release")
29+
PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap())
30+
.join(format!("../target/{}", get_build_profile_name()))
1831
}
1932
}
2033

tfhe/c_api_tests/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ project(tfhe-c-api-tests)
22

33
cmake_minimum_required(VERSION 3.16)
44

5-
set(TFHE_C_API_RELEASE "${CMAKE_CURRENT_SOURCE_DIR}/../../target/release/")
5+
if(NOT CARGO_PROFILE)
6+
set(CARGO_PROFILE release)
7+
endif()
8+
set(TFHE_C_API_RELEASE "${CMAKE_CURRENT_SOURCE_DIR}/../../target/${CARGO_PROFILE}")
69

710
include_directories(${TFHE_C_API_RELEASE})
811
add_library(Tfhe STATIC IMPORTED)

0 commit comments

Comments
 (0)