Bug 1408675 p4. Set per-directory include paths for Eclipse CDT. r=botond
authorJonathan Watt <jwatt@jwatt.org>
Wed, 31 Oct 2018 17:49:22 +0000
changeset 503555 300e5ba9c14285bd5c5db15bb365287e1de8c1b9
parent 503554 9797d26fd00e11add5a6d941f0f9e4a0486f5180
child 503556 81b77c4f014e368ae8fb20bde050ddeef1357195
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbotond
bugs1408675
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1408675 p4. Set per-directory include paths for Eclipse CDT. r=botond Differential Revision: https://phabricator.services.mozilla.com/D12011
python/mozbuild/mozbuild/backend/cpp_eclipse.py
--- a/python/mozbuild/mozbuild/backend/cpp_eclipse.py
+++ b/python/mozbuild/mozbuild/backend/cpp_eclipse.py
@@ -33,17 +33,17 @@ class CppEclipseBackend(CommonBackend):
         if os.name == 'nt':
             raise Exception('Eclipse is not supported on Windows. '
                             'Consider using Visual Studio instead.')
         super(CppEclipseBackend, self).__init__(environment)
 
     def _init(self):
         CommonBackend._init(self)
 
-        self._paths_to_defines = {}
+        self._args_for_dirs = {}
         self._project_name = 'Gecko'
         self._workspace_dir = self._get_workspace_path()
         self._project_dir = os.path.join(self._workspace_dir, self._project_name)
         self._overwriting_workspace = os.path.isdir(self._workspace_dir)
 
         self._macbundle = self.environment.substs['MOZ_MACBUNDLE_NAME']
         self._appname = self.environment.substs['MOZ_APP_NAME']
         self._bin_suffix = self.environment.substs['BIN_SUFFIX']
@@ -74,17 +74,25 @@ class CppEclipseBackend(CommonBackend):
         return os.path.join(srcdir_parent, workspace_dirname)
 
     def consume_object(self, obj):
         reldir = getattr(obj, 'relsrcdir', None)
 
         # Note that unlike VS, Eclipse' indexer seem to crawl the headers and
         # isn't picky about the local includes.
         if isinstance(obj, ComputedFlags):
-            defs = self._paths_to_defines.setdefault(reldir, [])
+            args = self._args_for_dirs.setdefault(reldir, {'includes': [], 'defines': []})
+
+            includes = args["includes"]
+            if "BASE_INCLUDES" in obj.flags and obj.flags["BASE_INCLUDES"]:
+                includes += obj.flags["BASE_INCLUDES"]
+            if "LOCAL_INCLUDES" in obj.flags and obj.flags["LOCAL_INCLUDES"]:
+                includes += obj.flags["LOCAL_INCLUDES"]
+
+            defs = args["defines"]
             if "DEFINES" in obj.flags and obj.flags["DEFINES"]:
                 defs += obj.flags["DEFINES"]
             if "LIBRARY_DEFINES" in obj.flags and obj.flags["LIBRARY_DEFINES"]:
                 defs += obj.flags["LIBRARY_DEFINES"]
 
         return True
 
     def consume_finished(self):
@@ -201,16 +209,20 @@ class CppEclipseBackend(CommonBackend):
         # This may fail if the entire tree has been removed; that's fine.
         try:
             os.remove(noindex_path)
         except OSError as e:
             if e.errno != errno.ENOENT:
                 raise
 
     def _write_language_settings(self, fh):
+        def add_abs_include_path(absinclude):
+            assert(absinclude[:3] == "-I/")
+            return LANGUAGE_SETTINGS_TEMPLATE_DIR_INCLUDE.replace("@INCLUDE_PATH@", absinclude[2:])
+
         def add_objdir_include_path(relpath):
             p = os.path.join(self.environment.topobjdir, relpath)
             return LANGUAGE_SETTINGS_TEMPLATE_DIR_INCLUDE.replace("@INCLUDE_PATH@", p)
 
         def add_define(name, value):
             define = LANGUAGE_SETTINGS_TEMPLATE_DIR_DEFINE
             define = define.replace("@NAME@", name)
             # We use quoteattr here because some defines contain characters
@@ -262,20 +274,22 @@ class CppEclipseBackend(CommonBackend):
         #
         # TODO: Investigate whether the ordering of directories in the project
         # file can be used to our advantage so that the first indexing of
         # important headers has the defines we want.
         #
         dirsettings_template += add_objdir_include_path('ipc/ipdl/_ipdlheaders')
         dirsettings_template += add_define('MOZILLA_INTERNAL_API', '1')
 
-        for path, defines in self._paths_to_defines.items():
+        for path, args in self._args_for_dirs.items():
             dirsettings = dirsettings_template
             dirsettings = dirsettings.replace('@RELATIVE_PATH@', path)
-            for d in defines:
+            for i in args["includes"]:
+                dirsettings += add_abs_include_path(i)
+            for d in args["defines"]:
                 assert(d[:2] == u"-D" or d[:2] == u"-U")
                 if d[:2] == u"-U":
                     # gfx/harfbuzz/src uses -UDEBUG, at least on Mac
                     # netwerk/sctp/src uses -U__APPLE__ on Mac
                     # XXX We should make this code smart enough to remove existing defines.
                     continue
                 d = d[2:] # get rid of leading "-D"
                 name_value = d.split("=", 1)