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

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: Spacing nits 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') | no next file with comments »
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 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 if 'rules' in spec: 554 if 'rules' in spec:
555 outputs += self.WriteRules(spec['rules'], extra_sources, prebuild, 555 outputs += self.WriteRules(spec['rules'], extra_sources, prebuild,
556 mac_bundle_resources, 556 mac_bundle_resources,
557 extra_mac_bundle_resources) 557 extra_mac_bundle_resources)
558 if 'copies' in spec: 558 if 'copies' in spec:
559 outputs += self.WriteCopies(spec['copies'], prebuild, mac_bundle_depends) 559 outputs += self.WriteCopies(spec['copies'], prebuild, mac_bundle_depends)
560 560
561 if 'sources' in spec and self.flavor == 'win': 561 if 'sources' in spec and self.flavor == 'win':
562 outputs += self.WriteWinIdlFiles(spec, prebuild) 562 outputs += self.WriteWinIdlFiles(spec, prebuild)
563 563
564 if self.xcode_settings and self.xcode_settings.IsIosFramework():
565 self.WriteiOSFrameworkHeaders(spec, outputs, prebuild)
566
564 stamp = self.WriteCollapsedDependencies('actions_rules_copies', outputs) 567 stamp = self.WriteCollapsedDependencies('actions_rules_copies', outputs)
565 568
566 if self.is_mac_bundle: 569 if self.is_mac_bundle:
567 xcassets = self.WriteMacBundleResources( 570 xcassets = self.WriteMacBundleResources(
568 extra_mac_bundle_resources + mac_bundle_resources, mac_bundle_depends) 571 extra_mac_bundle_resources + mac_bundle_resources, mac_bundle_depends)
569 partial_info_plist = self.WriteMacXCassets(xcassets, mac_bundle_depends) 572 partial_info_plist = self.WriteMacXCassets(xcassets, mac_bundle_depends)
570 self.WriteMacInfoPlist(partial_info_plist, mac_bundle_depends) 573 self.WriteMacInfoPlist(partial_info_plist, mac_bundle_depends)
571 574
572 return stamp 575 return stamp
573 576
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 implicit=inputs, 740 implicit=inputs,
738 order_only=prebuild, 741 order_only=prebuild,
739 variables=extra_bindings) 742 variables=extra_bindings)
740 743
741 all_outputs.extend(outputs) 744 all_outputs.extend(outputs)
742 745
743 return all_outputs 746 return all_outputs
744 747
745 def WriteCopies(self, copies, prebuild, mac_bundle_depends): 748 def WriteCopies(self, copies, prebuild, mac_bundle_depends):
746 outputs = [] 749 outputs = []
747 env = self.GetToolchainEnv() 750 if self.xcode_settings:
751 extra_env = self.xcode_settings.GetPerTargetSettings()
752 env = self.GetToolchainEnv(additional_settings=extra_env)
753 else:
754 env = self.GetToolchainEnv()
748 for copy in copies: 755 for copy in copies:
749 for path in copy['files']: 756 for path in copy['files']:
750 # Normalize the path so trailing slashes don't confuse us. 757 # Normalize the path so trailing slashes don't confuse us.
751 path = os.path.normpath(path) 758 path = os.path.normpath(path)
752 basename = os.path.split(path)[1] 759 basename = os.path.split(path)[1]
753 src = self.GypPathToNinja(path, env) 760 src = self.GypPathToNinja(path, env)
754 dst = self.GypPathToNinja(os.path.join(copy['destination'], basename), 761 dst = self.GypPathToNinja(os.path.join(copy['destination'], basename),
755 env) 762 env)
756 outputs += self.ninja.build(dst, 'copy', src, order_only=prebuild) 763 outputs += self.ninja.build(dst, 'copy', src, order_only=prebuild)
757 if self.is_mac_bundle: 764 if self.is_mac_bundle:
758 # gyp has mac_bundle_resources to copy things into a bundle's 765 # gyp has mac_bundle_resources to copy things into a bundle's
759 # Resources folder, but there's no built-in way to copy files to other 766 # Resources folder, but there's no built-in way to copy files to other
760 # places in the bundle. Hence, some targets use copies for this. Check 767 # places in the bundle. Hence, some targets use copies for this. Check
761 # if this file is copied into the current bundle, and if so add it to 768 # if this file is copied into the current bundle, and if so add it to
762 # the bundle depends so that dependent targets get rebuilt if the copy 769 # the bundle depends so that dependent targets get rebuilt if the copy
763 # input changes. 770 # input changes.
764 if dst.startswith(self.xcode_settings.GetBundleContentsFolderPath()): 771 if dst.startswith(self.xcode_settings.GetBundleContentsFolderPath()):
765 mac_bundle_depends.append(dst) 772 mac_bundle_depends.append(dst)
766 773
767 return outputs 774 return outputs
768 775
776 def WriteiOSFrameworkHeaders(self, spec, outputs, prebuild):
777 """Prebuild steps to generate hmap files and copy headers to destination."""
778 framework = self.ComputeMacBundleOutput()
779 all_sources = spec['sources']
780 copy_headers = spec['mac_framework_headers']
Nico 2016/03/31 16:17:03 I guess this and the thing above need to be .get()
781 output = self.GypPathToUniqueOutput('headers.hmap')
782 self.xcode_settings.header_map_path = output
783 all_headers = map(self.GypPathToNinja,
784 filter(lambda x:x.endswith(('.h')), all_sources))
785 variables = [('framework', framework),
786 ('copy_headers', map(self.GypPathToNinja, copy_headers))]
787 outputs.extend(self.ninja.build(
788 output, 'compile_ios_framework_headers', all_headers,
789 variables=variables, order_only=prebuild))
790
769 def WriteMacBundleResources(self, resources, bundle_depends): 791 def WriteMacBundleResources(self, resources, bundle_depends):
770 """Writes ninja edges for 'mac_bundle_resources'.""" 792 """Writes ninja edges for 'mac_bundle_resources'."""
771 xcassets = [] 793 xcassets = []
772 794
773 extra_env = self.xcode_settings.GetPerTargetSettings() 795 extra_env = self.xcode_settings.GetPerTargetSettings()
774 env = self.GetSortedXcodeEnv(additional_settings=extra_env) 796 env = self.GetSortedXcodeEnv(additional_settings=extra_env)
775 env = self.ComputeExportEnvString(env) 797 env = self.ComputeExportEnvString(env)
776 isBinary = self.xcode_settings.IsBinaryOutputFormat(self.config_name) 798 isBinary = self.xcode_settings.IsBinaryOutputFormat(self.config_name)
777 799
778 for output, res in gyp.xcode_emulation.GetMacBundleResources( 800 for output, res in gyp.xcode_emulation.GetMacBundleResources(
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after
1335 def WriteMacBundle(self, spec, mac_bundle_depends, is_empty): 1357 def WriteMacBundle(self, spec, mac_bundle_depends, is_empty):
1336 assert self.is_mac_bundle 1358 assert self.is_mac_bundle
1337 package_framework = spec['type'] in ('shared_library', 'loadable_module') 1359 package_framework = spec['type'] in ('shared_library', 'loadable_module')
1338 output = self.ComputeMacBundleOutput() 1360 output = self.ComputeMacBundleOutput()
1339 if is_empty: 1361 if is_empty:
1340 output += '.stamp' 1362 output += '.stamp'
1341 variables = [] 1363 variables = []
1342 self.AppendPostbuildVariable(variables, spec, output, self.target.binary, 1364 self.AppendPostbuildVariable(variables, spec, output, self.target.binary,
1343 is_command_start=not package_framework) 1365 is_command_start=not package_framework)
1344 if package_framework and not is_empty: 1366 if package_framework and not is_empty:
1345 variables.append(('version', self.xcode_settings.GetFrameworkVersion())) 1367 if spec['type'] == 'shared_library' and self.xcode_settings.isIOS:
1346 self.ninja.build(output, 'package_framework', mac_bundle_depends, 1368 self.ninja.build(output, 'package_ios_framework', mac_bundle_depends)
1347 variables=variables) 1369 else:
1370 variables.append(('version', self.xcode_settings.GetFrameworkVersion()))
1371 self.ninja.build(output, 'package_framework', mac_bundle_depends,
1372 variables=variables)
1348 else: 1373 else:
1349 self.ninja.build(output, 'stamp', mac_bundle_depends, 1374 self.ninja.build(output, 'stamp', mac_bundle_depends,
1350 variables=variables) 1375 variables=variables)
1351 self.target.bundle = output 1376 self.target.bundle = output
1352 return output 1377 return output
1353 1378
1354 def GetToolchainEnv(self, additional_settings=None): 1379 def GetToolchainEnv(self, additional_settings=None):
1355 """Returns the variables toolchain would set for build steps.""" 1380 """Returns the variables toolchain would set for build steps."""
1356 env = self.GetSortedXcodeEnv(additional_settings=additional_settings) 1381 env = self.GetSortedXcodeEnv(additional_settings=additional_settings)
1357 if self.flavor == 'win': 1382 if self.flavor == 'win':
(...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after
2239 command='$env ./gyp-mac-tool copy-info-plist $in $out $binary $keys') 2264 command='$env ./gyp-mac-tool copy-info-plist $in $out $binary $keys')
2240 master_ninja.rule( 2265 master_ninja.rule(
2241 'merge_infoplist', 2266 'merge_infoplist',
2242 description='MERGE INFOPLISTS $in', 2267 description='MERGE INFOPLISTS $in',
2243 command='$env ./gyp-mac-tool merge-info-plist $out $in') 2268 command='$env ./gyp-mac-tool merge-info-plist $out $in')
2244 master_ninja.rule( 2269 master_ninja.rule(
2245 'compile_xcassets', 2270 'compile_xcassets',
2246 description='COMPILE XCASSETS $in', 2271 description='COMPILE XCASSETS $in',
2247 command='$env ./gyp-mac-tool compile-xcassets $keys $in') 2272 command='$env ./gyp-mac-tool compile-xcassets $keys $in')
2248 master_ninja.rule( 2273 master_ninja.rule(
2274 'compile_ios_framework_headers',
2275 description='COMPILE HEADER MAPS AND COPY FRAMEWORK HEADERS $in',
2276 command='$env ./gyp-mac-tool compile-ios-framework-header-map $out '
2277 '$framework $in && $env ./gyp-mac-tool '
2278 'copy-ios-framework-headers $framework $copy_headers')
2279 master_ninja.rule(
2249 'mac_tool', 2280 'mac_tool',
2250 description='MACTOOL $mactool_cmd $in', 2281 description='MACTOOL $mactool_cmd $in',
2251 command='$env ./gyp-mac-tool $mactool_cmd $in $out $binary') 2282 command='$env ./gyp-mac-tool $mactool_cmd $in $out $binary')
2252 master_ninja.rule( 2283 master_ninja.rule(
2253 'package_framework', 2284 'package_framework',
2254 description='PACKAGE FRAMEWORK $out, POSTBUILDS', 2285 description='PACKAGE FRAMEWORK $out, POSTBUILDS',
2255 command='./gyp-mac-tool package-framework $out $version$postbuilds ' 2286 command='./gyp-mac-tool package-framework $out $version$postbuilds '
2256 '&& touch $out') 2287 '&& touch $out')
2288 master_ninja.rule(
2289 'package_ios_framework',
2290 description='PACKAGE IOS FRAMEWORK $out, POSTBUILDS',
2291 command='./gyp-mac-tool package-ios-framework $out $postbuilds '
2292 '&& touch $out')
2257 if flavor == 'win': 2293 if flavor == 'win':
2258 master_ninja.rule( 2294 master_ninja.rule(
2259 'stamp', 2295 'stamp',
2260 description='STAMP $out', 2296 description='STAMP $out',
2261 command='%s gyp-win-tool stamp $out' % sys.executable) 2297 command='%s gyp-win-tool stamp $out' % sys.executable)
2262 master_ninja.rule( 2298 master_ninja.rule(
2263 'copy', 2299 'copy',
2264 description='COPY $in $out', 2300 description='COPY $in $out',
2265 command='%s gyp-win-tool recursive-mirror $in $out' % sys.executable) 2301 command='%s gyp-win-tool recursive-mirror $in $out' % sys.executable)
2266 else: 2302 else:
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
2422 arglists.append( 2458 arglists.append(
2423 (target_list, target_dicts, data, params, config_name)) 2459 (target_list, target_dicts, data, params, config_name))
2424 pool.map(CallGenerateOutputForConfig, arglists) 2460 pool.map(CallGenerateOutputForConfig, arglists)
2425 except KeyboardInterrupt, e: 2461 except KeyboardInterrupt, e:
2426 pool.terminate() 2462 pool.terminate()
2427 raise e 2463 raise e
2428 else: 2464 else:
2429 for config_name in config_names: 2465 for config_name in config_names:
2430 GenerateOutputForConfig(target_list, target_dicts, data, params, 2466 GenerateOutputForConfig(target_list, target_dicts, data, params,
2431 config_name) 2467 config_name)
OLDNEW
« no previous file with comments | « no previous file | pylib/gyp/mac_tool.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698