Index: build/android/play_services/preprocess.py |
diff --git a/build/android/play_services/preprocess.py b/build/android/play_services/preprocess.py |
index b14ffad8b271023f46a260424fe7583209686faf..3f54329b8ad502037dc845ae965a211f765729f0 100755 |
--- a/build/android/play_services/preprocess.py |
+++ b/build/android/play_services/preprocess.py |
@@ -60,6 +60,11 @@ def main(): |
help='the output directory', |
required=True, |
metavar='FILE') |
+ required_args.add_argument('-g', |
+ '--gni-out-file', |
+ help='the GN output file', |
+ required=True, |
+ metavar='FILE') |
required_args.add_argument('-c', |
'--config-file', |
help='the config file path', |
@@ -74,10 +79,11 @@ def main(): |
return ProcessGooglePlayServices(args.repository, |
args.out_dir, |
+ args.gni_out_file, |
args.config_file) |
-def ProcessGooglePlayServices(repo, out_dir, config_path): |
+def ProcessGooglePlayServices(repo, out_dir, gni_out_file, config_path): |
config = utils.ConfigParser(config_path) |
tmp_root = tempfile.mkdtemp() |
@@ -86,6 +92,7 @@ def ProcessGooglePlayServices(repo, out_dir, config_path): |
_ImportFromExtractedRepo(config, tmp_paths, repo) |
_ProcessResources(config, tmp_paths, repo) |
_CopyToOutput(tmp_paths, out_dir) |
+ _EnumerateProguardFiles(gni_out_file, out_dir) |
_UpdateVersionInConfig(config, tmp_paths) |
finally: |
shutil.rmtree(tmp_root) |
@@ -187,6 +194,38 @@ def _CopyToOutput(tmp_paths, out_dir): |
shutil.copytree(tmp_paths['imported_clients'], out_dir) |
+gni_template = '''\ |
jbudorick
2017/04/19 18:42:26
nits: _GNI_TEMPLATE + use textwrap.dedent + indent
paulmiller
2017/04/19 21:28:10
Thanks, I didn't know about dedent. But if I can i
jbudorick
2017/04/19 21:29:46
heh, it's at least a reminder to people working in
|
+# Copyright 2017 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 generated by {script} |
+gms_proguard_configs = [ |
+{body} |
+] |
+''' |
+ |
+# Write a GN file containing a list of each GMS client's proguard file (if any). |
+def _EnumerateProguardFiles(gni_path, out_dir): |
+ gni_dir = os.path.dirname(gni_path) |
+ |
+ gni_lines = [] |
+ for client_dir in os.listdir(out_dir): |
+ proguard_path = os.path.join( |
+ out_dir, client_dir, 'proguard.txt') |
+ if os.path.exists(os.path.dirname(proguard_path)): |
+ relative = os.path.relpath(proguard_path, gni_dir) |
jbudorick
2017/04/19 18:42:26
I'm a bit concerned about the case in which out_di
paulmiller
2017/04/19 21:28:10
I'll make the paths absolute, then.
|
+ gni_lines.append(' "' + relative + '",') |
jbudorick
2017/04/19 18:42:26
nit: instead of the string appends, do
gni_lines
paulmiller
2017/04/19 21:28:10
Done.
|
+ gni_lines.sort() |
+ |
+ gni_text = gni_template.format( |
+ script=os.path.relpath(sys.argv[0], gni_dir), |
+ body='\n'.join(gni_lines)) |
+ |
+ with open(gni_path, 'w') as gni_file: |
+ gni_file.write(gni_text) |
+ |
+ |
def _UpdateVersionInConfig(config, tmp_paths): |
version_xml_path = os.path.join(tmp_paths['imported_clients'], |
config.version_xml_path) |