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

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

Issue 11031005: Add "standalone_static_library" flag (Closed) Base URL: http://gyp.googlecode.com/svn/trunk/
Patch Set: Created 8 years, 2 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 | « pylib/gyp/generator/android.py ('k') | pylib/gyp/generator/msvs.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 # Notes: 5 # Notes:
6 # 6 #
7 # This is all roughly based on the Makefile system used by the Linux 7 # This is all roughly based on the Makefile system used by the Linux
8 # kernel, but is a non-recursive make -- we put the entire dependency 8 # kernel, but is a non-recursive make -- we put the entire dependency
9 # graph in front of make and let it figure it out. 9 # graph in front of make and let it figure it out.
10 # 10 #
(...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 extra_mac_bundle_resources = [] 711 extra_mac_bundle_resources = []
712 mac_bundle_deps = [] 712 mac_bundle_deps = []
713 713
714 if self.is_mac_bundle: 714 if self.is_mac_bundle:
715 self.output = self.ComputeMacBundleOutput(spec) 715 self.output = self.ComputeMacBundleOutput(spec)
716 self.output_binary = self.ComputeMacBundleBinaryOutput(spec) 716 self.output_binary = self.ComputeMacBundleBinaryOutput(spec)
717 else: 717 else:
718 self.output = self.output_binary = self.ComputeOutput(spec) 718 self.output = self.output_binary = self.ComputeOutput(spec)
719 719
720 self._INSTALLABLE_TARGETS = ('executable', 'loadable_module', 720 self._INSTALLABLE_TARGETS = ('executable', 'loadable_module',
721 'shared_library') 721 'shared_library', 'standalone_static_library')
722 if self.type in self._INSTALLABLE_TARGETS: 722 if self.type in self._INSTALLABLE_TARGETS:
723 self.alias = os.path.basename(self.output) 723 self.alias = os.path.basename(self.output)
724 install_path = self._InstallableTargetInstallPath() 724 install_path = self._InstallableTargetInstallPath()
725 else: 725 else:
726 self.alias = self.output 726 self.alias = self.output
727 install_path = self.output 727 install_path = self.output
728 728
729 self.WriteLn("TOOLSET := " + self.toolset) 729 self.WriteLn("TOOLSET := " + self.toolset)
730 self.WriteLn("TARGET := " + self.target) 730 self.WriteLn("TARGET := " + self.target)
731 731
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 if self.is_mac_bundle: 778 if self.is_mac_bundle:
779 mac_bundle_deps.append(self.output_binary) 779 mac_bundle_deps.append(self.output_binary)
780 780
781 self.WriteTarget(spec, configs, deps, extra_link_deps + link_deps, 781 self.WriteTarget(spec, configs, deps, extra_link_deps + link_deps,
782 mac_bundle_deps, extra_outputs, part_of_all) 782 mac_bundle_deps, extra_outputs, part_of_all)
783 783
784 # Update global list of target outputs, used in dependency tracking. 784 # Update global list of target outputs, used in dependency tracking.
785 target_outputs[qualified_target] = install_path 785 target_outputs[qualified_target] = install_path
786 786
787 # Update global list of link dependencies. 787 # Update global list of link dependencies.
788 if self.type in ('static_library', 'shared_library'): 788 if self.type in ('static_library', 'standalone_static_library',
789 'shared_library'):
789 target_link_deps[qualified_target] = self.output_binary 790 target_link_deps[qualified_target] = self.output_binary
790 791
791 # Currently any versions have the same effect, but in future the behavior 792 # Currently any versions have the same effect, but in future the behavior
792 # could be different. 793 # could be different.
793 if self.generator_flags.get('android_ndk_version', None): 794 if self.generator_flags.get('android_ndk_version', None):
794 self.WriteAndroidNdkModuleRule(self.target, all_sources, link_deps) 795 self.WriteAndroidNdkModuleRule(self.target, all_sources, link_deps)
795 796
796 self.fp.close() 797 self.fp.close()
797 798
798 799
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
1280 1281
1281 def ComputeOutputBasename(self, spec): 1282 def ComputeOutputBasename(self, spec):
1282 """Return the 'output basename' of a gyp spec. 1283 """Return the 'output basename' of a gyp spec.
1283 1284
1284 E.g., the loadable module 'foobar' in directory 'baz' will produce 1285 E.g., the loadable module 'foobar' in directory 'baz' will produce
1285 'libfoobar.so' 1286 'libfoobar.so'
1286 """ 1287 """
1287 assert not self.is_mac_bundle 1288 assert not self.is_mac_bundle
1288 1289
1289 if self.flavor == 'mac' and self.type in ( 1290 if self.flavor == 'mac' and self.type in (
1290 'static_library', 'executable', 'shared_library', 'loadable_module'): 1291 'static_library', 'executable', 'shared_library', 'loadable_module',
1292 'standalone_static_library'):
1291 return self.xcode_settings.GetExecutablePath() 1293 return self.xcode_settings.GetExecutablePath()
1292 1294
1293 target = spec['target_name'] 1295 target = spec['target_name']
1294 target_prefix = '' 1296 target_prefix = ''
1295 target_ext = '' 1297 target_ext = ''
1296 if self.type == 'static_library': 1298 if self.type in ('static_library', 'standalone_static_library'):
1297 if target[:3] == 'lib': 1299 if target[:3] == 'lib':
1298 target = target[3:] 1300 target = target[3:]
1299 target_prefix = 'lib' 1301 target_prefix = 'lib'
1300 target_ext = '.a' 1302 target_ext = '.a'
1301 elif self.type in ('loadable_module', 'shared_library'): 1303 elif self.type in ('loadable_module', 'shared_library'):
1302 if target[:3] == 'lib': 1304 if target[:3] == 'lib':
1303 target = target[3:] 1305 target = target[3:]
1304 target_prefix = 'lib' 1306 target_prefix = 'lib'
1305 target_ext = '.so' 1307 target_ext = '.so'
1306 elif self.type == 'none': 1308 elif self.type == 'none':
1307 target = '%s.stamp' % target 1309 target = '%s.stamp' % target
1308 elif self.type != 'executable': 1310 elif self.type != 'executable':
1309 print ("ERROR: What output file should be generated?", 1311 print ("ERROR: What output file should be generated?",
1310 "type", self.type, "target", target) 1312 "type", self.type, "target", target)
1311 1313
1312 target_prefix = spec.get('product_prefix', target_prefix) 1314 target_prefix = spec.get('product_prefix', target_prefix)
1313 target = spec.get('product_name', target) 1315 target = spec.get('product_name', target)
1314 product_ext = spec.get('product_extension') 1316 product_ext = spec.get('product_extension')
1315 if product_ext: 1317 if product_ext:
1316 target_ext = '.' + product_ext 1318 target_ext = '.' + product_ext
1317 1319
1318 return target_prefix + target + target_ext 1320 return target_prefix + target + target_ext
1319 1321
1320 1322
1321 def _InstallImmediately(self): 1323 def _InstallImmediately(self):
1322 return self.toolset == 'target' and self.flavor == 'mac' and self.type in ( 1324 return self.toolset == 'target' and self.flavor == 'mac' and self.type in (
1323 'static_library', 'executable', 'shared_library', 'loadable_module') 1325 'static_library', 'standalone_static_library','executable',
1326 'shared_library', 'loadable_module')
1324 1327
1325 1328
1326 def ComputeOutput(self, spec): 1329 def ComputeOutput(self, spec):
1327 """Return the 'output' (full output path) of a gyp spec. 1330 """Return the 'output' (full output path) of a gyp spec.
1328 1331
1329 E.g., the loadable module 'foobar' in directory 'baz' will produce 1332 E.g., the loadable module 'foobar' in directory 'baz' will produce
1330 '$(obj)/baz/libfoobar.so' 1333 '$(obj)/baz/libfoobar.so'
1331 """ 1334 """
1332 assert not self.is_mac_bundle 1335 assert not self.is_mac_bundle
1333 1336
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1527 else: 1530 else:
1528 self.WriteDoCmd([self.output_binary], link_deps, 'link', part_of_all, 1531 self.WriteDoCmd([self.output_binary], link_deps, 'link', part_of_all,
1529 postbuilds=postbuilds) 1532 postbuilds=postbuilds)
1530 1533
1531 elif self.type == 'static_library': 1534 elif self.type == 'static_library':
1532 for link_dep in link_deps: 1535 for link_dep in link_deps:
1533 assert ' ' not in link_dep, ( 1536 assert ' ' not in link_dep, (
1534 "Spaces in alink input filenames not supported (%s)" % link_dep) 1537 "Spaces in alink input filenames not supported (%s)" % link_dep)
1535 self.WriteDoCmd([self.output_binary], link_deps, 'alink', part_of_all, 1538 self.WriteDoCmd([self.output_binary], link_deps, 'alink', part_of_all,
1536 postbuilds=postbuilds) 1539 postbuilds=postbuilds)
1540 elif self.type == 'standalone_static_library':
1541 self.WriteLn(
1542 'cmd_alink = rm -f $@ && $(AR.$(TOOLSET)) crs $@ $(filter %.o,$^)')
1543 for link_dep in link_deps:
1544 assert ' ' not in link_dep, (
1545 "Spaces in alink input filenames not supported (%s)" % link_dep)
1546 self.WriteDoCmd([self.output_binary], link_deps, 'alink', part_of_all,
1547 postbuilds=postbuilds)
borenet 2012/10/01 21:27:48 What should be the behavior when a standalone_stat
1537 elif self.type == 'shared_library': 1548 elif self.type == 'shared_library':
1538 self.WriteLn('%s: LD_INPUTS := %s' % ( 1549 self.WriteLn('%s: LD_INPUTS := %s' % (
1539 QuoteSpaces(self.output_binary), 1550 QuoteSpaces(self.output_binary),
1540 ' '.join(map(QuoteSpaces, link_deps)))) 1551 ' '.join(map(QuoteSpaces, link_deps))))
1541 self.WriteDoCmd([self.output_binary], link_deps, 'solink', part_of_all, 1552 self.WriteDoCmd([self.output_binary], link_deps, 'solink', part_of_all,
1542 postbuilds=postbuilds) 1553 postbuilds=postbuilds)
1543 elif self.type == 'loadable_module': 1554 elif self.type == 'loadable_module':
1544 for link_dep in link_deps: 1555 for link_dep in link_deps:
1545 assert ' ' not in link_dep, ( 1556 assert ' ' not in link_dep, (
1546 "Spaces in module input filenames not supported (%s)" % link_dep) 1557 "Spaces in module input filenames not supported (%s)" % link_dep)
(...skipping 22 matching lines...) Expand all
1569 comment = 'Add target alias to "all" target.', 1580 comment = 'Add target alias to "all" target.',
1570 phony = True) 1581 phony = True)
1571 1582
1572 # Add special-case rules for our installable targets. 1583 # Add special-case rules for our installable targets.
1573 # 1) They need to install to the build dir or "product" dir. 1584 # 1) They need to install to the build dir or "product" dir.
1574 # 2) They get shortcuts for building (e.g. "make chrome"). 1585 # 2) They get shortcuts for building (e.g. "make chrome").
1575 # 3) They are part of "make all". 1586 # 3) They are part of "make all".
1576 if self.type in self._INSTALLABLE_TARGETS: 1587 if self.type in self._INSTALLABLE_TARGETS:
1577 if self.type == 'shared_library': 1588 if self.type == 'shared_library':
1578 file_desc = 'shared library' 1589 file_desc = 'shared library'
1590 elif self.type == 'standalone_static_library':
1591 file_desc = 'static library'
1579 else: 1592 else:
1580 file_desc = 'executable' 1593 file_desc = 'executable'
1581 install_path = self._InstallableTargetInstallPath() 1594 install_path = self._InstallableTargetInstallPath()
1582 installable_deps = [self.output] 1595 installable_deps = [self.output]
1583 if (self.flavor == 'mac' and not 'product_dir' in spec and 1596 if (self.flavor == 'mac' and not 'product_dir' in spec and
1584 self.toolset == 'target'): 1597 self.toolset == 'target'):
1585 # On mac, products are created in install_path immediately. 1598 # On mac, products are created in install_path immediately.
1586 assert install_path == self.output, '%s != %s' % ( 1599 assert install_path == self.output, '%s != %s' % (
1587 install_path, self.output) 1600 install_path, self.output)
1588 1601
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1712 These variable definitions will be used by Android NDK but do nothing for 1725 These variable definitions will be used by Android NDK but do nothing for
1713 non-Android applications. 1726 non-Android applications.
1714 1727
1715 Arguments: 1728 Arguments:
1716 module_name: Android NDK module name, which must be unique among all 1729 module_name: Android NDK module name, which must be unique among all
1717 module names. 1730 module names.
1718 all_sources: A list of source files (will be filtered by Compilable). 1731 all_sources: A list of source files (will be filtered by Compilable).
1719 link_deps: A list of link dependencies, which must be sorted in 1732 link_deps: A list of link dependencies, which must be sorted in
1720 the order from dependencies to dependents. 1733 the order from dependencies to dependents.
1721 """ 1734 """
1722 if self.type not in ('executable', 'shared_library', 'static_library'): 1735 if self.type not in ('executable', 'shared_library', 'static_library',
1736 'standalone_static_library'):
1723 return 1737 return
1724 1738
1725 self.WriteLn('# Variable definitions for Android applications') 1739 self.WriteLn('# Variable definitions for Android applications')
1726 self.WriteLn('include $(CLEAR_VARS)') 1740 self.WriteLn('include $(CLEAR_VARS)')
1727 self.WriteLn('LOCAL_MODULE := ' + module_name) 1741 self.WriteLn('LOCAL_MODULE := ' + module_name)
1728 self.WriteLn('LOCAL_CFLAGS := $(CFLAGS_$(BUILDTYPE)) ' 1742 self.WriteLn('LOCAL_CFLAGS := $(CFLAGS_$(BUILDTYPE)) '
1729 '$(DEFS_$(BUILDTYPE)) ' 1743 '$(DEFS_$(BUILDTYPE)) '
1730 # LOCAL_CFLAGS is applied to both of C and C++. There is 1744 # LOCAL_CFLAGS is applied to both of C and C++. There is
1731 # no way to specify $(CFLAGS_C_$(BUILDTYPE)) only for C 1745 # no way to specify $(CFLAGS_C_$(BUILDTYPE)) only for C
1732 # sources. 1746 # sources.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1777 self.WriteList( 1791 self.WriteList(
1778 DepsToModules(link_deps, 1792 DepsToModules(link_deps,
1779 generator_default_variables['STATIC_LIB_PREFIX'], 1793 generator_default_variables['STATIC_LIB_PREFIX'],
1780 generator_default_variables['STATIC_LIB_SUFFIX']), 1794 generator_default_variables['STATIC_LIB_SUFFIX']),
1781 'LOCAL_STATIC_LIBRARIES') 1795 'LOCAL_STATIC_LIBRARIES')
1782 1796
1783 if self.type == 'executable': 1797 if self.type == 'executable':
1784 self.WriteLn('include $(BUILD_EXECUTABLE)') 1798 self.WriteLn('include $(BUILD_EXECUTABLE)')
1785 elif self.type == 'shared_library': 1799 elif self.type == 'shared_library':
1786 self.WriteLn('include $(BUILD_SHARED_LIBRARY)') 1800 self.WriteLn('include $(BUILD_SHARED_LIBRARY)')
1787 elif self.type == 'static_library': 1801 elif self.type in ('static_library', 'standalone_static_library'):
1788 self.WriteLn('include $(BUILD_STATIC_LIBRARY)') 1802 self.WriteLn('include $(BUILD_STATIC_LIBRARY)')
1789 self.WriteLn() 1803 self.WriteLn()
1790 1804
1791 1805
1792 def WriteLn(self, text=''): 1806 def WriteLn(self, text=''):
1793 self.fp.write(text + '\n') 1807 self.fp.write(text + '\n')
1794 1808
1795 1809
1796 def GetSortedXcodeEnv(self, additional_settings=None): 1810 def GetSortedXcodeEnv(self, additional_settings=None):
1797 return gyp.xcode_emulation.GetSortedXcodeEnv( 1811 return gyp.xcode_emulation.GetSortedXcodeEnv(
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
2127 root_makefile.write("endif\n") 2141 root_makefile.write("endif\n")
2128 root_makefile.write('\n') 2142 root_makefile.write('\n')
2129 2143
2130 if (not generator_flags.get('standalone') 2144 if (not generator_flags.get('standalone')
2131 and generator_flags.get('auto_regeneration', True)): 2145 and generator_flags.get('auto_regeneration', True)):
2132 WriteAutoRegenerationRule(params, root_makefile, makefile_name, build_files) 2146 WriteAutoRegenerationRule(params, root_makefile, makefile_name, build_files)
2133 2147
2134 root_makefile.write(SHARED_FOOTER) 2148 root_makefile.write(SHARED_FOOTER)
2135 2149
2136 root_makefile.close() 2150 root_makefile.close()
OLDNEW
« no previous file with comments | « pylib/gyp/generator/android.py ('k') | pylib/gyp/generator/msvs.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698