コード例 #1
0
		//Used for updating the details of fileRef.
		public void SetDetails(PBXFileReference fileRef, bool weak = false)
		{
			this.Remove(FILE_REF_KEY);//Removing if it exists.
			SetWeakLink( weak );
			
			this.Add( FILE_REF_KEY, fileRef.guid );
			if (!string.IsNullOrEmpty(fileRef.compilerFlags))
			{
				foreach (var flag in fileRef.compilerFlags.Split(','))
					AddCompilerFlag(flag);
			}
			
		}
コード例 #2
0
		public PBXBuildFile( PBXFileReference fileRef, bool weak = false ) : base()
		{
			SetDetails(fileRef, weak);
		}
コード例 #3
0
		//This returs true if update was done. False if it didnt find PBXBuildFile in buildFiles.
		private bool UpdateBuildFileIfExists(PBXFileReference fileReference, bool weak)
		{
			PBXBuildFile existingFile = null;
			
			//check if buildfiles already has this file reference.
			foreach( KeyValuePair<string, PBXBuildFile> currentItem in buildFiles )
			{
				if(currentItem.Value.fileRef.Equals(fileReference.guid))
				{
					existingFile = currentItem.Value;	
					break;
				}		
			}
			
			if(existingFile != null)
			{
				existingFile.SetDetails(fileReference, weak);
			}
			
			return existingFile != null;
		}
コード例 #4
0
		private void BuildAddFile (PBXFileReference fileReference, KeyValuePair<string, PBXCopyFilesBuildPhase> currentObject,bool weak)
		{
			if(!UpdateBuildFileIfExists(fileReference, weak))
			{
				PBXBuildFile buildFile = new PBXBuildFile( fileReference, weak );
				buildFiles.Add( buildFile );
				currentObject.Value.AddBuildFile( buildFile );
			}
		}
コード例 #5
0
		public PBXDictionary AddFile( string filePath, PBXGroup parent = null, string tree = "SOURCE_ROOT", bool createBuildFiles = true, bool weak = false, string compilerFlags = null)
		{
			//Debug.Log("AddFile " + filePath + ", " + parent + ", " + tree + ", " + (createBuildFiles? "TRUE":"FALSE") + ", " + (weak? "TRUE":"FALSE") ); 
			
			PBXDictionary results = new PBXDictionary();
			if (filePath == null) {
				Debug.LogError ("AddFile called with null filePath");
				return results;
			}

			string absPath = string.Empty;
			
			if( Path.IsPathRooted( filePath ) ) {
				Debug.Log( "Path is Rooted" );
				absPath = filePath;
			}
			else if( tree.CompareTo( "SDKROOT" ) != 0) {
				absPath = Path.Combine( Application.dataPath, filePath );
			}
			
			if( !( File.Exists( absPath ) || Directory.Exists( absPath ) ) && tree.CompareTo( "SDKROOT" ) != 0 ) {
				Debug.Log( "Missing file: " + filePath );
				return results;
			}
			else if( tree.CompareTo( "SOURCE_ROOT" ) == 0 ) {
				Debug.Log( "Source Root File" );
				System.Uri fileURI = new System.Uri( absPath );
				System.Uri rootURI = new System.Uri( ( projectRootPath + "/." ) );
				filePath = rootURI.MakeRelativeUri( fileURI ).ToString();
			}
			else if( tree.CompareTo("GROUP") == 0) {
				Debug.Log( "Group File" );
				filePath = Path.GetFileName( filePath );
			}

			if( parent == null ) {
				parent = _rootGroup;
			}
			
			//Check if there is already a file
			PBXFileReference fileReference = GetFile( Path.GetFileName( filePath ) );	
			if( fileReference != null ) 
			{
				//Updating internal data with this call.
				fileReference.GuessFileType();	
			}
			else
			{
				fileReference = new PBXFileReference( filePath, (TreeEnum)System.Enum.Parse( typeof(TreeEnum), tree ) );
			}

			// Adding compiler flag
			if (!string.IsNullOrEmpty(compilerFlags))
			{
				fileReference.compilerFlags	= compilerFlags;
			}

			parent.AddChild( fileReference );
			fileReferences.Add( fileReference );
			results.Add( fileReference.guid, fileReference );
			
			//Create a build file for reference
			if( !string.IsNullOrEmpty( fileReference.buildPhase ) && createBuildFiles ) {
				
				switch( fileReference.buildPhase ) {
					case "PBXFrameworksBuildPhase":
						foreach( KeyValuePair<string, PBXFrameworksBuildPhase> currentObject in frameworkBuildPhases ) {
							BuildAddFile(fileReference,currentObject,weak);
						}
						if ( !string.IsNullOrEmpty( absPath ) && ( tree.CompareTo( "SOURCE_ROOT" ) == 0 )) {
							string libraryPath = Path.Combine( "$(SRCROOT)", Path.GetDirectoryName( filePath ) );
							if (File.Exists(absPath)) {
								this.AddLibrarySearchPaths( new PBXList( libraryPath ) ); 
							} else {
								this.AddFrameworkSearchPaths( new PBXList( libraryPath ) );  
							}
							
						}
						break;
					case "PBXResourcesBuildPhase":
						foreach( KeyValuePair<string, PBXResourcesBuildPhase> currentObject in resourcesBuildPhases ) {
							Debug.Log( "Adding Resources Build File" );
							BuildAddFile(fileReference,currentObject,weak);
						}
						break;
					case "PBXShellScriptBuildPhase":
						foreach( KeyValuePair<string, PBXShellScriptBuildPhase> currentObject in shellScriptBuildPhases ) {
							Debug.Log( "Adding Script Build File" );
							BuildAddFile(fileReference,currentObject,weak);
						}
						break;
					case "PBXSourcesBuildPhase":
						foreach( KeyValuePair<string, PBXSourcesBuildPhase> currentObject in sourcesBuildPhases ) {
							Debug.Log( "Adding Source Build File" );
							BuildAddFile(fileReference,currentObject,weak);
						}
						break;
					case "PBXCopyFilesBuildPhase":
						foreach( KeyValuePair<string, PBXCopyFilesBuildPhase> currentObject in copyBuildPhases ) {
							Debug.Log( "Adding Copy Files Build Phase" );
							BuildAddFile(fileReference,currentObject,weak);
						}
						break;
					case null:
						Debug.LogWarning( "File Not Supported: " + filePath );
						break;
					default:
						Debug.LogWarning( "File Not Supported." );
						return null;
				}
			}
			return results;
		}
