void FileRefsRemove(string guid) { PBXFileReference fileRef = fileRefs[guid]; fileRefs.RemoveEntry(guid); m_ProjectPathToFileRefMap.Remove(m_FileRefGuidToProjectPathMap[guid]); m_FileRefGuidToProjectPathMap.Remove(guid); foreach (var tree in FileTypeUtils.AllSourceTrees()) { m_RealPathToFileRefMap[tree].Remove(fileRef.path); } m_GuidToParentGroupMap.Remove(guid); }
private void AddBuildFileImpl(string targetGuid, string fileGuid, bool weak, string compileFlags) { PBXNativeTarget target = nativeTargets[targetGuid]; string ext = Path.GetExtension(fileRefs[fileGuid].path); if (FileTypeUtils.IsBuildable(ext) && GetBuildFileForFileGuid(targetGuid, fileGuid) == null) { PBXBuildFile buildFile = PBXBuildFile.CreateFromFile(fileGuid, weak, compileFlags); BuildFilesAdd(targetGuid, buildFile); BuildSection(target, ext).AddGUID(buildFile.guid); } }
public string FindFileGuidByRealPath(string path) { path = FixSlashesInPath(path); foreach (var tree in FileTypeUtils.AllSourceTrees()) { string res = FindFileGuidByRealPath(path, tree); if (res != null) { return(res); } } return(null); }
private FileGUIDListBase BuildSection(PBXNativeTarget target, string path) { string ext = Path.GetExtension(path); var phase = FileTypeUtils.GetFileType(ext); switch (phase) { case PBXFileType.Framework: foreach (var guid in target.phase) { if (frameworks.entry.ContainsKey(guid)) { return(frameworks.entry[guid]); } } break; case PBXFileType.Resource: foreach (var guid in target.phase) { if (resources.entry.ContainsKey(guid)) { return(resources.entry[guid]); } } break; case PBXFileType.Source: foreach (var guid in target.phase) { if (sources.entry.ContainsKey(guid)) { return(sources.entry[guid]); } } break; case PBXFileType.CopyFile: foreach (var guid in target.phase) { if (copyFiles.entry.ContainsKey(guid)) { return(copyFiles.entry[guid]); } } break; } return(null); }
public static PBXFileReference CreateFromFile(string path, string projectFileName, PBXSourceTree tree) { string guid = PBXGUID.Generate(); PBXFileReference fileRef = new PBXFileReference(); fileRef.guid = guid; fileRef.path = path; fileRef.name = projectFileName; fileRef.tree = tree; fileRef.text = String.Format("{{isa = PBXFileReference; lastKnownFileType = {0}; name = {1}; path = {2}; sourceTree = {3}; }}", FileTypeUtils.GetTypeName(Path.GetExtension(fileRef.name)), PBXStream.QuoteStringIfNeeded(fileRef.name), PBXStream.QuoteStringIfNeeded(fileRef.path), PBXStream.QuoteStringIfNeeded(FileTypeUtils.SourceTreeDesc(tree))); return(fileRef); }
void Clear() { m_Section = new Dictionary <string, SectionBase> { { "PBXBuildFile", new PBXBuildFileSection("PBXBuildFile") }, { "PBXFileReference", new PBXFileReferenceSection("PBXFileReference") }, { "PBXGroup", new PBXGroupSection("PBXGroup") }, { "PBXContainerItemProxy", new PBXContainerItemProxySection("PBXContainerItemProxy") }, { "PBXReferenceProxy", new PBXReferenceProxySection("PBXReferenceProxy") }, { "PBXSourcesBuildPhase", new PBXSourcesBuildPhaseSection("PBXSourcesBuildPhase") }, { "PBXFrameworksBuildPhase", new PBXFrameworksBuildPhaseSection("PBXFrameworksBuildPhase") }, { "PBXResourcesBuildPhase", new PBXResourcesBuildPhaseSection("PBXResourcesBuildPhase") }, { "PBXCopyFilesBuildPhase", new PBXCopyFilesBuildPhaseSection("PBXCopyFilesBuildPhase") }, { "PBXShellScriptBuildPhase", new PBXShellScriptBuildPhaseSection("PBXShellScriptBuildPhase") }, { "PBXNativeTarget", new PBXNativeTargetSection("PBXNativeTarget") }, { "PBXTargetDependency", new PBXTargetDependencySection("PBXTargetDependency") }, { "PBXVariantGroup", new PBXVariantGroupSection("PBXVariantGroup") }, { "XCBuildConfiguration", new XCBuildConfigurationSection("XCBuildConfiguration") }, { "XCConfigurationList", new XCConfigurationListSection("XCConfigurationList") }, { "PBXProject", new PBXProjectSection() }, }; m_Header = new List <string>(); m_Footer = new List <string>(); 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, PBXBuildFile> >(); m_ProjectPathToFileRefMap = new Dictionary <string, PBXFileReference>(); m_FileRefGuidToProjectPathMap = new Dictionary <string, string>(); m_RealPathToFileRefMap = new Dictionary <PBXSourceTree, Dictionary <string, PBXFileReference> >(); foreach (var tree in FileTypeUtils.AllSourceTrees()) { m_RealPathToFileRefMap.Add(tree, new Dictionary <string, PBXFileReference>()); } m_ProjectPathToGroupMap = new Dictionary <string, PBXGroup>(); m_GroupGuidToProjectPathMap = new Dictionary <string, string>(); m_GuidToParentGroupMap = new Dictionary <string, PBXGroup>(); }
/** 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: wtf. 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) { PBXNativeTarget target = nativeTargets[targetGuid]; filename = FixSlashesInPath(filename); projectPath = 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"); } PBXGroup productGroup = groups[productsGroupGuid]; // verify file extension string ext = Path.GetExtension(filename); if (!FileTypeUtils.IsBuildable(ext)) { throw new Exception("Wrong file extension"); } // create ContainerItemProxy object var container = PBXContainerItemProxy.Create(projectGuid, "2", remoteFileGuid, remoteInfo); containerItems.AddEntry(container); // create a reference and build file for the library string typeName = FileTypeUtils.GetTypeName(ext); var libRef = PBXReferenceProxy.Create(filename, typeName, container.guid, "BUILT_PRODUCTS_DIR"); references.AddEntry(libRef); PBXBuildFile libBuildFile = PBXBuildFile.CreateFromFile(libRef.guid, false, null); BuildFilesAdd(targetGuid, libBuildFile); BuildSection(target, ext).AddGUID(libBuildFile.guid); // add to products folder productGroup.AddGUID(libRef.guid); }
public static bool IsBuildable(string ext) { return(FileTypeUtils.IsBuildable(ext)); }
public static bool IsKnownExtension(string ext) { return(FileTypeUtils.IsKnownExtension(ext)); }