summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2019-06-24 17:21:17 +0530
committerNirbheek Chauhan <nirbheek@centricular.com>2019-06-25 12:21:43 +0530
commit3c2643410eeeab55bbf448a2c9ada8d4191c4982 (patch)
tree9f3cec43e10297dd16f42267f2f834884f13a35a
parentbadd0fa500ba3b145f73aadbde9356ce0c336dab (diff)
meson and glib: Fix quoting issues with c_args when cross-compiling
Use shlex.quote for escaping CFLAGS to be more accurate, and also fix Meson to correctly quote c_args obtained from the cross file when adding them to the compiler rules. This is already done correctly when adding c_args to the compile commands, so this patch is not needed in newer versions of meson and does not need to be upstreamed. Fixes https://gitlab.freedesktop.org/gstreamer/cerbero/issues/162 Also reported at https://gitlab.freedesktop.org/gstreamer/cerbero/merge_requests/210
-rw-r--r--recipes/build-tools/meson.recipe2
-rw-r--r--recipes/build-tools/meson/0001-ninja-backend-Quote-args-to-compiler-rules.patch31
-rw-r--r--recipes/glib.recipe7
3 files changed, 39 insertions, 1 deletions
diff --git a/recipes/build-tools/meson.recipe b/recipes/build-tools/meson.recipe
index 85fc65d2..fb473e6e 100644
--- a/recipes/build-tools/meson.recipe
+++ b/recipes/build-tools/meson.recipe
@@ -23,6 +23,8 @@ class Recipe(recipe.Recipe):
'meson/0001-meson-Add-a-quick-hack-to-support-VS2019.patch',
# https://github.com/mesonbuild/meson/pull/5517, in 0.51.1
'meson/0001-compilers-Fix-bitcode-and-other-options-for-objc-cod.patch',
+ # Not needed with 0.50, code changed
+ 'meson/0001-ninja-backend-Quote-args-to-compiler-rules.patch',
]
deps = ['ninja']
diff --git a/recipes/build-tools/meson/0001-ninja-backend-Quote-args-to-compiler-rules.patch b/recipes/build-tools/meson/0001-ninja-backend-Quote-args-to-compiler-rules.patch
new file mode 100644
index 00000000..226f8ccc
--- /dev/null
+++ b/recipes/build-tools/meson/0001-ninja-backend-Quote-args-to-compiler-rules.patch
@@ -0,0 +1,31 @@
+From e61d4cbbc9c67416af83e812606b6ef7bcb79eab Mon Sep 17 00:00:00 2001
+From: Nirbheek Chauhan <nirbheek@centricular.com>
+Date: Tue, 25 Jun 2019 10:24:43 +0530
+Subject: [PATCH] ninja backend: Quote args to compiler rules
+
+These must be quoted in the same way as args in each compile line.
+This is not needed in 0.50 anymore because we don't add compiler args
+directly to the compiler rule there.
+
+This is needed to correctly quote arguments added through c_args in
+the cross file.
+---
+ mesonbuild/backend/ninjabackend.py | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
+index f49649be..de178b38 100644
+--- a/mesonbuild/backend/ninjabackend.py
++++ b/mesonbuild/backend/ninjabackend.py
+@@ -1599,7 +1599,7 @@ rule FORTRAN_DEP_HACK%s
+ command_template = ' command = {executable} $ARGS {cross_args} {dep_args} {output_args} {compile_only_args} $in\n'
+ command = command_template.format(
+ executable=' '.join([ninja_quote(i) for i in compiler.get_exelist()]),
+- cross_args=' '.join(cross_args),
++ cross_args=' '.join([quote_func(i) for i in cross_args]),
+ dep_args=' '.join(quoted_depargs),
+ output_args=' '.join(compiler.get_output_args('$out')),
+ compile_only_args=' '.join(compiler.get_compile_only_args())
+--
+2.21.0
+
diff --git a/recipes/glib.recipe b/recipes/glib.recipe
index 68891ace..718b1101 100644
--- a/recipes/glib.recipe
+++ b/recipes/glib.recipe
@@ -1,4 +1,5 @@
# -*- Mode: Python -*- vi:si:et:sw=4:sts=4:ts=4:syntax=python
+import shlex
import shutil
from cerbero.errors import FatalError
from cerbero.tools.libtool import LibtoolLibrary
@@ -105,7 +106,11 @@ class Recipe(recipe.Recipe):
def _gio_flags(self, path1=None, path2=None, use_old_uri_scheme=False):
flags = []
def escape(path):
- return '\\"%s\\"' % path
+ # We want the define the macro to a C string, then we quote it
+ # because it is expanded inside cerbero to set c_args in the cross
+ # file or to pass directly to meson using the env var for native
+ # builds
+ return shlex.quote('"{}"'.format(path))
if path1 is not None:
flags.append('-DGST_SDK_GLIB_GIO_DISTRO_GIO_MODULE_PATH=' + escape(path1))
if path2 is not None: