diff options
-rwxr-xr-x | meta/recipes-devtools/meson/meson/meson-setup.py | 69 | ||||
-rwxr-xr-x | meta/recipes-devtools/meson/meson/meson-wrapper | 2 | ||||
-rw-r--r-- | meta/recipes-devtools/meson/nativesdk-meson_0.49.0.bb | 41 |
3 files changed, 36 insertions, 76 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 | ||
3 | import os | 3 | import os |
4 | import string | ||
4 | import sys | 5 | import sys |
5 | 6 | ||
6 | def bail(msg): | 7 | class Template(string.Template): |
7 | print(msg, file=sys.stderr) | 8 | delimiter = "@" |
8 | sys.exit(1) | ||
9 | |||
10 | _MARKER = '@@' | ||
11 | def 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. | 10 | class 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. | ||
41 | try: | 18 | try: |
42 | sysroot = os.environ['OECORE_NATIVE_SYSROOT'] | 19 | sysroot = os.environ['OECORE_NATIVE_SYSROOT'] |
43 | except KeyError: | 20 | except KeyError: |
44 | bail('OECORE_NATIVE_SYSROOT env var must be set') | 21 | print("Not in environment setup, bailing") |
45 | 22 | sys.exit(1) | |
46 | cross_file = os.path.join(sysroot, 'usr/share/meson/meson.cross') | ||
47 | tmp_cross_file = '%s.tmp' % cross_file | ||
48 | 23 | ||
49 | # Read through and transform the current meson.cross. | 24 | template_file = os.path.join(sysroot, 'usr/share/meson/meson.cross.template') |
50 | lines = [] | 25 | cross_file = os.path.join(sysroot, 'usr/share/meson/%smeson.cross' % os.environ["TARGET_PREFIX"]) |
51 | with 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 | 27 | with 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() |
57 | with 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()) | ||
62 | os.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 | |||
10 | unset CC CXX CPP LD AR NM STRIP | 10 | unset CC CXX CPP LD AR NM STRIP |
11 | 11 | ||
12 | exec "$OECORE_NATIVE_SYSROOT/usr/bin/meson.real" \ | 12 | exec "$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 | "$@" |
diff --git a/meta/recipes-devtools/meson/nativesdk-meson_0.49.0.bb b/meta/recipes-devtools/meson/nativesdk-meson_0.49.0.bb index 721ee8c8f1..55c57775e0 100644 --- a/meta/recipes-devtools/meson/nativesdk-meson_0.49.0.bb +++ b/meta/recipes-devtools/meson/nativesdk-meson_0.49.0.bb | |||
@@ -5,9 +5,6 @@ inherit nativesdk | |||
5 | SRC_URI += "file://meson-setup.py \ | 5 | SRC_URI += "file://meson-setup.py \ |
6 | file://meson-wrapper" | 6 | file://meson-wrapper" |
7 | 7 | ||
8 | def meson_array(var, d): | ||
9 | return "', '".join(d.getVar(var).split()).join(("'", "'")) | ||
10 | |||
11 | # both are required but not used by meson | 8 | # both are required but not used by meson |
12 | MESON_SDK_ENDIAN = "bogus-endian" | 9 | MESON_SDK_ENDIAN = "bogus-endian" |
13 | MESON_TARGET_ENDIAN = "bogus-endian" | 10 | MESON_TARGET_ENDIAN = "bogus-endian" |
@@ -17,32 +14,31 @@ MESON_C_ARGS = "${MESON_TOOLCHAIN_ARGS} ${BUILDSDK_CFLAGS}" | |||
17 | MESON_CPP_ARGS = "${MESON_TOOLCHAIN_ARGS} ${BUILDSDK_CXXFLAGS}" | 14 | MESON_CPP_ARGS = "${MESON_TOOLCHAIN_ARGS} ${BUILDSDK_CXXFLAGS}" |
18 | MESON_LINK_ARGS = "${MESON_TOOLCHAIN_ARGS} ${BUILDSDK_LDFLAGS}" | 15 | MESON_LINK_ARGS = "${MESON_TOOLCHAIN_ARGS} ${BUILDSDK_LDFLAGS}" |
19 | 16 | ||
20 | # This logic is similar but not identical to that in meson.bbclass, since it's | 17 | # The cross file logic is similar but not identical to that in meson.bbclass, |
21 | # generating for an SDK rather than a cross-compile. Important differences are: | 18 | # since it's generating for an SDK rather than a cross-compile. Important |
19 | # differences are: | ||
22 | # - We can't set vars like CC, CXX, etc. yet because they will be filled in with | 20 | # - We can't set vars like CC, CXX, etc. yet because they will be filled in with |
23 | # real paths by meson-setup.sh when the SDK is extracted. | 21 | # real paths by meson-setup.sh when the SDK is extracted. |
24 | # - Some overrides aren't needed, since the SDK injects paths that take care of | 22 | # - Some overrides aren't needed, since the SDK injects paths that take care of |
25 | # them. | 23 | # them. |
26 | addtask write_config before do_install | 24 | do_install_append() { |
27 | do_write_config[vardeps] += "MESON_C_ARGS MESON_CPP_ARGS MESON_LINK_ARGS CC CXX LD AR NM STRIP READELF" | 25 | install -d ${D}${datadir}/meson |
28 | do_write_config() { | 26 | cat >${D}${datadir}/meson/meson.cross.template <<EOF |
29 | # This needs to be Py to split the args into single-element lists | ||
30 | cat >${WORKDIR}/meson.cross <<EOF | ||
31 | [binaries] | 27 | [binaries] |
32 | c = @@CC@@ | 28 | c = @CC |
33 | cpp = @@CXX@@ | 29 | cpp = @CXX |
34 | ar = @@AR@@ | 30 | ar = @AR |
35 | nm = @@NM@@ | 31 | nm = @NM |
36 | ld = @@LD@@ | 32 | ld = @LD |
37 | strip = @@STRIP@@ | 33 | strip = @STRIP |
38 | pkgconfig = 'pkg-config' | 34 | pkgconfig = 'pkg-config' |
39 | 35 | ||
40 | [properties] | 36 | [properties] |
41 | needs_exe_wrapper = true | 37 | needs_exe_wrapper = true |
42 | c_args = @@CFLAGS@@ | 38 | c_args = @CFLAGS |
43 | c_link_args = @@LDFLAGS@@ | 39 | c_link_args = @LDFLAGS |
44 | cpp_args = @@CPPFLAGS@@ | 40 | cpp_args = @CPPFLAGS |
45 | cpp_link_args = @@LDFLAGS@@ | 41 | cpp_link_args = @LDFLAGS |
46 | 42 | ||
47 | [host_machine] | 43 | [host_machine] |
48 | system = '${SDK_OS}' | 44 | system = '${SDK_OS}' |
@@ -50,11 +46,6 @@ cpu_family = '${SDK_ARCH}' | |||
50 | cpu = '${SDK_ARCH}' | 46 | cpu = '${SDK_ARCH}' |
51 | endian = '${MESON_SDK_ENDIAN}' | 47 | endian = '${MESON_SDK_ENDIAN}' |
52 | EOF | 48 | EOF |
53 | } | ||
54 | |||
55 | do_install_append() { | ||
56 | install -d ${D}${datadir}/meson | ||
57 | install -m 0644 ${WORKDIR}/meson.cross ${D}${datadir}/meson/ | ||
58 | 49 | ||
59 | install -d ${D}${SDKPATHNATIVE}/post-relocate-setup.d | 50 | install -d ${D}${SDKPATHNATIVE}/post-relocate-setup.d |
60 | install -m 0755 ${WORKDIR}/meson-setup.py ${D}${SDKPATHNATIVE}/post-relocate-setup.d/ | 51 | install -m 0755 ${WORKDIR}/meson-setup.py ${D}${SDKPATHNATIVE}/post-relocate-setup.d/ |