aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/modules/windows.py
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2018-06-29 19:33:17 +0530
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2018-07-01 13:59:48 +0000
commitec29f19c1274d72e3a2639e47caf4a7f17ffa436 (patch)
tree70ffad6c031159508e92b05ff69acbc052262480 /mesonbuild/modules/windows.py
parentae8d044cb6dca20c1d6504a27660bcbed16db438 (diff)
downloadmeson-ec29f19c1274d72e3a2639e47caf4a7f17ffa436.zip
meson-ec29f19c1274d72e3a2639e47caf4a7f17ffa436.tar.gz
meson-ec29f19c1274d72e3a2639e47caf4a7f17ffa436.tar.bz2
Add a helper for fetching of binaries from cross files
A number of cases have to be taken care of while doing this, so refactor it into a helper on ExternalProgram and use it everywhere. 1. Command is a list of len > 1, use it as-is 2. Command is a list of len == 1 (or a string), use as a string 3. If command is an absolute path, use it as-is 4. If command is not an absolute path, search for it
Diffstat (limited to 'mesonbuild/modules/windows.py')
-rw-r--r--mesonbuild/modules/windows.py18
1 files changed, 10 insertions, 8 deletions
diff --git a/mesonbuild/modules/windows.py b/mesonbuild/modules/windows.py
index 44a9ebb..19f3e2b 100644
--- a/mesonbuild/modules/windows.py
+++ b/mesonbuild/modules/windows.py
@@ -15,13 +15,14 @@
import os
from .. import mlog
-from .. import mesonlib, dependencies, build
+from .. import mesonlib, build
from ..mesonlib import MesonException, extract_as_list
from . import get_include_args
from . import ModuleReturnValue
from . import ExtensionModule
from ..interpreter import CustomTargetHolder
from ..interpreterbase import permittedKwargs, FeatureNewKwargs
+from ..dependencies import ExternalProgram
class WindowsModule(ExtensionModule):
@@ -49,7 +50,7 @@ class WindowsModule(ExtensionModule):
extra_args += get_include_args(inc_dirs)
if comp.id == 'msvc':
- rescomp = dependencies.ExternalProgram('rc', silent=True)
+ rescomp = ExternalProgram('rc', silent=True)
res_args = extra_args + ['/nologo', '/fo@OUTPUT@', '@INPUT@']
suffix = 'res'
else:
@@ -58,22 +59,23 @@ class WindowsModule(ExtensionModule):
for arg in extra_args:
if ' ' in arg:
mlog.warning(m.format(arg))
- rescomp_name = None
+ rescomp = None
# FIXME: Does not handle `native: true` executables, see
# https://github.com/mesonbuild/meson/issues/1531
if state.environment.is_cross_build():
# If cross compiling see if windres has been specified in the
# cross file before trying to find it another way.
- rescomp_name = state.environment.cross_info.config['binaries'].get('windres')
- if rescomp_name is None:
+ cross_info = state.environment.cross_info
+ rescomp = ExternalProgram.from_cross_info(cross_info, 'windres')
+ if not rescomp or not rescomp.found():
# Pick-up env var WINDRES if set. This is often used for
# specifying an arch-specific windres.
- rescomp_name = os.environ.get('WINDRES', 'windres')
- rescomp = dependencies.ExternalProgram(rescomp_name, silent=True)
+ rescomp = ExternalProgram(os.environ.get('WINDRES', 'windres'), silent=True)
res_args = extra_args + ['@INPUT@', '@OUTPUT@']
suffix = 'o'
if not rescomp.found():
- raise MesonException('Could not find Windows resource compiler "%s".' % rescomp_name)
+ raise MesonException('Could not find Windows resource compiler {!r}'
+ ''.format(rescomp.get_path()))
res_targets = []