File tree 1 file changed +14
-8
lines changed
1 file changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -22,14 +22,20 @@ pub fn main_inner(profile: Profile) {
22
22
let tempdir = TempDir :: new ( ) . expect ( "temp dir" ) ;
23
23
let current_dir = current_dir ( ) . expect ( "current dir" ) ;
24
24
let current_dir = current_dir. to_str ( ) . expect ( "current dir" ) . to_string ( ) ;
25
- let toml = Toml :: parse ( include_str ! ( "../config.toml" ) ) . expect ( "Failed to parse `config.toml`" ) ;
26
- let gcc_path = if let Ok ( gcc_path) = toml. get_string ( "gcc-path" ) {
27
- PathBuf :: from ( gcc_path. to_string ( ) )
28
- } else {
29
- // then we try to retrieve it from the `target` folder.
30
- let commit = include_str ! ( "../libgccjit.version" ) . trim ( ) ;
31
- Path :: new ( "build/libgccjit" ) . join ( commit)
32
- } ;
25
+
26
+ let manifest_dir = Path :: new ( env ! ( "CARGO_MANIFEST_DIR" ) ) ;
27
+
28
+ let gcc_path = std:: fs:: read_to_string ( manifest_dir. join ( "config.toml" ) )
29
+ . ok ( )
30
+ . and_then ( |v| {
31
+ let toml = Toml :: parse ( & v) . expect ( "Failed to parse `config.toml`" ) ;
32
+ toml. get_string ( "gcc-path" ) . map ( PathBuf :: from) . ok ( )
33
+ } )
34
+ . unwrap_or_else ( || {
35
+ // then we try to retrieve it from the `target` folder.
36
+ let commit = include_str ! ( "../libgccjit.version" ) . trim ( ) ;
37
+ Path :: new ( "build/libgccjit" ) . join ( commit)
38
+ } ) ;
33
39
34
40
let gcc_path = Path :: new ( & gcc_path)
35
41
. canonicalize ( )
You can’t perform that action at this time.
0 commit comments