aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Turney <jon.turney@dronecode.org.uk>2018-02-21 13:39:52 +0000
committerJussi Pakkanen <jpakkane@gmail.com>2018-02-21 23:58:14 +0200
commitcf98f5e3705603ae21bef9b0a577bcd001a8c92e (patch)
tree0570e0fcc4d15e6f8b155844ad11e4676f010198
parent845dbfcbbc40b0060b1ed7d7df0431c5f4a11497 (diff)
downloadmeson-cf98f5e3705603ae21bef9b0a577bcd001a8c92e.zip
meson-cf98f5e3705603ae21bef9b0a577bcd001a8c92e.tar.gz
meson-cf98f5e3705603ae21bef9b0a577bcd001a8c92e.tar.bz2
Enable searching system crossfile locations on more platforms
There's no reason not to also look in these places on Cygwin or OSX. Don't do this on Windows, as these paths aren't meaningful there. Move test_cross_file_system_paths from LinuxlikeTests to AllPlatformTests.
-rw-r--r--mesonbuild/coredata.py14
-rwxr-xr-xrun_unittests.py91
2 files changed, 54 insertions, 51 deletions
diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py
index f87e62c..bae207b 100644
--- a/mesonbuild/coredata.py
+++ b/mesonbuild/coredata.py
@@ -222,17 +222,17 @@ class CoreData:
(after resolving variables and ~), return that absolute path. Next,
check if the file is relative to the current source dir. If the path
still isn't resolved do the following:
- Linux + BSD:
+ Windows:
+ - Error
+ *:
- $XDG_DATA_HOME/meson/cross (or ~/.local/share/meson/cross if
undefined)
- $XDG_DATA_DIRS/meson/cross (or
/usr/local/share/meson/cross:/usr/share/meson/cross if undefined)
- Error
- *:
- - Error
- BSD follows the Linux path and will honor XDG_* if set. This simplifies
- the implementation somewhat, especially since most BSD users wont set
- those environment variables.
+
+ Non-Windows follows the Linux path and will honor XDG_* if set. This
+ simplifies the implementation somewhat.
"""
if filename is None:
return None
@@ -242,7 +242,7 @@ class CoreData:
path_to_try = os.path.abspath(filename)
if os.path.exists(path_to_try):
return path_to_try
- if sys.platform == 'linux' or 'bsd' in sys.platform.lower():
+ if sys.platform != 'win32':
paths = [
os.environ.get('XDG_DATA_HOME', os.path.expanduser('~/.local/share')),
] + os.environ.get('XDG_DATA_DIRS', '/usr/local/share:/usr/share').split(':')
diff --git a/run_unittests.py b/run_unittests.py
index fd424be..41cbf39 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -1749,6 +1749,53 @@ int main(int argc, char **argv) {
self._run(ninja,
workdir=os.path.join(tmpdir, 'builddir'))
+ def test_cross_file_system_paths(self):
+ if is_windows():
+ raise unittest.SkipTest('system crossfile paths not defined for Windows (yet)')
+
+ testdir = os.path.join(self.common_test_dir, '1 trivial')
+ cross_content = textwrap.dedent("""\
+ [binaries]
+ c = '/usr/bin/cc'
+ ar = '/usr/bin/ar'
+ strip = '/usr/bin/ar'
+
+ [properties]
+
+ [host_machine]
+ system = 'linux'
+ cpu_family = 'x86'
+ cpu = 'i686'
+ endian = 'little'
+ """)
+
+ with tempfile.TemporaryDirectory() as d:
+ dir_ = os.path.join(d, 'meson', 'cross')
+ os.makedirs(dir_)
+ with tempfile.NamedTemporaryFile('w', dir=dir_, delete=False) as f:
+ f.write(cross_content)
+ name = os.path.basename(f.name)
+
+ with mock.patch.dict(os.environ, {'XDG_DATA_HOME': d}):
+ self.init(testdir, ['--cross-file=' + name], inprocess=True)
+ self.wipe()
+
+ with mock.patch.dict(os.environ, {'XDG_DATA_DIRS': d}):
+ os.environ.pop('XDG_DATA_HOME', None)
+ self.init(testdir, ['--cross-file=' + name], inprocess=True)
+ self.wipe()
+
+ with tempfile.TemporaryDirectory() as d:
+ dir_ = os.path.join(d, '.local', 'share', 'meson', 'cross')
+ os.makedirs(dir_)
+ with tempfile.NamedTemporaryFile('w', dir=dir_, delete=False) as f:
+ f.write(cross_content)
+ name = os.path.basename(f.name)
+
+ with mock.patch('mesonbuild.coredata.os.path.expanduser', lambda x: x.replace('~', d)):
+ self.init(testdir, ['--cross-file=' + name], inprocess=True)
+ self.wipe()
+
class FailureTests(BasePlatformTests):
'''
@@ -2546,50 +2593,6 @@ endian = 'little'
self.init(testdir, ['-Db_lto=true'], default_args=False)
self.build('reconfigure')
- def test_cross_file_system_paths(self):
- testdir = os.path.join(self.common_test_dir, '1 trivial')
- cross_content = textwrap.dedent("""\
- [binaries]
- c = '/usr/bin/cc'
- ar = '/usr/bin/ar'
- strip = '/usr/bin/ar'
-
- [properties]
-
- [host_machine]
- system = 'linux'
- cpu_family = 'x86'
- cpu = 'i686'
- endian = 'little'
- """)
-
- with tempfile.TemporaryDirectory() as d:
- dir_ = os.path.join(d, 'meson', 'cross')
- os.makedirs(dir_)
- with tempfile.NamedTemporaryFile('w', dir=dir_, delete=False) as f:
- f.write(cross_content)
- name = os.path.basename(f.name)
-
- with mock.patch.dict(os.environ, {'XDG_DATA_HOME': d}):
- self.init(testdir, ['--cross-file=' + name], inprocess=True)
- self.wipe()
-
- with mock.patch.dict(os.environ, {'XDG_DATA_DIRS': d}):
- os.environ.pop('XDG_DATA_HOME', None)
- self.init(testdir, ['--cross-file=' + name], inprocess=True)
- self.wipe()
-
- with tempfile.TemporaryDirectory() as d:
- dir_ = os.path.join(d, '.local', 'share', 'meson', 'cross')
- os.makedirs(dir_)
- with tempfile.NamedTemporaryFile('w', dir=dir_, delete=False) as f:
- f.write(cross_content)
- name = os.path.basename(f.name)
-
- with mock.patch('mesonbuild.coredata.os.path.expanduser', lambda x: x.replace('~', d)):
- self.init(testdir, ['--cross-file=' + name], inprocess=True)
- self.wipe()
-
def test_vala_generated_source_buildir_inside_source_tree(self):
'''
Test that valac outputs generated C files in the expected location when