mirror of
https://github.com/zama-ai/tfhe-rs.git
synced 2026-01-10 07:08:03 -05:00
chore(ci): fix C API build system to manage profiles other than release
This commit is contained in:
12
Makefile
12
Makefile
@@ -243,16 +243,20 @@ test_boolean: install_rs_build_toolchain
|
||||
RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_BUILD_TOOLCHAIN) test --profile $(CARGO_PROFILE) \
|
||||
--features=$(TARGET_ARCH_FEATURE),boolean -p tfhe -- boolean::
|
||||
|
||||
.PHONY: test_c_api # Run the tests for the C API
|
||||
test_c_api: install_rs_check_toolchain
|
||||
.PHONY: test_c_api_rs # Run the rust tests for the C API
|
||||
test_c_api_rs: install_rs_check_toolchain
|
||||
RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_CHECK_TOOLCHAIN) test --profile $(CARGO_PROFILE) \
|
||||
--features=$(TARGET_ARCH_FEATURE),boolean-c-api,shortint-c-api,high-level-c-api \
|
||||
-p tfhe \
|
||||
c_api
|
||||
|
||||
"$(MAKE)" build_c_api
|
||||
|
||||
.PHONY: test_c_api_c # Run the C tests for the C API
|
||||
test_c_api_c: build_c_api
|
||||
./scripts/c_api_tests.sh
|
||||
|
||||
.PHONY: test_c_api # Run all the tests for the C API
|
||||
test_c_api: test_c_api_rs test_c_api_c
|
||||
|
||||
.PHONY: test_shortint_ci # Run the tests for shortint ci
|
||||
test_shortint_ci: install_rs_build_toolchain install_cargo_nextest
|
||||
BIG_TESTS_INSTANCE="$(BIG_TESTS_INSTANCE)" \
|
||||
|
||||
@@ -40,7 +40,7 @@ mkdir -p "${TFHE_BUILD_DIR}"
|
||||
|
||||
cd "${TFHE_BUILD_DIR}"
|
||||
|
||||
cmake .. -DCMAKE_BUILD_TYPE=RELEASE
|
||||
cmake .. -DCMAKE_BUILD_TYPE=RELEASE -DCARGO_PROFILE="${CARGO_PROFILE}"
|
||||
|
||||
make -j
|
||||
|
||||
|
||||
@@ -7,6 +7,18 @@ fn gen_c_api() {
|
||||
return;
|
||||
}
|
||||
|
||||
fn get_build_profile_name() -> String {
|
||||
// The profile name is always the 3rd last part of the path (with 1 based indexing).
|
||||
// e.g. /code/core/target/cli/build/my-build-info-9f91ba6f99d7a061/out
|
||||
let out_dir = std::env::var("OUT_DIR")
|
||||
.expect("OUT_DIR is not set, cannot determine build profile, aborting");
|
||||
out_dir
|
||||
.split(std::path::MAIN_SEPARATOR)
|
||||
.nth_back(3)
|
||||
.expect("Cannot determine build profile, aborting")
|
||||
.to_string()
|
||||
}
|
||||
|
||||
/// Find the location of the `target/` directory. Note that this may be
|
||||
/// overridden by `cmake`, so we also need to check the `CARGO_TARGET_DIR`
|
||||
/// variable.
|
||||
@@ -14,7 +26,8 @@ fn gen_c_api() {
|
||||
if let Ok(target) = env::var("CARGO_TARGET_DIR") {
|
||||
PathBuf::from(target)
|
||||
} else {
|
||||
PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()).join("../target/release")
|
||||
PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap())
|
||||
.join(format!("../target/{}", get_build_profile_name()))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,10 @@ project(tfhe-c-api-tests)
|
||||
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
set(TFHE_C_API_RELEASE "${CMAKE_CURRENT_SOURCE_DIR}/../../target/release/")
|
||||
if(NOT CARGO_PROFILE)
|
||||
set(CARGO_PROFILE release)
|
||||
endif()
|
||||
set(TFHE_C_API_RELEASE "${CMAKE_CURRENT_SOURCE_DIR}/../../target/${CARGO_PROFILE}")
|
||||
|
||||
include_directories(${TFHE_C_API_RELEASE})
|
||||
add_library(Tfhe STATIC IMPORTED)
|
||||
|
||||
Reference in New Issue
Block a user