コード例 #6
0
ファイル: XCProject.cs プロジェクト: plentypvp/Projects
        public PBXDictionary AddFile(string filePath, PBXGroup parent = null, string tree = "SOURCE_ROOT", bool createBuildFiles = true, bool weak = false, string compilerFlags = null)
        {
            // Converting path to use Forward slashes
            filePath = filePath.Replace('\\', '/');

//			Debug.Log("AddFile " + filePath + ", " + parent + ", " + tree + ", " + (createBuildFiles? "TRUE":"FALSE") + ", " + (weak? "TRUE":"FALSE") );

            PBXDictionary results = new PBXDictionary();

            if (filePath == null)
            {
                Debug.LogError("AddFile called with null filePath");
                return(results);
            }

            string absPath = string.Empty;

            if (Path.IsPathRooted(filePath))
            {
//				Debug.Log( "Path is Rooted" );
                absPath = filePath;
            }
            else if (tree.CompareTo("SDKROOT") != 0)
            {
                absPath = Path.Combine(Application.dataPath, filePath);
            }

            if (!(File.Exists(absPath) || Directory.Exists(absPath)) && tree.CompareTo("SDKROOT") != 0)
            {
//				Debug.Log( "Missing file: " + filePath );
                return(results);
            }
            else if (tree.CompareTo("SOURCE_ROOT") == 0)
            {
//				Debug.Log( "Source Root File" );
                System.Uri fileURI = new System.Uri(absPath);
                System.Uri rootURI = new System.Uri((projectRootPath + "/."));
                filePath = rootURI.MakeRelativeUri(fileURI).ToString();
            }
            else if (tree.CompareTo("GROUP") == 0)
            {
//				Debug.Log( "Group File" );
                filePath = Path.GetFileName(filePath);
            }

            if (parent == null)
            {
                parent = _rootGroup;
            }

            //Check if there is already a file
            PBXFileReference fileReference = GetFile(Path.GetFileName(filePath));

            if (fileReference != null)
            {
                //Updating internal data with this call.
                fileReference.GuessFileType();
            }
            else
            {
                fileReference = new PBXFileReference(filePath, (TreeEnum)System.Enum.Parse(typeof(TreeEnum), tree));
            }

            // Adding compiler flag
            if (!string.IsNullOrEmpty(compilerFlags))
            {
                fileReference.compilerFlags = compilerFlags;
            }

            parent.AddChild(fileReference);
            fileReferences.Add(fileReference);
            results.Add(fileReference.guid, fileReference);

            //Create a build file for reference
            if (!string.IsNullOrEmpty(fileReference.buildPhase) && createBuildFiles)
            {
                switch (fileReference.buildPhase)
                {
                case "PBXFrameworksBuildPhase":
                    foreach (KeyValuePair <string, PBXFrameworksBuildPhase> currentObject in frameworkBuildPhases)
                    {
                        BuildAddFile(fileReference, currentObject, weak);
                    }
                    if (!string.IsNullOrEmpty(absPath) && (tree.CompareTo("SOURCE_ROOT") == 0))
                    {
                        string libraryPath = Path.Combine("$(SRCROOT)", Path.GetDirectoryName(filePath));
                        if (File.Exists(absPath))
                        {
                            this.AddLibrarySearchPaths(new PBXList(libraryPath));
                        }
                        else
                        {
                            this.AddFrameworkSearchPaths(new PBXList(libraryPath));
                        }
                    }
                    break;

                case "PBXResourcesBuildPhase":
                    foreach (KeyValuePair <string, PBXResourcesBuildPhase> currentObject in resourcesBuildPhases)
                    {
//							Debug.Log( "Adding Resources Build File" );
                        BuildAddFile(fileReference, currentObject, weak);
                    }
                    break;

                case "PBXShellScriptBuildPhase":
                    foreach (KeyValuePair <string, PBXShellScriptBuildPhase> currentObject in shellScriptBuildPhases)
                    {
//							Debug.Log( "Adding Script Build File" );
                        BuildAddFile(fileReference, currentObject, weak);
                    }
                    break;

                case "PBXSourcesBuildPhase":
                    foreach (KeyValuePair <string, PBXSourcesBuildPhase> currentObject in sourcesBuildPhases)
                    {
//							Debug.Log( "Adding Source Build File" );
                        BuildAddFile(fileReference, currentObject, weak);
                    }
                    break;

                case "PBXCopyFilesBuildPhase":
                    foreach (KeyValuePair <string, PBXCopyFilesBuildPhase> currentObject in copyBuildPhases)
                    {
//							Debug.Log( "Adding Copy Files Build Phase" );
                        BuildAddFile(fileReference, currentObject, weak);
                    }
                    break;

                case null:
                    Debug.LogWarning("File Not Supported: " + filePath);
                    break;

                default:
                    Debug.LogWarning("File Not Supported.");
                    return(null);
                }
            }
            return(results);
        }
