This repository was archived by the owner on Dec 29, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +22
-10
lines changed Expand file tree Collapse file tree 1 file changed +22
-10
lines changed Original file line number Diff line number Diff line change @@ -690,16 +690,28 @@ pub fn make_cargo_config(
690
690
. entry ( "build" . to_owned ( ) )
691
691
. or_insert_with ( || ConfigValue :: Table ( HashMap :: new ( ) , config_path. clone ( ) ) ) ;
692
692
693
- let target_dir = target_dir
694
- . map ( |d| d. to_str ( ) . unwrap ( ) . to_owned ( ) )
695
- . unwrap_or_else ( || {
696
- build_dir
697
- . join ( "target" )
698
- . join ( "rls" )
699
- . to_str ( )
700
- . unwrap ( )
701
- . to_owned ( )
702
- } ) ;
693
+ let target_dir = target_dir
694
+ . map ( |d| d. to_str ( ) . unwrap ( ) . to_owned ( ) )
695
+ . unwrap_or_else ( || {
696
+ // Try to use .cargo/config build.target-dir + "/rls"
697
+ let cargo_target = build_value
698
+ . table ( "build" )
699
+ . ok ( )
700
+ . and_then ( |( build, _) | build. get ( "target-dir" ) )
701
+ . and_then ( |td| td. string ( "target-dir" ) . ok ( ) )
702
+ . map ( |( target, _) | {
703
+ let t_path = Path :: new ( target) ;
704
+ if t_path. is_absolute ( ) {
705
+ t_path. into ( )
706
+ } else {
707
+ build_dir. join ( t_path)
708
+ }
709
+ } )
710
+ . unwrap_or_else ( || build_dir. join ( "target" ) ) ;
711
+
712
+ cargo_target. join ( "rls" ) . to_str ( ) . unwrap ( ) . to_owned ( )
713
+ } ) ;
714
+
703
715
let td_value = ConfigValue :: String ( target_dir, config_path) ;
704
716
if let ConfigValue :: Table ( ref mut build_table, _) = * build_value {
705
717
build_table. insert ( "target-dir" . to_owned ( ) , td_value) ;
You can’t perform that action at this time.
0 commit comments