| 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 files_listfile: The name of a file containing a list of files, one per | 138 files_listfile: The name of a file containing a list of files, one per |
| 139 line, identifying the resources to include in this webapp. | 139 line, identifying the resources to include in this webapp. |
| 140 This is an alternate to specifying the files directly via | 140 This is an alternate to specifying the files directly via |
| 141 the 'files' option. The files listed in this file are | 141 the 'files' option. The files listed in this file are |
| 142 appended to the files passed via the 'files' option, if any. | 142 appended to the files passed via the 'files' option, if any. |
| 143 locales_listfile: The name of a file containing a list of locales, one per | 143 locales_listfile: The name of a file containing a list of locales, one per |
| 144 line, which are copied, along with their directory | 144 line, which are copied, along with their directory |
| 145 structure, from the _locales directory down. | 145 structure, from the _locales directory down. |
| 146 jinja_paths: An array of paths to search for {%include} directives in | 146 jinja_paths: An array of paths to search for {%include} directives in |
| 147 addition to the directory containing the manifest template. | 147 addition to the directory containing the manifest template. |
| 148 service_environment: Used to point the webapp to one of the | 148 service_environment: Used to point the webapp to the dev/prod environments. |
| 149 dev/test/staging/vendor/prod/prod-testing environments | |
| 150 use_gcd: True if GCD support should be enabled. | 149 use_gcd: True if GCD support should be enabled. |
| 151 """ | 150 """ |
| 152 | 151 |
| 153 # Load the locales files from the locales_listfile. | 152 # Load the locales files from the locales_listfile. |
| 154 if not locales_listfile: | 153 if not locales_listfile: |
| 155 raise Exception('You must specify a locales_listfile') | 154 raise Exception('You must specify a locales_listfile') |
| 156 locales = [] | 155 locales = [] |
| 157 with open(locales_listfile) as input: | 156 with open(locales_listfile) as input: |
| 158 for s in input: | 157 for s in input: |
| 159 locales.append(s.rstrip()) | 158 locales.append(s.rstrip()) |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 elif extension == '.pak': | 210 elif extension == '.pak': |
| 212 destination_file = os.path.join(remoting_locales, | 211 destination_file = os.path.join(remoting_locales, |
| 213 os.path.split(current_locale)[1]) | 212 os.path.split(current_locale)[1]) |
| 214 shutil.copy2(current_locale, destination_file) | 213 shutil.copy2(current_locale, destination_file) |
| 215 else: | 214 else: |
| 216 raise Exception('Unknown extension: ' + current_locale) | 215 raise Exception('Unknown extension: ' + current_locale) |
| 217 | 216 |
| 218 is_app_remoting_webapp = webapp_type == 'app_remoting' | 217 is_app_remoting_webapp = webapp_type == 'app_remoting' |
| 219 is_app_remoting_shared_module = webapp_type == 'shared_module' | 218 is_app_remoting_shared_module = webapp_type == 'shared_module' |
| 220 is_app_remoting = is_app_remoting_webapp or is_app_remoting_shared_module | 219 is_app_remoting = is_app_remoting_webapp or is_app_remoting_shared_module |
| 221 is_prod_service_environment = service_environment == 'vendor' or \ | 220 is_prod_service_environment = service_environment == 'prod' |
| 222 service_environment == 'prod' or \ | |
| 223 service_environment == 'prod-testing' | |
| 224 is_desktop_remoting = not is_app_remoting | 221 is_desktop_remoting = not is_app_remoting |
| 225 | 222 |
| 226 # Allow host names for google services/apis to be overriden via env vars. | 223 # Allow host names for google services/apis to be overriden via env vars. |
| 227 oauth2AccountsHost = os.environ.get( | 224 oauth2AccountsHost = os.environ.get( |
| 228 'OAUTH2_ACCOUNTS_HOST', 'https://accounts.google.com') | 225 'OAUTH2_ACCOUNTS_HOST', 'https://accounts.google.com') |
| 229 oauth2ApiHost = os.environ.get( | 226 oauth2ApiHost = os.environ.get( |
| 230 'OAUTH2_API_HOST', 'https://www.googleapis.com') | 227 'OAUTH2_API_HOST', 'https://www.googleapis.com') |
| 231 directoryApiHost = os.environ.get( | 228 directoryApiHost = os.environ.get( |
| 232 'DIRECTORY_API_HOST', 'https://www.googleapis.com') | 229 'DIRECTORY_API_HOST', 'https://www.googleapis.com') |
| 233 remotingApiHost = os.environ.get( | 230 remotingApiHost = os.environ.get( |
| 234 'REMOTING_API_HOST', 'https://remoting-pa.googleapis.com') | 231 'REMOTING_API_HOST', 'https://remoting-pa.googleapis.com') |
| 235 | 232 |
| 236 if is_app_remoting: | 233 if is_app_remoting: |
| 237 appRemotingApiHost = os.environ.get( | 234 appRemotingApiHost = os.environ.get( |
| 238 'APP_REMOTING_API_HOST', None) | 235 'APP_REMOTING_API_HOST', None) |
| 239 | 236 |
| 240 if is_app_remoting_webapp: | 237 if is_app_remoting_webapp: |
| 241 appRemotingApplicationId = os.environ.get( | 238 appRemotingApplicationId = os.environ.get( |
| 242 'APP_REMOTING_APPLICATION_ID', None) | 239 'APP_REMOTING_APPLICATION_ID', None) |
| 243 | 240 |
| 244 # Release/Official builds are special because they are what we will upload | 241 # Release/Official builds are special because they are what we will upload |
| 245 # to the web store. The checks below will validate that prod builds are | 242 # to the web store. The checks below will validate that prod builds are |
| 246 # being generated correctly (no overrides) and with the correct buildtype. | 243 # being generated correctly (no overrides) and with the correct buildtype. |
| 247 # They also verify that folks are not accidentally building dev/test/staging | 244 # They also verify that folks are not accidentally building dev apps for |
| 248 # apps for release (no impersonation) instead of dev. | 245 # Release (no impersonation) instead of Dev. |
| 249 if is_prod_service_environment and buildtype == 'Dev': | 246 if is_prod_service_environment and buildtype == 'Dev': |
| 250 raise Exception("Prod environment cannot be built for 'dev' builds") | 247 raise Exception("Prod environment cannot be built for 'dev' builds") |
| 251 | 248 |
| 252 if buildtype != 'Dev': | 249 if buildtype != 'Dev': |
| 253 if not is_prod_service_environment: | 250 if not is_prod_service_environment: |
| 254 raise Exception('Invalid service_environment targeted for ' | 251 raise Exception('Invalid service_environment targeted for ' |
| 255 + buildtype + ': ' + service_environment) | 252 + buildtype + ': ' + service_environment) |
| 256 if appid != None: | 253 if appid != None: |
| 257 raise Exception('Cannot pass in an appid for ' | 254 raise Exception('Cannot pass in an appid for ' |
| 258 + buildtype + ' builds: ' + service_environment) | 255 + buildtype + ' builds: ' + service_environment) |
| (...skipping 13 matching lines...) Expand all Loading... |
| 272 appRemotingApplicationId = "chrome.i18n.getMessage('@@extension_id')" | 269 appRemotingApplicationId = "chrome.i18n.getMessage('@@extension_id')" |
| 273 findAndReplace(os.path.join(destination, 'arv_main.js'), | 270 findAndReplace(os.path.join(destination, 'arv_main.js'), |
| 274 "'APP_REMOTING_APPLICATION_ID'", appRemotingApplicationId) | 271 "'APP_REMOTING_APPLICATION_ID'", appRemotingApplicationId) |
| 275 | 272 |
| 276 oauth2BaseUrl = oauth2AccountsHost + '/o/oauth2' | 273 oauth2BaseUrl = oauth2AccountsHost + '/o/oauth2' |
| 277 oauth2ApiBaseUrl = oauth2ApiHost + '/oauth2' | 274 oauth2ApiBaseUrl = oauth2ApiHost + '/oauth2' |
| 278 directoryApiBaseUrl = directoryApiHost + '/chromoting/v1' | 275 directoryApiBaseUrl = directoryApiHost + '/chromoting/v1' |
| 279 telemetryApiBaseUrl = remotingApiHost + '/v1/events' | 276 telemetryApiBaseUrl = remotingApiHost + '/v1/events' |
| 280 | 277 |
| 281 if is_app_remoting: | 278 if is_app_remoting: |
| 282 # Set the apiary endpoint and then set the endpoint version | 279 # Set the base endpoint url first and then set the endpoint version. |
| 283 if not appRemotingApiHost: | 280 if not appRemotingApiHost: |
| 284 if is_prod_service_environment: | 281 if is_prod_service_environment: |
| 285 appRemotingApiHost = 'https://www.googleapis.com' | 282 appRemotingApiHost = 'https://www.googleapis.com' |
| 286 else: | 283 else: |
| 287 appRemotingApiHost = 'https://www-googleapis-test.sandbox.google.com' | 284 appRemotingApiHost = 'https://www-googleapis-test.sandbox.google.com' |
| 288 | 285 |
| 289 # TODO(garykac) Currently, the shared module is always set up for the | 286 # TODO(garykac) Currently, the shared module is always set up for the |
| 290 # dev service_environment. Update build so that the dev environment can | 287 # dev service_environment. Update build so that the dev environment can |
| 291 # be controlled by the app stub rather than hard-coded into the shared | 288 # be controlled by the app stub rather than hard-coded into the shared |
| 292 # module. | 289 # module. |
| 293 if service_environment == 'dev' or is_app_remoting_shared_module: | 290 if service_environment == 'dev' or is_app_remoting_shared_module: |
| 294 appRemotingServicePath = '/appremoting/v1beta1_dev' | 291 appRemotingServicePath = '/appremoting/v1beta1_dev' |
| 295 elif service_environment == 'test': | |
| 296 appRemotingServicePath = '/appremoting/v1beta1' | |
| 297 elif service_environment == 'staging': | |
| 298 appRemotingServicePath = '/appremoting/v1beta1_staging' | |
| 299 elif service_environment == 'vendor': | |
| 300 appRemotingServicePath = '/appremoting/v1beta1_vendor' | |
| 301 elif service_environment == 'prod': | 292 elif service_environment == 'prod': |
| 302 appRemotingServicePath = '/appremoting/v1beta1' | 293 appRemotingServicePath = '/appremoting/v1beta1' |
| 303 elif service_environment == 'prod-testing': | |
| 304 appRemotingServicePath = '/appremoting/v1beta1_prod_testing' | |
| 305 else: | 294 else: |
| 306 raise Exception('Unknown service environment: ' + service_environment) | 295 raise Exception('Unknown service environment: ' + service_environment) |
| 307 appRemotingApiBaseUrl = appRemotingApiHost + appRemotingServicePath | 296 appRemotingApiBaseUrl = appRemotingApiHost + appRemotingServicePath |
| 308 else: | 297 else: |
| 309 appRemotingApiBaseUrl = '' | 298 appRemotingApiBaseUrl = '' |
| 310 | 299 |
| 311 # TODO(garykac) replaceString (et al.) implictly update plugin_settings.js, | 300 # TODO(garykac) replaceString (et al.) implictly update plugin_settings.js, |
| 312 # which doesn't exist for the app stub. We need to move app-specific | 301 # which doesn't exist for the app stub. We need to move app-specific |
| 313 # AppRemoting options into arv_main.js. | 302 # AppRemoting options into arv_main.js. |
| 314 if not is_app_remoting_webapp: | 303 if not is_app_remoting_webapp: |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 parser.add_argument('--use_gcd', choices=['0', '1'], default='0') | 473 parser.add_argument('--use_gcd', choices=['0', '1'], default='0') |
| 485 | 474 |
| 486 args = parser.parse_args() | 475 args = parser.parse_args() |
| 487 args.use_gcd = (args.use_gcd != '0') | 476 args.use_gcd = (args.use_gcd != '0') |
| 488 args.app_capabilities = set(args.app_capabilities) | 477 args.app_capabilities = set(args.app_capabilities) |
| 489 return buildWebApp(**vars(args)) | 478 return buildWebApp(**vars(args)) |
| 490 | 479 |
| 491 | 480 |
| 492 if __name__ == '__main__': | 481 if __name__ == '__main__': |
| 493 sys.exit(main()) | 482 sys.exit(main()) |
| OLD | NEW |