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 import os | 5 import os |
6 import re | 6 import re |
7 from util import build_utils | 7 from util import build_utils |
8 | 8 |
9 | 9 |
10 class _ProguardOutputFilter(object): | 10 class _ProguardOutputFilter(object): |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 self.build() | 144 self.build() |
145 inputs = [self._proguard_jar_path] + self._configs + self._injars | 145 inputs = [self._proguard_jar_path] + self._configs + self._injars |
146 if self._mapping: | 146 if self._mapping: |
147 inputs.append(self._mapping) | 147 inputs.append(self._mapping) |
148 if self._libraries: | 148 if self._libraries: |
149 inputs += self._libraries | 149 inputs += self._libraries |
150 if self._tested_apk_info_path: | 150 if self._tested_apk_info_path: |
151 inputs += [self._tested_apk_info_path] | 151 inputs += [self._tested_apk_info_path] |
152 return inputs | 152 return inputs |
153 | 153 |
| 154 def _WriteFlagsFile(self, out): |
| 155 # Quite useful for auditing proguard flags. |
| 156 for config in self._configs: |
| 157 out.write('#' * 80 + '\n') |
| 158 out.write(config + '\n') |
| 159 out.write('#' * 80 + '\n') |
| 160 with open(config) as config_file: |
| 161 out.write(config_file.read().rstrip()) |
| 162 out.write('\n\n') |
| 163 out.write('#' * 80 + '\n') |
| 164 out.write('Command-line\n') |
| 165 out.write('#' * 80 + '\n') |
| 166 out.write(' '.join(self._cmd) + '\n') |
154 | 167 |
155 def CheckOutput(self): | 168 def CheckOutput(self): |
156 self.build() | 169 self.build() |
157 # Proguard will skip writing these files if they would be empty. Create | 170 # Proguard will skip writing these files if they would be empty. Create |
158 # empty versions of them all now so that they are updated as the build | 171 # empty versions of them all now so that they are updated as the build |
159 # expects. | 172 # expects. |
160 open(self._outjar + '.seeds', 'w').close() | 173 open(self._outjar + '.seeds', 'w').close() |
161 open(self._outjar + '.usage', 'w').close() | 174 open(self._outjar + '.usage', 'w').close() |
162 open(self._outjar + '.mapping', 'w').close() | 175 open(self._outjar + '.mapping', 'w').close() |
| 176 |
| 177 with open(self._outjar + '.flags', 'w') as out: |
| 178 self._WriteFlagsFile(out) |
| 179 |
163 # Warning: and Error: are sent to stderr, but messages and Note: are sent | 180 # Warning: and Error: are sent to stderr, but messages and Note: are sent |
164 # to stdout. | 181 # to stdout. |
165 stdout_filter = None | 182 stdout_filter = None |
166 stderr_filter = None | 183 stderr_filter = None |
167 if not self._verbose: | 184 if not self._verbose: |
168 stdout_filter = _ProguardOutputFilter() | 185 stdout_filter = _ProguardOutputFilter() |
169 stderr_filter = _ProguardOutputFilter() | 186 stderr_filter = _ProguardOutputFilter() |
170 build_utils.CheckOutput(self._cmd, print_stdout=True, | 187 build_utils.CheckOutput(self._cmd, print_stdout=True, |
171 print_stderr=True, | 188 print_stderr=True, |
172 stdout_filter=stdout_filter, | 189 stdout_filter=stdout_filter, |
173 stderr_filter=stderr_filter) | 190 stderr_filter=stderr_filter) |
174 | 191 |
175 this_info = { | 192 this_info = { |
176 'inputs': self._injars, | 193 'inputs': self._injars, |
177 'configs': self._configs, | 194 'configs': self._configs, |
178 'mapping': self._outjar + '.mapping', | 195 'mapping': self._outjar + '.mapping', |
179 } | 196 } |
180 | 197 |
181 build_utils.WriteJson(this_info, self._outjar + '.info') | 198 build_utils.WriteJson(this_info, self._outjar + '.info') |
182 | 199 |
OLD | NEW |