@@ -8,17 +8,20 @@ fn get_current_working_dir() -> std::io::Result<PathBuf> {
8
8
env:: current_dir ( )
9
9
}
10
10
11
- fn get_lib_directory ( ) -> Result < String , VarError > {
12
- env:: var ( "CBMC_LIB_DIR" )
13
- }
14
-
15
11
// Passed by the top-level CMakeLists.txt to control which version of the
16
12
// static library of CBMC we're linking against. A user can also change the
17
13
// environment variable to link against different versions of CBMC.
18
14
fn get_cbmc_version ( ) -> Result < String , VarError > {
19
15
env:: var ( "CBMC_VERSION" )
20
16
}
21
17
18
+ // Passed by the top-level CMakeLists.txt to control where the static library we
19
+ // link against is located. A user can also change the location of the library
20
+ // on their system by supplying the environment variable themselves.
21
+ fn get_lib_directory ( ) -> Result < String , VarError > {
22
+ env:: var ( "CBMC_LIB_DIR" )
23
+ }
24
+
22
25
fn get_library_build_dir ( ) -> std:: io:: Result < PathBuf > {
23
26
let env_var_fetch_result = get_lib_directory ( ) ;
24
27
if let Ok ( build_dir) = env_var_fetch_result {
@@ -28,7 +31,7 @@ fn get_library_build_dir() -> std::io::Result<PathBuf> {
28
31
}
29
32
Err ( Error :: new (
30
33
ErrorKind :: Other ,
31
- "Please set the environment variable CBMC_LIB_DIR with the path that contains the libcprover.x.y.z.a library on your system " ,
34
+ "Environment variable ` CBMC_LIB_DIR' not set " ,
32
35
) )
33
36
}
34
37
@@ -48,7 +51,14 @@ fn main() {
48
51
49
52
let libraries_path = match get_library_build_dir ( ) {
50
53
Ok ( path) => path,
51
- Err ( err) => panic ! ( "Error: {}" , err) ,
54
+ Err ( err) => {
55
+ let error_message = & format ! (
56
+ "Error: {}.\n Advice: {}." ,
57
+ err,
58
+ "Please set the environment variable `CBMC_LIB_DIR' with the path that contains libcprover.x.y.z.a on your system"
59
+ ) ;
60
+ panic ! ( "{}" , error_message) ;
61
+ }
52
62
} ;
53
63
54
64
println ! (
@@ -58,7 +68,14 @@ fn main() {
58
68
59
69
let cprover_static_libname = match get_cbmc_version ( ) {
60
70
Ok ( version) => String :: from ( "cprover." ) + & version,
61
- Err ( err) => panic ! ( "Error: {}" , err) ,
71
+ Err ( _) => {
72
+ let error_message = & format ! (
73
+ "Error: {}.\n Advice: {}." ,
74
+ "Environment variable `CBMC_VERSION' not set" ,
75
+ "Please set the environment variable `CBMC_VERSION' with the version of CBMC you want to link against (e.g. 5.78.0)"
76
+ ) ;
77
+ panic ! ( "{}" , error_message) ;
78
+ }
62
79
} ;
63
80
64
81
println ! ( "cargo:rustc-link-lib=static={}" , cprover_static_libname) ;
0 commit comments