Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1575)

Side by Side Diff: build/android/gyp/java_google_api_keys.py

Issue 1411913005: Make Google API keys available for the Java codebase (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | build/android/java_google_api_keys.gypi » ('j') | chrome/chrome_browser.gypi » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 #
3 # Copyright 2015 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
6
7 # Generates a Java file with API keys.
8
9 import os
10 from string import Template
11 import sys
12
13 sys.path.append(
14 os.path.abspath(os.path.join(sys.path[0], '../../../google_apis')))
15 from google_api_keys import (GetAPIKey, GetAPIKeyRemoting, GetClientID,
16 GetClientSecret)
17
18 def GetScriptName():
19 script_components = os.path.abspath(sys.argv[0]).split(os.path.sep)
20 build_index = script_components.index('build')
21 return os.sep.join(script_components[build_index:])
22
23 def GenerateOutput(constant_definitions):
24 template = Template("""
25 // Copyright 2015 The Chromium Authors. All rights reserved.
26 // Use of this source code is governed by a BSD-style license that can be
27 // found in the LICENSE file.
28
29 // This file is autogenerated by
30 // ${SCRIPT_NAME}
31 // From
32 // ${SOURCE_PATH}
33
34 package ${PACKAGE};
35
36 public class ${CLASS_NAME} {
37 ${CONSTANT_ENTRIES}
38 }
39 """)
40
41 constant_template = Template(
42 ' public static final String ${NAME} = "${VALUE}";')
43 constant_entries_string = []
44 for constant_name, constant_value in constant_definitions.iteritems():
45 values = {
46 'NAME': constant_name,
47 'VALUE': constant_value,
48 }
49 constant_entries_string.append(constant_template.substitute(values))
50 constant_entries_string = '\n'.join(constant_entries_string)
51
52 values = {
53 'CLASS_NAME': 'GoogleAPIKeys',
54 'CONSTANT_ENTRIES': constant_entries_string,
55 'PACKAGE': 'org.chromium.chrome',
56 'SCRIPT_NAME': GetScriptName(),
57 'SOURCE_PATH': 'google_api_keys/google_api_keys.h',
58 }
59 return template.substitute(values)
60
61 def DoWriteOutput(output_path, constant_definition):
62 with open(output_path + os.path.sep + 'GoogleAPIKeys.java', 'w') as out_file:
63 out_file.write(GenerateOutput(constant_definition))
64
65 def DoMain(argv):
66 values = {}
67 values['GOOGLE_API_KEY'] = GetAPIKey()
68 values['GOOGLE_API_KEY_REMOTING'] = GetAPIKeyRemoting()
69 values['GOOGLE_CLIENT_ID_MAIN'] = GetClientID('MAIN')
70 values['GOOGLE_CLIENT_SECRET_MAIN'] = GetClientSecret('MAIN')
71 values['GOOGLE_CLIENT_ID_CLOUD_PRINT'] = GetClientID('CLOUD_PRINT')
72 values['GOOGLE_CLIENT_SECRET_CLOUD_PRINT'] = GetClientSecret('CLOUD_PRINT')
73 values['GOOGLE_CLIENT_ID_REMOTING'] = GetClientID('REMOTING')
74 values['GOOGLE_CLIENT_SECRET_REMOTING'] = GetClientSecret('REMOTING')
75 values['GOOGLE_CLIENT_ID_REMOTING_HOST'] = GetClientID('REMOTING_HOST')
76 values['GOOGLE_CLIENT_SECRET_REMOTING_HOST'] = GetClientSecret(
77 'REMOTING_HOST')
78 values['GOOGLE_CLIENT_ID_REMOTING_IDENTITY_API'] = GetClientID(
79 'REMOTING_IDENTITY_API')
80 DoWriteOutput(argv[0], values)
81
82 if __name__ == '__main__':
83 DoMain(sys.argv[1:])
84
OLDNEW
« no previous file with comments | « no previous file | build/android/java_google_api_keys.gypi » ('j') | chrome/chrome_browser.gypi » ('J')

Powered by Google App Engine
This is Rietveld 408576698