Repository: mesonbuild/meson

Issue:
AttributeError: 'ValaCompiler' object has no attribute 'get_program_dirs' when cross compiling
I'm trying to cross compile my Vala program from a Fedora container to Windows. Here is the end of the log:

```
Native C compiler: cc (gcc 9.1.1 "cc (GCC) 9.1.1 20190503 (Red Hat 9.1.1-1)")
Cross C compiler: /usr/bin/x86_64-w64-mingw32-gcc (gcc 8.3.0)
Native Vala compiler: valac (valac 0.44.3)
Cross Vala compiler: valac (valac 0.44.3)
Host machine cpu family: x86
Host machine cpu: i686
Target machine cpu family: x86
Target machine cpu: i686
Build machine cpu family: x86_64
Build machine cpu: x86_64
Found pkg-config: /usr/bin/pkg-config (1.6.1)
Found pkg-config: /usr/bin/x86_64-w64-mingw32-pkg-config (0.28)
Cross dependency glib-2.0 found: YES 2.58.3
Cross dependency gio-2.0 found: YES 2.58.3
Cross dependency gobject-2.0 found: YES 2.58.3
Cross dependency gee-0.8 found: YES 0.20.1
Cross dependency json-glib-1.0 found: YES 1.4.2
Cross dependency cairo found: YES 1.14.10
Cross dependency gtk+-3.0 found: YES 3.22.30
Cross dependency gdk-pixbuf-2.0 found: YES 2.36.11
Cross dependency gstreamer-1.0 found: YES 1.14.1
Cross dependency gstreamer-app-1.0 found: YES 1.14.1
Library m found: YES
Build targets in project: 8
Found ninja-1.9.0 at /usr/bin/ninja
Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/mesonbuild/mesonmain.py", line 122, in run
    return options.run_func(options)
  File "/usr/lib/python3.7/site-packages/mesonbuild/msetup.py", line 246, in run
    app.generate()
  File "/usr/lib/python3.7/site-packages/mesonbuild/msetup.py", line 163, in generate
    self._generate(env)
  File "/usr/lib/python3.7/site-packages/mesonbuild/msetup.py", line 216, in _generate
    intr.backend.generate(intr)
  File "/usr/lib/python3.7/site-packages/mesonbuild/backend/ninjabackend.py", line 228, in generate
    self.generate_tests(outfile)
  File "/usr/lib/python3.7/site-packages/mesonbuild/backend/ninjabackend.py", line 738, in generate_tests
    self.serialize_tests()
  File "/usr/lib/python3.7/site-packages/mesonbuild/backend/backends.py", line 376, in serialize_tests
    self.write_test_file(datafile)
  File "/usr/lib/python3.7/site-packages/mesonbuild/backend/backends.py", line 716, in write_test_file
    self.write_test_serialisation(self.build.get_tests(), datafile)
  File "/usr/lib/python3.7/site-packages/mesonbuild/backend/backends.py", line 768, in write_test_serialisation
    pickle.dump(self.create_test_serialisation(tests), datafile)
  File "/usr/lib/python3.7/site-packages/mesonbuild/backend/backends.py", line 743, in create_test_serialisation
    extra_paths = self.determine_windows_extra_paths(exe, extra_bdeps, is_cross)
  File "/usr/lib/python3.7/site-packages/mesonbuild/backend/backends.py", line 709, in determine_windows_extra_paths
    result.update(self.get_mingw_extra_paths(target))
  File "/usr/lib/python3.7/site-packages/mesonbuild/backend/backends.py", line 684, in get_mingw_extra_paths
    paths.update(cc.get_program_dirs(self.environment))
AttributeError: 'ValaCompiler' object has no attribute 'get_program_dirs'
```


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
@@ -1653,8 +1653,7 @@ def generate_compile_rule_for(self, langname, compiler):
                 self.generate_cs_compile_rule(compiler)
             return
         if langname == 'vala':
-            if self.environment.machines.matches_build_machine(compiler.for_machine):
-                self.generate_vala_compile_rules(compiler)
+            self.generate_vala_compile_rules(compiler)
             return
         if langname == 'rust':
             self.generate_rust_compile_rules(compiler)
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py
--- a/mesonbuild/compilers/compilers.py
+++ b/mesonbuild/compilers/compilers.py
@@ -1117,6 +1117,9 @@ def find_library(self, *args, **kwargs):
     def get_library_dirs(self, *args, **kwargs):
         return ()
 
+    def get_program_dirs(self, *args, **kwargs):
+        return ()
+
     def has_multi_arguments(self, args, env) -> Tuple[bool, bool]:
         raise EnvironmentException(
             'Language {} does not support has_multi_arguments.'.format(


Test patch: