public void Clear() { buildFiles = new PBXBuildFileSection("PBXBuildFile"); fileRefs = new PBXFileReferenceSection("PBXFileReference"); groups = new PBXGroupSection("PBXGroup"); containerItems = new PBXContainerItemProxySection("PBXContainerItemProxy"); references = new PBXReferenceProxySection("PBXReferenceProxy"); sources = new PBXSourcesBuildPhaseSection("PBXSourcesBuildPhase"); frameworks = new PBXFrameworksBuildPhaseSection("PBXFrameworksBuildPhase"); resources = new PBXResourcesBuildPhaseSection("PBXResourcesBuildPhase"); copyFiles = new PBXCopyFilesBuildPhaseSection("PBXCopyFilesBuildPhase"); shellScripts = new PBXShellScriptBuildPhaseSection("PBXShellScriptBuildPhase"); nativeTargets = new PBXNativeTargetSection("PBXNativeTarget"); targetDependencies = new PBXTargetDependencySection("PBXTargetDependency"); variantGroups = new PBXVariantGroupSection("PBXVariantGroup"); buildConfigs = new XCBuildConfigurationSection("XCBuildConfiguration"); configs = new XCConfigurationListSection("XCConfigurationList"); project = new PBXProjectSection(); m_UnknownSections = new Dictionary <string, UnknownSection> (); m_Section = new Dictionary <string, SectionBase> { { "PBXBuildFile", buildFiles }, { "PBXFileReference", fileRefs }, { "PBXGroup", groups }, { "PBXContainerItemProxy", containerItems }, { "PBXReferenceProxy", references }, { "PBXSourcesBuildPhase", sources }, { "PBXFrameworksBuildPhase", frameworks }, { "PBXResourcesBuildPhase", resources }, { "PBXCopyFilesBuildPhase", copyFiles }, { "PBXShellScriptBuildPhase", shellScripts }, { "PBXNativeTarget", nativeTargets }, { "PBXTargetDependency", targetDependencies }, { "PBXVariantGroup", variantGroups }, { "XCBuildConfiguration", buildConfigs }, { "XCConfigurationList", configs }, { "PBXProject", project }, }; m_RootElements = new PBXElementDict(); m_UnknownObjects = new PBXElementDict(); m_ObjectVersion = null; m_SectionOrder = new List <string> { "PBXBuildFile", "PBXContainerItemProxy", "PBXCopyFilesBuildPhase", "PBXFileReference", "PBXFrameworksBuildPhase", "PBXGroup", "PBXNativeTarget", "PBXProject", "PBXReferenceProxy", "PBXResourcesBuildPhase", "PBXShellScriptBuildPhase", "PBXSourcesBuildPhase", "PBXTargetDependency", "PBXVariantGroup", "XCBuildConfiguration", "XCConfigurationList" }; m_FileGuidToBuildFileMap = new Dictionary <string, Dictionary <string, PBXBuildFileData> > (); m_ProjectPathToFileRefMap = new Dictionary <string, PBXFileReferenceData> (); m_FileRefGuidToProjectPathMap = new Dictionary <string, string> (); m_RealPathToFileRefMap = new Dictionary <PBXSourceTree, Dictionary <string, PBXFileReferenceData> > (); foreach (var tree in FileTypeUtils.AllAbsoluteSourceTrees()) { m_RealPathToFileRefMap.Add(tree, new Dictionary <string, PBXFileReferenceData> ()); } m_ProjectPathToGroupMap = new Dictionary <string, PBXGroupData> (); m_GroupGuidToProjectPathMap = new Dictionary <string, string> (); m_GuidToParentGroupMap = new Dictionary <string, PBXGroupData> (); }
public override void UpdateProps() { string ext = null; if (m_ExplicitFileType != null) { SetPropertyString("explicitFileType", m_ExplicitFileType); } else if (m_LastKnownFileType != null) { SetPropertyString("lastKnownFileType", m_LastKnownFileType); } else { if (name != null) { ext = Path.GetExtension(name); } else if (m_Path != null) { ext = Path.GetExtension(m_Path); } if (ext != null) { if (FileTypeUtils.IsFileTypeExplicit(ext)) { SetPropertyString("explicitFileType", FileTypeUtils.GetTypeName(ext)); } else { SetPropertyString("lastKnownFileType", FileTypeUtils.GetTypeName(ext)); } } } if (m_Path == name) { SetPropertyString("name", null); } else { SetPropertyString("name", name); } if (m_Path == null) { SetPropertyString("path", ""); } else { SetPropertyString("path", m_Path); } SetPropertyString("sourceTree", FileTypeUtils.SourceTreeDesc(tree)); }
public void FileRefsRemove(string guid) { PBXFileReferenceData fileRef = fileRefs[guid]; fileRefs.RemoveEntry(guid); m_ProjectPathToFileRefMap.Remove(m_FileRefGuidToProjectPathMap[guid]); m_FileRefGuidToProjectPathMap.Remove(guid); foreach (var tree in FileTypeUtils.AllAbsoluteSourceTrees()) { m_RealPathToFileRefMap[tree].Remove(fileRef.path); } m_GuidToParentGroupMap.Remove(guid); }
public string FindFileGuidByRealPath(string path) { path = Utils.FixSlashesInPath(path); foreach (var tree in FileTypeUtils.AllAbsoluteSourceTrees()) { string res = FindFileGuidByRealPath(path, tree); if (res != null) { return(res); } } return(null); }
public FileGUIDListBase BuildSectionAny(PBXNativeTargetData target, string path, bool isFolderRef) { string ext = Path.GetExtension(path); var phase = FileTypeUtils.GetFileType(ext, isFolderRef); switch (phase) { case PBXFileType.Framework: foreach (var guid in target.phases) { if (frameworks.HasEntry(guid)) { return(frameworks[guid]); } } break; case PBXFileType.Resource: foreach (var guid in target.phases) { if (resources.HasEntry(guid)) { return(resources[guid]); } } break; case PBXFileType.Source: foreach (var guid in target.phases) { if (sources.HasEntry(guid)) { return(sources[guid]); } } break; case PBXFileType.CopyFile: foreach (var guid in target.phases) { if (copyFiles.HasEntry(guid)) { return(copyFiles[guid]); } } break; } return(null); }
private void AddBuildFileImpl(string targetGuid, string fileGuid, bool weak, string compileFlags) { PBXNativeTargetData target = nativeTargets[targetGuid]; PBXFileReferenceData fileRef = FileRefsGet(fileGuid); string ext = System.IO.Path.GetExtension(fileRef.path); if (FileTypeUtils.IsBuildable(ext, fileRef.isFolderReference) && BuildFilesGetForSourceFile(targetGuid, fileGuid) == null) { PBXBuildFileData buildFile = PBXBuildFileData.CreateFromFile(fileGuid, weak, compileFlags); BuildFilesAdd(targetGuid, buildFile); BuildSectionAny(target, ext, fileRef.isFolderReference).files.AddGUID(buildFile.guid); } }
public override void UpdateVars() { children = GetPropertyList("children"); path = GetPropertyString("path"); name = GetPropertyString("name"); if (name == null) { name = path; } if (path == null) { path = ""; } tree = FileTypeUtils.ParseSourceTree(GetPropertyString("sourceTree")); }
public override void UpdateVars() { name = GetPropertyString("name"); m_Path = GetPropertyString("path"); if (name == null) { name = m_Path; } if (m_Path == null) { m_Path = ""; } tree = FileTypeUtils.ParseSourceTree(GetPropertyString("sourceTree")); m_ExplicitFileType = GetPropertyString("explicitFileType"); m_LastKnownFileType = GetPropertyString("lastKnownFileType"); }
internal static void AddExternalLibraryDependency(this PBXProject proj, string targetGuid, string filename, string remoteFileGuid, string projectPath, string remoteInfo) { PBXNativeTargetData target = proj.nativeTargets[targetGuid]; filename = PBXPath.FixSlashes(filename); projectPath = PBXPath.FixSlashes(projectPath); string fileGuidByRealPath = proj.FindFileGuidByRealPath(projectPath); if (fileGuidByRealPath == null) { throw new Exception("No such project"); } string guid = (string)null; foreach (ProjectReference projectReference in proj.project.project.projectReferences) { if (projectReference.projectRef == fileGuidByRealPath) { guid = projectReference.group; break; } } if (guid == null) { throw new Exception("Malformed project: no project in project references"); } PBXGroupData pbxGroupData = proj.GroupsGet(guid); string extension = Path.GetExtension(filename); if (!FileTypeUtils.IsBuildableFile(extension)) { throw new Exception("Wrong file extension"); } PBXContainerItemProxyData containerItemProxyData = PBXContainerItemProxyData.Create(fileGuidByRealPath, "2", remoteFileGuid, remoteInfo); proj.containerItems.AddEntry(containerItemProxyData); string typeName = FileTypeUtils.GetTypeName(extension); PBXReferenceProxyData referenceProxyData = PBXReferenceProxyData.Create(filename, typeName, containerItemProxyData.guid, "BUILT_PRODUCTS_DIR"); proj.references.AddEntry(referenceProxyData); PBXBuildFileData fromFile = PBXBuildFileData.CreateFromFile(referenceProxyData.guid, false, (string)null); proj.BuildFilesAdd(targetGuid, fromFile); proj.BuildSectionAny(target, extension, false).files.AddGUID(fromFile.guid); pbxGroupData.children.AddGUID(referenceProxyData.guid); }
public override void UpdateProps() { // The name property is set only if it is different from the path property SetPropertyList("children", children); if (name == path) { SetPropertyString("name", null); } else { SetPropertyString("name", name); } if (path == "") { SetPropertyString("path", null); } else { SetPropertyString("path", path); } SetPropertyString("sourceTree", FileTypeUtils.SourceTreeDesc(tree)); }
/** This function must be called only after the project the library is in has * been added as a dependency via AddExternalProjectDependency. projectPath must be * the same as the 'path' parameter passed to the AddExternalProjectDependency. * remoteFileGuid must be the guid of the referenced file as specified in * PBXFileReference section of the external project * * TODO: what. is remoteInfo entry in PBXContainerItemProxy? Is in referenced project name or * referenced library name without extension? */ public void AddExternalLibraryDependency(string targetGuid, string filename, string remoteFileGuid, string projectPath, string remoteInfo) { PBXNativeTargetData target = nativeTargets[targetGuid]; filename = Utils.FixSlashesInPath(filename); projectPath = Utils.FixSlashesInPath(projectPath); // find the products group to put the new library in string projectGuid = FindFileGuidByRealPath(projectPath); if (projectGuid == null) { throw new Exception("No such project"); } string productsGroupGuid = null; foreach (var proj in project.project.projectReferences) { if (proj.projectRef == projectGuid) { productsGroupGuid = proj.group; break; } } if (productsGroupGuid == null) { throw new Exception("Malformed project: no project in project references"); } PBXGroupData productGroup = GroupsGet(productsGroupGuid); // verify file extension string ext = Path.GetExtension(filename); if (!FileTypeUtils.IsBuildableFile(ext)) { throw new Exception("Wrong file extension"); } // create ContainerItemProxy object var container = PBXContainerItemProxyData.Create(projectGuid, "2", remoteFileGuid, remoteInfo); containerItems.AddEntry(container); // create a reference and build file for the library string typeName = FileTypeUtils.GetTypeName(ext); var libRef = PBXReferenceProxyData.Create(filename, typeName, container.guid, "BUILT_PRODUCTS_DIR"); references.AddEntry(libRef); PBXBuildFileData libBuildFile = PBXBuildFileData.CreateFromFile(libRef.guid, false, null); BuildFilesAdd(targetGuid, libBuildFile); BuildSectionAny(target, ext, false).files.AddGUID(libBuildFile.guid); // add to products folder productGroup.children.AddGUID(libRef.guid); }
public static bool IsBuildable(string ext) { return(FileTypeUtils.IsBuildableFile(ext)); }
public static bool IsKnownExtension(string ext) { return(FileTypeUtils.IsKnownExtension(ext)); }
// This function returns a build section that a particular file should be automatically added to. // Returns null for non-buildable file types. // Throws an exception if the file should be added to a section, but that particular section does not exist for given target // Note that for unknown file types we add them to resource build sections public FileGUIDListBase BuildSectionAny(PBXNativeTargetData target, string path, bool isFolderRef) { string ext = Path.GetExtension(path); var phase = FileTypeUtils.GetFileType(ext, isFolderRef); switch (phase) { case PBXFileType.Framework: foreach (var guid in target.phases) { if (frameworks.HasEntry(guid)) { return(frameworks[guid]); } } break; case PBXFileType.Resource: foreach (var guid in target.phases) { if (resources.HasEntry(guid)) { return(resources[guid]); } } break; case PBXFileType.Source: foreach (var guid in target.phases) { if (sources.HasEntry(guid)) { return(sources[guid]); } } break; case PBXFileType.CopyFile: foreach (var guid in target.phases) { if (copyFiles.HasEntry(guid)) { return(copyFiles[guid]); } } break; case PBXFileType.ShellScript: foreach (var guid in target.phases) { if (shellScripts.HasEntry(guid)) { return(shellScripts[guid]); } } break; case PBXFileType.NotBuildable: return(null); } throw new Exception(String.Format("The given path {0} does not refer to a file in a known build section", path)); }