Move includes associated with CPP_UNIT_TESTS to the CppUnitTests template. draft
authorChris Manchester <cmanchester@mozilla.com>
Thu, 17 Aug 2017 16:05:02 -0700
changeset 648552 686561e3335b7bbfbde3f38aa85069ae73bf7810
parent 648551 fb0682de85ec4a032fcd7d9d025fef8fd75b2959
child 726855 984dc44ce6fff051f07d37eff8a97175d8c25c54
push id74790
push userbmo:cmanchester@mozilla.com
push dateThu, 17 Aug 2017 23:05:10 +0000
milestone57.0a1
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,19 @@ 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.
     '''
+    dist_include_testing = '-I%s/dist/include/testing' % TOPOBJDIR
+    if dist_include_testing not in COMPILE_FLAGS['EXTRA_INCLUDES']:
+        COMPILE_FLAGS['EXTRA_INCLUDES'] += [dist_include_testing]
     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
@@ -1025,22 +1025,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),