Skip to content

Commit 3852ddc

Browse files
committed
Simplify rust API project build script.
We no longer need to know where the individual solver libraries are located, as they have been built into the libcprover.a static library we are now building against.
1 parent 5e52670 commit 3852ddc

File tree

2 files changed

+1
-63
lines changed

2 files changed

+1
-63
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ else()
274274

275275
corrosion_import_crate(MANIFEST_PATH src/libcprover-rust/Cargo.toml)
276276
list(JOIN sat_impl " " sat_impl_str)
277-
corrosion_set_env_vars(cprover-api-rust CBMC_BUILD_DIR=${CMAKE_BINARY_DIR} "SAT_IMPL=${sat_impl_str}")
277+
corrosion_set_env_vars(cprover-api-rust CBMC_BUILD_DIR=${CMAKE_BINARY_DIR})
278278
corrosion_link_libraries(cprover-api-rust cprover-api-cpp)
279279
install(TARGETS cprover-api-rust RUNTIME DESTINATION lib)
280280
# NOTE: We want to rename to a name consistent with the name of the

src/libcprover-rust/build.rs

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -26,47 +26,6 @@ fn get_library_build_dir() -> std::io::Result<PathBuf> {
2626
))
2727
}
2828

29-
fn get_cadical_build_dir() -> std::io::Result<PathBuf> {
30-
let env_var_fetch_result = get_build_directory();
31-
if let Ok(build_dir) = env_var_fetch_result {
32-
let mut path = PathBuf::new();
33-
path.push(build_dir);
34-
path.push("cadical-src/build/");
35-
return Ok(path);
36-
}
37-
Err(Error::new(
38-
ErrorKind::Other,
39-
"failed to get build output directory",
40-
))
41-
}
42-
43-
fn get_sat_libraries() -> std::io::Result<Vec<&'static str>> {
44-
let env_var_name = "SAT_IMPL";
45-
let env_var_fetch_result = env::var(env_var_name);
46-
if let Ok(sat_impls) = env_var_fetch_result {
47-
let mut solver_libs = Vec::new();
48-
for sat_impl in sat_impls.split(" ") {
49-
let solver_lib = match sat_impl {
50-
"minisat2" => "minisat2-condensed",
51-
"glucose" => "glucose-condensed",
52-
"cadical" => "cadical",
53-
_ => {
54-
return Err(Error::new(
55-
ErrorKind::Other,
56-
"no identifiable solver detected",
57-
))
58-
}
59-
};
60-
solver_libs.push(solver_lib);
61-
}
62-
return Ok(solver_libs);
63-
}
64-
Err(Error::new(
65-
ErrorKind::Other,
66-
"SAT_IMPL environment variable not set",
67-
))
68-
}
69-
7029
fn main() {
7130
let cbmc_source_path = Path::new("..");
7231
let cpp_api_path = Path::new("../libcprover-cpp/");
@@ -86,27 +45,6 @@ fn main() {
8645
Err(err) => panic!("Error: {}", err),
8746
};
8847

89-
let solver_libs = match get_sat_libraries() {
90-
Ok(solvers) => solvers,
91-
Err(err) => panic!("Error: {}", err),
92-
};
93-
94-
for solver_lib in solver_libs.iter() {
95-
// Cadical is being built in its own directory, with the resultant artefacts being
96-
// present only there. Hence, we need to instruct cargo to look for them in cadical's
97-
// build directory, otherwise we're going to get build errors.
98-
if *solver_lib == "cadical" {
99-
let cadical_build_dir = match get_cadical_build_dir() {
100-
Ok(cadical_directory) => cadical_directory,
101-
Err(err) => panic!("Error: {}", err),
102-
};
103-
println!(
104-
"cargo:rustc-link-search=native={}",
105-
cadical_build_dir.display()
106-
);
107-
}
108-
}
109-
11048
println!(
11149
"cargo:rustc-link-search=native={}",
11250
libraries_path.display()

0 commit comments

Comments
 (0)