1 |
commit: e6770aa6e9cd2d8fe3b833ad1844c3f3c80438af |
2 |
Author: Raul E Rangel <rrangel <AT> chromium <DOT> org> |
3 |
AuthorDate: Mon Apr 23 15:53:07 2018 +0000 |
4 |
Commit: Mike Gilbert <floppym <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat May 5 19:56:43 2018 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e6770aa6 |
7 |
|
8 |
meson.eclass: Write *FLAGS into meson cross build file |
9 |
|
10 |
Use python's shlex to parse the flags and generate an array that is |
11 |
usable by meson. This will pass the flags correctly when doing a cross |
12 |
build. |
13 |
|
14 |
Example cross file output: |
15 |
|
16 |
[properties] |
17 |
c_args = ['-O2', '-pipe', '-march=armv8-a+crc', '-mtune=cortex-a57.cortex-a53', '-mfpu=crypto-neon-fp-armv8', '-mfloat-abi=hard', '-g', '-fno-exceptions', '-fno-unwind-tables', '-fno-asynchronous-unwind-tables', '-clang-syntax'] |
18 |
c_link_args = ['-Wl,-O1', '-Wl,-O2', '-Wl,--as-needed'] |
19 |
cpp_args = ['-O2', '-O2', '-pipe', '-march=armv8-a+crc', '-mtune=cortex-a57.cortex-a53', '-mfpu=crypto-neon-fp-armv8', '-mfloat-abi=hard', '-g', '-fno-exceptions', '-fno-unwind-tables', '-fno-asynchronous-unwind-tables', '-clang-syntax'] |
20 |
cpp_link_args = ['-Wl,-O1', '-Wl,-O2', '-Wl,--as-needed'] |
21 |
fortran_args = ['-O2'] |
22 |
objc_args = [] |
23 |
objcpp_args = [] |
24 |
|
25 |
See https://bugs.gentoo.org/653900 for upstream patch. |
26 |
|
27 |
BUG=b:78351764 |
28 |
TEST=emerge-grunt and emerge-bob and verified the flags are passed to |
29 |
mosys |
30 |
BRANCH=none |
31 |
|
32 |
Change-Id: Ic3d852232ec718141b87bc0729318699f0fad4f8 |
33 |
Signed-off-by: Raul E Rangel <rrangel <AT> chromium.org> |
34 |
Closes: https://bugs.gentoo.org/653900 |
35 |
|
36 |
eclass/meson.eclass | 44 ++++++++++++++++++++++++++++++++++++++++++++ |
37 |
1 file changed, 44 insertions(+) |
38 |
|
39 |
diff --git a/eclass/meson.eclass b/eclass/meson.eclass |
40 |
index 71735fbfc67..ddceffd8c63 100644 |
41 |
--- a/eclass/meson.eclass |
42 |
+++ b/eclass/meson.eclass |
43 |
@@ -92,6 +92,41 @@ __MESON_AUTO_DEPEND=${MESON_AUTO_DEPEND} # See top of eclass |
44 |
# Optional meson arguments as Bash array; this should be defined before |
45 |
# calling meson_src_configure. |
46 |
|
47 |
+ |
48 |
+read -d '' __MESON_ARRAY_PARSER <<"EOF" |
49 |
+import shlex; |
50 |
+ |
51 |
+# See http://mesonbuild.com/Syntax.html#strings |
52 |
+def quote(str): |
53 |
+ escaped = str.replace("\\\\", "\\\\\\\\").replace("'", "\\\\'") |
54 |
+ return "'{}'".format(escaped) |
55 |
+ |
56 |
+print("[{}]".format( |
57 |
+ ", ".join([quote(x) for x in shlex.split(None)]))) |
58 |
+EOF |
59 |
+ |
60 |
+# @FUNCTION: _meson_env_array |
61 |
+# @INTERNAL |
62 |
+# @DESCRIPTION: |
63 |
+# Parses the command line flags and converts them into an array suitable for |
64 |
+# use in a cross file. |
65 |
+# |
66 |
+# Input: --single-quote=\' --double-quote=\" --dollar=\$ --backtick=\` |
67 |
+# --backslash=\\ --full-word-double="Hello World" |
68 |
+# --full-word-single='Hello World' |
69 |
+# --full-word-backslash=Hello\ World |
70 |
+# --simple --unicode-8=© --unicode-16=𐐷 --unicode-32=𐤅 |
71 |
+# |
72 |
+# Output: ['--single-quote=\'', '--double-quote="', '--dollar=$', |
73 |
+# '--backtick=`', '--backslash=\\', '--full-word-double=Hello World', |
74 |
+# '--full-word-single=Hello World', |
75 |
+# '--full-word-backslash=Hello World', '--simple', '--unicode-8=©', |
76 |
+# '--unicode-16=𐐷', '--unicode-32=𐤅'] |
77 |
+# |
78 |
+_meson_env_array() { |
79 |
+ echo "$1" | python -c "$__MESON_ARRAY_PARSER" |
80 |
+} |
81 |
+ |
82 |
# @FUNCTION: _meson_create_cross_file |
83 |
# @INTERNAL |
84 |
# @DESCRIPTION: |
85 |
@@ -129,6 +164,15 @@ _meson_create_cross_file() { |
86 |
pkgconfig = '${PKG_CONFIG}' |
87 |
strip = '${STRIP}' |
88 |
|
89 |
+ [properties] |
90 |
+ c_args = $(_meson_env_array "$CFLAGS") |
91 |
+ c_link_args = $(_meson_env_array "$LDFLAGS") |
92 |
+ cpp_args = $(_meson_env_array "$CXXFLAGS") |
93 |
+ cpp_link_args = $(_meson_env_array "$LDFLAGS") |
94 |
+ fortran_args = $(_meson_env_array "$FCFLAGS") |
95 |
+ objc_args = $(_meson_env_array "$OBJCFLAGS") |
96 |
+ objcpp_args = $(_meson_env_array "$OBJCXXFLAGS") |
97 |
+ |
98 |
[host_machine] |
99 |
system = '${system}' |
100 |
cpu_family = '${cpu_family}' |