コード例 #7
0
ファイル: PBXParser.cs プロジェクト: plentypvp/Projects
        public string ResolveName(string guid)
        {
            if (!this.objects.ContainsKey(guid))
            {
                Debug.LogWarning(this + " ResolveName could not resolve " + guid);
                return(string.Empty);                //"UNRESOLVED GUID:" + guid;
            }

            object entity = this.objects[guid];

            if (entity is PBXBuildFile)
            {
                return(ResolveName(((PBXBuildFile)entity).fileRef));
            }
            else if (entity is PBXFileReference)
            {
                PBXFileReference casted = (PBXFileReference)entity;
                return(casted.name != null ? casted.name : casted.path);
            }
            else if (entity is PBXGroup)
            {
                PBXGroup casted = (PBXGroup)entity;
                return(casted.name != null ? casted.name : casted.path);
            }
            else if (entity is PBXProject || guid == this.rootObject)
            {
                return("Project object");
            }
            else if (entity is PBXFrameworksBuildPhase)
            {
                return("Frameworks");
            }
            else if (entity is PBXResourcesBuildPhase)
            {
                return("Resources");
            }
            else if (entity is PBXShellScriptBuildPhase)
            {
                return("ShellScript");
            }
            else if (entity is PBXSourcesBuildPhase)
            {
                return("Sources");
            }
            else if (entity is PBXCopyFilesBuildPhase)
            {
                return("CopyFiles");
            }
            else if (entity is XCConfigurationList)
            {
                XCConfigurationList casted = (XCConfigurationList)entity;
                //Debug.LogWarning ("XCConfigurationList " + guid + " " + casted.ToString());

                if (casted.data.ContainsKey("defaultConfigurationName"))
                {
                    //Debug.Log ("XCConfigurationList " + (string)casted.data[ "defaultConfigurationName" ] + " " + guid);
                    return((string)casted.data["defaultConfigurationName"]);
                }

                return(null);
            }
            else if (entity is PBXNativeTarget)
            {
                PBXNativeTarget obj = (PBXNativeTarget)entity;
                //Debug.LogWarning ("PBXNativeTarget " + guid + " " + obj.ToString());

                if (obj.data.ContainsKey("name"))
                {
                    //Debug.Log ("PBXNativeTarget " + (string)obj.data[ "name" ] + " " + guid);
                    return((string)obj.data["name"]);
                }

                return(null);
            }
            else if (entity is XCBuildConfiguration)
            {
                XCBuildConfiguration obj = (XCBuildConfiguration)entity;
                //Debug.LogWarning ("XCBuildConfiguration UNRESOLVED GUID:" + guid + " " + (obj==null?"":obj.ToString()));

                if (obj.data.ContainsKey("name"))
                {
                    //Debug.Log ("XCBuildConfiguration " + (string)obj.data[ "name" ] + " " + guid + " " + (obj==null?"":obj.ToString()));
                    return((string)obj.data["name"]);
                }
            }
            else if (entity is PBXObject)
            {
                PBXObject obj = (PBXObject)entity;

                if (obj.data.ContainsKey("name"))
                {
                    Debug.Log("PBXObject " + (string)obj.data["name"] + " " + guid + " " + (obj == null?"":obj.ToString()));
                }
                return((string)obj.data["name"]);
            }

            //return "UNRESOLVED GUID:" + guid;
            Debug.LogWarning("UNRESOLVED GUID:" + guid);
            return(null);
        }