@@ -10,8 +10,12 @@ fn main() {
1010 let profile = env:: var ( "PROFILE" ) . unwrap_or_else ( |_| "debug" . to_string ( ) ) ;
1111
1212 // Get target and host triples
13- let target_triple = env:: var ( "TARGET" ) . ok ( ) ;
14- let host_triple = env:: var ( "HOST" ) . ok ( ) ;
13+ let target_triple = env:: var ( "TARGET" ) ;
14+ let host_triple = env:: var ( "HOST" ) ;
15+
16+ // Debug: Print the values we're working with
17+ println ! ( "cargo:warning=Target triple: {:?}" , target_triple) ;
18+ println ! ( "cargo:warning=Host triple: {:?}" , host_triple) ;
1519
1620 // Construct the path to the coreutils binary
1721 let binary_name = if cfg ! ( windows) {
@@ -20,18 +24,23 @@ fn main() {
2024 "coreutils"
2125 } ;
2226
23- // Build the binary path based on whether we're cross-compiling
24- let binary_path = if target_triple != host_triple {
25- // For cross compilation: target/<target-triple>/debug/coreutils
26- target_dir
27- . join ( target_triple. unwrap ( ) )
28- . join ( & profile)
29- . join ( binary_name)
27+ // Try both possible paths
28+ let direct_path = target_dir. join ( & profile) . join ( binary_name) ;
29+ let target_path = if let Ok ( target) = target_triple {
30+ target_dir. join ( & target) . join ( & profile) . join ( binary_name)
3031 } else {
31- // For native compilation: target/debug/coreutils
32- target_dir. join ( & profile) . join ( binary_name)
32+ direct_path. clone ( )
3333 } ;
3434
35+ // Check which path exists
36+ let binary_path = if target_path. exists ( ) {
37+ target_path
38+ } else {
39+ direct_path
40+ } ;
41+
42+ println ! ( "cargo:warning=Checking path: {}" , binary_path) ;
43+
3544 // Output the binary path for use in the tests
3645 println ! ( "cargo:rustc-env=CARGO_BIN_EXE_coreutils={}" , binary_path) ;
3746}
0 commit comments