Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 1928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1939 class PBXCopyFilesBuildPhase(XCBuildPhase): | 1939 class PBXCopyFilesBuildPhase(XCBuildPhase): |
| 1940 _schema = XCBuildPhase._schema.copy() | 1940 _schema = XCBuildPhase._schema.copy() |
| 1941 _schema.update({ | 1941 _schema.update({ |
| 1942 'dstPath': [0, str, 0, 1], | 1942 'dstPath': [0, str, 0, 1], |
| 1943 'dstSubfolderSpec': [0, int, 0, 1], | 1943 'dstSubfolderSpec': [0, int, 0, 1], |
| 1944 'name': [0, str, 0, 0], | 1944 'name': [0, str, 0, 0], |
| 1945 }) | 1945 }) |
| 1946 | 1946 |
| 1947 # path_tree_re matches "$(DIR)/path" or just "$(DIR)". Match group 1 is | 1947 # path_tree_re matches "$(DIR)/path" or just "$(DIR)". Match group 1 is |
| 1948 # "DIR", match group 3 is "path" or None. | 1948 # "DIR", match group 3 is "path" or None. |
| 1949 path_tree_re = re.compile('^\\$\\((.*)\\)(/(.*)|)$') | 1949 path_tree_re = re.compile('^\\$\\((.*?)\\)(/(.*)|)$') |
| 1950 | 1950 |
| 1951 # path_tree_to_subfolder maps names of Xcode variables to the associated | 1951 # path_tree_to_subfolder maps names of Xcode variables to the associated |
| 1952 # dstSubfolderSpec property value used in a PBXCopyFilesBuildPhase object. | 1952 # dstSubfolderSpec property value used in a PBXCopyFilesBuildPhase object. |
| 1953 path_tree_to_subfolder = { | 1953 path_tree_to_subfolder = { |
| 1954 'BUILT_PRODUCTS_DIR': 16, # Products Directory | 1954 # Types that can be chosen via the Xcode UI. |
| 1955 # Other types that can be chosen via the Xcode UI. | 1955 'BUILT_PRODUCTS_DIR': 16, # Products Directory |
|
Mark Mentovai
2014/08/13 17:56:43
Can you sort this list a little bit better?
| |
| 1956 # TODO(mark): Map Xcode variable names to these. | 1956 'WRAPPER_NAME': 1, # Wrapper |
| 1957 # : 1, # Wrapper | 1957 # Although Xcode's friendly name is "Executables", the destination |
| 1958 # : 6, # Executables: 6 | 1958 # is demonstrably the value of the build setting |
| 1959 # : 7, # Resources | 1959 # EXECUTABLE_FOLDER_PATH not EXECUTABLES_FOLDER_PATH. |
| 1960 # : 15, # Java Resources | 1960 'EXECUTABLE_FOLDER_PATH': 6, # Executables. |
|
Mark Mentovai
2014/08/13 17:56:43
No period at the end of this comment.
| |
| 1961 # : 10, # Frameworks | 1961 'UNLOCALIZED_RESOURCES_FOLDER_PATH': 7, # Resources |
| 1962 # : 11, # Shared Frameworks | 1962 'JAVA_FOLDER_PATH': 15, # Java Resources |
| 1963 # : 12, # Shared Support | 1963 'FRAMEWORKS_FOLDER_PATH': 10, # Frameworks |
| 1964 # : 13, # PlugIns | 1964 'SHARED_FRAMEWORKS_FOLDER_PATH': 11, # Shared Frameworks |
| 1965 'SHARED_SUPPORT_FOLDER_PATH': 12, # Shared Support | |
| 1966 'PLUGINS_FOLDER_PATH': 13, # PlugIns | |
| 1967 # For XPC Services, Xcode sets both dstPath and dstSubfolderSpec. | |
| 1968 # Note that it re-uses the BUILT_PRODUCTS_DIR value for | |
| 1969 # dstSubfolderSpec. dstPath is set below. | |
| 1970 'XPCSERVICES_FOLDER_PATH': 16, # XPC Services. | |
| 1965 } | 1971 } |
| 1966 | 1972 |
| 1967 def Name(self): | 1973 def Name(self): |
| 1968 if 'name' in self._properties: | 1974 if 'name' in self._properties: |
| 1969 return self._properties['name'] | 1975 return self._properties['name'] |
| 1970 | 1976 |
| 1971 return 'CopyFiles' | 1977 return 'CopyFiles' |
| 1972 | 1978 |
| 1973 def FileGroup(self, path): | 1979 def FileGroup(self, path): |
| 1974 return self.PBXProjectAncestor().RootGroupForPath(path) | 1980 return self.PBXProjectAncestor().RootGroupForPath(path) |
| 1975 | 1981 |
| 1976 def SetDestination(self, path): | 1982 def SetDestination(self, path): |
| 1977 """Set the dstSubfolderSpec and dstPath properties from path. | 1983 """Set the dstSubfolderSpec and dstPath properties from path. |
| 1978 | 1984 |
| 1979 path may be specified in the same notation used for XCHierarchicalElements, | 1985 path may be specified in the same notation used for XCHierarchicalElements, |
| 1980 specifically, "$(DIR)/path". | 1986 specifically, "$(DIR)/path". |
| 1981 """ | 1987 """ |
| 1982 | 1988 |
| 1983 path_tree_match = self.path_tree_re.search(path) | 1989 path_tree_match = self.path_tree_re.search(path) |
| 1984 if path_tree_match: | 1990 if path_tree_match: |
| 1985 # Everything else needs to be relative to an Xcode variable. | 1991 # Everything else needs to be relative to an Xcode variable. |
| 1986 path_tree = path_tree_match.group(1) | 1992 path_tree = path_tree_match.group(1) |
| 1987 relative_path = path_tree_match.group(3) | 1993 relative_path = path_tree_match.group(3) |
| 1994 separator = '/' | |
|
Mark Mentovai
2014/08/13 17:56:43
I think that separator is '/' if match group 2 is
| |
| 1988 | 1995 |
| 1989 if path_tree in self.path_tree_to_subfolder: | 1996 if path_tree in self.path_tree_to_subfolder: |
| 1990 subfolder = self.path_tree_to_subfolder[path_tree] | 1997 subfolder = self.path_tree_to_subfolder[path_tree] |
| 1991 if relative_path is None: | 1998 if relative_path is None: |
| 1992 relative_path = '' | 1999 relative_path = '' |
| 2000 separator = '' | |
| 2001 if path_tree == 'XPCSERVICES_FOLDER_PATH': | |
| 2002 relative_path = '$(CONTENTS_FOLDER_PATH)/XPCServices' \ | |
| 2003 + separator + relative_path | |
| 1993 else: | 2004 else: |
| 1994 # The path starts with an unrecognized Xcode variable | 2005 # The path starts with an unrecognized Xcode variable |
| 1995 # name like $(SRCROOT). Xcode will still handle this | 2006 # name like $(SRCROOT). Xcode will still handle this |
| 1996 # as an "absolute path" that starts with the variable. | 2007 # as an "absolute path" that starts with the variable. |
| 1997 subfolder = 0 | 2008 subfolder = 0 |
| 1998 relative_path = path | 2009 relative_path = path |
| 1999 elif path.startswith('/'): | 2010 elif path.startswith('/'): |
| 2000 # Special case. Absolute paths are in dstSubfolderSpec 0. | 2011 # Special case. Absolute paths are in dstSubfolderSpec 0. |
| 2001 subfolder = 0 | 2012 subfolder = 0 |
| 2002 relative_path = path[1:] | 2013 relative_path = path[1:] |
| (...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2881 self._XCPrint(file, 0, '/* Begin ' + class_name + ' section */\n') | 2892 self._XCPrint(file, 0, '/* Begin ' + class_name + ' section */\n') |
| 2882 for object in sorted(objects_by_class[class_name], | 2893 for object in sorted(objects_by_class[class_name], |
| 2883 cmp=lambda x, y: cmp(x.id, y.id)): | 2894 cmp=lambda x, y: cmp(x.id, y.id)): |
| 2884 object.Print(file) | 2895 object.Print(file) |
| 2885 self._XCPrint(file, 0, '/* End ' + class_name + ' section */\n') | 2896 self._XCPrint(file, 0, '/* End ' + class_name + ' section */\n') |
| 2886 | 2897 |
| 2887 if self._should_print_single_line: | 2898 if self._should_print_single_line: |
| 2888 self._XCPrint(file, 0, '}; ') | 2899 self._XCPrint(file, 0, '}; ') |
| 2889 else: | 2900 else: |
| 2890 self._XCPrint(file, 1, '};\n') | 2901 self._XCPrint(file, 1, '};\n') |
| OLD | NEW |