OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright 2014 The Chromium Authors. All rights reserved. | 3 # Copyright 2014 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 """ | 7 """ |
8 Release: | 8 Release: |
9 - Concatenates autostart modules, application modules' module.json descriptors
, | 9 - Concatenates autostart modules, application modules' module.json descriptors
, |
10 and the application loader into a single script. | 10 and the application loader into a single script. |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 | 93 |
94 # Outputs: | 94 # Outputs: |
95 # <app_name>.html | 95 # <app_name>.html |
96 # <app_name>.js | 96 # <app_name>.js |
97 # <module_name>_module.js | 97 # <module_name>_module.js |
98 class ReleaseBuilder(AppBuilder): | 98 class ReleaseBuilder(AppBuilder): |
99 def __init__(self, application_name, descriptors, application_dir, output_di
r): | 99 def __init__(self, application_name, descriptors, application_dir, output_di
r): |
100 AppBuilder.__init__(self, application_name, descriptors, application_dir
, output_dir) | 100 AppBuilder.__init__(self, application_name, descriptors, application_dir
, output_dir) |
101 | 101 |
102 def build_app(self): | 102 def build_app(self): |
103 for module in self.descriptors.application.values(): | |
104 if 'type' in module and module['type'] == 'remoteInRelease': | |
105 module['type'] = 'remote' | |
106 if self.descriptors.has_html: | 103 if self.descriptors.has_html: |
107 self._build_html() | 104 self._build_html() |
108 self._build_app_script() | 105 self._build_app_script() |
109 for module in filter(lambda desc: (not desc.get('type') or desc.get('typ
e') == 'remote'), self.descriptors.application.values()): | 106 for module in filter(lambda desc: (not desc.get('type') or desc.get('typ
e') == 'remote'), self.descriptors.application.values()): |
110 self._concatenate_dynamic_module(module['name']) | 107 self._concatenate_dynamic_module(module['name']) |
111 | 108 |
112 def _build_html(self): | 109 def _build_html(self): |
113 html_name = self.app_file('html') | 110 html_name = self.app_file('html') |
114 output = StringIO() | 111 output = StringIO() |
115 with open(join(self.application_dir, html_name), 'r') as app_input_html: | 112 with open(join(self.application_dir, html_name), 'r') as app_input_html: |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 symlink_or_copy_file(join(os.getcwd(), self.application_dir, html_name),
join(self.output_dir, html_name), True) | 238 symlink_or_copy_file(join(os.getcwd(), self.application_dir, html_name),
join(self.output_dir, html_name), True) |
242 | 239 |
243 | 240 |
244 def build_application(application_name, loader, application_dir, output_dir, rel
ease_mode): | 241 def build_application(application_name, loader, application_dir, output_dir, rel
ease_mode): |
245 descriptors = loader.load_application(application_name + '.json') | 242 descriptors = loader.load_application(application_name + '.json') |
246 if release_mode: | 243 if release_mode: |
247 builder = ReleaseBuilder(application_name, descriptors, application_dir,
output_dir) | 244 builder = ReleaseBuilder(application_name, descriptors, application_dir,
output_dir) |
248 else: | 245 else: |
249 builder = DebugBuilder(application_name, descriptors, application_dir, o
utput_dir) | 246 builder = DebugBuilder(application_name, descriptors, application_dir, o
utput_dir) |
250 builder.build_app() | 247 builder.build_app() |
OLD | NEW |