Index: remoting/webapp/build-webapp.py |
diff --git a/remoting/webapp/build-webapp.py b/remoting/webapp/build-webapp.py |
index 833e1f3ead52e6bde15223ae3576f37e9a90e5d0..b7b87dccf911dcab13df9534bd139051b8ea0b59 100755 |
--- a/remoting/webapp/build-webapp.py |
+++ b/remoting/webapp/build-webapp.py |
@@ -78,7 +78,7 @@ def processJinjaTemplate(input_file, include_paths, output_file, context): |
Jamie
2015/02/03 18:06:24
I think this blank line should stay, because it se
|
def buildWebApp(buildtype, version, destination, zip_path, |
manifest_template, webapp_type, app_id, app_name, |
- app_description, files, locales, jinja_paths, |
+ app_description, app_features, files, locales, jinja_paths, |
service_environment): |
"""Does the main work of building the webapp directory and zipfile. |
@@ -95,6 +95,8 @@ def buildWebApp(buildtype, version, destination, zip_path, |
test API server. |
app_name: A string with the name of the application. |
app_description: A string with the description of the application. |
+ app_features: A set of strings naming the features that should be enabled |
+ for this application. |
files: An array of strings listing the paths for resources to include |
in this webapp. |
locales: An array of strings listing locales, which are copied, along |
@@ -218,6 +220,7 @@ def buildWebApp(buildtype, version, destination, zip_path, |
findAndReplace(os.path.join(destination, 'plugin_settings.js'), |
"'APP_REMOTING_APPLICATION_ID'", appRemotingApplicationId) |
+ |
Jamie
2015/02/02 22:57:47
No need for an extra blank line here (IIRC, that c
garykac
2015/02/03 01:50:21
I fixed this locally but forgot to upload. grr.
|
oauth2BaseUrl = oauth2AccountsHost + '/o/oauth2' |
oauth2ApiBaseUrl = oauth2ApiHost + '/oauth2' |
directoryApiBaseUrl = directoryApiHost + '/chromoting/v1' |
@@ -316,6 +319,11 @@ def buildWebApp(buildtype, version, destination, zip_path, |
replaceString(destination, 'API_CLIENT_ID', apiClientId) |
replaceString(destination, 'API_CLIENT_SECRET', apiClientSecret) |
+ # Write the application features. |
+ appFeatures = ''.join(["'" + x + "'" for x in app_features]) |
+ findAndReplace(os.path.join(destination, 'app_features.js'), |
+ "'APPLICATION_FEATURES'", appFeatures) |
+ |
# Use a consistent extension id for dev builds. |
# AppRemoting builds always use the dev app id - the correct app id gets |
# written into the manifest later. |
@@ -342,7 +350,11 @@ def buildWebApp(buildtype, version, destination, zip_path, |
'GOOGLE_API_HOSTS': googleApiHosts, |
'APP_NAME': app_name, |
'APP_DESCRIPTION': app_description, |
+ 'OAUTH_GDRIVE_SCOPE': '', |
} |
+ if 'gdrive' in app_features: |
+ context['OAUTH_GDRIVE_SCOPE'] = ('https://docs.google.com/feeds/ ' |
+ 'https://www.googleapis.com/auth/drive') |
processJinjaTemplate(manifest_template, |
jinja_paths, |
os.path.join(destination, 'manifest.json'), |
@@ -355,16 +367,20 @@ def buildWebApp(buildtype, version, destination, zip_path, |
def main(): |
+ valid_app_features = ['cast', 'gdrive'] |
Jamie
2015/02/02 22:57:47
If you use an enumerated type, you can get rid of
garykac
2015/02/03 01:50:21
Done.
|
+ |
if len(sys.argv) < 6: |
print ('Usage: build-webapp.py ' |
'<build-type> <version> <dst> <zip-path> <manifest_template> ' |
'<webapp_type> <other files...> ' |
'--app_name <name> ' |
'--app_description <description> ' |
+ '--app_features <features...> ' |
'[--appid <appid>] ' |
'[--locales <locales...>] ' |
'[--jinja_paths <paths...>] ' |
'[--service_environment <service_environment>]') |
+ print 'Where <features> are', valid_app_features |
return 1 |
arg_type = '' |
@@ -374,6 +390,7 @@ def main(): |
app_id = None |
app_name = None |
app_description = None |
+ app_features = set([]) |
service_environment = '' |
for arg in sys.argv[7:]: |
@@ -382,6 +399,7 @@ def main(): |
'--appid', |
'--app_name', |
'--app_description', |
+ '--app_features', |
'--service_environment']: |
arg_type = arg |
elif arg_type == '--locales': |
@@ -397,6 +415,11 @@ def main(): |
elif arg_type == '--app_description': |
app_description = arg |
arg_type = '' |
+ elif arg_type == '--app_features': |
+ if arg in valid_app_features: |
+ app_features.add(arg) |
+ else: |
+ raise Exception('Invalid app_feature: ' + arg) |
elif arg_type == '--service_environment': |
service_environment = arg |
arg_type = '' |
@@ -405,8 +428,8 @@ def main(): |
return buildWebApp(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], |
sys.argv[5], sys.argv[6], app_id, app_name, |
- app_description, files, locales, jinja_paths, |
- service_environment) |
+ app_description, app_features, files, locales, |
+ jinja_paths, service_environment) |
if __name__ == '__main__': |