aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2019-02-06 13:53:40 -0800
committerDylan Baker <dylan@pnwbakers.com>2019-02-11 12:50:32 -0800
commitb5d847e38c90292af351ff4aa99cef0300886660 (patch)
tree0c81d8195ea2647ce41139010d27d390e2ca6e36
parent5b896ed70bbf18e633bbeca442c90610e3d66a22 (diff)
downloadmeson-b5d847e38c90292af351ff4aa99cef0300886660.zip
meson-b5d847e38c90292af351ff4aa99cef0300886660.tar.gz
meson-b5d847e38c90292af351ff4aa99cef0300886660.tar.bz2
allow paths to be set in the cross file
Just like the previous patch, but for cross files Fixes #1433
-rw-r--r--docs/markdown/Cross-compilation.md16
-rw-r--r--docs/markdown/snippets/native-file-paths.md6
-rw-r--r--mesonbuild/environment.py1
-rwxr-xr-xrun_unittests.py47
-rw-r--r--test cases/unit/54 native file override/crossfile16
5 files changed, 81 insertions, 5 deletions
diff --git a/docs/markdown/Cross-compilation.md b/docs/markdown/Cross-compilation.md
index 7d316ed..36620eb 100644
--- a/docs/markdown/Cross-compilation.md
+++ b/docs/markdown/Cross-compilation.md
@@ -150,7 +150,7 @@ binaries are not actually compatible. In such cases you may use the
needs_exe_wrapper = true
```
-The last bit is the definition of host and target machines. Every
+The next bit is the definition of host and target machines. Every
cross build definition must have one or both of them. If it had
neither, the build would not be a cross build but a native build. You
do not need to define the build machine, as all necessary information
@@ -186,6 +186,20 @@ If you do not define your host machine, it is assumed to be the build
machine. Similarly if you do not specify target machine, it is assumed
to be the host machine.
+Additionally, you can define the paths that you want to install to in your
+cross file. This may be especially useful when cross compiling an entire
+operating system, or for operating systems to use internally for consistency.
+
+```ini
+[paths]
+prefix = '/my/prefix'
+libdir = 'lib/i386-linux-gnu'
+bindir = 'bin'
+```
+
+This will be overwritten by any options passed on the command line.
+
+
## Starting a cross build
diff --git a/docs/markdown/snippets/native-file-paths.md b/docs/markdown/snippets/native-file-paths.md
index 6979241..b091c40 100644
--- a/docs/markdown/snippets/native-file-paths.md
+++ b/docs/markdown/snippets/native-file-paths.md
@@ -1,4 +1,4 @@
-## Native File Paths and Directories
+## Native and Cross File Paths and Directories
-A new `[paths]` section has been added to the native file. This can be used to
-set paths such a prefix and libdir in a persistent way.
+A new `[paths]` section has been added to native and cross files. This
+can be used to set paths such a prefix and libdir in a persistent way.
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
index afa6cd8..b2cc657 100644
--- a/mesonbuild/environment.py
+++ b/mesonbuild/environment.py
@@ -399,6 +399,7 @@ class Environment:
self.machines.host = MachineInfo.from_literal(config['host_machine'])
if 'target_machine' in config:
self.machines.target = MachineInfo.from_literal(config['target_machine'])
+ self.paths.host = Directories(**config.get('paths', {}))
self.machines.default_missing()
self.binaries.default_missing()
diff --git a/run_unittests.py b/run_unittests.py
index 2e2741f..9dd734a 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -5450,6 +5450,51 @@ class NativeFileTests(BasePlatformTests):
'-Ddef_libdir=liblib', '-Dlibdir=liblib'])
+class CrossFileTests(BasePlatformTests):
+
+ """Tests for cross file functioality not directly related to
+ cross compiling.
+
+ This is mainly aimed to testing overrides from cross files.
+ """
+
+ def test_cross_file_dirs(self):
+ testcase = os.path.join(self.unit_test_dir, '54 native file override')
+ self.init(testcase, default_args=False,
+ extra_args=['--native-file', os.path.join(testcase, 'nativefile'),
+ '--cross-file', os.path.join(testcase, 'crossfile'),
+ '-Ddef_bindir=binbar',
+ '-Ddef_datadir=databar',
+ '-Ddef_includedir=includebar',
+ '-Ddef_infodir=infobar',
+ '-Ddef_libdir=libbar',
+ '-Ddef_libexecdir=libexecbar',
+ '-Ddef_localedir=localebar',
+ '-Ddef_localstatedir=localstatebar',
+ '-Ddef_mandir=manbar',
+ '-Ddef_sbindir=sbinbar',
+ '-Ddef_sharedstatedir=sharedstatebar',
+ '-Ddef_sysconfdir=sysconfbar'])
+
+ def test_cross_file_dirs_overriden(self):
+ testcase = os.path.join(self.unit_test_dir, '54 native file override')
+ self.init(testcase, default_args=False,
+ extra_args=['--native-file', os.path.join(testcase, 'nativefile'),
+ '--cross-file', os.path.join(testcase, 'crossfile'),
+ '-Ddef_libdir=liblib', '-Dlibdir=liblib',
+ '-Ddef_bindir=binbar',
+ '-Ddef_datadir=databar',
+ '-Ddef_includedir=includebar',
+ '-Ddef_infodir=infobar',
+ '-Ddef_libexecdir=libexecbar',
+ '-Ddef_localedir=localebar',
+ '-Ddef_localstatedir=localstatebar',
+ '-Ddef_mandir=manbar',
+ '-Ddef_sbindir=sbinbar',
+ '-Ddef_sharedstatedir=sharedstatebar',
+ '-Ddef_sysconfdir=sysconfbar'])
+
+
def unset_envs():
# For unit tests we must fully control all command lines
# so that there are no unexpected changes coming from the
@@ -5468,7 +5513,7 @@ def should_run_cross_mingw_tests():
def main():
unset_envs()
cases = ['InternalTests', 'DataTests', 'AllPlatformTests', 'FailureTests',
- 'PythonTests', 'NativeFileTests', 'RewriterTests']
+ 'PythonTests', 'NativeFileTests', 'RewriterTests', 'CrossFileTests']
if not is_windows():
cases += ['LinuxlikeTests']
if should_run_cross_arm_tests():
diff --git a/test cases/unit/54 native file override/crossfile b/test cases/unit/54 native file override/crossfile
new file mode 100644
index 0000000..9dc4fbc
--- /dev/null
+++ b/test cases/unit/54 native file override/crossfile
@@ -0,0 +1,16 @@
+[paths]
+bindir = 'binbar'
+datadir = 'databar'
+includedir = 'includebar'
+infodir = 'infobar'
+libdir = 'libbar'
+libexecdir = 'libexecbar'
+localedir = 'localebar'
+localstatedir = 'localstatebar'
+mandir = 'manbar'
+prefix = '/prefix'
+sbindir = 'sbinbar'
+sharedstatedir = 'sharedstatebar'
+sysconfdir = 'sysconfbar'
+
+; vim: ft=dosini