@@ -628,7 +628,7 @@ fn resolve_targets_with_legacy_path(
628
628
fn inferred_lib ( package_root : & Path ) -> Option < PathBuf > {
629
629
let lib = Path :: new ( "src" ) . join ( "lib.rs" ) ;
630
630
if package_root. join ( & lib) . exists ( ) {
631
- Some ( lib)
631
+ Some ( normalize_case ( package_root , & lib) )
632
632
} else {
633
633
None
634
634
}
@@ -638,7 +638,7 @@ fn inferred_bins(package_root: &Path, package_name: &str) -> Vec<(String, PathBu
638
638
let main = "src/main.rs" ;
639
639
let mut result = Vec :: new ( ) ;
640
640
if package_root. join ( main) . exists ( ) {
641
- let main = PathBuf :: from ( main) ;
641
+ let main = normalize_case ( package_root , Path :: new ( main) ) ;
642
642
result. push ( ( package_name. to_string ( ) , main) ) ;
643
643
}
644
644
let default_bin_dir_name = Path :: new ( "src" ) . join ( "bin" ) ;
@@ -1046,7 +1046,12 @@ pub fn resolve_build(build: Option<&StringOrBool>, package_root: &Path) -> Optio
1046
1046
// a build script.
1047
1047
let build_rs = package_root. join ( BUILD_RS ) ;
1048
1048
if build_rs. is_file ( ) {
1049
- Some ( StringOrBool :: String ( BUILD_RS . to_owned ( ) ) )
1049
+ let build_rs = normalize_case ( package_root, Path :: new ( BUILD_RS ) ) ;
1050
+ let build_rs = build_rs
1051
+ . into_os_string ( )
1052
+ . into_string ( )
1053
+ . unwrap_or_else ( |_| BUILD_RS . to_owned ( ) ) ;
1054
+ Some ( StringOrBool :: String ( build_rs) )
1050
1055
} else {
1051
1056
Some ( StringOrBool :: Bool ( false ) )
1052
1057
}
@@ -1057,6 +1062,18 @@ pub fn resolve_build(build: Option<&StringOrBool>, package_root: &Path) -> Optio
1057
1062
}
1058
1063
}
1059
1064
1065
+ fn normalize_case ( package_root : & Path , rel_path : & Path ) -> PathBuf {
1066
+ try_normalize_case ( package_root, rel_path) . unwrap_or_else ( || rel_path. to_owned ( ) )
1067
+ }
1068
+
1069
+ fn try_normalize_case ( package_root : & Path , rel_path : & Path ) -> Option < PathBuf > {
1070
+ let path = package_root. join ( rel_path) ;
1071
+ let path = path. canonicalize ( ) . ok ( ) ?;
1072
+ let package_root = package_root. canonicalize ( ) . ok ( ) ?;
1073
+ let rel_path = path. strip_prefix ( & package_root) . ok ( ) ?;
1074
+ Some ( rel_path. to_owned ( ) )
1075
+ }
1076
+
1060
1077
fn name_or_panic ( target : & TomlTarget ) -> & str {
1061
1078
target
1062
1079
. name
0 commit comments