summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorRoss Burton <ross.burton@intel.com>2019-03-21 12:44:09 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-03-24 17:00:52 +0000
commitd956c45baf65f8b28d732ed4dd3ca4b40e36ee66 (patch)
treedd4b81cb650f16f59380a530a05809648082ee04 /meta
parent06606fd9e0c1000c7479f2899eb6e5c48fa5b2cd (diff)
downloadpoky-d956c45baf65f8b28d732ed4dd3ca4b40e36ee66.tar.gz
meson: support multiple cross configuration files
For historical reasons Meson supports only a single cross configuration file but multiple native configuration files. Add support for multiple cross files, so that recipes such as glib can use the toolchain cross file and extend it with a recipe-specific cross file containing values needed to build. (From OE-Core rev: 3d97cddeec8635988e414e6854d850cea20bcb36) Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/recipes-devtools/meson/meson.inc3
-rw-r--r--meta/recipes-devtools/meson/meson/cross-libdir.patch18
-rw-r--r--meta/recipes-devtools/meson/meson/many-cross.patch207
3 files changed, 215 insertions, 13 deletions
diff --git a/meta/recipes-devtools/meson/meson.inc b/meta/recipes-devtools/meson/meson.inc
index ca448b00a0..2d18f72c0c 100644
--- a/meta/recipes-devtools/meson/meson.inc
+++ b/meta/recipes-devtools/meson/meson.inc
@@ -11,10 +11,11 @@ SRC_URI = "https://github.com/mesonbuild/meson/releases/download/${PV}/meson-${P
11 file://0003-native_bindir.patch \ 11 file://0003-native_bindir.patch \
12 file://0001-python-module-do-not-manipulate-the-environment-when.patch \ 12 file://0001-python-module-do-not-manipulate-the-environment-when.patch \
13 file://disable-rpath-handling.patch \ 13 file://disable-rpath-handling.patch \
14 file://cross-libdir.patch \
15 file://0001-modules-windows-split-WINDRES-env-variable.patch \ 14 file://0001-modules-windows-split-WINDRES-env-variable.patch \
16 file://0002-environment.py-detect-windows-also-if-the-system-str.patch \ 15 file://0002-environment.py-detect-windows-also-if-the-system-str.patch \
17 file://cross-prop-default.patch \ 16 file://cross-prop-default.patch \
17 file://many-cross.patch \
18 file://cross-libdir.patch \
18 " 19 "
19SRC_URI[sha256sum] = "ef9f14326ec1e30d3ba1a26df0f92826ede5a79255ad723af78a2691c37109fd" 20SRC_URI[sha256sum] = "ef9f14326ec1e30d3ba1a26df0f92826ede5a79255ad723af78a2691c37109fd"
20SRC_URI[md5sum] = "0267b0871266056184c484792572c682" 21SRC_URI[md5sum] = "0267b0871266056184c484792572c682"
diff --git a/meta/recipes-devtools/meson/meson/cross-libdir.patch b/meta/recipes-devtools/meson/meson/cross-libdir.patch
index 2bd4fb3f9e..7395fdbdaa 100644
--- a/meta/recipes-devtools/meson/meson/cross-libdir.patch
+++ b/meta/recipes-devtools/meson/meson/cross-libdir.patch
@@ -7,17 +7,11 @@ Date: Thu, 27 Dec 2018 23:43:35 +0200
7Subject: [PATCH] Default libdir is "lib" when cross compiling. Closes #2535. 7Subject: [PATCH] Default libdir is "lib" when cross compiling. Closes #2535.
8 8
9--- 9---
10 docs/markdown/snippets/crosslib.md | 7 +++++++
11 mesonbuild/coredata.py | 8 ++++++++
12 run_unittests.py | 13 +++++++++++++
13 3 files changed, 28 insertions(+)
14 create mode 100644 docs/markdown/snippets/crosslib.md
15
16diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py 10diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py
17index d70c23038c..4e2f3e008c 100644 11index ff810683..9ee23a69 100644
18--- a/mesonbuild/coredata.py 12--- a/mesonbuild/coredata.py
19+++ b/mesonbuild/coredata.py 13+++ b/mesonbuild/coredata.py
20@@ -299,6 +299,7 @@ def __init__(self, options): 14@@ -298,6 +298,7 @@ class CoreData:
21 # Only to print a warning if it changes between Meson invocations. 15 # Only to print a warning if it changes between Meson invocations.
22 self.pkgconf_envvar = os.environ.get('PKG_CONFIG_PATH', '') 16 self.pkgconf_envvar = os.environ.get('PKG_CONFIG_PATH', '')
23 self.config_files = self.__load_config_files(options.native_file) 17 self.config_files = self.__load_config_files(options.native_file)
@@ -25,15 +19,15 @@ index d70c23038c..4e2f3e008c 100644
25 19
26 @staticmethod 20 @staticmethod
27 def __load_config_files(filenames): 21 def __load_config_files(filenames):
28@@ -348,6 +349,13 @@ def __load_cross_file(filename): 22@@ -309,6 +310,13 @@ class CoreData:
29 23 for f in filenames]
30 raise MesonException('Cannot find specified cross file: ' + filename) 24 return filenames
31 25
32+ def libdir_cross_fixup(self): 26+ def libdir_cross_fixup(self):
33+ # By default set libdir to "lib" when cross compiling since 27+ # By default set libdir to "lib" when cross compiling since
34+ # getting the "system default" is always wrong on multiarch 28+ # getting the "system default" is always wrong on multiarch
35+ # platforms as it gets a value like lib/x86_64-linux-gnu. 29+ # platforms as it gets a value like lib/x86_64-linux-gnu.
36+ if self.cross_file is not None: 30+ if self.cross_files:
37+ self.builtins['libdir'].value = 'lib' 31+ self.builtins['libdir'].value = 'lib'
38+ 32+
39 def sanitize_prefix(self, prefix): 33 def sanitize_prefix(self, prefix):
diff --git a/meta/recipes-devtools/meson/meson/many-cross.patch b/meta/recipes-devtools/meson/meson/many-cross.patch
new file mode 100644
index 0000000000..d04c28b8a3
--- /dev/null
+++ b/meta/recipes-devtools/meson/meson/many-cross.patch
@@ -0,0 +1,207 @@
1mesonbuild: allow multiple --cross-file options
2
3Just like --native-file, allow multiple --cross-file options. This is mostly
4unifying the logic between cross_files and config_files.
5
6Upstream-Status: Backport [will be in 0.50.1]
7Signed-off-by: Ross Burton <ross.burton@intel.com>
8
9diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py
10index 40402513..4b9bcb59 100644
11--- a/mesonbuild/backend/backends.py
12+++ b/mesonbuild/backend/backends.py
13@@ -726,8 +726,7 @@ class Backend:
14 deps = [os.path.join(self.build_to_src, df)
15 for df in self.interpreter.get_build_def_files()]
16 if self.environment.is_cross_build():
17- deps.append(os.path.join(self.build_to_src,
18- self.environment.coredata.cross_file))
19+ deps.extend(self.environment.coredata.cross_files)
20 deps.append('meson-private/coredata.dat')
21 if os.path.exists(os.path.join(self.environment.get_source_dir(), 'meson_options.txt')):
22 deps.append(os.path.join(self.build_to_src, 'meson_options.txt'))
23diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py
24index c3f5a745..ff810683 100644
25--- a/mesonbuild/coredata.py
26+++ b/mesonbuild/coredata.py
27@@ -201,8 +201,8 @@ class UserFeatureOption(UserComboOption):
28 return self.value == 'auto'
29
30
31-def load_configs(filenames):
32- """Load native files."""
33+def load_configs(filenames, subdir):
34+ """Load configuration files from a named subdirectory."""
35 def gen():
36 for f in filenames:
37 f = os.path.expanduser(os.path.expandvars(f))
38@@ -215,7 +215,7 @@ def load_configs(filenames):
39 os.environ.get('XDG_DATA_HOME', os.path.expanduser('~/.local/share')),
40 ] + os.environ.get('XDG_DATA_DIRS', '/usr/local/share:/usr/share').split(':')
41 for path in paths:
42- path_to_try = os.path.join(path, 'meson', 'native', f)
43+ path_to_try = os.path.join(path, 'meson', subdir, f)
44 if os.path.isfile(path_to_try):
45 yield path_to_try
46 break
47@@ -291,7 +291,7 @@ class CoreData:
48 self.compiler_options = {}
49 self.base_options = {}
50 self.external_preprocess_args = {} # CPPFLAGS only
51- self.cross_file = self.__load_cross_file(options.cross_file)
52+ self.cross_files = self.__load_config_files(options.cross_file)
53 self.compilers = OrderedDict()
54 self.cross_compilers = OrderedDict()
55 self.deps = OrderedDict()
56@@ -301,52 +301,14 @@ class CoreData:
57
58 @staticmethod
59 def __load_config_files(filenames):
60+ # Need to try and make the passed filenames absolute because when the
61+ # files are parsed later we'll have chdir()d.
62 if not filenames:
63 return []
64 filenames = [os.path.abspath(os.path.expanduser(os.path.expanduser(f)))
65 for f in filenames]
66 return filenames
67
68- @staticmethod
69- def __load_cross_file(filename):
70- """Try to load the cross file.
71-
72- If the filename is None return None. If the filename is an absolute
73- (after resolving variables and ~), return that absolute path. Next,
74- check if the file is relative to the current source dir. If the path
75- still isn't resolved do the following:
76- Windows:
77- - Error
78- *:
79- - $XDG_DATA_HOME/meson/cross (or ~/.local/share/meson/cross if
80- undefined)
81- - $XDG_DATA_DIRS/meson/cross (or
82- /usr/local/share/meson/cross:/usr/share/meson/cross if undefined)
83- - Error
84-
85- Non-Windows follows the Linux path and will honor XDG_* if set. This
86- simplifies the implementation somewhat.
87- """
88- if filename is None:
89- return None
90- filename = os.path.expanduser(os.path.expandvars(filename))
91- if os.path.isabs(filename):
92- return filename
93- path_to_try = os.path.abspath(filename)
94- if os.path.isfile(path_to_try):
95- return path_to_try
96- if sys.platform != 'win32':
97- paths = [
98- os.environ.get('XDG_DATA_HOME', os.path.expanduser('~/.local/share')),
99- ] + os.environ.get('XDG_DATA_DIRS', '/usr/local/share:/usr/share').split(':')
100- for path in paths:
101- path_to_try = os.path.join(path, 'meson', 'cross', filename)
102- if os.path.isfile(path_to_try):
103- return path_to_try
104- raise MesonException('Cannot find specified cross file: ' + filename)
105-
106- raise MesonException('Cannot find specified cross file: ' + filename)
107-
108 def sanitize_prefix(self, prefix):
109 if not os.path.isabs(prefix):
110 raise MesonException('prefix value {!r} must be an absolute path'
111@@ -558,8 +520,8 @@ def read_cmd_line_file(build_dir, options):
112 options.cmd_line_options = d
113
114 properties = config['properties']
115- if options.cross_file is None:
116- options.cross_file = properties.get('cross_file', None)
117+ if not options.cross_file:
118+ options.cross_file = ast.literal_eval(properties.get('cross_file', '[]'))
119 if not options.native_file:
120 # This will be a string in the form: "['first', 'second', ...]", use
121 # literal_eval to get it into the list of strings.
122@@ -570,7 +532,7 @@ def write_cmd_line_file(build_dir, options):
123 config = CmdLineFileParser()
124
125 properties = {}
126- if options.cross_file is not None:
127+ if options.cross_file:
128 properties['cross_file'] = options.cross_file
129 if options.native_file:
130 properties['native_file'] = options.native_file
131diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
132index 6d86daf9..406ab8b8 100644
133--- a/mesonbuild/environment.py
134+++ b/mesonbuild/environment.py
135@@ -355,8 +355,8 @@ class Environment:
136 self.machines = MachineInfos()
137 # Will be fully initialized later using compilers later.
138 self.machines.detect_build()
139- if self.coredata.cross_file:
140- self.cross_info = CrossBuildInfo(self.coredata.cross_file)
141+ if self.coredata.cross_files:
142+ self.cross_info = CrossBuildInfo(self.coredata.cross_files)
143 if 'exe_wrapper' in self.cross_info.config['binaries']:
144 from .dependencies import ExternalProgram
145 self.exe_wrapper = ExternalProgram.from_bin_list(
146@@ -373,7 +373,7 @@ class Environment:
147
148 if self.coredata.config_files:
149 self.config_info = coredata.ConfigData(
150- coredata.load_configs(self.coredata.config_files))
151+ coredata.load_configs(self.coredata.config_files, 'native'))
152 else:
153 self.config_info = coredata.ConfigData()
154
155@@ -1113,13 +1113,8 @@ class CrossBuildInfo:
156 def ok_type(self, i):
157 return isinstance(i, (str, int, bool))
158
159- def parse_datafile(self, filename):
160- config = configparser.ConfigParser()
161- try:
162- with open(filename, 'r') as f:
163- config.read_file(f, filename)
164- except FileNotFoundError:
165- raise EnvironmentException('File not found: %s.' % filename)
166+ def parse_datafile(self, filenames):
167+ config = coredata.load_configs(filenames, 'cross')
168 # This is a bit hackish at the moment.
169 for s in config.sections():
170 self.config[s] = {}
171diff --git a/mesonbuild/msetup.py b/mesonbuild/msetup.py
172index 56a0e9a7..f0a1ae19 100644
173--- a/mesonbuild/msetup.py
174+++ b/mesonbuild/msetup.py
175@@ -27,7 +27,9 @@ from .mesonlib import MesonException
176
177 def add_arguments(parser):
178 coredata.register_builtin_arguments(parser)
179- parser.add_argument('--cross-file', default=None,
180+ parser.add_argument('--cross-file',
181+ default=[],
182+ action='append',
183 help='File describing cross compilation environment.')
184 parser.add_argument('--native-file',
185 default=[],
186diff --git a/run_unittests.py b/run_unittests.py
187index e6874b25..1d247291 100755
188--- a/run_unittests.py
189+++ b/run_unittests.py
190@@ -529,7 +529,7 @@ class InternalTests(unittest.TestCase):
191 config.write(configfile)
192 configfile.flush()
193 configfile.close()
194- detected_value = mesonbuild.environment.CrossBuildInfo(configfile.name).need_exe_wrapper()
195+ detected_value = mesonbuild.environment.CrossBuildInfo((configfile.name,)).need_exe_wrapper()
196 os.unlink(configfilename)
197
198 desired_value = not detected_value
199@@ -541,7 +541,7 @@ class InternalTests(unittest.TestCase):
200 configfilename = configfile.name
201 config.write(configfile)
202 configfile.close()
203- forced_value = mesonbuild.environment.CrossBuildInfo(configfile.name).need_exe_wrapper()
204+ forced_value = mesonbuild.environment.CrossBuildInfo((configfile.name,)).need_exe_wrapper()
205 os.unlink(configfilename)
206
207 self.assertEqual(forced_value, desired_value)