Chromium Code Reviews| Index: Source/devtools/scripts/modular_build.py |
| diff --git a/Source/devtools/scripts/modular_build.py b/Source/devtools/scripts/modular_build.py |
| index f3dd6999b1b6027780828954ea24a61205bdcebe..1aef6b10823c4d71e935be8115d5e042cf48b09b 100755 |
| --- a/Source/devtools/scripts/modular_build.py |
| +++ b/Source/devtools/scripts/modular_build.py |
| @@ -44,13 +44,15 @@ def concatenate_scripts(file_names, module_dir, output_dir, output): |
| class Descriptors: |
| - def __init__(self, application_dir, application_descriptor, module_descriptors, application_json): |
| + def __init__(self, application_dir, application_descriptor, module_descriptors): |
| self.application_dir = application_dir |
| self.application = application_descriptor |
| self.modules = module_descriptors |
| - self.application_json = application_json |
| self._cached_sorted_modules = None |
| + def application_json(self): |
| + return json.dumps(self.application.values()) |
| + |
| def all_compiled_files(self): |
| files = {} |
| for name in self.modules: |
| @@ -63,7 +65,7 @@ class Descriptors: |
| def module_compiled_files(self, name): |
| files = [] |
| - module = self.modules[name] |
| + module = self.modules.get(name) |
| skipped_files = set(module.get('skip_compilation', [])) |
| for script in module.get('scripts', []): |
| if script not in skipped_files: |
| @@ -133,23 +135,32 @@ class DescriptorLoader: |
| self.application_dir = application_dir |
| def load_application(self, application_descriptor_name): |
| - application_descriptor_filename = path.join(self.application_dir, application_descriptor_name) |
| - application_descriptor_json = read_file(application_descriptor_filename) |
| - application_descriptor = {desc['name']: desc for desc in json.loads(application_descriptor_json)} |
| - |
| - module_descriptors = {} |
| - for (module_name, module) in application_descriptor.items(): |
| - if module_descriptors.get(module_name): |
| - bail_error('Duplicate definition of module "%s" in %s' % (module_name, application_descriptor_filename)) |
| - module_json_filename = path.join(self.application_dir, module_name, 'module.json') |
| - module_descriptors[module_name] = self._read_module_descriptor(module_name, application_descriptor_filename) |
| - |
| - for module in module_descriptors.values(): |
| - deps = module.get('dependencies', []) |
| - for dep in deps: |
| - if dep not in application_descriptor: |
| - bail_error('Module "%s" (dependency of "%s") not listed in application descriptor %s' % (dep, module['name'], application_descriptor_filename)) |
| - return Descriptors(self.application_dir, application_descriptor, module_descriptors, application_descriptor_json) |
| + return self.load_applications([application_descriptor_name]) |
| + |
| + def load_applications(self, application_descriptor_names): |
| + merged_application_descriptor = {} |
| + all_module_descriptors = {} |
| + for application_descriptor_name in application_descriptor_names: |
| + module_descriptors = {} |
| + application_descriptor_filename = path.join(self.application_dir, application_descriptor_name) |
| + application_descriptor_json = read_file(application_descriptor_filename) |
| + application_descriptor = {desc['name']: desc for desc in json.loads(application_descriptor_json)} |
| + for name in application_descriptor: |
| + merged_application_descriptor[name] = application_descriptor[name] |
| + |
| + for (module_name, module) in application_descriptor.items(): |
| + if module_descriptors.get(module_name): |
| + bail_error('Duplicate definition of module "%s" in %s' % (module_name, application_descriptor_filename)) |
| + module_descriptors[module_name] = self._read_module_descriptor(module_name, application_descriptor_filename) |
|
dgozman
2014/10/22 12:48:24
Let's not load the same module twice?
if not all_m
apavlov
2014/10/22 13:14:20
Done.
|
| + all_module_descriptors[module_name] = module_descriptors[module_name] |
| + |
| + for module in module_descriptors.values(): |
| + deps = module.get('dependencies', []) |
| + for dep in deps: |
| + if dep not in application_descriptor: |
| + bail_error('Module "%s" (dependency of "%s") not listed in application descriptor %s' % (dep, module['name'], application_descriptor_filename)) |
| + |
| + return Descriptors(self.application_dir, merged_application_descriptor, all_module_descriptors) |
| def _read_module_descriptor(self, module_name, application_descriptor_filename): |
| json_filename = path.join(self.application_dir, module_name, 'module.json') |