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

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

Issue 344573002: Introduce '--no-duplicate-basename-check' option to disable the check of duplicate basenames (Closed) Base URL: http://gyp.googlecode.com/svn/trunk
Patch Set: Rebase with r1946 Created 6 years, 5 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/__init__.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) 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 # 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 11 matching lines...) Expand all
22 # the side to keep the the files readable. 22 # the side to keep the the files readable.
23 23
24 import os 24 import os
25 import re 25 import re
26 import sys 26 import sys
27 import subprocess 27 import subprocess
28 import gyp 28 import gyp
29 import gyp.common 29 import gyp.common
30 import gyp.xcode_emulation 30 import gyp.xcode_emulation
31 from gyp.common import GetEnvironFallback 31 from gyp.common import GetEnvironFallback
32 from gyp.common import GypError
32 33
33 generator_default_variables = { 34 generator_default_variables = {
34 'EXECUTABLE_PREFIX': '', 35 'EXECUTABLE_PREFIX': '',
35 'EXECUTABLE_SUFFIX': '', 36 'EXECUTABLE_SUFFIX': '',
36 'STATIC_LIB_PREFIX': 'lib', 37 'STATIC_LIB_PREFIX': 'lib',
37 'SHARED_LIB_PREFIX': 'lib', 38 'SHARED_LIB_PREFIX': 'lib',
38 'STATIC_LIB_SUFFIX': '.a', 39 'STATIC_LIB_SUFFIX': '.a',
39 'INTERMEDIATE_DIR': '$(obj).$(TOOLSET)/$(TARGET)/geni', 40 'INTERMEDIATE_DIR': '$(obj).$(TOOLSET)/$(TARGET)/geni',
40 'SHARED_INTERMEDIATE_DIR': '$(obj)/gen', 41 'SHARED_INTERMEDIATE_DIR': '$(obj)/gen',
41 'PRODUCT_DIR': '$(builddir)', 42 'PRODUCT_DIR': '$(builddir)',
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 return path 625 return path
625 if os.path.isabs(path): 626 if os.path.isabs(path):
626 return path 627 return path
627 return srcdir_prefix + path 628 return srcdir_prefix + path
628 629
629 630
630 def QuoteSpaces(s, quote=r'\ '): 631 def QuoteSpaces(s, quote=r'\ '):
631 return s.replace(' ', quote) 632 return s.replace(' ', quote)
632 633
633 634
635 # TODO: Avoid code duplication with _ValidateSourcesForMSVSProject in msvs.py.
636 def _ValidateSourcesForOSX(spec, all_sources):
637 """Makes sure if duplicate basenames are not specified in the source list.
638
639 Arguments:
640 spec: The target dictionary containing the properties of the target.
641 """
642 if spec.get('type', None) != 'static_library':
643 return
644
645 basenames = {}
646 for source in all_sources:
647 name, ext = os.path.splitext(source)
648 is_compiled_file = ext in [
649 '.c', '.cc', '.cpp', '.cxx', '.m', '.mm', '.s', '.S']
650 if not is_compiled_file:
651 continue
652 basename = os.path.basename(name) # Don't include extension.
653 basenames.setdefault(basename, []).append(source)
654
655 error = ''
656 for basename, files in basenames.iteritems():
657 if len(files) > 1:
658 error += ' %s: %s\n' % (basename, ' '.join(files))
659
660 if error:
661 print('static library %s has several files with the same basename:\n' %
662 spec['target_name'] + error + 'libtool on OS X will generate' +
663 ' warnings for them.')
664 raise GypError('Duplicate basenames in sources section, see list above')
665
666
634 # Map from qualified target to path to output. 667 # Map from qualified target to path to output.
635 target_outputs = {} 668 target_outputs = {}
636 # Map from qualified target to any linkable output. A subset 669 # Map from qualified target to any linkable output. A subset
637 # of target_outputs. E.g. when mybinary depends on liba, we want to 670 # of target_outputs. E.g. when mybinary depends on liba, we want to
638 # include liba in the linker line; when otherbinary depends on 671 # include liba in the linker line; when otherbinary depends on
639 # mybinary, we just want to build mybinary first. 672 # mybinary, we just want to build mybinary first.
640 target_link_deps = {} 673 target_link_deps = {}
641 674
642 675
643 class MakefileWriter: 676 class MakefileWriter:
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 # Bundle resources. 784 # Bundle resources.
752 if self.is_mac_bundle: 785 if self.is_mac_bundle:
753 all_mac_bundle_resources = ( 786 all_mac_bundle_resources = (
754 spec.get('mac_bundle_resources', []) + extra_mac_bundle_resources) 787 spec.get('mac_bundle_resources', []) + extra_mac_bundle_resources)
755 self.WriteMacBundleResources(all_mac_bundle_resources, mac_bundle_deps) 788 self.WriteMacBundleResources(all_mac_bundle_resources, mac_bundle_deps)
756 self.WriteMacInfoPlist(mac_bundle_deps) 789 self.WriteMacInfoPlist(mac_bundle_deps)
757 790
758 # Sources. 791 # Sources.
759 all_sources = spec.get('sources', []) + extra_sources 792 all_sources = spec.get('sources', []) + extra_sources
760 if all_sources: 793 if all_sources:
794 if self.flavor == 'mac':
795 # libtool on OS X generates warnings for duplicate basenames in the same
796 # target.
797 _ValidateSourcesForOSX(spec, all_sources)
761 self.WriteSources( 798 self.WriteSources(
762 configs, deps, all_sources, extra_outputs, 799 configs, deps, all_sources, extra_outputs,
763 extra_link_deps, part_of_all, 800 extra_link_deps, part_of_all,
764 gyp.xcode_emulation.MacPrefixHeader( 801 gyp.xcode_emulation.MacPrefixHeader(
765 self.xcode_settings, lambda p: Sourceify(self.Absolutify(p)), 802 self.xcode_settings, lambda p: Sourceify(self.Absolutify(p)),
766 self.Pchify)) 803 self.Pchify))
767 sources = filter(Compilable, all_sources) 804 sources = filter(Compilable, all_sources)
768 if sources: 805 if sources:
769 self.WriteLn(SHARED_HEADER_SUFFIX_RULES_COMMENT1) 806 self.WriteLn(SHARED_HEADER_SUFFIX_RULES_COMMENT1)
770 extensions = set([os.path.splitext(s)[1] for s in sources]) 807 extensions = set([os.path.splitext(s)[1] for s in sources])
(...skipping 1401 matching lines...) Expand 10 before | Expand all | Expand 10 after
2172 root_makefile.write("endif\n") 2209 root_makefile.write("endif\n")
2173 root_makefile.write('\n') 2210 root_makefile.write('\n')
2174 2211
2175 if (not generator_flags.get('standalone') 2212 if (not generator_flags.get('standalone')
2176 and generator_flags.get('auto_regeneration', True)): 2213 and generator_flags.get('auto_regeneration', True)):
2177 WriteAutoRegenerationRule(params, root_makefile, makefile_name, build_files) 2214 WriteAutoRegenerationRule(params, root_makefile, makefile_name, build_files)
2178 2215
2179 root_makefile.write(SHARED_FOOTER) 2216 root_makefile.write(SHARED_FOOTER)
2180 2217
2181 root_makefile.close() 2218 root_makefile.close()
OLDNEW
« no previous file with comments | « pylib/gyp/__init__.py ('k') | pylib/gyp/generator/msvs.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698