@@ -788,7 +788,20 @@ pub fn parse_arguments(
788
788
) ;
789
789
}
790
790
Some ( o) => {
791
- if o. extension ( ) . is_none ( ) && compilation {
791
+ if o. as_os_str ( )
792
+ . to_string_lossy ( )
793
+ . ends_with ( std:: path:: MAIN_SEPARATOR ) {
794
+ match Path :: new ( & input) . file_name ( ) {
795
+ Some ( i) => outputs. insert (
796
+ "obj" ,
797
+ ArtifactDescriptor {
798
+ path : o. join ( Path :: new ( i) ) . with_extension ( "obj" ) ,
799
+ optional : false ,
800
+ } ,
801
+ ) ,
802
+ None => cannot_cache ! ( "invalid input file" ) ,
803
+ } ;
804
+ } else if o. extension ( ) . is_none ( ) {
792
805
outputs. insert (
793
806
"obj" ,
794
807
ArtifactDescriptor {
@@ -1795,6 +1808,38 @@ mod test {
1795
1808
assert ! ( msvc_show_includes) ;
1796
1809
}
1797
1810
1811
+ #[ test]
1812
+ fn parse_argument_output_file_trailing_backslash ( ) {
1813
+ let args = ovec ! [ "-c" , "foo.c" , "/Fomyrelease\\ folder\\ " ] ;
1814
+ let ParsedArguments {
1815
+ input,
1816
+ language,
1817
+ outputs,
1818
+ preprocessor_args,
1819
+ msvc_show_includes,
1820
+ common_args,
1821
+ ..
1822
+ } = match parse_arguments ( args) {
1823
+ CompilerArguments :: Ok ( args) => args,
1824
+ o => panic ! ( "Got unexpected parse result: {:?}" , o) ,
1825
+ } ;
1826
+ assert_eq ! ( Some ( "foo.c" ) , input. to_str( ) ) ;
1827
+ assert_eq ! ( Language :: C , language) ;
1828
+ assert_map_contains ! (
1829
+ outputs,
1830
+ (
1831
+ "obj" ,
1832
+ ArtifactDescriptor {
1833
+ path: PathBuf :: from( "myrelease/folder/foo.obj" ) ,
1834
+ optional: false
1835
+ }
1836
+ )
1837
+ ) ;
1838
+ assert ! ( preprocessor_args. is_empty( ) ) ;
1839
+ assert ! ( common_args. is_empty( ) ) ;
1840
+ assert ! ( !msvc_show_includes) ;
1841
+ }
1842
+
1798
1843
#[ test]
1799
1844
fn test_parse_arguments_pdb ( ) {
1800
1845
let args = ovec ! [ "-c" , "foo.c" , "-Zi" , "-Fdfoo.pdb" , "-Fofoo.obj" ] ;
0 commit comments