From abbc702358e40c2f5cd975824a3d464ce685a1e2 Mon Sep 17 00:00:00 2001 From: Jeff Verkoeyen Date: Fri, 22 Oct 2010 13:15:09 -0400 Subject: [PATCH] [ttmodule] Properly check for duplicate LDFLAGS. Xcode annoyingly reformats the LDFLAGS if there is a space in them. --- src/scripts/Pbxproj.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/scripts/Pbxproj.py b/src/scripts/Pbxproj.py index 3556f033a9..e2f2e310a2 100644 --- a/src/scripts/Pbxproj.py +++ b/src/scripts/Pbxproj.py @@ -373,19 +373,28 @@ def add_build_setting(self, configuration, setting_name, value): match = re.search(re.escape(setting_name)+' = ((?:.|\n)+?);', build_settings) if not match: + # Add a brand new build setting. No checking for existing settings necessary. settingtext = '\t\t\t\t'+setting_name+' = '+value+';\n' project_data = project_data[:settings_start] + settingtext + project_data[settings_start:] else: + # Build settings already exist. Is there one or many? (search_paths,) = match.groups() if re.search('\(\n', search_paths): + # Many match = re.search(re.escape(value), search_paths) if not match: - match = re.search(re.escape(setting_name)+' = \(\n', build_settings) - - build_settings = build_settings[:match.end()] + '\t\t\t\t\t'+value+',\n' + build_settings[match.end():] - project_data = project_data[:settings_start] + build_settings + project_data[settings_end:] + # If value has any spaces in it, Xcode will split it up into + # multiple entries. + escaped_value = re.escape(value).replace(' ', '",\n[ \t]+"') + match = re.search(escaped_value, search_paths) + if not match: + match = re.search(re.escape(setting_name)+' = \(\n', build_settings) + + build_settings = build_settings[:match.end()] + '\t\t\t\t\t'+value+',\n' + build_settings[match.end():] + project_data = project_data[:settings_start] + build_settings + project_data[settings_end:] else: + # One if search_paths != value: existing_path = search_paths path_set = '(\n\t\t\t\t\t'+value+',\n\t\t\t\t\t'+existing_path+'\n\t\t\t\t)' @@ -649,9 +658,9 @@ def add_dependency(self, dep): if match: logging.info("This product group already exists.") (children, ) = match.groups() - match = re.search('([A-Z0-9]+) \/\* '+dep._product_name+' \*\/', children) + match = re.search('([A-Z0-9]+) \/\* '+re.escape(dep._product_name)+' \*\/', children) if not match: - logging.error("No product found.") + logging.error("No product found") return False # TODO: Add this product. else: @@ -727,7 +736,7 @@ def add_dependency(self, dep): if not referenceExists: match = re.search('\/\* Begin PBXReferenceProxy section \*\/\n', project_data) - referenceproxytext = "\t\t"+lib_hash+" /* "+dep._product_name+" */ = {\n\t\t\tisa = PBXReferenceProxy;\n\t\t\tfileType = archive.ar;\n\t\t\tpath = "+dep._product_name+";\n\t\t\tremoteRef = "+targetproduct_hash+" /* PBXContainerItemProxy */;\n\t\t\tsourceTree = BUILT_PRODUCTS_DIR;\n\t\t};\n" + referenceproxytext = "\t\t"+lib_hash+" /* "+dep._product_name+" */ = {\n\t\t\tisa = PBXReferenceProxy;\n\t\t\tfileType = archive.ar;\n\t\t\tpath = \""+dep._product_name+"\";\n\t\t\tremoteRef = "+targetproduct_hash+" /* PBXContainerItemProxy */;\n\t\t\tsourceTree = BUILT_PRODUCTS_DIR;\n\t\t};\n" project_data = project_data[:match.end()] + referenceproxytext + project_data[match.end():] logging.info("Done: Created reference proxy.")