OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Creates a directory with with the unpacked contents of the remoting webapp. | 6 """Creates a directory with with the unpacked contents of the remoting webapp. |
7 | 7 |
8 The directory will contain a copy-of or a link-to to all remoting webapp | 8 The directory will contain a copy-of or a link-to to all remoting webapp |
9 resources. This includes HTML/JS and any plugin binaries. The script also | 9 resources. This includes HTML/JS and any plugin binaries. The script also |
10 massages resulting files appropriately with host plugin data. Finally, | 10 massages resulting files appropriately with host plugin data. Finally, |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 except OSError: | 110 except OSError: |
111 if os.path.exists(destination): | 111 if os.path.exists(destination): |
112 raise | 112 raise |
113 else: | 113 else: |
114 pass | 114 pass |
115 os.mkdir(destination, 0775) | 115 os.mkdir(destination, 0775) |
116 | 116 |
117 if buildtype != 'Official' and buildtype != 'Release' and buildtype != 'Dev': | 117 if buildtype != 'Official' and buildtype != 'Release' and buildtype != 'Dev': |
118 raise Exception('Unknown buildtype: ' + buildtype) | 118 raise Exception('Unknown buildtype: ' + buildtype) |
119 | 119 |
120 # Use symlinks on linux and mac for faster compile/edit cycle. | 120 jinja_context = { |
121 # | 121 'webapp_type': webapp_type, |
122 # On Windows Vista platform.system() can return 'Microsoft' with some | 122 'buildtype': buildtype, |
123 # versions of Python, see http://bugs.python.org/issue1082 | 123 } |
124 # should_symlink = platform.system() not in ['Windows', 'Microsoft'] | |
125 # | |
126 # TODO(ajwong): Pending decision on http://crbug.com/27185 we may not be | |
127 # able to load symlinked resources. | |
128 should_symlink = False | |
129 | 124 |
130 # Copy all the files. | 125 # Copy all the files. |
131 for current_file in files: | 126 for current_file in files: |
132 destination_file = os.path.join(destination, os.path.basename(current_file)) | 127 destination_file = os.path.join(destination, os.path.basename(current_file)) |
133 destination_dir = os.path.dirname(destination_file) | |
134 if not os.path.exists(destination_dir): | |
135 os.makedirs(destination_dir, 0775) | |
136 | 128 |
137 if should_symlink: | 129 # Process *.jinja2 files as jinja2 templates |
138 # TODO(ajwong): Detect if we're vista or higher. Then use win32file | 130 if current_file.endswith(".jinja2"): |
139 # to create a symlink in that case. | 131 destination_file = destination_file[:-len(".jinja2")] |
140 targetname = os.path.relpath(os.path.realpath(current_file), | 132 processJinjaTemplate(current_file, jinja_paths, |
141 os.path.realpath(destination_file)) | 133 destination_file, jinja_context) |
142 os.symlink(targetname, destination_file) | |
143 else: | 134 else: |
144 shutil.copy2(current_file, destination_file) | 135 shutil.copy2(current_file, destination_file) |
145 | 136 |
146 # Copy all the locales, preserving directory structure | 137 # Copy all the locales, preserving directory structure |
147 destination_locales = os.path.join(destination, '_locales') | 138 destination_locales = os.path.join(destination, '_locales') |
148 os.mkdir(destination_locales, 0775) | 139 os.mkdir(destination_locales, 0775) |
149 remoting_locales = os.path.join(destination, 'remoting_locales') | 140 remoting_locales = os.path.join(destination, 'remoting_locales') |
150 os.mkdir(remoting_locales, 0775) | 141 os.mkdir(remoting_locales, 0775) |
151 for current_locale in locales: | 142 for current_locale in locales: |
152 extension = os.path.splitext(current_locale)[1] | 143 extension = os.path.splitext(current_locale)[1] |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 files.append(arg) | 395 files.append(arg) |
405 | 396 |
406 return buildWebApp(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], | 397 return buildWebApp(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], |
407 sys.argv[5], sys.argv[6], app_id, app_name, | 398 sys.argv[5], sys.argv[6], app_id, app_name, |
408 app_description, files, locales, jinja_paths, | 399 app_description, files, locales, jinja_paths, |
409 service_environment) | 400 service_environment) |
410 | 401 |
411 | 402 |
412 if __name__ == '__main__': | 403 if __name__ == '__main__': |
413 sys.exit(main()) | 404 sys.exit(main()) |
OLD | NEW |