Bug 1398897 - Move includes associated with CPP_UNIT_TESTS to the CppUnitTests template. draft
authorChris Manchester <cmanchester@mozilla.com>
Fri, 15 Sep 2017 11:49:07 -0700
changeset 665611 de15735b0d3cf331d2a4512b6feb7dc0705518d5
parent 665610 28ae08fe3db5bbb20c452a33e4118ed4ea28bd67
child 665612 0cf0f92e91e3390780aee4bcbf6c273a69bc46be
push id80119
push userbmo:cmanchester@mozilla.com
push dateFri, 15 Sep 2017 18:49:23 +0000
bugs1398897
milestone57.0a1
Bug 1398897 - Move includes associated with CPP_UNIT_TESTS to the CppUnitTests template. MozReview-Commit-ID: DhjnzhAjoyy
build/templates.mozbuild
python/mozbuild/mozbuild/frontend/emitter.py
--- a/build/templates.mozbuild
+++ b/build/templates.mozbuild
@@ -47,16 +47,18 @@ def SimplePrograms(names, ext='.cpp'):
 
 
 @template
 def CppUnitTests(names, ext='.cpp'):
     '''Template for C++ unit tests.
 
     Those have a single source with the same base name as the executable.
     '''
+    COMPILE_FLAGS['EXTRA_INCLUDES'] = ['-I%s/dist/include' % TOPOBJDIR,
+                                       '-I%s/dist/include/testing' % TOPOBJDIR]
     CPP_UNIT_TESTS += names
     SOURCES += ['%s%s' % (name, ext) for name in names]
 
     Binary()
 
 
 @template
 def Library(name):
--- a/python/mozbuild/mozbuild/frontend/emitter.py
+++ b/python/mozbuild/mozbuild/frontend/emitter.py
@@ -1029,22 +1029,16 @@ class TreeMetadataEmitter(LoggingMixin):
                     'does not exist: %s (resolved to %s)' % (local_include,
                     local_include.full_path), context)
             include_obj = LocalInclude(context, local_include)
             local_includes.append(include_obj.path.full_path)
             yield include_obj
 
         computed_flags.resolve_flags('LOCAL_INCLUDES', ['-I%s' % p for p in local_includes])
 
-        if len(context['CPP_UNIT_TESTS']):
-            # TODO: Move this to the CppUnitTests template.
-            dist_include_testing = mozpath.join(self.config.topobjdir,
-                                                'dist', 'include', 'testing')
-            computed_flags.flags['EXTRA_INCLUDES'].append('-I%s' % dist_include_testing)
-
         for obj in self._handle_linkables(context, passthru, generated_files):
             yield obj
 
         generated_files.update(['%s%s' % (k, self.config.substs.get('BIN_SUFFIX', '')) for k in self._binaries.keys()])
 
         components = []
         for var, cls in (
             ('BRANDING_FILES', BrandingFiles),