aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2018-05-27 01:03:35 +0530
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2018-06-05 10:50:22 +0000
commiteb383ef4a2daad1766a8ace3164e6b083c388130 (patch)
treea6cab6c9a1069657f140af0a6908b3fcd3a2dfaf
parent21dc45dbbb567068ae2dafc9e34fba24e04e0d93 (diff)
downloadmeson-eb383ef4a2daad1766a8ace3164e6b083c388130.zip
meson-eb383ef4a2daad1766a8ace3164e6b083c388130.tar.gz
meson-eb383ef4a2daad1766a8ace3164e6b083c388130.tar.bz2
Automatically add cross-mingw root and sysroot bindir to WINEPATH
This ensures that all the system DLLs required by executables such as libstdc++-6.dll can be found out of the box and tests can run
-rw-r--r--mesonbuild/backend/backends.py33
-rw-r--r--mesonbuild/backend/ninjabackend.py3
-rw-r--r--mesonbuild/environment.py6
3 files changed, 31 insertions, 11 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py
index e56d18d..d02f2dd 100644
--- a/mesonbuild/backend/backends.py
+++ b/mesonbuild/backend/backends.py
@@ -567,28 +567,41 @@ class Backend:
args.append(d_arg)
return args
- def determine_windows_extra_paths(self, target, extra_bdeps):
+ def get_mingw_extra_paths(self):
+ paths = []
+ # The cross bindir
+ root = self.environment.cross_info.get_root()
+ if root:
+ paths.append(os.path.join(root, 'bin'))
+ # The toolchain bindir
+ sys_root = self.environment.cross_info.get_sys_root()
+ if sys_root:
+ paths.append(os.path.join(sys_root, 'bin'))
+ return paths
+
+ def determine_windows_extra_paths(self, target, extra_bdeps, is_cross=False):
'''On Windows there is no such thing as an rpath.
We must determine all locations of DLLs that this exe
links to and return them so they can be used in unit
tests.'''
- result = []
- prospectives = []
+ result = set()
+ prospectives = set()
if isinstance(target, build.BuildTarget):
- prospectives = target.get_transitive_link_deps()
+ prospectives.update(target.get_transitive_link_deps())
# External deps
for deppath in self.rpaths_for_bundled_shared_libraries(target):
- result.append(os.path.normpath(os.path.join(self.environment.get_build_dir(), deppath)))
+ result.add(os.path.normpath(os.path.join(self.environment.get_build_dir(), deppath)))
for bdep in extra_bdeps:
- prospectives += bdep.get_transitive_link_deps()
+ prospectives.update(bdep.get_transitive_link_deps())
# Internal deps
for ld in prospectives:
if ld == '' or ld == '.':
continue
dirseg = os.path.join(self.environment.get_build_dir(), self.get_target_dir(ld))
- if dirseg not in result:
- result.append(dirseg)
- return result
+ result.add(dirseg)
+ if is_cross:
+ result.update(self.get_mingw_extra_paths())
+ return list(result)
def write_benchmark_file(self, datafile):
self.write_test_serialisation(self.build.get_benchmarks(), datafile)
@@ -622,7 +635,7 @@ class Backend:
extra_bdeps = []
if isinstance(exe, build.CustomTarget):
extra_bdeps = exe.get_transitive_build_target_deps()
- extra_paths = self.determine_windows_extra_paths(exe, extra_bdeps)
+ extra_paths = self.determine_windows_extra_paths(exe, extra_bdeps, is_cross)
else:
extra_paths = []
cmd_args = []
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index 6082c85..423c2ff 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -536,7 +536,8 @@ int dummy;
if mesonlib.for_windows(is_cross, self.environment) or \
mesonlib.for_cygwin(is_cross, self.environment):
extra_bdeps = target.get_transitive_build_target_deps()
- extra_paths = self.determine_windows_extra_paths(target.command[0], extra_bdeps)
+ extra_paths = self.determine_windows_extra_paths(target.command[0],
+ extra_bdeps, is_cross)
if extra_paths:
serialize = True
if serialize:
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
index 37bfe60..6339570 100644
--- a/mesonbuild/environment.py
+++ b/mesonbuild/environment.py
@@ -1045,6 +1045,12 @@ class CrossBuildInfo:
def get_properties(self):
return self.config['properties']
+ def get_root(self):
+ return self.get_properties().get('root', None)
+
+ def get_sys_root(self):
+ return self.get_properties().get('sys_root', None)
+
# When compiling a cross compiler we use the native compiler for everything.
# But not when cross compiling a cross compiler.
def need_cross_compiler(self):