Bug 1224452 - Quote passthru variables. r=gps

Ideally, we should properly make and shell quote everything we print out
in makefiles, but that's a can of worms I don't want to open just yet. So
I'll limit myself to just passthru variables.
This commit is contained in:
Mike Hommey 2015-11-20 17:24:25 +09:00
parent dcfc35f1b9
commit b5c0f9f920
4 changed files with 12 additions and 6 deletions

View File

@ -111,4 +111,4 @@ if CONFIG['CPU_ARCH'] == 'arm' and CONFIG['GNU_AS']:
# Suppress warnings in third-party code.
if CONFIG['GNU_CC']:
if CONFIG['CLANG_CXX']:
CFLAGS += ['-Wno-\#pragma-messages']
CFLAGS += ['-Wno-#pragma-messages']

View File

@ -77,6 +77,7 @@ from ..util import (
FileAvoidWrite,
)
from ..makeutil import Makefile
from mozbuild.shellutil import quote as shell_quote
MOZBUILD_VARIABLES = [
b'ANDROID_APK_NAME',
@ -169,6 +170,10 @@ DEPRECATED_VARIABLES_MESSAGE = (
)
def make_quote(s):
return s.replace('#', '\#').replace('$', '$$')
class BackendMakeFile(object):
"""Represents a generated backend.mk file.
@ -494,7 +499,8 @@ class RecursiveMakeBackend(CommonBackend):
for k, v in sorted(obj.variables.items()):
if isinstance(v, list):
for item in v:
backend_file.write('%s += %s\n' % (k, item))
backend_file.write(
'%s += %s\n' % (k, make_quote(shell_quote(item))))
elif isinstance(v, bool):
if v:
backend_file.write('%s := 1\n' % k)

View File

@ -17,8 +17,8 @@ DEFFILE = 'baz.def'
USE_STATIC_LIBS = True
CFLAGS += ['-fno-exceptions', '-w']
CXXFLAGS += ['-fcxx-exceptions', '-include foo.h']
LDFLAGS += ['-framework Foo', '-x']
CXXFLAGS += ['-fcxx-exceptions', '-option with spaces']
LDFLAGS += ['-ld flag with spaces', '-x']
HOST_CFLAGS += ['-funroll-loops', '-wall']
HOST_CXXFLAGS += ['-funroll-loops-harder', '-wall-day-everyday']
WIN32_EXE_LDFLAGS += ['-subsystem:console']

View File

@ -299,10 +299,10 @@ class TestRecursiveMakeBackend(BackendTester):
],
'MOZBUILD_CXXFLAGS': [
'MOZBUILD_CXXFLAGS += -fcxx-exceptions',
'MOZBUILD_CXXFLAGS += -include foo.h',
"MOZBUILD_CXXFLAGS += '-option with spaces'",
],
'MOZBUILD_LDFLAGS': [
'MOZBUILD_LDFLAGS += -framework Foo',
"MOZBUILD_LDFLAGS += '-ld flag with spaces'",
'MOZBUILD_LDFLAGS += -x',
'MOZBUILD_LDFLAGS += -DELAYLOAD:foo.dll',
'MOZBUILD_LDFLAGS += -DELAYLOAD:bar.dll',