OLD | NEW |
1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 ''' | 5 ''' |
6 Utility functions for all things related to manipulating google play services | 6 Utility functions for all things related to manipulating google play services |
7 related files. | 7 related files. |
8 ''' | 8 ''' |
9 | 9 |
10 import argparse | 10 import argparse |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 Should be relative to the library base directory | 58 Should be relative to the library base directory |
59 Example: "res/values/version.xml" | 59 Example: "res/values/version.xml" |
60 | 60 |
61 - locale_whitelist | 61 - locale_whitelist |
62 List of strings. List of locales to keep from the resources. Can be | 62 List of strings. List of locales to keep from the resources. Can be |
63 obtained by generating an android build and looking at the content of | 63 obtained by generating an android build and looking at the content of |
64 `out/Debug/gen/chrome/java/res`; or looking at the android section in | 64 `out/Debug/gen/chrome/java/res`; or looking at the android section in |
65 `//chrome/app/generated_resources.grd` | 65 `//chrome/app/generated_resources.grd` |
66 Example: ["am", "ar", "bg", "ca", "cs"] | 66 Example: ["am", "ar", "bg", "ca", "cs"] |
67 | 67 |
| 68 - resource_whitelist |
| 69 List of strings. List of resource files to explicitely keep in the final |
| 70 output. Use it to keep drawables for example, as we currently remove them |
| 71 all. |
| 72 Example: ["play-services-base/res/drawables/foobar.xml"] |
68 ''' | 73 ''' |
69 _VERSION_NUMBER_KEY = 'version_number' | 74 _VERSION_NUMBER_KEY = 'version_number' |
70 | 75 |
71 def __init__(self, path): | 76 def __init__(self, path): |
72 self.path = path | 77 self.path = path |
73 self._data = {} | 78 self._data = {} |
74 | 79 |
75 with open(path, 'r') as stream: | 80 with open(path, 'r') as stream: |
76 self._data = json.load(stream) | 81 self._data = json.load(stream) |
77 | 82 |
(...skipping 10 matching lines...) Expand all Loading... |
88 return self._data.get('clients') or [] | 93 return self._data.get('clients') or [] |
89 | 94 |
90 @property | 95 @property |
91 def version_xml_path(self): | 96 def version_xml_path(self): |
92 return self._data.get('version_xml_path') | 97 return self._data.get('version_xml_path') |
93 | 98 |
94 @property | 99 @property |
95 def locale_whitelist(self): | 100 def locale_whitelist(self): |
96 return self._data.get('locale_whitelist') or [] | 101 return self._data.get('locale_whitelist') or [] |
97 | 102 |
| 103 @property |
| 104 def resource_whitelist(self): |
| 105 return self._data.get('resource_whitelist') or [] |
| 106 |
98 def UpdateVersionNumber(self, new_version_number): | 107 def UpdateVersionNumber(self, new_version_number): |
99 '''Updates the version number and saves it in the configuration file. ''' | 108 '''Updates the version number and saves it in the configuration file. ''' |
100 | 109 |
101 with open(self.path, 'w') as stream: | 110 with open(self.path, 'w') as stream: |
102 self._data[self._VERSION_NUMBER_KEY] = new_version_number | 111 self._data[self._VERSION_NUMBER_KEY] = new_version_number |
103 stream.write(DumpTrimmedJson(self._data)) | 112 stream.write(DumpTrimmedJson(self._data)) |
104 | 113 |
105 | 114 |
106 def DumpTrimmedJson(json_data): | 115 def DumpTrimmedJson(json_data): |
107 ''' | 116 ''' |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 def MakeLocalCommit(repo_root, files_to_commit, message): | 161 def MakeLocalCommit(repo_root, files_to_commit, message): |
153 '''Makes a local git commit.''' | 162 '''Makes a local git commit.''' |
154 | 163 |
155 logging.debug('Staging files (%s) for commit.', files_to_commit) | 164 logging.debug('Staging files (%s) for commit.', files_to_commit) |
156 if cmd_helper.Call(['git', 'add'] + files_to_commit, cwd=repo_root) != 0: | 165 if cmd_helper.Call(['git', 'add'] + files_to_commit, cwd=repo_root) != 0: |
157 raise Exception('The local commit failed.') | 166 raise Exception('The local commit failed.') |
158 | 167 |
159 logging.debug('Committing.') | 168 logging.debug('Committing.') |
160 if cmd_helper.Call(['git', 'commit', '-m', message], cwd=repo_root) != 0: | 169 if cmd_helper.Call(['git', 'commit', '-m', message], cwd=repo_root) != 0: |
161 raise Exception('The local commit failed.') | 170 raise Exception('The local commit failed.') |
OLD | NEW |