diff options
author | Raul E Rangel <rrangel@chromium.org> | 2018-04-23 09:53:07 -0600 |
---|---|---|
committer | Mike Gilbert <floppym@gentoo.org> | 2018-05-05 15:56:43 -0400 |
commit | e6770aa6e9cd2d8fe3b833ad1844c3f3c80438af (patch) | |
tree | e8d2160ae3dd972477aec787571f234d3a1de0bd /eclass | |
parent | dev-cpp/gmock: treeclean (diff) | |
download | gentoo-e6770aa6e9cd2d8fe3b833ad1844c3f3c80438af.tar.gz gentoo-e6770aa6e9cd2d8fe3b833ad1844c3f3c80438af.tar.bz2 gentoo-e6770aa6e9cd2d8fe3b833ad1844c3f3c80438af.zip |
meson.eclass: Write *FLAGS into meson cross build file
Use python's shlex to parse the flags and generate an array that is
usable by meson. This will pass the flags correctly when doing a cross
build.
Example cross file output:
[properties]
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']
c_link_args = ['-Wl,-O1', '-Wl,-O2', '-Wl,--as-needed']
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']
cpp_link_args = ['-Wl,-O1', '-Wl,-O2', '-Wl,--as-needed']
fortran_args = ['-O2']
objc_args = []
objcpp_args = []
See https://bugs.gentoo.org/653900 for upstream patch.
BUG=b:78351764
TEST=emerge-grunt and emerge-bob and verified the flags are passed to
mosys
BRANCH=none
Change-Id: Ic3d852232ec718141b87bc0729318699f0fad4f8
Signed-off-by: Raul E Rangel <rrangel@chromium.org>
Closes: https://bugs.gentoo.org/653900
Diffstat (limited to 'eclass')
-rw-r--r-- | eclass/meson.eclass | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/eclass/meson.eclass b/eclass/meson.eclass index 71735fbfc67d..ddceffd8c63c 100644 --- a/eclass/meson.eclass +++ b/eclass/meson.eclass @@ -92,6 +92,41 @@ __MESON_AUTO_DEPEND=${MESON_AUTO_DEPEND} # See top of eclass # Optional meson arguments as Bash array; this should be defined before # calling meson_src_configure. + +read -d '' __MESON_ARRAY_PARSER <<"EOF" +import shlex; + +# See http://mesonbuild.com/Syntax.html#strings +def quote(str): + escaped = str.replace("\\\\", "\\\\\\\\").replace("'", "\\\\'") + return "'{}'".format(escaped) + +print("[{}]".format( + ", ".join([quote(x) for x in shlex.split(None)]))) +EOF + +# @FUNCTION: _meson_env_array +# @INTERNAL +# @DESCRIPTION: +# Parses the command line flags and converts them into an array suitable for +# use in a cross file. +# +# Input: --single-quote=\' --double-quote=\" --dollar=\$ --backtick=\` +# --backslash=\\ --full-word-double="Hello World" +# --full-word-single='Hello World' +# --full-word-backslash=Hello\ World +# --simple --unicode-8=© --unicode-16=𐐷 --unicode-32=𐤅 +# +# Output: ['--single-quote=\'', '--double-quote="', '--dollar=$', +# '--backtick=`', '--backslash=\\', '--full-word-double=Hello World', +# '--full-word-single=Hello World', +# '--full-word-backslash=Hello World', '--simple', '--unicode-8=©', +# '--unicode-16=𐐷', '--unicode-32=𐤅'] +# +_meson_env_array() { + echo "$1" | python -c "$__MESON_ARRAY_PARSER" +} + # @FUNCTION: _meson_create_cross_file # @INTERNAL # @DESCRIPTION: @@ -129,6 +164,15 @@ _meson_create_cross_file() { pkgconfig = '${PKG_CONFIG}' strip = '${STRIP}' + [properties] + c_args = $(_meson_env_array "$CFLAGS") + c_link_args = $(_meson_env_array "$LDFLAGS") + cpp_args = $(_meson_env_array "$CXXFLAGS") + cpp_link_args = $(_meson_env_array "$LDFLAGS") + fortran_args = $(_meson_env_array "$FCFLAGS") + objc_args = $(_meson_env_array "$OBJCFLAGS") + objcpp_args = $(_meson_env_array "$OBJCXXFLAGS") + [host_machine] system = '${system}' cpu_family = '${cpu_family}' |