@@ -732,7 +732,20 @@ pub fn parse_arguments(
732
732
) ;
733
733
}
734
734
Some ( o) => {
735
- if o. extension ( ) . is_none ( ) && compilation {
735
+ if o. as_os_str ( )
736
+ . to_string_lossy ( )
737
+ . ends_with ( std:: path:: MAIN_SEPARATOR ) {
738
+ match Path :: new ( & input) . file_name ( ) {
739
+ Some ( i) => outputs. insert (
740
+ "obj" ,
741
+ ArtifactDescriptor {
742
+ path : o. join ( Path :: new ( i) ) . with_extension ( "obj" ) ,
743
+ optional : false ,
744
+ } ,
745
+ ) ,
746
+ None => cannot_cache ! ( "invalid input file" ) ,
747
+ } ;
748
+ } else if o. extension ( ) . is_none ( ) {
736
749
outputs. insert (
737
750
"obj" ,
738
751
ArtifactDescriptor {
@@ -1833,6 +1846,38 @@ mod test {
1833
1846
assert ! ( msvc_show_includes) ;
1834
1847
}
1835
1848
1849
+ #[ test]
1850
+ fn parse_argument_output_file_trailing_backslash ( ) {
1851
+ let args = ovec ! [ "-c" , "foo.c" , "/Fomyrelease\\ folder\\ " ] ;
1852
+ let ParsedArguments {
1853
+ input,
1854
+ language,
1855
+ outputs,
1856
+ preprocessor_args,
1857
+ msvc_show_includes,
1858
+ common_args,
1859
+ ..
1860
+ } = match parse_arguments ( args) {
1861
+ CompilerArguments :: Ok ( args) => args,
1862
+ o => panic ! ( "Got unexpected parse result: {:?}" , o) ,
1863
+ } ;
1864
+ assert_eq ! ( Some ( "foo.c" ) , input. to_str( ) ) ;
1865
+ assert_eq ! ( Language :: C , language) ;
1866
+ assert_map_contains ! (
1867
+ outputs,
1868
+ (
1869
+ "obj" ,
1870
+ ArtifactDescriptor {
1871
+ path: PathBuf :: from( "myrelease/folder/foo.obj" ) ,
1872
+ optional: false
1873
+ }
1874
+ )
1875
+ ) ;
1876
+ assert ! ( preprocessor_args. is_empty( ) ) ;
1877
+ assert ! ( common_args. is_empty( ) ) ;
1878
+ assert ! ( !msvc_show_includes) ;
1879
+ }
1880
+
1836
1881
#[ test]
1837
1882
fn test_parse_arguments_pdb ( ) {
1838
1883
let args = ovec ! [ "-c" , "foo.c" , "-Zi" , "-Fdfoo.pdb" , "-Fofoo.obj" ] ;
0 commit comments