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

Side by Side Diff: pylib/gyp/xcodeproj_file.py

Issue 748793002: Fixed Gyp Xcode generator for libraries with identical names. (Closed) Base URL: http://gyp.googlecode.com/svn/trunk
Patch Set: Added comments in the empty CLs for them to be correctly patched. Created 6 years 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/mac/gyptest-identical-name.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 """Xcode project file generator. 5 """Xcode project file generator.
6 6
7 This module is both an Xcode project file generator and a documentation of the 7 This module is both an Xcode project file generator and a documentation of the
8 Xcode project file format. Knowledge of the project file format was gained 8 Xcode project file format. Knowledge of the project file format was gained
9 based on extensive experience with Xcode, and by making changes to projects in 9 based on extensive experience with Xcode, and by making changes to projects in
10 Xcode.app and observing the resultant changes in the associated project files. 10 Xcode.app and observing the resultant changes in the associated project files.
(...skipping 2718 matching lines...) Expand 10 before | Expand all | Expand 10 after
2729 cmp(x['ProjectRef'].Name().lower(), 2729 cmp(x['ProjectRef'].Name().lower(),
2730 y['ProjectRef'].Name().lower())) 2730 y['ProjectRef'].Name().lower()))
2731 else: 2731 else:
2732 # The link already exists. Pull out the relevnt data. 2732 # The link already exists. Pull out the relevnt data.
2733 project_ref_dict = self._other_pbxprojects[other_pbxproject] 2733 project_ref_dict = self._other_pbxprojects[other_pbxproject]
2734 product_group = project_ref_dict['ProductGroup'] 2734 product_group = project_ref_dict['ProductGroup']
2735 project_ref = project_ref_dict['ProjectRef'] 2735 project_ref = project_ref_dict['ProjectRef']
2736 2736
2737 self._SetUpProductReferences(other_pbxproject, product_group, project_ref) 2737 self._SetUpProductReferences(other_pbxproject, product_group, project_ref)
2738 2738
2739 inherit_unique_symroot = self._AllSymrootsUnique(other_pbxproject, False)
2740 targets = other_pbxproject.GetProperty('targets')
2741 if all(self._AllSymrootsUnique(t, inherit_unique_symroot) for t in targets):
2742 dir_path = project_ref._properties['path']
2743 product_group._hashables.extend(dir_path)
2744
2739 return [product_group, project_ref] 2745 return [product_group, project_ref]
2740 2746
2747 def _AllSymrootsUnique(self, target, inherit_unique_symroot):
2748 # Returns True if all configurations have a unique 'SYMROOT' attribute.
2749 # The value of inherit_unique_symroot decides, if a configuration is assumed
2750 # to inherit a unique 'SYMROOT' attribute from its parent, if it doesn't
2751 # define an explicit value for 'SYMROOT'.
2752 for s in self._DefinedSymroots(target):
2753 if (s is not None and not self._IsUniqueSymrootForTarget(s) or
2754 s is None and not inherit_unique_symroot):
2755 return False
2756 return True
2757
2758 def _DefinedSymroots(self, target):
2759 # Returns all values for the 'SYMROOT' attribute defined in all
2760 # configurations for this target. If any configuration doesn't define the
2761 # 'SYMROOT' attribute, None is added to the returned set. If all
2762 # configurations don't define the 'SYMROOT' attribute, an empty set is
2763 # returned.
2764 config_list = target.GetProperty('buildConfigurationList')
2765 symroots = set()
2766 for config in config_list.GetProperty('buildConfigurations'):
2767 setting = config.GetProperty('buildSettings')
2768 if 'SYMROOT' in setting:
2769 symroots.add(setting['SYMROOT'])
2770 else:
2771 symroots.add(None)
2772 if len(symroots) == 1 and None in symroots:
2773 return set()
2774 return symroots
2775
2776 def _IsUniqueSymrootForTarget(self, symroot):
2777 # This method returns True if all configurations in target contain a
2778 # 'SYMROOT' attribute that is unique for the given target. A value is
2779 # unique, if the Xcode macro '$SRCROOT' appears in it in any form.
2780 uniquifier = ['$SRCROOT', '$(SRCROOT)']
2781 if any(x in symroot for x in uniquifier):
2782 return True
2783 return False
2784
2741 def _SetUpProductReferences(self, other_pbxproject, product_group, 2785 def _SetUpProductReferences(self, other_pbxproject, product_group,
2742 project_ref): 2786 project_ref):
2743 # TODO(mark): This only adds references to products in other_pbxproject 2787 # TODO(mark): This only adds references to products in other_pbxproject
2744 # when they don't exist in this pbxproject. Perhaps it should also 2788 # when they don't exist in this pbxproject. Perhaps it should also
2745 # remove references from this pbxproject that are no longer present in 2789 # remove references from this pbxproject that are no longer present in
2746 # other_pbxproject. Perhaps it should update various properties if they 2790 # other_pbxproject. Perhaps it should update various properties if they
2747 # change. 2791 # change.
2748 for target in other_pbxproject._properties['targets']: 2792 for target in other_pbxproject._properties['targets']:
2749 if not isinstance(target, PBXNativeTarget): 2793 if not isinstance(target, PBXNativeTarget):
2750 continue 2794 continue
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
2883 self._XCPrint(file, 0, '/* Begin ' + class_name + ' section */\n') 2927 self._XCPrint(file, 0, '/* Begin ' + class_name + ' section */\n')
2884 for object in sorted(objects_by_class[class_name], 2928 for object in sorted(objects_by_class[class_name],
2885 cmp=lambda x, y: cmp(x.id, y.id)): 2929 cmp=lambda x, y: cmp(x.id, y.id)):
2886 object.Print(file) 2930 object.Print(file)
2887 self._XCPrint(file, 0, '/* End ' + class_name + ' section */\n') 2931 self._XCPrint(file, 0, '/* End ' + class_name + ' section */\n')
2888 2932
2889 if self._should_print_single_line: 2933 if self._should_print_single_line:
2890 self._XCPrint(file, 0, '}; ') 2934 self._XCPrint(file, 0, '}; ')
2891 else: 2935 else:
2892 self._XCPrint(file, 1, '};\n') 2936 self._XCPrint(file, 1, '};\n')
OLDNEW
« no previous file with comments | « no previous file | test/mac/gyptest-identical-name.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698