Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/python | 1 #!/usr/bin/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 """Convert GN Xcode projects to platform and configuration independent targets. | 6 """Convert GN Xcode projects to platform and configuration independent targets. |
| 7 | 7 |
| 8 GN generates Xcode projects that build one configuration only. However, typical | 8 GN generates Xcode projects that build one configuration only. However, typical |
| 9 iOS development involves using the Xcode IDE to toggle the platform and | 9 iOS development involves using the Xcode IDE to toggle the platform and |
| 10 configuration. This script replaces the 'gn' configuration with 'Debug', | 10 configuration. This script replaces the 'gn' configuration with 'Debug', |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 160 configurations: list of string corresponding to the configurations that | 160 configurations: list of string corresponding to the configurations that |
| 161 need to be supported by the tweaked Xcode projects, must contains at | 161 need to be supported by the tweaked Xcode projects, must contains at |
| 162 least one value. | 162 least one value. |
| 163 ''' | 163 ''' |
| 164 # Update products project. | 164 # Update products project. |
| 165 products = os.path.join('products.xcodeproj', 'project.pbxproj') | 165 products = os.path.join('products.xcodeproj', 'project.pbxproj') |
| 166 product_input = os.path.join(input_dir, products) | 166 product_input = os.path.join(input_dir, products) |
| 167 product_output = os.path.join(output_dir, products) | 167 product_output = os.path.join(output_dir, products) |
| 168 UpdateProductsProject(product_input, product_output, configurations) | 168 UpdateProductsProject(product_input, product_output, configurations) |
| 169 | 169 |
| 170 # Copy sources project and all workspace. | 170 # Copy sources project and all workspace. |
|
sdefresne
2017/01/17 10:08:40
nit: Please update comment (as this no longer copy
liaoyuke
2017/01/17 18:35:19
Done.
| |
| 171 sources = os.path.join('sources.xcodeproj', 'project.pbxproj') | |
| 172 CopyFileIfChanged(os.path.join(input_dir, sources), | |
| 173 os.path.join(output_dir, sources)) | |
| 174 xcwspace = os.path.join('all.xcworkspace', 'contents.xcworkspacedata') | 171 xcwspace = os.path.join('all.xcworkspace', 'contents.xcworkspacedata') |
| 175 CopyFileIfChanged(os.path.join(input_dir, xcwspace), | 172 CopyFileIfChanged(os.path.join(input_dir, xcwspace), |
| 176 os.path.join(output_dir, xcwspace)) | 173 os.path.join(output_dir, xcwspace)) |
| 177 | 174 # TODO(crbug.com/679110): gn has been modified to remove 'sources.xcodeproj' |
| 175 # and keep 'all.xcworkspace' and 'products.xcodeproj'. The following code is | |
| 176 # here to support both old and new projects setup and will be removed once gn | |
| 177 # has rolled past it. | |
| 178 if 'sources.xcodeproj' in os.listdir(input_dir): | |
|
sdefresne
2017/01/17 10:08:40
nit: I would just test whether the file "sources"
liaoyuke
2017/01/17 18:35:19
Done.
| |
| 179 sources = os.path.join('sources.xcodeproj', 'project.pbxproj') | |
| 180 CopyFileIfChanged(os.path.join(input_dir, sources), | |
| 181 os.path.join(output_dir, sources)) | |
| 178 | 182 |
| 179 def Main(args): | 183 def Main(args): |
| 180 parser = argparse.ArgumentParser( | 184 parser = argparse.ArgumentParser( |
| 181 description='Convert GN Xcode projects for iOS.') | 185 description='Convert GN Xcode projects for iOS.') |
| 182 parser.add_argument( | 186 parser.add_argument( |
| 183 'input', | 187 'input', |
| 184 help='directory containing [product|sources|all] Xcode projects.') | 188 help='directory containing [product|all] Xcode projects.') |
| 185 parser.add_argument( | 189 parser.add_argument( |
| 186 'output', | 190 'output', |
| 187 help='directory where to generate the iOS configuration.') | 191 help='directory where to generate the iOS configuration.') |
| 188 parser.add_argument( | 192 parser.add_argument( |
| 189 '--add-config', dest='configurations', default=[], action='append', | 193 '--add-config', dest='configurations', default=[], action='append', |
| 190 help='configuration to add to the Xcode project') | 194 help='configuration to add to the Xcode project') |
| 191 args = parser.parse_args(args) | 195 args = parser.parse_args(args) |
| 192 | 196 |
| 193 if not os.path.isdir(args.input): | 197 if not os.path.isdir(args.input): |
| 194 sys.stderr.write('Input directory does not exists.\n') | 198 sys.stderr.write('Input directory does not exists.\n') |
| 195 return 1 | 199 return 1 |
| 196 | 200 |
| 197 required = set(['products.xcodeproj', 'sources.xcodeproj', 'all.xcworkspace']) | 201 required = set(['products.xcodeproj', 'all.xcworkspace']) |
| 198 if not required.issubset(os.listdir(args.input)): | 202 if not required.issubset(os.listdir(args.input)): |
| 199 sys.stderr.write( | 203 sys.stderr.write( |
| 200 'Input directory does not contain all necessary Xcode projects.\n') | 204 'Input directory does not contain all necessary Xcode projects.\n') |
| 201 return 1 | 205 return 1 |
| 202 | 206 |
| 203 if not args.configurations: | 207 if not args.configurations: |
| 204 sys.stderr.write('At least one configuration required, see --add-config.\n') | 208 sys.stderr.write('At least one configuration required, see --add-config.\n') |
| 205 return 1 | 209 return 1 |
| 206 | 210 |
| 207 ConvertGnXcodeProject(args.input, args.output, args.configurations) | 211 ConvertGnXcodeProject(args.input, args.output, args.configurations) |
| 208 | 212 |
| 209 if __name__ == '__main__': | 213 if __name__ == '__main__': |
| 210 sys.exit(Main(sys.argv[1:])) | 214 sys.exit(Main(sys.argv[1:])) |
| 211 | 215 |
| 212 | 216 |
| OLD | NEW |