Bug 1143932 - Factor out programs processing code from emit_from_context; r=gps
authorMs2ger <ms2ger@gmail.com>
Tue, 17 Mar 2015 10:36:55 +0100
changeset 251100 7ea00e33ac0228fc273f4eb24c6bc46471f84828
parent 251099 4a493366d2e9be256ac507e98b3a93f48728f57b
child 251101 9e27b05b961f0ec67a33b9ecf261c2672ca695fd
push id1096
push userbcampen@mozilla.com
push dateTue, 17 Mar 2015 18:28:18 +0000
reviewersgps
bugs1143932
milestone39.0a1
Bug 1143932 - Factor out programs processing code from emit_from_context; r=gps
python/mozbuild/mozbuild/frontend/emitter.py
--- a/python/mozbuild/mozbuild/frontend/emitter.py
+++ b/python/mozbuild/mozbuild/frontend/emitter.py
@@ -643,43 +643,17 @@ class TreeMetadataEmitter(LoggingMixin):
 
         resources = context.get('RESOURCE_FILES')
         if resources:
             yield Resources(context, resources, defines)
 
         for pref in sorted(context['JS_PREFERENCE_FILES']):
             yield JsPreferenceFile(context, pref)
 
-        for kind, cls in [('PROGRAM', Program), ('HOST_PROGRAM', HostProgram)]:
-            program = context.get(kind)
-            if program:
-                if program in self._binaries:
-                    raise SandboxValidationError(
-                        'Cannot use "%s" as %s name, '
-                        'because it is already used in %s' % (program, kind,
-                        self._binaries[program].relativedir), context)
-                self._binaries[program] = cls(context, program)
-                self._linkage.append((context, self._binaries[program],
-                    kind.replace('PROGRAM', 'USE_LIBS')))
-
-        for kind, cls in [
-                ('SIMPLE_PROGRAMS', SimpleProgram),
-                ('CPP_UNIT_TESTS', SimpleProgram),
-                ('HOST_SIMPLE_PROGRAMS', HostSimpleProgram)]:
-            for program in context[kind]:
-                if program in self._binaries:
-                    raise SandboxValidationError(
-                        'Cannot use "%s" in %s, '
-                        'because it is already used in %s' % (program, kind,
-                        self._binaries[program].relativedir), context)
-                self._binaries[program] = cls(context, program,
-                    is_unit_test=kind == 'CPP_UNIT_TESTS')
-                self._linkage.append((context, self._binaries[program],
-                    'HOST_USE_LIBS' if kind == 'HOST_SIMPLE_PROGRAMS'
-                    else 'USE_LIBS'))
+        self._handle_programs(context)
 
         extra_js_modules = context.get('EXTRA_JS_MODULES')
         if extra_js_modules:
             yield JavaScriptModules(context, extra_js_modules, 'extra')
 
         extra_pp_js_modules = context.get('EXTRA_PP_JS_MODULES')
         if extra_pp_js_modules:
             yield JavaScriptModules(context, extra_pp_js_modules, 'extra_pp')
@@ -861,16 +835,45 @@ class TreeMetadataEmitter(LoggingMixin):
                             'Input for generating %s does not exist: %s'
                             % (f, i), context)
             else:
                 script = None
                 method = None
                 inputs = []
             yield GeneratedFile(context, script, method, output, inputs)
 
+    def _handle_programs(self, context):
+        for kind, cls in [('PROGRAM', Program), ('HOST_PROGRAM', HostProgram)]:
+            program = context.get(kind)
+            if program:
+                if program in self._binaries:
+                    raise SandboxValidationError(
+                        'Cannot use "%s" as %s name, '
+                        'because it is already used in %s' % (program, kind,
+                        self._binaries[program].relativedir), context)
+                self._binaries[program] = cls(context, program)
+                self._linkage.append((context, self._binaries[program],
+                    kind.replace('PROGRAM', 'USE_LIBS')))
+
+        for kind, cls in [
+                ('SIMPLE_PROGRAMS', SimpleProgram),
+                ('CPP_UNIT_TESTS', SimpleProgram),
+                ('HOST_SIMPLE_PROGRAMS', HostSimpleProgram)]:
+            for program in context[kind]:
+                if program in self._binaries:
+                    raise SandboxValidationError(
+                        'Cannot use "%s" in %s, '
+                        'because it is already used in %s' % (program, kind,
+                        self._binaries[program].relativedir), context)
+                self._binaries[program] = cls(context, program,
+                    is_unit_test=kind == 'CPP_UNIT_TESTS')
+                self._linkage.append((context, self._binaries[program],
+                    'HOST_USE_LIBS' if kind == 'HOST_SIMPLE_PROGRAMS'
+                    else 'USE_LIBS'))
+
     def _process_test_manifests(self, context):
         # While there are multiple test manifests, the behavior is very similar
         # across them. We enforce this by having common handling of all
         # manifests and outputting a single class type with the differences
         # described inside the instance.
         #
         # Keys are variable prefixes and values are tuples describing how these
         # manifests should be handled: