OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2016 The Chromium Authors. All rights reserved. | 2 # Copyright 2016 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Generates an Android Studio project from a GN target.""" | 6 """Generates an Android Studio project from a GN target.""" |
7 | 7 |
8 import argparse | 8 import argparse |
9 import codecs | 9 import codecs |
10 import logging | 10 import logging |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 | 108 |
109 def NinjaBuildConfigTarget(self): | 109 def NinjaBuildConfigTarget(self): |
110 return '%s__build_config' % self.NinjaTarget() | 110 return '%s__build_config' % self.NinjaTarget() |
111 | 111 |
112 def GradleSubdir(self): | 112 def GradleSubdir(self): |
113 """Returns the output subdirectory.""" | 113 """Returns the output subdirectory.""" |
114 return self.NinjaTarget().replace(':', os.path.sep) | 114 return self.NinjaTarget().replace(':', os.path.sep) |
115 | 115 |
116 def ProjectName(self): | 116 def ProjectName(self): |
117 """Returns the Gradle project name.""" | 117 """Returns the Gradle project name.""" |
118 return self.GradleSubdir().replace(os.path.sep, '\\$') | 118 return self.GradleSubdir().replace(os.path.sep, '>') |
119 | 119 |
120 def BuildConfig(self): | 120 def BuildConfig(self): |
121 """Reads and returns the project's .build_config JSON.""" | 121 """Reads and returns the project's .build_config JSON.""" |
122 if not self._build_config: | 122 if not self._build_config: |
123 path = os.path.join('gen', self.GradleSubdir() + '.build_config') | 123 path = os.path.join('gen', self.GradleSubdir() + '.build_config') |
124 self._build_config = build_utils.ReadJson(_RebasePath(path)) | 124 self._build_config = build_utils.ReadJson(_RebasePath(path)) |
125 return self._build_config | 125 return self._build_config |
126 | 126 |
127 | 127 |
128 def _ComputeJavaSourceDirs(java_files): | 128 def _ComputeJavaSourceDirs(java_files): |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 if srcjar_tuples: | 376 if srcjar_tuples: |
377 logging.warning('Building all .srcjar files...') | 377 logging.warning('Building all .srcjar files...') |
378 targets = _RebasePath([s[0] for s in srcjar_tuples], output_dir) | 378 targets = _RebasePath([s[0] for s in srcjar_tuples], output_dir) |
379 _RunNinja(output_dir, targets) | 379 _RunNinja(output_dir, targets) |
380 _ExtractSrcjars(gradle_output_dir, srcjar_tuples) | 380 _ExtractSrcjars(gradle_output_dir, srcjar_tuples) |
381 logging.warning('Project created successfully!') | 381 logging.warning('Project created successfully!') |
382 | 382 |
383 | 383 |
384 if __name__ == '__main__': | 384 if __name__ == '__main__': |
385 main() | 385 main() |
OLD | NEW |