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

Side by Side Diff: pylib/gyp/generator/ninja.py

Issue 1745173002: Add support for iOS Frameworks with header maps. (Closed) Base URL: https://chromium.googlesource.com/external/gyp.git@master
Patch Set: rebase Created 4 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | pylib/gyp/mac_tool.py » ('j') | pylib/gyp/mac_tool.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2013 Google Inc. All rights reserved. 1 # Copyright (c) 2013 Google Inc. 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 collections 5 import collections
6 import copy 6 import copy
7 import hashlib 7 import hashlib
8 import json 8 import json
9 import multiprocessing 9 import multiprocessing
10 import os.path 10 import os.path
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 if 'rules' in spec: 552 if 'rules' in spec:
553 outputs += self.WriteRules(spec['rules'], extra_sources, prebuild, 553 outputs += self.WriteRules(spec['rules'], extra_sources, prebuild,
554 mac_bundle_resources, 554 mac_bundle_resources,
555 extra_mac_bundle_resources) 555 extra_mac_bundle_resources)
556 if 'copies' in spec: 556 if 'copies' in spec:
557 outputs += self.WriteCopies(spec['copies'], prebuild, mac_bundle_depends) 557 outputs += self.WriteCopies(spec['copies'], prebuild, mac_bundle_depends)
558 558
559 if 'sources' in spec and self.flavor == 'win': 559 if 'sources' in spec and self.flavor == 'win':
560 outputs += self.WriteWinIdlFiles(spec, prebuild) 560 outputs += self.WriteWinIdlFiles(spec, prebuild)
561 561
562 if self.xcode_settings.IsIosFramework():
563 self.WriteiOSFrameworkHeaders(spec, outputs, prebuild)
564
562 stamp = self.WriteCollapsedDependencies('actions_rules_copies', outputs) 565 stamp = self.WriteCollapsedDependencies('actions_rules_copies', outputs)
563 566
564 if self.is_mac_bundle: 567 if self.is_mac_bundle:
565 xcassets = self.WriteMacBundleResources( 568 xcassets = self.WriteMacBundleResources(
566 extra_mac_bundle_resources + mac_bundle_resources, mac_bundle_depends) 569 extra_mac_bundle_resources + mac_bundle_resources, mac_bundle_depends)
567 partial_info_plist = self.WriteMacXCassets(xcassets, mac_bundle_depends) 570 partial_info_plist = self.WriteMacXCassets(xcassets, mac_bundle_depends)
568 self.WriteMacInfoPlist(partial_info_plist, mac_bundle_depends) 571 self.WriteMacInfoPlist(partial_info_plist, mac_bundle_depends)
569 572
570 return stamp 573 return stamp
571 574
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 implicit=inputs, 738 implicit=inputs,
736 order_only=prebuild, 739 order_only=prebuild,
737 variables=extra_bindings) 740 variables=extra_bindings)
738 741
739 all_outputs.extend(outputs) 742 all_outputs.extend(outputs)
740 743
741 return all_outputs 744 return all_outputs
742 745
743 def WriteCopies(self, copies, prebuild, mac_bundle_depends): 746 def WriteCopies(self, copies, prebuild, mac_bundle_depends):
744 outputs = [] 747 outputs = []
745 env = self.GetToolchainEnv() 748 extra_env = self.xcode_settings.GetPerTargetSettings()
749 env = self.GetToolchainEnv(additional_settings=extra_env)
746 for copy in copies: 750 for copy in copies:
747 for path in copy['files']: 751 for path in copy['files']:
748 # Normalize the path so trailing slashes don't confuse us. 752 # Normalize the path so trailing slashes don't confuse us.
749 path = os.path.normpath(path) 753 path = os.path.normpath(path)
750 basename = os.path.split(path)[1] 754 basename = os.path.split(path)[1]
751 src = self.GypPathToNinja(path, env) 755 src = self.GypPathToNinja(path, env)
752 dst = self.GypPathToNinja(os.path.join(copy['destination'], basename), 756 dst = self.GypPathToNinja(os.path.join(copy['destination'], basename),
753 env) 757 env)
754 outputs += self.ninja.build(dst, 'copy', src, order_only=prebuild) 758 outputs += self.ninja.build(dst, 'copy', src, order_only=prebuild)
755 if self.is_mac_bundle: 759 if self.is_mac_bundle:
756 # gyp has mac_bundle_resources to copy things into a bundle's 760 # gyp has mac_bundle_resources to copy things into a bundle's
757 # Resources folder, but there's no built-in way to copy files to other 761 # Resources folder, but there's no built-in way to copy files to other
758 # places in the bundle. Hence, some targets use copies for this. Check 762 # places in the bundle. Hence, some targets use copies for this. Check
759 # if this file is copied into the current bundle, and if so add it to 763 # if this file is copied into the current bundle, and if so add it to
760 # the bundle depends so that dependent targets get rebuilt if the copy 764 # the bundle depends so that dependent targets get rebuilt if the copy
761 # input changes. 765 # input changes.
762 if dst.startswith(self.xcode_settings.GetBundleContentsFolderPath()): 766 if dst.startswith(self.xcode_settings.GetBundleContentsFolderPath()):
763 mac_bundle_depends.append(dst) 767 mac_bundle_depends.append(dst)
764 768
765 return outputs 769 return outputs
766 770
771 def WriteiOSFrameworkHeaders(self, spec, outputs, prebuild):
772 """{rebuild steps on hmap generation and header copies in iOS frameworks."""
773 framework = self.ComputeMacBundleOutput()
774 all_sources = spec['sources']
775 copy_headers = spec['mac_framework_headers']
776 output = self.GypPathToUniqueOutput('headers.hmap')
777 self.xcode_settings.header_map_path = output
778 all_headers = map(self.GypPathToNinja,
779 filter(lambda x:x.endswith(('.h')), all_sources))
780 variables = [('framework', framework),
781 ('copy_headers', map(self.GypPathToNinja, copy_headers))]
782 outputs.extend(self.ninja.build(
783 output, 'compile_ios_framework_headers', all_headers,
784 variables=variables, order_only=prebuild))
785
767 def WriteMacBundleResources(self, resources, bundle_depends): 786 def WriteMacBundleResources(self, resources, bundle_depends):
768 """Writes ninja edges for 'mac_bundle_resources'.""" 787 """Writes ninja edges for 'mac_bundle_resources'."""
769 xcassets = [] 788 xcassets = []
770 789
771 extra_env = self.xcode_settings.GetPerTargetSettings() 790 extra_env = self.xcode_settings.GetPerTargetSettings()
772 env = self.GetSortedXcodeEnv(additional_settings=extra_env) 791 env = self.GetSortedXcodeEnv(additional_settings=extra_env)
773 env = self.ComputeExportEnvString(env) 792 env = self.ComputeExportEnvString(env)
774 isBinary = self.xcode_settings.IsBinaryOutputFormat(self.config_name) 793 isBinary = self.xcode_settings.IsBinaryOutputFormat(self.config_name)
775 794
776 for output, res in gyp.xcode_emulation.GetMacBundleResources( 795 for output, res in gyp.xcode_emulation.GetMacBundleResources(
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
1331 def WriteMacBundle(self, spec, mac_bundle_depends, is_empty): 1350 def WriteMacBundle(self, spec, mac_bundle_depends, is_empty):
1332 assert self.is_mac_bundle 1351 assert self.is_mac_bundle
1333 package_framework = spec['type'] in ('shared_library', 'loadable_module') 1352 package_framework = spec['type'] in ('shared_library', 'loadable_module')
1334 output = self.ComputeMacBundleOutput() 1353 output = self.ComputeMacBundleOutput()
1335 if is_empty: 1354 if is_empty:
1336 output += '.stamp' 1355 output += '.stamp'
1337 variables = [] 1356 variables = []
1338 self.AppendPostbuildVariable(variables, spec, output, self.target.binary, 1357 self.AppendPostbuildVariable(variables, spec, output, self.target.binary,
1339 is_command_start=not package_framework) 1358 is_command_start=not package_framework)
1340 if package_framework and not is_empty: 1359 if package_framework and not is_empty:
1341 variables.append(('version', self.xcode_settings.GetFrameworkVersion())) 1360 if spec['type'] == 'shared_library' and self.xcode_settings.isIOS:
1342 self.ninja.build(output, 'package_framework', mac_bundle_depends, 1361 self.ninja.build(output, 'package_ios_framework', mac_bundle_depends)
1343 variables=variables) 1362 else:
1363 variables.append(('version', self.xcode_settings.GetFrameworkVersion()))
1364 self.ninja.build(output, 'package_framework', mac_bundle_depends,
1365 variables=variables)
1344 else: 1366 else:
1345 self.ninja.build(output, 'stamp', mac_bundle_depends, 1367 self.ninja.build(output, 'stamp', mac_bundle_depends,
1346 variables=variables) 1368 variables=variables)
1347 self.target.bundle = output 1369 self.target.bundle = output
1348 return output 1370 return output
1349 1371
1350 def GetToolchainEnv(self, additional_settings=None): 1372 def GetToolchainEnv(self, additional_settings=None):
1351 """Returns the variables toolchain would set for build steps.""" 1373 """Returns the variables toolchain would set for build steps."""
1352 env = self.GetSortedXcodeEnv(additional_settings=additional_settings) 1374 env = self.GetSortedXcodeEnv(additional_settings=additional_settings)
1353 if self.flavor == 'win': 1375 if self.flavor == 'win':
(...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after
2235 command='$env ./gyp-mac-tool copy-info-plist $in $out $binary $keys') 2257 command='$env ./gyp-mac-tool copy-info-plist $in $out $binary $keys')
2236 master_ninja.rule( 2258 master_ninja.rule(
2237 'merge_infoplist', 2259 'merge_infoplist',
2238 description='MERGE INFOPLISTS $in', 2260 description='MERGE INFOPLISTS $in',
2239 command='$env ./gyp-mac-tool merge-info-plist $out $in') 2261 command='$env ./gyp-mac-tool merge-info-plist $out $in')
2240 master_ninja.rule( 2262 master_ninja.rule(
2241 'compile_xcassets', 2263 'compile_xcassets',
2242 description='COMPILE XCASSETS $in', 2264 description='COMPILE XCASSETS $in',
2243 command='$env ./gyp-mac-tool compile-xcassets $keys $in') 2265 command='$env ./gyp-mac-tool compile-xcassets $keys $in')
2244 master_ninja.rule( 2266 master_ninja.rule(
2267 'compile_ios_framework_headers',
2268 description='COMPILE HEADER MAPS AND COPY FRAMEWORK HEADER $in',
2269 command='$env ./gyp-mac-tool compile-ios-framework-header-map $out '
2270 '$framework $in && $env ./gyp-mac-tool '
2271 'copy-ios-framework-headers $framework $copy_headers')
2272 master_ninja.rule(
2245 'mac_tool', 2273 'mac_tool',
2246 description='MACTOOL $mactool_cmd $in', 2274 description='MACTOOL $mactool_cmd $in',
2247 command='$env ./gyp-mac-tool $mactool_cmd $in $out $binary') 2275 command='$env ./gyp-mac-tool $mactool_cmd $in $out $binary')
2248 master_ninja.rule( 2276 master_ninja.rule(
2249 'package_framework', 2277 'package_framework',
2250 description='PACKAGE FRAMEWORK $out, POSTBUILDS', 2278 description='PACKAGE FRAMEWORK $out, POSTBUILDS',
2251 command='./gyp-mac-tool package-framework $out $version$postbuilds ' 2279 command='./gyp-mac-tool package-framework $out $version$postbuilds '
2252 '&& touch $out') 2280 '&& touch $out')
2281 master_ninja.rule(
2282 'package_ios_framework',
2283 description='PACKAGE IOS FRAMEWORK $out, POSTBUILDS',
2284 command='./gyp-mac-tool package-ios-framework $out $postbuilds '
2285 '&& touch $out')
2253 if flavor == 'win': 2286 if flavor == 'win':
2254 master_ninja.rule( 2287 master_ninja.rule(
2255 'stamp', 2288 'stamp',
2256 description='STAMP $out', 2289 description='STAMP $out',
2257 command='%s gyp-win-tool stamp $out' % sys.executable) 2290 command='%s gyp-win-tool stamp $out' % sys.executable)
2258 master_ninja.rule( 2291 master_ninja.rule(
2259 'copy', 2292 'copy',
2260 description='COPY $in $out', 2293 description='COPY $in $out',
2261 command='%s gyp-win-tool recursive-mirror $in $out' % sys.executable) 2294 command='%s gyp-win-tool recursive-mirror $in $out' % sys.executable)
2262 else: 2295 else:
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
2418 arglists.append( 2451 arglists.append(
2419 (target_list, target_dicts, data, params, config_name)) 2452 (target_list, target_dicts, data, params, config_name))
2420 pool.map(CallGenerateOutputForConfig, arglists) 2453 pool.map(CallGenerateOutputForConfig, arglists)
2421 except KeyboardInterrupt, e: 2454 except KeyboardInterrupt, e:
2422 pool.terminate() 2455 pool.terminate()
2423 raise e 2456 raise e
2424 else: 2457 else:
2425 for config_name in config_names: 2458 for config_name in config_names:
2426 GenerateOutputForConfig(target_list, target_dicts, data, params, 2459 GenerateOutputForConfig(target_list, target_dicts, data, params,
2427 config_name) 2460 config_name)
OLDNEW
« no previous file with comments | « no previous file | pylib/gyp/mac_tool.py » ('j') | pylib/gyp/mac_tool.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698