Repository: mesonbuild/meson

Issue:
DLL import lib placed in subdirectory despite --layout=flat 
When I build this [example project](https://github.com/melak47/repro) with

```
meson target --layout=flat
cd target
ninja -v
```

I get:
```
[1/5] c++ @meson-out/repro@exe/src_main.cpp.obj.rsp
[2/5] c++ @meson-out/foo@sha/src_foo.cpp.obj.rsp
[3/5] c++ @meson-out/libfoo.dll.rsp
[4/5] "c:\python36\python.exe" "C:\Python36\Scripts\meson.py" --internal symbolextractor meson-out/libfoo.dll meson-out/foo@sha/meson-out/libfoo.dll.symbols
[5/5] c++ @meson-out/repro.exe.rsp
FAILED: meson-out/repro.exe
c++ @meson-out/repro.exe.rsp
c++: error: meson-out\libfoo.dll.a: No such file or directory
ninja: build stopped: subcommand failed.
```

The `libfoo.dll` target is defined in the `vendor/foo` subdirectory.
`libfoo.dll` is correctly put into the `target/meson-out` directory, but `libfoo.dll.a` is put into `target/vendor/foo` (as with `--layout=mirror`):

```
.                                 
├── meson-private                 
│   ...
├── meson-out                     
│   ├── libfoo.dll                
│   ├── foo@sha                   
│   │   ├── src_foo.cpp.obj       
│   │   └── meson-out             
│   │       └── libfoo.dll.symbols
│   ├── repro@exe                 
│   │   └── src_main.cpp.obj      
│   └── repro.exe.rsp             
├── build.ninja                   
├── vendor                        
│   └── foo                       
│       └── libfoo.dll.a          
├── meson-logs                    
│   └── meson-log.txt             
└── compile_commands.json         
```


Discussion:

Resolving patch:
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -2263,7 +2263,7 @@ def get_target_type_link_args(self, target, linker):
                 commands += linker.get_gui_app_args()
             # If implib, and that's significant on this platform (i.e. Windows using either GCC or Visual Studio)
             if target.import_filename:
-                commands += linker.gen_import_library_args(os.path.join(target.subdir, target.import_filename))
+                commands += linker.gen_import_library_args(os.path.join(self.get_target_dir(target), target.import_filename))
         elif isinstance(target, build.SharedLibrary):
             if isinstance(target, build.SharedModule):
                 commands += linker.get_std_shared_module_link_args()
@@ -2280,7 +2280,7 @@ def get_target_type_link_args(self, target, linker):
                 commands += linker.gen_vs_module_defs_args(target.vs_module_defs.rel_to_builddir(self.build_to_src))
             # This is only visited when building for Windows using either GCC or Visual Studio
             if target.import_filename:
-                commands += linker.gen_import_library_args(os.path.join(target.subdir, target.import_filename))
+                commands += linker.gen_import_library_args(os.path.join(self.get_target_dir(target), target.import_filename))
         elif isinstance(target, build.StaticLibrary):
             commands += linker.get_std_link_args()
         else:


Test patch: