| Index: build/android/gyp/java_google_api_keys.py
|
| diff --git a/build/android/gyp/java_google_api_keys.py b/build/android/gyp/java_google_api_keys.py
|
| new file mode 100755
|
| index 0000000000000000000000000000000000000000..e95b43ebeb0e032cc24988b61dba41b9b56f12c2
|
| --- /dev/null
|
| +++ b/build/android/gyp/java_google_api_keys.py
|
| @@ -0,0 +1,84 @@
|
| +#!/usr/bin/env python
|
| +#
|
| +# Copyright 2015 The Chromium Authors. All rights reserved.
|
| +# Use of this source code is governed by a BSD-style license that can be
|
| +# found in the LICENSE file.
|
| +
|
| +# Generates a Java file with API keys.
|
| +
|
| +import os
|
| +from string import Template
|
| +import sys
|
| +
|
| +sys.path.append(
|
| + os.path.abspath(os.path.join(sys.path[0], '../../../google_apis')))
|
| +from google_api_keys import (GetAPIKey, GetAPIKeyRemoting, GetClientID,
|
| + GetClientSecret)
|
| +
|
| +def GetScriptName():
|
| + script_components = os.path.abspath(sys.argv[0]).split(os.path.sep)
|
| + build_index = script_components.index('build')
|
| + return os.sep.join(script_components[build_index:])
|
| +
|
| +def GenerateOutput(constant_definitions):
|
| + template = Template("""
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +// This file is autogenerated by
|
| +// ${SCRIPT_NAME}
|
| +// From
|
| +// ${SOURCE_PATH}
|
| +
|
| +package ${PACKAGE};
|
| +
|
| +public class ${CLASS_NAME} {
|
| +${CONSTANT_ENTRIES}
|
| +}
|
| +""")
|
| +
|
| + constant_template = Template(
|
| + ' public static final String ${NAME} = "${VALUE}";')
|
| + constant_entries_string = []
|
| + for constant_name, constant_value in constant_definitions.iteritems():
|
| + values = {
|
| + 'NAME': constant_name,
|
| + 'VALUE': constant_value,
|
| + }
|
| + constant_entries_string.append(constant_template.substitute(values))
|
| + constant_entries_string = '\n'.join(constant_entries_string)
|
| +
|
| + values = {
|
| + 'CLASS_NAME': 'GoogleAPIKeys',
|
| + 'CONSTANT_ENTRIES': constant_entries_string,
|
| + 'PACKAGE': 'org.chromium.chrome',
|
| + 'SCRIPT_NAME': GetScriptName(),
|
| + 'SOURCE_PATH': 'google_api_keys/google_api_keys.h',
|
| + }
|
| + return template.substitute(values)
|
| +
|
| +def DoWriteOutput(output_path, constant_definition):
|
| + with open(output_path + os.path.sep + 'GoogleAPIKeys.java', 'w') as out_file:
|
| + out_file.write(GenerateOutput(constant_definition))
|
| +
|
| +def DoMain(argv):
|
| + values = {}
|
| + values['GOOGLE_API_KEY'] = GetAPIKey()
|
| + values['GOOGLE_API_KEY_REMOTING'] = GetAPIKeyRemoting()
|
| + values['GOOGLE_CLIENT_ID_MAIN'] = GetClientID('MAIN')
|
| + values['GOOGLE_CLIENT_SECRET_MAIN'] = GetClientSecret('MAIN')
|
| + values['GOOGLE_CLIENT_ID_CLOUD_PRINT'] = GetClientID('CLOUD_PRINT')
|
| + values['GOOGLE_CLIENT_SECRET_CLOUD_PRINT'] = GetClientSecret('CLOUD_PRINT')
|
| + values['GOOGLE_CLIENT_ID_REMOTING'] = GetClientID('REMOTING')
|
| + values['GOOGLE_CLIENT_SECRET_REMOTING'] = GetClientSecret('REMOTING')
|
| + values['GOOGLE_CLIENT_ID_REMOTING_HOST'] = GetClientID('REMOTING_HOST')
|
| + values['GOOGLE_CLIENT_SECRET_REMOTING_HOST'] = GetClientSecret(
|
| + 'REMOTING_HOST')
|
| + values['GOOGLE_CLIENT_ID_REMOTING_IDENTITY_API'] = GetClientID(
|
| + 'REMOTING_IDENTITY_API')
|
| + DoWriteOutput(argv[0], values)
|
| +
|
| +if __name__ == '__main__':
|
| + DoMain(sys.argv[1:])
|
| +
|
|
|