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 jinja_context = { | 120 # Use symlinks on linux and mac for faster compile/edit cycle. |
121 'webapp_type': webapp_type, | 121 # |
122 'buildtype': buildtype, | 122 # On Windows Vista platform.system() can return 'Microsoft' with some |
123 } | 123 # versions of Python, see http://bugs.python.org/issue1082 |
| 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 |
124 | 129 |
125 # Copy all the files. | 130 # Copy all the files. |
126 for current_file in files: | 131 for current_file in files: |
127 destination_file = os.path.join(destination, os.path.basename(current_file)) | 132 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) |
128 | 136 |
129 # Process *.jinja2 files as jinja2 templates | 137 if should_symlink: |
130 if current_file.endswith(".jinja2"): | 138 # TODO(ajwong): Detect if we're vista or higher. Then use win32file |
131 destination_file = destination_file[:-len(".jinja2")] | 139 # to create a symlink in that case. |
132 processJinjaTemplate(current_file, jinja_paths, | 140 targetname = os.path.relpath(os.path.realpath(current_file), |
133 destination_file, jinja_context) | 141 os.path.realpath(destination_file)) |
| 142 os.symlink(targetname, destination_file) |
134 else: | 143 else: |
135 shutil.copy2(current_file, destination_file) | 144 shutil.copy2(current_file, destination_file) |
136 | 145 |
137 # Copy all the locales, preserving directory structure | 146 # Copy all the locales, preserving directory structure |
138 destination_locales = os.path.join(destination, '_locales') | 147 destination_locales = os.path.join(destination, '_locales') |
139 os.mkdir(destination_locales, 0775) | 148 os.mkdir(destination_locales, 0775) |
140 remoting_locales = os.path.join(destination, 'remoting_locales') | 149 remoting_locales = os.path.join(destination, 'remoting_locales') |
141 os.mkdir(remoting_locales, 0775) | 150 os.mkdir(remoting_locales, 0775) |
142 for current_locale in locales: | 151 for current_locale in locales: |
143 extension = os.path.splitext(current_locale)[1] | 152 extension = os.path.splitext(current_locale)[1] |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 files.append(arg) | 404 files.append(arg) |
396 | 405 |
397 return buildWebApp(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], | 406 return buildWebApp(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], |
398 sys.argv[5], sys.argv[6], app_id, app_name, | 407 sys.argv[5], sys.argv[6], app_id, app_name, |
399 app_description, files, locales, jinja_paths, | 408 app_description, files, locales, jinja_paths, |
400 service_environment) | 409 service_environment) |
401 | 410 |
402 | 411 |
403 if __name__ == '__main__': | 412 if __name__ == '__main__': |
404 sys.exit(main()) | 413 sys.exit(main()) |
OLD | NEW |