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

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

Issue 1452843002: Use hermetic timestamps in apkbuilder.py and refactor helper function (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 1 month 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 | « build/android/gyp/java_cpp_enum.py ('k') | build/android/gyp/util/build_utils.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright 2015 The Chromium Authors. All rights reserved. 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 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 # Generates a Java file with API keys. 7 # Generates a Java file with API keys.
8 8
9 import argparse 9 import argparse
10 import os 10 import os
11 import string 11 import string
12 import sys 12 import sys
13 import zipfile 13 import zipfile
14 14
15 from util import build_utils
16
15 sys.path.append( 17 sys.path.append(
16 os.path.abspath(os.path.join(sys.path[0], '../../../google_apis'))) 18 os.path.abspath(os.path.join(sys.path[0], '../../../google_apis')))
17 import google_api_keys 19 import google_api_keys
18 20
19 sys.path.append(os.path.abspath(os.path.join( 21 sys.path.append(os.path.abspath(os.path.join(
20 os.path.dirname(__file__), os.pardir))) 22 os.path.dirname(__file__), os.pardir)))
21 from pylib import constants 23 from pylib import constants
22 24
23 25
24 PACKAGE = 'org.chromium.chrome' 26 PACKAGE = 'org.chromium.chrome'
25 CLASSNAME = 'GoogleAPIKeys' 27 CLASSNAME = 'GoogleAPIKeys'
26 HERMETIC_TIMESTAMP = (2001, 1, 1, 0, 0, 0)
27 HERMETIC_FILE_ATTR = (0644 << 16L)
28 28
29 29
30 def GetScriptName(): 30 def GetScriptName():
31 return os.path.relpath(__file__, constants.DIR_SOURCE_ROOT) 31 return os.path.relpath(__file__, constants.DIR_SOURCE_ROOT)
32 32
33 33
34 def GenerateOutput(constant_definitions): 34 def GenerateOutput(constant_definitions):
35 template = string.Template(""" 35 template = string.Template("""
36 // Copyright 2015 The Chromium Authors. All rights reserved. 36 // Copyright 2015 The Chromium Authors. All rights reserved.
37 // Use of this source code is governed by a BSD-style license that can be 37 // Use of this source code is governed by a BSD-style license that can be
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 with open(output_path, 'w') as out_file: 77 with open(output_path, 'w') as out_file:
78 out_file.write(GenerateOutput(constant_definition)) 78 out_file.write(GenerateOutput(constant_definition))
79 79
80 80
81 def _DoWriteJarOutput(output_path, constant_definition): 81 def _DoWriteJarOutput(output_path, constant_definition):
82 folder = os.path.dirname(output_path) 82 folder = os.path.dirname(output_path)
83 if folder and not os.path.exists(folder): 83 if folder and not os.path.exists(folder):
84 os.makedirs(folder) 84 os.makedirs(folder)
85 with zipfile.ZipFile(output_path, 'w') as srcjar: 85 with zipfile.ZipFile(output_path, 'w') as srcjar:
86 path = '%s/%s' % (PACKAGE.replace('.', '/'), CLASSNAME + '.java') 86 path = '%s/%s' % (PACKAGE.replace('.', '/'), CLASSNAME + '.java')
87 zipinfo = zipfile.ZipInfo(filename=path, 87 data = GenerateOutput(constant_definition)
88 date_time=HERMETIC_TIMESTAMP) 88 build_utils.AddToZipHermetic(srcjar, path, data=data)
89 zipinfo.external_attr = HERMETIC_FILE_ATTR
90 srcjar.writestr(zipinfo, GenerateOutput(constant_definition))
91 89
92 90
93 def _DoMain(argv): 91 def _DoMain(argv):
94 parser = argparse.ArgumentParser() 92 parser = argparse.ArgumentParser()
95 parser.add_argument("--out", help="Path for java output.") 93 parser.add_argument("--out", help="Path for java output.")
96 parser.add_argument("--srcjar", help="Path for srcjar output.") 94 parser.add_argument("--srcjar", help="Path for srcjar output.")
97 options = parser.parse_args(argv) 95 options = parser.parse_args(argv)
98 if not options.out and not options.srcjar: 96 if not options.out and not options.srcjar:
99 parser.print_help() 97 parser.print_help()
100 sys.exit(-1) 98 sys.exit(-1)
(...skipping 21 matching lines...) Expand all
122 120
123 if options.out: 121 if options.out:
124 _DoWriteJavaOutput(options.out, values) 122 _DoWriteJavaOutput(options.out, values)
125 if options.srcjar: 123 if options.srcjar:
126 _DoWriteJarOutput(options.srcjar, values) 124 _DoWriteJarOutput(options.srcjar, values)
127 125
128 126
129 if __name__ == '__main__': 127 if __name__ == '__main__':
130 _DoMain(sys.argv[1:]) 128 _DoMain(sys.argv[1:])
131 129
OLDNEW
« no previous file with comments | « build/android/gyp/java_cpp_enum.py ('k') | build/android/gyp/util/build_utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698