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

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

Issue 9424042: Support import libraries for Windows ninja (Closed) Base URL: http://gyp.googlecode.com/svn/trunk/
Patch Set: Created 8 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | test/lib/TestGyp.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) 2012 Google Inc. All rights reserved. 1 # Copyright (c) 2012 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 copy 5 import copy
6 import gyp 6 import gyp
7 import gyp.common 7 import gyp.common
8 import gyp.msvs_emulation 8 import gyp.msvs_emulation
9 import gyp.system_test 9 import gyp.system_test
10 import gyp.xcode_emulation 10 import gyp.xcode_emulation
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 'cc': 'cflags_pch_cc', 656 'cc': 'cflags_pch_cc',
657 'm': 'cflags_pch_objc', 657 'm': 'cflags_pch_objc',
658 'mm': 'cflags_pch_objcc', 658 'mm': 'cflags_pch_objcc',
659 }[lang] 659 }[lang]
660 660
661 cmd = { 'c': 'cc', 'cc': 'cxx', 'm': 'objc', 'mm': 'objcxx', }.get(lang) 661 cmd = { 'c': 'cc', 'cc': 'cxx', 'm': 'objc', 'mm': 'objcxx', }.get(lang)
662 self.ninja.build(gch, cmd, input, variables=[(var_name, lang_flag)]) 662 self.ninja.build(gch, cmd, input, variables=[(var_name, lang_flag)])
663 663
664 664
665 def WriteLink(self, spec, config_name, config, link_deps): 665 def WriteLink(self, spec, config_name, config, link_deps):
666 """Write out a link step. Returns the path to the output.""" 666 """Write out a link step. Fills out target.binary. """
667 667
668 command = { 668 command = {
669 'executable': 'link', 669 'executable': 'link',
670 'loadable_module': 'solink_module', 670 'loadable_module': 'solink_module',
671 'shared_library': 'solink', 671 'shared_library': 'solink',
672 }[spec['type']] 672 }[spec['type']]
673 673
674 implicit_deps = set() 674 implicit_deps = set()
675 675
676 if 'dependencies' in spec: 676 if 'dependencies' in spec:
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 self.WriteVariableList('ldflags', 710 self.WriteVariableList('ldflags',
711 gyp.common.uniquer(map(self.ExpandSpecial, 711 gyp.common.uniquer(map(self.ExpandSpecial,
712 ldflags))) 712 ldflags)))
713 713
714 libraries = gyp.common.uniquer(map(self.ExpandSpecial, 714 libraries = gyp.common.uniquer(map(self.ExpandSpecial,
715 spec.get('libraries', []))) 715 spec.get('libraries', [])))
716 if self.flavor == 'mac': 716 if self.flavor == 'mac':
717 libraries = self.xcode_settings.AdjustLibraries(libraries) 717 libraries = self.xcode_settings.AdjustLibraries(libraries)
718 self.WriteVariableList('libs', libraries) 718 self.WriteVariableList('libs', libraries)
719 719
720 self.target.binary = output
721
720 if command in ('solink', 'solink_module'): 722 if command in ('solink', 'solink_module'):
721 extra_bindings.append(('soname', os.path.split(output)[1])) 723 extra_bindings.append(('soname', os.path.split(output)[1]))
724 if self.flavor == 'win':
725 import_lib = output + '.lib'
726 extra_bindings.append(('dll', output))
727 extra_bindings.append(('implib', import_lib))
728 self.target.binary = import_lib
729 output = [output, import_lib]
Nico 2012/02/22 00:46:23 Is this last line still needed? Could you do ou
scottmg 2012/02/22 00:53:42 Yes, still required because there has to be a buil
722 730
723 self.ninja.build(output, command, link_deps, 731 self.ninja.build(output, command, link_deps,
724 implicit=list(implicit_deps), 732 implicit=list(implicit_deps),
725 variables=extra_bindings) 733 variables=extra_bindings)
726 return output
727 734
728 def WriteTarget(self, spec, config_name, config, link_deps, compile_deps): 735 def WriteTarget(self, spec, config_name, config, link_deps, compile_deps):
729 if spec['type'] == 'none': 736 if spec['type'] == 'none':
730 # TODO(evan): don't call this function for 'none' target types, as 737 # TODO(evan): don't call this function for 'none' target types, as
731 # it doesn't do anything, and we fake out a 'binary' with a stamp file. 738 # it doesn't do anything, and we fake out a 'binary' with a stamp file.
732 self.target.binary = compile_deps 739 self.target.binary = compile_deps
733 elif spec['type'] == 'static_library': 740 elif spec['type'] == 'static_library':
734 self.target.binary = self.ComputeOutput(spec) 741 self.target.binary = self.ComputeOutput(spec)
735 self.ninja.build(self.target.binary, 'alink', link_deps, 742 self.ninja.build(self.target.binary, 'alink', link_deps,
736 order_only=compile_deps, 743 order_only=compile_deps,
737 variables=[('postbuilds', self.GetPostbuildCommand( 744 variables=[('postbuilds', self.GetPostbuildCommand(
738 spec, self.target.binary, self.target.binary))]) 745 spec, self.target.binary, self.target.binary))])
739 else: 746 else:
740 self.target.binary = self.WriteLink(spec, config_name, config, link_deps) 747 self.WriteLink(spec, config_name, config, link_deps)
741 return self.target.binary 748 return self.target.binary
742 749
743 def WriteMacBundle(self, spec, mac_bundle_depends): 750 def WriteMacBundle(self, spec, mac_bundle_depends):
744 assert self.is_mac_bundle 751 assert self.is_mac_bundle
745 package_framework = spec['type'] in ('shared_library', 'loadable_module') 752 package_framework = spec['type'] in ('shared_library', 'loadable_module')
746 output = self.ComputeMacBundleOutput() 753 output = self.ComputeMacBundleOutput()
747 postbuild = self.GetPostbuildCommand(spec, output, self.target.binary, 754 postbuild = self.GetPostbuildCommand(spec, output, self.target.binary,
748 is_command_start=not package_framework) 755 is_command_start=not package_framework)
749 variables = [] 756 variables = []
750 if postbuild: 757 if postbuild:
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 903
897 if 'product_dir' in spec: 904 if 'product_dir' in spec:
898 path = os.path.join(spec['product_dir'], filename) 905 path = os.path.join(spec['product_dir'], filename)
899 return self.ExpandSpecial(path) 906 return self.ExpandSpecial(path)
900 907
901 # Some products go into the output root, libraries go into shared library 908 # Some products go into the output root, libraries go into shared library
902 # dir, and everything else goes into the normal place. 909 # dir, and everything else goes into the normal place.
903 type_in_output_root = ['executable', 'loadable_module'] 910 type_in_output_root = ['executable', 'loadable_module']
904 if self.flavor == 'mac' and self.toolset == 'target': 911 if self.flavor == 'mac' and self.toolset == 'target':
905 type_in_output_root += ['shared_library', 'static_library'] 912 type_in_output_root += ['shared_library', 'static_library']
913 elif self.flavor == 'win' and self.toolset == 'target':
914 type_in_output_root += ['shared_library']
906 915
907 if type in type_in_output_root: 916 if type in type_in_output_root:
908 return filename 917 return filename
909 elif type == 'shared_library': 918 elif type == 'shared_library':
910 libdir = 'lib' 919 libdir = 'lib'
911 if self.toolset != 'target': 920 if self.toolset != 'target':
912 libdir = os.path.join('lib', '%s' % self.toolset) 921 libdir = os.path.join('lib', '%s' % self.toolset)
913 return os.path.join(libdir, filename) 922 return os.path.join(libdir, filename)
914 else: 923 else:
915 return self.GypPathToUniqueOutput(filename, qualified=False) 924 return self.GypPathToUniqueOutput(filename, qualified=False)
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1109 command=('$ld -shared $ldflags -o $out -Wl,-soname=$soname ' 1118 command=('$ld -shared $ldflags -o $out -Wl,-soname=$soname '
1110 '-Wl,--start-group $in -Wl,--end-group $libs')) 1119 '-Wl,--start-group $in -Wl,--end-group $libs'))
1111 master_ninja.rule( 1120 master_ninja.rule(
1112 'link', 1121 'link',
1113 description='LINK $out', 1122 description='LINK $out',
1114 command=('$ld $ldflags -o $out -Wl,-rpath=\$$ORIGIN/lib ' 1123 command=('$ld $ldflags -o $out -Wl,-rpath=\$$ORIGIN/lib '
1115 '-Wl,--start-group $in -Wl,--end-group $libs')) 1124 '-Wl,--start-group $in -Wl,--end-group $libs'))
1116 elif flavor == 'win': 1125 elif flavor == 'win':
1117 master_ninja.rule( 1126 master_ninja.rule(
1118 'alink', 1127 'alink',
1119 description='AR $out', 1128 description='LIB $out',
1120 command='lib /nologo /OUT:$out $in') 1129 command='lib /nologo /OUT:$out $in')
1121 master_ninja.rule( 1130 master_ninja.rule(
1122 'solink', 1131 'solink',
1123 description='SOLINK $out', 1132 description='LINK(DLL) $dll',
1124 command=('$ld /nologo /DLL $ldflags /OUT:$out $in $libs')) 1133 command=('$ld /nologo /IMPLIB:$implib /DLL $ldflags /OUT:$dll $in $libs'))
1125 master_ninja.rule( 1134 master_ninja.rule(
1126 'solink_module', 1135 'solink_module',
1127 description='SOLINK(module) $out', 1136 description='LINK(DLL) $dll',
1128 command=('$ld /nologo /DLL $ldflags /OUT:$out $in $libs')) 1137 command=('$ld /nologo /IMPLIB:$implib /DLL $ldflags /OUT:$dll $in $libs'))
1129 master_ninja.rule( 1138 master_ninja.rule(
1130 'link', 1139 'link',
1131 description='LINK $out', 1140 description='LINK $out',
1132 command=('$ld /nologo $ldflags /OUT:$out $in $libs')) 1141 command=('$ld /nologo $ldflags /OUT:$out $in $libs'))
1133 else: 1142 else:
1134 master_ninja.rule( 1143 master_ninja.rule(
1135 'objc', 1144 'objc',
1136 description='OBJC $out', 1145 description='OBJC $out',
1137 command=('$cc -MMD -MF $out.d $defines $includes $cflags $cflags_objc ' 1146 command=('$cc -MMD -MF $out.d $defines $includes $cflags $cflags_objc '
1138 '$cflags_pch_objc -c $in -o $out'), 1147 '$cflags_pch_objc -c $in -o $out'),
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1250 1259
1251 user_config = params.get('generator_flags', {}).get('config', None) 1260 user_config = params.get('generator_flags', {}).get('config', None)
1252 if user_config: 1261 if user_config:
1253 GenerateOutputForConfig(target_list, target_dicts, data, params, 1262 GenerateOutputForConfig(target_list, target_dicts, data, params,
1254 user_config) 1263 user_config)
1255 else: 1264 else:
1256 config_names = target_dicts[target_list[0]]['configurations'].keys() 1265 config_names = target_dicts[target_list[0]]['configurations'].keys()
1257 for config_name in config_names: 1266 for config_name in config_names:
1258 GenerateOutputForConfig(target_list, target_dicts, data, params, 1267 GenerateOutputForConfig(target_list, target_dicts, data, params,
1259 config_name) 1268 config_name)
OLDNEW
« no previous file with comments | « no previous file | test/lib/TestGyp.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698