Bug 1235733 - Use absolute paths for include paths. r=gps

Limit ourselves to include paths for now, because there are tricky things
involved in making this globally.

While here, use shell_quote instead of manual quoting for those paths.
This commit is contained in:
Mike Hommey 2015-12-30 13:46:38 +09:00
parent 673e7f80f7
commit 122ab4c005
6 changed files with 33 additions and 23 deletions

View File

@ -287,9 +287,9 @@ CCC = $(CXX)
INCLUDES = \
-I$(srcdir) \
-I. \
-I$(CURDIR) \
$(LOCAL_INCLUDES) \
-I$(DIST)/include \
-I$(ABS_DIST)/include \
$(NULL)
ifndef IS_GYP_DIR

View File

@ -60,7 +60,7 @@ ifdef COMPILE_ENVIRONMENT
# through TestHarness.h, by modifying the list of includes and the libs against
# which stuff links.
SIMPLE_PROGRAMS += $(CPP_UNIT_TESTS)
INCLUDES += -I$(DIST)/include/testing
INCLUDES += -I$(ABS_DIST)/include/testing
ifndef MOZ_PROFILE_GENERATE
CPP_UNIT_TESTS_FILES = $(CPP_UNIT_TESTS)

View File

@ -1503,7 +1503,7 @@ if test "$GNU_CC"; then
esac
fi
_DEFINES_CFLAGS='-include $(DEPTH)/mozilla-config.h -DMOZILLA_CLIENT'
_DEFINES_CFLAGS='-include $(topobjdir)/mozilla-config.h -DMOZILLA_CLIENT'
_USE_CPP_INCLUDE_FLAG=1
ASFLAGS="$ASFLAGS $_DEFINES_CFLAGS"
@ -1607,7 +1607,7 @@ if test "$GNU_CXX"; then
esac
fi
_DEFINES_CXXFLAGS='-DMOZILLA_CLIENT -include $(DEPTH)/mozilla-config.h'
_DEFINES_CXXFLAGS='-DMOZILLA_CLIENT -include $(topobjdir)/mozilla-config.h'
_USE_CPP_INCLUDE_FLAG=1
# Recent clang and gcc support C++11 deleted functions without warnings if
@ -2215,8 +2215,8 @@ ia64*-hpux*)
WIN32_GUI_EXE_LDFLAGS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
DSO_LDOPTS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
_USE_CPP_INCLUDE_FLAG=1
_DEFINES_CFLAGS='-FI $(DEPTH)/dist/include/mozilla-config.h -DMOZILLA_CLIENT'
_DEFINES_CXXFLAGS='-FI $(DEPTH)/dist/include/mozilla-config.h -DMOZILLA_CLIENT'
_DEFINES_CFLAGS='-FI $(topobjdir)/mozilla-config.h -DMOZILLA_CLIENT'
_DEFINES_CXXFLAGS='-FI $(topobjdir)/mozilla-config.h -DMOZILLA_CLIENT'
CFLAGS="$CFLAGS -W3 -Gy"
CXXFLAGS="$CXXFLAGS -W3 -Gy"
if test "$CPU_ARCH" = "x86" -a -z "$CLANG_CL"; then

View File

