Repository: mesonbuild/meson

Issue:
vs backend: generators + find_program() in subdirectory fails starting in 1.0.1
Hi,

https://cirrus-ci.com/task/4910545246093312?logs=configure#L7
```
[20:06:51.875] Traceback (most recent call last):
[20:06:51.875]   File "C:\python\lib\site-packages\mesonbuild\mesonmain.py", line 194, in run
[20:06:51.875]     return options.run_func(options)
[20:06:51.875]   File "C:\python\lib\site-packages\mesonbuild\msetup.py", line 310, in run
[20:06:51.875]     app.generate()
[20:06:51.875]   File "C:\python\lib\site-packages\mesonbuild\msetup.py", line 187, in generate
[20:06:51.875]     self._generate(env)
[20:06:51.875]   File "C:\python\lib\site-packages\mesonbuild\msetup.py", line 251, in _generate
[20:06:51.875]     intr.backend.generate()
[20:06:51.875]   File "C:\python\lib\site-packages\mesonbuild\backend\vs2010backend.py", line 231, in generate
[20:06:51.875]     projlist = self.generate_projects()
[20:06:51.875]   File "C:\python\lib\site-packages\mesonbuild\backend\vs2010backend.py", line 483, in generate_projects
[20:06:51.875]     self.gen_vcxproj(target, str(projfile_path), proj_uuid)
[20:06:51.875]   File "C:\python\lib\site-packages\mesonbuild\backend\vs2010backend.py", line 1003, in gen_vcxproj
[20:06:51.875]     generated_files, custom_target_output_files, generated_files_include_dirs = self.generate_custom_generator_commands(
[20:06:51.875]   File "C:\python\lib\site-packages\mesonbuild\backend\vs2010backend.py", line 166, in generate_custom_generator_commands
[20:06:51.875]     cmd, _ = self.as_meson_exe_cmdline(
[20:06:51.875]   File "C:\python\lib\site-packages\mesonbuild\backend\backends.py", line 654, in as_meson_exe_cmdline
[20:06:51.875]     with open(exe_data, 'wb') as f:
[20:06:51.875] FileNotFoundError: [Errno 2] No such file or directory: 'C:\\cirrus\\build\\meson-private\\meson_exe_src/tools/rcgen_48e43c9e04f83e196fb11101079ca74c762c2654.dat'
```

The src/tools/rcgen is from `rcgen = find_program('src/tools/rcgen', native: true)`.

I reported this a while back on IRC, and  @eli-schwartz pinpointed it to 6aeec808367f05463394e30a8d40834e97c7afc0 and wrote a quick fix that I verified as fixing the issue:
https://github.com/mesonbuild/meson/commit/0d064ca9bd4ed7d6bac601cef3f39c380b0318b7
successful build with that: https://cirrus-ci.com/task/4681717106081792

I am creating this to issue just to track that this still needs to be fixed.

Regards,

Andres




Discussion:

Resolving patch:
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py
--- a/mesonbuild/backend/backends.py
+++ b/mesonbuild/backend/backends.py
@@ -633,7 +633,7 @@ def as_meson_exe_cmdline(self, exe: T.Union[str, mesonlib.File, build.BuildTarge
 
         if isinstance(exe, (programs.ExternalProgram,
                             build.BuildTarget, build.CustomTarget)):
-            basename = exe.name
+            basename = os.path.basename(exe.name)
         elif isinstance(exe, mesonlib.File):
             basename = os.path.basename(exe.fname)
         else:


Test patch:
diff --git a/test cases/common/195 generator in subdir/com/mesonbuild/meson.build b/test cases/common/195 generator in subdir/com/mesonbuild/meson.build
--- a/test cases/common/195 generator in subdir/com/mesonbuild/meson.build	
+++ b/test cases/common/195 generator in subdir/com/mesonbuild/meson.build	
@@ -1,4 +1,4 @@
-gprog = find_program('genprog.py')
+gprog = find_program('tooldir/genprog.py')
 
 gen = generator(gprog, \
   output    : ['@BASENAME@.c', '@BASENAME@.h'],
diff --git a/test cases/common/195 generator in subdir/com/mesonbuild/genprog.py b/test cases/common/195 generator in subdir/com/mesonbuild/tooldir/genprog.py
similarity index 100%
rename from test cases/common/195 generator in subdir/com/mesonbuild/genprog.py
rename to test cases/common/195 generator in subdir/com/mesonbuild/tooldir/genprog.py