예제 #1
0
        public void ApplyMod(XCMod mod)
        {
            PBXGroup modGroup = this.GetGroup(mod.group);

//			UnityEngine.Debug.Log( "Adding libraries..." );
//			PBXGroup librariesGroup = this.GetGroup( "Libraries" );
            foreach (XCModFile libRef in mod.libs)
            {
                string completeLibPath = System.IO.Path.Combine("usr/lib", libRef.filePath);
                this.AddFile(completeLibPath, modGroup, "SDKROOT", true, libRef.isWeak);
            }

//			UnityEngine.Debug.Log( "Adding frameworks..." );
            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);
            }

//			UnityEngine.Debug.Log( "Adding files..." );
//			foreach( string filePath in mod.files ) {
//				string absoluteFilePath = System.IO.Path.Combine( mod.path, filePath );
//
//
//				if( filePath.EndsWith(".framework") )
//					this.AddFile( absoluteFilePath, frameworkGroup, "GROUP", true, false);
//				else
//					this.AddFile( absoluteFilePath, modGroup );
//			}

//			UnityEngine.Debug.Log( "Adding folders..." );
            foreach (string folderPath in mod.folders)
            {
                string absoluteFolderPath = System.IO.Path.Combine(mod.path, folderPath);
                this.AddFolder(absoluteFolderPath, modGroup, (string[])mod.excludes.ToArray(typeof(string)));
            }

//			UnityEngine.Debug.Log( "Adding headerpaths..." );
            foreach (string headerpath in mod.headerpaths)
            {
                string absoluteHeaderPath = System.IO.Path.Combine(mod.path, headerpath);
                this.AddHeaderSearchPaths(absoluteHeaderPath);
            }
//			UnityEngine.Debug.Log( "Adding librarypaths..." );
            foreach (string headerpath in mod.librarypaths)
            {
                string absoluteLibraryPath = System.IO.Path.Combine(mod.path, headerpath);
                this.AddLibrarySearchPaths(absoluteLibraryPath);
            }

//			UnityEngine.Debug.Log ("Adding Zip...");
            foreach (string zipPath in mod.zipPaths)
            {
                string zipFileName = zipPath;
                string sdkName     = zipFileName.Remove(zipFileName.LastIndexOf("."));

                string sdkshell = mod.path + "/import.sh";
                string modPath  = mod.path;
                string action   = "decompress";

                //解压命令参数说明
                //$1 - .zip文件所在路径(即.projmod所在路径,即mod.path)
                //$2 - 行为: 解压为:"decompress"; 移动为:"movefile"
                //$3 - zip完整文件名,例如ShareSDK.zip,此处即 zipFileName = zipPath
                //解压zip
                string  unzipCommand = sdkshell + " " + modPath + " " + action + " " + zipPath;
                Process zipProcess   = new Process();
                zipProcess.StartInfo.FileName  = "/bin/bash";
                zipProcess.StartInfo.Arguments = unzipCommand;
                zipProcess.Start();
                zipProcess.WaitForExit();
                zipProcess.Close();

                //移动命令参数说明
                //$1 - .zip文件所在路径(即.projmod所在路径,即mod.path)
                //$2 - 行为: 解压为:"decompress"; 移动为:"movefile"
                //$3 - 目标路径,此处即为生成的项目的根目录,即this.projectRootPath
                //$4 - SDK名称,一般应该为解压后得到的文件夹的名称,例如 ShareSDK
                //移动解压的文件到项目
                action = "movefile";
                string  movefileCommand = sdkshell + " " + modPath + " " + action + " " + this.projectRootPath + " " + sdkName;
                Process moveProcess     = new Process();
                moveProcess.StartInfo.FileName  = "/bin/bash";
                moveProcess.StartInfo.Arguments = movefileCommand;
                moveProcess.Start();
                moveProcess.WaitForExit();
                moveProcess.Close();

                string absoluteFolderPath = System.IO.Path.Combine(this.projectRootPath, sdkName + "/");
//				this.AddFolder( absoluteFolderPath, modGroup, (string[])mod.excludes.ToArray( typeof(string) ) );
                //第二个参数传null,能够在xcode项目再减少一层文件夹
                this.AddFolder(absoluteFolderPath, null, (string[])mod.excludes.ToArray(typeof(string)));
            }

//			UnityEngine.Debug.Log( "Adding files..." );
            foreach (string filePath in mod.files)
            {
                //原版为根据.projmods中的files来添加
//				string absoluteFilePath = System.IO.Path.Combine( mod.path, filePath );

                //对于ShareSDK,由于解压的文件夹已经移动至Xcode根目录,所以要根据根目录路径进行库路径添加
                string absoluteFilePath = System.IO.Path.Combine(this.projectRootPath, filePath);

                if (filePath.EndsWith(".framework"))
                {
                    this.AddFile(absoluteFilePath, frameworkGroup, "GROUP", true, false);
                }
                else
                {
                    this.AddFile(absoluteFilePath, modGroup);
                }
            }


//			UnityEngine.Debug.Log( "Configure build settings..." );
            Hashtable buildSettings = mod.buildSettings;

            if (buildSettings.ContainsKey("OTHER_LDFLAGS"))
            {
//				UnityEngine.Debug.Log( "    Adding other linker flags..." );
                ArrayList otherLinkerFlags = (ArrayList)buildSettings["OTHER_LDFLAGS"];
                foreach (string linker in otherLinkerFlags)
                {
                    string _linker = linker;
                    if (!_linker.StartsWith("-"))
                    {
                        _linker = "-" + _linker;
                    }
                    this.AddOtherLDFlags(_linker);
                }
            }

            if (buildSettings.ContainsKey("GCC_ENABLE_CPP_EXCEPTIONS"))
            {
//				UnityEngine.Debug.Log( "    GCC_ENABLE_CPP_EXCEPTIONS = " + buildSettings["GCC_ENABLE_CPP_EXCEPTIONS"] );
                this.GccEnableCppExceptions((string)buildSettings["GCC_ENABLE_CPP_EXCEPTIONS"]);
            }

            if (buildSettings.ContainsKey("GCC_ENABLE_OBJC_EXCEPTIONS"))
            {
//				UnityEngine.Debug.Log( "    GCC_ENABLE_OBJC_EXCEPTIONS = " + buildSettings["GCC_ENABLE_OBJC_EXCEPTIONS"] );
                this.GccEnableObjCExceptions((string)buildSettings["GCC_ENABLE_OBJC_EXCEPTIONS"]);
            }

            this.Consolidate();
        }
예제 #2
0
        public void ApplyMod(string pbxmod)
        {
            XCMod mod = new XCMod(pbxmod);

            ApplyMod(mod);
        }