@ -1272,7 +1272,7 @@ if test "$GNU_CC"; then
esac
fi
_DEFINES_CFLAGS='-include $(DEPTH)/js/src/js-confdefs.h -DMOZILLA_CLIENT'
_DEFINES_CFLAGS='-include $(topobjdir)/js/src/js-confdefs.h -DMOZILLA_CLIENT'
_USE_CPP_INCLUDE_FLAG=1
elif test "$SOLARIS_SUNPRO_CC"; then
@ -1384,7 +1384,7 @@ if test "$GNU_CXX"; then
esac
fi
_DEFINES_CXXFLAGS='-DMOZILLA_CLIENT -include $(DEPTH)/js/src/js-confdefs.h'
_DEFINES_CXXFLAGS='-DMOZILLA_CLIENT -include $(topobjdir)/js/src/js-confdefs.h'
_USE_CPP_INCLUDE_FLAG=1
# Recent clang and gcc support C++11 deleted functions without warnings if
@ -1744,8 +1744,8 @@ ia64*-hpux*)
WIN32_GUI_EXE_LDFLAGS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
DSO_LDOPTS=-SUBSYSTEM:WINDOWS,$WIN32_SUBSYSTEM_VERSION
_USE_CPP_INCLUDE_FLAG=1
_DEFINES_CFLAGS='-FI $(DEPTH)/js/src/js-confdefs.h -DMOZILLA_CLIENT'
_DEFINES_CXXFLAGS='-FI $(DEPTH)/js/src/js-confdefs.h -DMOZILLA_CLIENT'
_DEFINES_CFLAGS='-FI $(topobjdir)/js/src/js-confdefs.h -DMOZILLA_CLIENT'
_DEFINES_CXXFLAGS='-FI $(topobjdir)/js/src/js-confdefs.h -DMOZILLA_CLIENT'
CFLAGS="$CFLAGS -W3 -Gy"
CXXFLAGS="$CXXFLAGS -W3 -Gy"
if test "$CPU_ARCH" = "x86" -a -z "$CLANG_CL"; then

View File

@ -858,20 +858,23 @@ class RecursiveMakeBackend(CommonBackend):
ensureParentDir(mozpath.join(self.environment.topobjdir, 'dist', 'foo'))
def _pretty_path(self, path, backend_file):
def _pretty_path_parts(self, path, backend_file):
assert isinstance(path, Path)
if isinstance(path, SourcePath):
if path.full_path.startswith(backend_file.srcdir):
return '$(srcdir)' + path.full_path[len(backend_file.srcdir):]
return '$(srcdir)', path.full_path[len(backend_file.srcdir):]
if path.full_path.startswith(backend_file.topsrcdir):
return '$(topsrcdir)' + path.full_path[len(backend_file.topsrcdir):]
return '$(topsrcdir)', path.full_path[len(backend_file.topsrcdir):]
elif isinstance(path, ObjDirPath):
if path.full_path.startswith(backend_file.objdir):
return path.full_path[len(backend_file.objdir) + 1:]
return '', path.full_path[len(backend_file.objdir) + 1:]
if path.full_path.startswith(self.environment.topobjdir):
return '$(DEPTH)' + path.full_path[len(self.environment.topobjdir):]
return '$(DEPTH)', path.full_path[len(self.environment.topobjdir):]
return path.full_path
return '', path.full_path
def _pretty_path(self, path, backend_file):
return ''.join(self._pretty_path_parts(path, backend_file))
def _process_unified_sources(self, obj):
backend_file = self._get_backend_file_for(obj)
@ -1112,11 +1115,18 @@ INSTALL_TARGETS += %(prefix)s
self.backend_input_files |= obj.manifest.manifests
def _process_local_include(self, local_include, backend_file):
path = self._pretty_path(local_include, backend_file)
if ' ' in path:
backend_file.write('LOCAL_INCLUDES += -I\'%s\'\n' % path)
d, path = self._pretty_path_parts(local_include, backend_file)
if isinstance(local_include, ObjDirPath) and not d:
# path doesn't start with a slash in this case
d = '$(CURDIR)/'
elif d == '$(DEPTH)':
d = '$(topobjdir)'
quoted_path = shell_quote(path) if path else path
if quoted_path != path:
path = quoted_path[0] + d + quoted_path[1:]
else:
backend_file.write('LOCAL_INCLUDES += -I%s\n' % path)
path = d + path
backend_file.write('LOCAL_INCLUDES += -I%s\n' % path)
def _process_per_source_flag(self, per_source_flag, backend_file):
for flag in per_source_flag.flags:

View File

@ -657,8 +657,8 @@ class TestRecursiveMakeBackend(BackendTester):
topobjdir = env.topobjdir.replace('\\', '/')
expected = [
'LOCAL_INCLUDES += -Ibar/baz',
'LOCAL_INCLUDES += -Ifoo',
'LOCAL_INCLUDES += -I$(CURDIR)/bar/baz',
'LOCAL_INCLUDES += -I$(CURDIR)/foo',
]
found = [str for str in lines if str.startswith('LOCAL_INCLUDES')]