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

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

Issue 2827793005: Get Proguard flags from GMS clients (upstream part) (Closed)
Patch Set: absolute GN paths 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..16fd3c46764585455c2ae5fd377eeba76c4beba8 100755
--- a/build/android/play_services/preprocess.py
+++ b/build/android/play_services/preprocess.py
@@ -35,6 +35,7 @@ import shutil
import stat
import sys
import tempfile
+import textwrap
import zipfile
sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir))
@@ -55,11 +56,21 @@ def main():
'location'),
required=True,
metavar='FILE')
+ required_args.add_argument('-d',
+ '--root-dir',
+ help='the directory which GN considers the root',
+ required=True,
+ metavar='FILE')
required_args.add_argument('-o',
'--out-dir',
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',
@@ -73,11 +84,14 @@ def main():
args = parser.parse_args()
return ProcessGooglePlayServices(args.repository,
+ args.root_dir,
args.out_dir,
+ args.gni_out_file,
args.config_file)
-def ProcessGooglePlayServices(repo, out_dir, config_path):
+def ProcessGooglePlayServices(
+ repo, root_dir, out_dir, gni_out_file, config_path):
config = utils.ConfigParser(config_path)
tmp_root = tempfile.mkdtemp()
@@ -86,6 +100,7 @@ def ProcessGooglePlayServices(repo, out_dir, config_path):
_ImportFromExtractedRepo(config, tmp_paths, repo)
_ProcessResources(config, tmp_paths, repo)
_CopyToOutput(tmp_paths, out_dir)
+ _EnumerateProguardFiles(root_dir, out_dir, gni_out_file)
_UpdateVersionInConfig(config, tmp_paths)
finally:
shutil.rmtree(tmp_root)
@@ -187,6 +202,37 @@ def _CopyToOutput(tmp_paths, out_dir):
shutil.copytree(tmp_paths['imported_clients'], out_dir)
+# Write a GN file containing a list of each GMS client's proguard file (if any).
+def _EnumerateProguardFiles(root_dir, out_dir, gni_path):
+ gni_dir = os.path.dirname(gni_path)
+ gni_template = textwrap.dedent('''\
+ # 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}
+ ]
+ ''')
+
+ 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)):
+ rooted_path = os.path.relpath(proguard_path, root_dir)
+ gni_lines.append(' "//{}",'.format(rooted_path))
+ 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)
« 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