public void ApplyMod( XCMod mod )
        {
            string[] groupsName = mod.group.Split('/');

            PBXGroup[] groups = new PBXGroup[groupsName.Length];

            groups[0] = GetGroup (groupsName[0]);
            for (int i = 1; i < groupsName.Length ; i++ ) {
                groups[i] = this.GetGroup ( groupsName[i], null, groups[i-1] );
            }

            PBXGroup modGroup = groups[groups.Length - 1];

            foreach( XCModFile libRef in mod.libs ) {
                string completeLibPath;
                if(libRef.sourceTree.Equals("SDKROOT")) {
                    completeLibPath = System.IO.Path.Combine( "usr/lib", libRef.filePath );
                    PBXGroup libraryGroup = GetGroup("Libraries");
                    this.AddFile( completeLibPath, libraryGroup, libRef.sourceTree, true, libRef.isWeak );
                }
                else {
                    completeLibPath = System.IO.Path.Combine( mod.path, libRef.filePath );
                    this.AddFile( completeLibPath, modGroup, libRef.sourceTree, true, libRef.isWeak );
                }
            }
            PBXGroup frameworkGroup = this.GetGroup( "Frameworks" );
            foreach( string framework in mod.frameworks ) {
                string[] filename = framework.Split( ':' );
                bool isWeak = ( filename.Length > 1 ) ? true : false;
                string completePath = System.IO.Path.Combine( "System/Library/Frameworks", filename[0] );
                this.AddFile( completePath, frameworkGroup, "SDKROOT", true, isWeak );
            }

            foreach( string file in mod.files ) {
                string[] fileDesc = file.Split(':');
                string[] compilerFlags = null;
                if (fileDesc.Length > 1)
                    compilerFlags = fileDesc[1].Split(';');
                string absoluteFilePath = System.IO.Path.Combine( mod.path, fileDesc[0] );
                //string filePath, PBXGroup parent = null, string tree = "SOURCE_ROOT", bool createBuildFiles = true, bool weak = false
                this.AddFile( absoluteFilePath, modGroup, "SOURCE_ROOT", true, false, compilerFlags );
            }

            foreach( string folderPath in mod.folders ) {
                string absoluteFolderPath = System.IO.Path.Combine( mod.path, folderPath );
                absoluteFolderPath = System.IO.Path.GetFullPath(absoluteFolderPath).TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
                this.AddFolder( absoluteFolderPath, mod.path, modGroup, mod.excludes.ToArray(), false/*recursive*/);
            }

            foreach( string headerpath in mod.headerpaths ) {
                string absoluteHeaderPath = AddXcodeQuotes( System.IO.Path.Combine( mod.path, headerpath ) );
                this.AddHeaderSearchPaths( absoluteHeaderPath );
            }

            foreach( string librarypath in mod.librarysearchpaths ) {
                string absolutePath = AddXcodeQuotes(System.IO.Path.Combine( mod.path, librarypath ));
                this.AddLibrarySearchPaths( absolutePath );
            }

            if(mod.frameworksearchpath != null)
            {
                foreach( string frameworksearchpath in mod.frameworksearchpath ) {
                    string absoluteHeaderPath = AddXcodeQuotes(System.IO.Path.Combine( mod.path, frameworksearchpath ));
                    this.AddFrameworkSearchPaths( absoluteHeaderPath );
                }
            }

            if (mod.linkers != null)
            {
                foreach( string linker in mod.linkers ) {
                    string _linker = linker;
                    if( !_linker.StartsWith("-") )
                        _linker = "-" + _linker;
                    this.AddOtherLDFlags( _linker );
                }
            }

            this.Consolidate();

            foreach (string plistMod in mod.plist) {
                UnityEditor.SponsorPayEditor.PlistUpdater.UpdatePlist(projectRootPath, plistMod);
            }
        }
