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

Unified Diff: build/android/play_services/preprocess.py

Issue 2827793005: Get Proguard flags from GMS clients (upstream part) (Closed)
Patch Set: . Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..1b6898cd662af82afeef829ba1ee2148e342eb83 100755
--- a/build/android/play_services/preprocess.py
+++ b/build/android/play_services/preprocess.py
@@ -28,6 +28,7 @@ provided output directory.
'''
import argparse
+import datetime
import glob
import itertools
import os
@@ -60,6 +61,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 +80,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 +93,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 +195,39 @@ def _CopyToOutput(tmp_paths, out_dir):
shutil.copytree(tmp_paths['imported_clients'], out_dir)
+gni_template = '''\
+# Copyright {year} The Chromium Authors. All rights reserved.
Maria 2017/04/19 18:20:22 not sure that year should be computed. Generally c
paulmiller 2017/04/19 18:34:27 Done.
+# 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)
+ gni_lines.append(' "' + relative + '",')
+ gni_lines.sort()
+
+ gni_text = gni_template.format(
+ year=datetime.datetime.now().year,
+ 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)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698