summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/meson/meson
diff options
context:
space:
mode:
authorRoss Burton <ross.burton@intel.com>2019-01-07 15:07:43 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-01-08 11:16:45 +0000
commitc2556c44ecfb21c3fefddf12f9d9abdf482b90c7 (patch)
tree85b6c90b72f4fdf94e3859b0acc08d72c8078838 /meta/recipes-devtools/meson/meson
parent3bda6b8e0aa2656818e36a95e32252dc0e434105 (diff)
downloadpoky-c2556c44ecfb21c3fefddf12f9d9abdf482b90c7.tar.gz
meson: fix nativesdk-meson for multilib SDKs
Multilib SDKs differ only in the environment variables set, so nativesdk-meson's setup script needs to write a cross file for each environment. Rename the shipped meson.cross to meson.cross.template, as it cannot be used directly. Now that post-relocate scripts are called once for each environment, the generated meson.cross can be prefixed with TARGET_PREFIX to ensure it is unique. Finally rewrite the setup script to use string.Template to perform the expansion instead of hand-coding the logic. (From OE-Core rev: 8596f871ef834a38e3375443f7eb08e43816347a) Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools/meson/meson')
-rwxr-xr-xmeta/recipes-devtools/meson/meson/meson-setup.py69
-rwxr-xr-xmeta/recipes-devtools/meson/meson/meson-wrapper2
2 files changed, 20 insertions, 51 deletions
diff --git a/meta/recipes-devtools/meson/meson/meson-setup.py b/meta/recipes-devtools/meson/meson/meson-setup.py
index a9749eae9d..808e2a062f 100755
--- a/meta/recipes-devtools/meson/meson/meson-setup.py
+++ b/meta/recipes-devtools/meson/meson/meson-setup.py
@@ -1,62 +1,31 @@
1#!/usr/bin/env python3 1#!/usr/bin/env python3
2 2
3import os 3import os
4import string
4import sys 5import sys
5 6
6def bail(msg): 7class Template(string.Template):
7 print(msg, file=sys.stderr) 8 delimiter = "@"
8 sys.exit(1)
9
10_MARKER = '@@'
11def transform_line(line):
12 # Substitute any special markers of this form:
13 # @@ENV@@
14 # with the value of ENV, split into meson array syntax.
15 start = line.find(_MARKER)
16 if start == -1:
17 return line
18
19 end = line.rfind(_MARKER)
20 if end == start:
21 return line
22
23 # Lookup value of the env var.
24 var = line[start+len(_MARKER):end]
25 try:
26 val = os.environ[var]
27 except KeyError:
28 bail('cannot generate meson.cross; env var %s not set' % var)
29 9
30 # Transform into meson array. 10class Environ():
31 val = ["'%s'" % x for x in val.split()] 11 def __getitem__(self, name):
32 val = ', '.join(val) 12 val = os.environ[name]
33 val = '[%s]' % val 13 val = ["'%s'" % x for x in val.split()]
14 val = ', '.join(val)
15 val = '[%s]' % val
16 return val
34 17
35 before = line[:start]
36 after = line[end+len(_MARKER):]
37
38 return '%s%s%s' % (before, val, after)
39
40# Make sure this is really an SDK extraction environment.
41try: 18try:
42 sysroot = os.environ['OECORE_NATIVE_SYSROOT'] 19 sysroot = os.environ['OECORE_NATIVE_SYSROOT']
43except KeyError: 20except KeyError:
44 bail('OECORE_NATIVE_SYSROOT env var must be set') 21 print("Not in environment setup, bailing")
45 22 sys.exit(1)
46cross_file = os.path.join(sysroot, 'usr/share/meson/meson.cross')
47tmp_cross_file = '%s.tmp' % cross_file
48 23
49# Read through and transform the current meson.cross. 24template_file = os.path.join(sysroot, 'usr/share/meson/meson.cross.template')
50lines = [] 25cross_file = os.path.join(sysroot, 'usr/share/meson/%smeson.cross' % os.environ["TARGET_PREFIX"])
51with open(cross_file, 'r') as f:
52 for line in f:
53 lines.append(transform_line(line))
54 26
55# Write the transformed result to a tmp file and atomically rename it. In case 27with open(template_file) as in_file:
56# we crash during the file write, we don't want an invalid meson.cross file. 28 template = in_file.read()
57with open(tmp_cross_file, 'w') as f: 29 output = Template(template).substitute(Environ())
58 for line in lines: 30 with open(cross_file, "w") as out_file:
59 f.write(line) 31 out_file.write(output)
60 f.flush()
61 os.fdatasync(f.fileno())
62os.rename(tmp_cross_file, cross_file)
diff --git a/meta/recipes-devtools/meson/meson/meson-wrapper b/meta/recipes-devtools/meson/meson/meson-wrapper
index b2e00da513..d4ffe60f9a 100755
--- a/meta/recipes-devtools/meson/meson/meson-wrapper
+++ b/meta/recipes-devtools/meson/meson/meson-wrapper
@@ -10,5 +10,5 @@ fi
10unset CC CXX CPP LD AR NM STRIP 10unset CC CXX CPP LD AR NM STRIP
11 11
12exec "$OECORE_NATIVE_SYSROOT/usr/bin/meson.real" \ 12exec "$OECORE_NATIVE_SYSROOT/usr/bin/meson.real" \
13 --cross-file "$OECORE_NATIVE_SYSROOT/usr/share/meson/meson.cross" \ 13 --cross-file "${OECORE_NATIVE_SYSROOT}/usr/share/meson/${TARGET_PREFIX}meson.cross" \
14 "$@" 14 "$@"