Beispiel #2
0
        public void ApplyMod(XCMod mod)
        {
            string[] groupsName = mod.group.Split('/');

            PBXGroup[] groups = new PBXGroup[groupsName.Length];

            groups[0] = GetGroup(groupsName[0]);
            for (int i = 1; i < groupsName.Length; i++)
            {
                groups[i] = this.GetGroup(groupsName[i], null, groups[i - 1]);
            }

            PBXGroup modGroup = groups[groups.Length - 1];

            foreach (XCModFile libRef in mod.libs)
            {
                string completeLibPath;
                if (libRef.sourceTree.Equals("SDKROOT"))
                {
                    completeLibPath = System.IO.Path.Combine("usr/lib", libRef.filePath);
                    PBXGroup libraryGroup = GetGroup("Libraries");
                    this.AddFile(completeLibPath, libraryGroup, libRef.sourceTree, true, libRef.isWeak);
                }
                else
                {
                    completeLibPath = System.IO.Path.Combine(mod.path, libRef.filePath);
                    this.AddFile(completeLibPath, modGroup, libRef.sourceTree, true, libRef.isWeak);
                }
            }

            PBXGroup frameworkGroup = this.GetGroup("Frameworks");

            foreach (string framework in mod.frameworks)
            {
                string[] filename     = framework.Split(':');
                bool     isWeak       = (filename.Length > 1) ? true : false;
                string   completePath = System.IO.Path.Combine("System/Library/Frameworks", filename[0]);
                this.AddFile(completePath, frameworkGroup, "SDKROOT", true, isWeak);
            }

            foreach (string file in mod.files)
            {
                string[] fileDesc      = file.Split(':');
                string[] compilerFlags = null;
                if (fileDesc.Length > 1)
                {
                    compilerFlags = fileDesc[1].Split(';');
                }
                string absoluteFilePath = System.IO.Path.Combine(mod.path, fileDesc[0]);
                //string filePath, PBXGroup parent = null, string tree = "SOURCE_ROOT", bool createBuildFiles = true, bool weak = false
                this.AddFile(absoluteFilePath, modGroup, "SOURCE_ROOT", true, false, compilerFlags);
            }

            foreach (string folderPath in mod.folders)
            {
                string absoluteFolderPath = System.IO.Path.Combine(mod.path, folderPath);
                absoluteFolderPath = System.IO.Path.GetFullPath(absoluteFolderPath).TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
                this.AddFolder(absoluteFolderPath, mod.path, modGroup, mod.excludes.ToArray(), false /*recursive*/);
            }


            foreach (string headerpath in mod.headerpaths)
            {
                string absoluteHeaderPath = AddXcodeQuotes(System.IO.Path.Combine(mod.path, headerpath));
                this.AddHeaderSearchPaths(absoluteHeaderPath);
            }

            foreach (string librarypath in mod.librarysearchpaths)
            {
                string absolutePath = AddXcodeQuotes(System.IO.Path.Combine(mod.path, librarypath));
                this.AddLibrarySearchPaths(absolutePath);
            }

            if (mod.frameworksearchpath != null)
            {
                foreach (string frameworksearchpath in mod.frameworksearchpath)
                {
                    string absoluteHeaderPath = AddXcodeQuotes(System.IO.Path.Combine(mod.path, frameworksearchpath));
                    this.AddFrameworkSearchPaths(absoluteHeaderPath);
                }
            }

            if (mod.linkers != null)
            {
                foreach (string linker in mod.linkers)
                {
                    string _linker = linker;
                    if (!_linker.StartsWith("-"))
                    {
                        _linker = "-" + _linker;
                    }
                    this.AddOtherLDFlags(_linker);
                }
            }

            this.Consolidate();

            foreach (string plistMod in mod.plist)
            {
                UnityEditor.SponsorPayEditor.PlistUpdater.UpdatePlist(projectRootPath, plistMod);
            }
        }
 public void ApplyMod( string rootPath, string pbxmod )
 {
     XCMod mod = new XCMod( System.IO.Path.GetFullPath(rootPath), pbxmod );
     ApplyMod( mod );
 }
Beispiel #4
0
        public void ApplyMod(string rootPath, string pbxmod)
        {
            XCMod mod = new XCMod(System.IO.Path.GetFullPath(rootPath), pbxmod);

            ApplyMod(mod);
        }