protected override void PreProcess()
        {
            Module.DisplayProgressBar("Clear Wrap Files...", 0, true);
            ToLuaMenu.ClearLuaWraps();
            Module.DisplayProgressBar("Clear Lua Files...", 0.2f, true);
            LuaScriptsPreProcessor.Clean();

            EBPUtility.RefreshAssets();
        }
        protected override void PreProcess()
        {
            EBPUtility.RefreshAssets();

            Module.DisplayProgressBar("-- Start Handle Lua Files --", 0f, true);
            HandleLuaFiles(0f, 1f);
            Module.DisplayProgressBar("-- End Handle Lua Files --", 1f, true);

            EBPUtility.RefreshAssets();
        }
Esempio n. 3
0
        public void Prepare()
        {
            try
            {
                Module.StartLog();
                Module.LogHead("Start Prepare", 1);

                Module.DisplayProgressBar("Clear Lua Wraps", 0, true);
                ToLuaMenu.ClearLuaWraps();

                EBPUtility.RefreshAssets();

                Module.DisplayProgressBar("Preparing BuildOptions", 0.2f, true);
                PrepareBuildOptions();

                Module.DisplayProgressBar("Start DownloadConfigs", 0.22f, true);
                DownLoadConfigs(0.22f, 0.5f);

                Module.DisplayProgressBar("Creating Building Configs Class File", 0.5f, true);
                CreateBuildingConfigsClassFile();

                Module.DisplayProgressBar("Applying PlayerSettings", 0.55f, true);
                ApplyPlayerSettings(BuildPlayerOptions.target);

                if (CommonModule.CommonConfig.IsBatchMode)
                {
                    Module.DisplayProgressBar("Start Copy Directories", 0.6f, true);
                    CopyAllDirectories(BuildPlayerOptions.target, Path.Combine(CommonModule.CommonConfig.CurrentLogFolderPath, copyFileLogName));

                    Module.DisplayProgressBar("Applying Scripting Defines", 0.95f, true);
                    ApplyScriptDefines(BuildPlayerOptions.target);
                }
                EBPUtility.RefreshAssets();
            }
            catch (Exception e)
            {
                var state = Module.ModuleStateConfig.Json;
                state.ErrorMessage         = e.Message;
                state.DetailedErrorMessage = e.ToString();
                if (!string.IsNullOrEmpty(Module.ModuleStateConfig.JsonPath))
                {
                    Module.ModuleStateConfig.Save();
                }
                Module.Log(state.DetailedErrorMessage);
                throw new EBPException(e.Message, e);
            }
            finally
            {
                Module.LogHead("End Prepare", 1);
                Module.EndLog();
                EditorUtility.ClearProgressBar();
            }
        }
Esempio n. 4
0
        protected override void RunProcess()
        {
            CommonModule.CommonConfig.Json.CurrentAssetTag = new string[] { "Applying" }.Concat(Module.UserConfig.Json.Tags).ToArray();
            CommonModule.CommonConfig.Save();

            //初始化两个步骤的信息集
            totalCountList = new List <int> {
                -1, -1
            };
            skipCountList = new List <int>()
            {
                -1, -1
            };
            successCountList = new List <int> {
                -1, -1
            };
            LogFilePathList = new List <string> {
                null, null
            };

            //第一步
            currentStepIndex = 0;
            string copyFileArgs = Path.Combine(Module.ModuleConfig.ShellsFolderPath, "CopyFile.sh") + " "
                                  + Path.Combine(CommonModule.CommonConfig.CurrentLogFolderPath, "CopyPreAssets.log") + " Assets " + Module.ModuleConfig.PreStoredAssetsFolderPath;

            copyFileArgs += " " + Module.UserConfig.Json.CopyFileTags;
            RunShell_ShowProgress_WaitForExit(copyFileArgs, "正在从PreStoredAssets里查找文件...", "第1步(共2步) 从PreStoredAssets拷贝文件至Assets目录");
            if (process.ExitCode != 0) //第一步出错
            {
                throw new EBPException("第一步CopyFile时发生错误:" + errorMessage);
            }

            EBPUtility.RefreshAssets();

            //第二步
            currentStepIndex = 1;
            string importerLogPath = Path.Combine(CommonModule.CommonConfig.CurrentLogFolderPath, "ImporterSetting.log");

            LogFilePathList[currentStepIndex] = importerLogPath;
            using (var writer = new StreamWriter(importerLogPath)
            {
                AutoFlush = true
            })
            {
                ApplyImporter(writer);
            }

            CommonModule.CommonConfig.Json.CurrentAssetTag = Module.UserConfig.Json.Tags;
            CommonModule.CommonConfig.Save();
        }
Esempio n. 5
0
        protected override void PostProcess()
        {
            //工程需要的后处理
            switch (BuildPlayerOptions.target)
            {
            case BuildTarget.Android:
                Module.DisplayProgressBar("Renaming OBB File...", 0, true);
                RenameOBBFileForAndroid();
                break;

            case BuildTarget.iOS:
                Module.DisplayProgressBar("Postprocessing for iOS...", 0, true);
                IOSPostProcess(BuildPlayerOptions.locationPathName);
                break;

            default:
                throw new EBPException("意外的平台:" + BuildPlayerOptions.target.ToString());
            }

            EBPUtility.RefreshAssets();
        }
Esempio n. 6
0
        protected override void PreProcess()
        {
            EBPUtility.RefreshAssets();

            Module.DisplayProgressBar("Preparing BuildOptions", 0, true);
            PrepareBuildOptions();

            Module.DisplayProgressBar("-- Start Handle Wrap Files --", 0f, true);
            HandleWrapFiles(0f, 1f);
            Module.DisplayProgressBar("-- End Handle Wrap Files --", 1f, true);

            Module.DisplayProgressBar("Applying PostProcess Settings", 1f, true);
            ApplyPostProcessSettings();

            //为了防止第二次启动Unity后部分设置自动消失(如Android的Keystore配置)
            Module.DisplayProgressBar("Applying PlayerSettings", 1f, true);
            ApplyPlayerSettings(BuildPlayerOptions.target);

            EBPUtility.RefreshAssets();

            iOSBuildPostProcessor.DisableOnce = true; //HACK: 关闭一次旧的后处理过程
        }
Esempio n. 7
0
        protected override void Finally()
        {
            iOSBuildPostProcessor.DisableOnce = false;

            if (CommonModule.CommonConfig.IsBatchMode)
            {
                //还原宏定义
                Module.DisplayProgressBar("Revert Scripting Defines", 0f, true);
                ApplyScriptDefines(EditorUserBuildSettings.activeBuildTarget, true);

                //还原被拷贝覆盖的文件
                Module.DisplayProgressBar("Revert Copied Files", 0f, true);
                string copyFileLogPath = Path.Combine(CommonModule.CommonConfig.CurrentLogFolderPath, copyFileLogName);
                if (File.Exists(copyFileLogPath))
                {
                    RevertAllCopiedFiles(File.ReadAllLines(copyFileLogPath), Path.Combine(CommonModule.CommonConfig.CurrentLogFolderPath, "RevertFiles.log"));
                }

                //清除Wrap
                ToLuaMenu.ClearLuaWraps();
            }

            EBPUtility.RefreshAssets();
        }
 protected override void PostProcess()
 {
     EBPUtility.RefreshAssets();
 }
Esempio n. 9
0
        public void RevertAllCopiedFiles(string[] copiedFilesLogText, string revertLogPath)
        {
            //读入所有已拷贝的文件列表
            var  revertFolderList = new List <string>();
            var  revertFilesList  = new List <string>();
            bool revertThis       = false;

            foreach (var line in copiedFilesLogText)
            {
                if (line[0] == 'R' && line[1] == ' ')
                {
                    revertFolderList.Add(line.Substring(2).Trim());
                    revertThis = true;
                }
                else if (line[0] == 'D' && line[1] == ' ')
                {
                    revertThis = false;
                }
                else if (line[0] == ' ' && line[1] == ' ' && revertThis)
                {
                    revertFilesList.Add(line.Substring(2).Trim());
                }
            }
            //单独的日志文件
            errorMessage = "";
            float progress = 0;

            //删除所有已拷贝并标记为R(revert)的文件(不存在的文件不记录日志)
            using (var logWriter = new StreamWriter(revertLogPath, true))
            {
                Module.DisplayProgressBar("Start Delete Copied Files", 0, true);
                logWriter.WriteLine("Start Delete Files"); logWriter.Flush();
                foreach (string file in revertFilesList)
                {
                    if (File.Exists(file))
                    {
                        Module.DisplayProgressBar("Delete Copied Files", file, progress++ % 1000 / 1000);
                        File.Delete(file);
                        logWriter.WriteLine("Deleted: " + file); logWriter.Flush();
                    }
                }
                logWriter.WriteLine("End Delete Files"); logWriter.Flush();
                Module.DisplayProgressBar("End Delete Copied Files", 0, true);
            }

            //还原目录
            progress = 0;
            Module.DisplayProgressBar("Start Revert All Copied Files", 0, true);
            foreach (var folderPath in revertFolderList)
            {
                string title = "Revert Copied Files in " + EBPUtility.Quote(Path.GetFileName(folderPath));
                Module.DisplayProgressBar(title, "Start Revert " + EBPUtility.Quote(folderPath), 0, true);

                Process p = SVNUpdate.Runner.ExcuteCommand("/bin/bash",
                                                           EBPUtility.Quote(Path.Combine(Module.ModuleConfig.ModuleRootPath, "Shells/SVNRevert.sh")) + " " +
                                                           EBPUtility.Quote(folderPath) + " " +
                                                           EBPUtility.Quote(revertLogPath), OnReceived, OnErrorReceived, null);

                while (!p.HasExited)
                {
                    Module.DisplayProgressBar(title, message, progress++ % 1000 / 1000);
                    System.Threading.Thread.Sleep(50);
                }

                if (p.ExitCode != 0)
                {
                    throw new EBPException("还原目录(" + folderPath + ")时发生错误:" + errorMessage);
                }
                Module.DisplayProgressBar(title, "Finish!", 1, true);
            }
            Module.DisplayProgressBar("End Revert All Copied Files", 1, true);
            EBPUtility.RefreshAssets();
        }
Esempio n. 10
0
        public void CopyAllDirectories(BuildTarget buildTarget, string logPath)
        {
            string directoryRegexStr = CommonModule.CommonConfig.Json.DirectoryRegex;
            string fileRegexStr      = CommonModule.CommonConfig.Json.FileRegex;
            List <UserConfig.PlayerSettings.CopyItem> copyList;

            switch (buildTarget)
            {
            case BuildTarget.Android:
                string directoryRegexStr_Android = Module.UserConfig.Json.PlayerSettings.Android.CopyDirectoryRegex;
                string fileRegexStr_Android      = Module.UserConfig.Json.PlayerSettings.Android.CopyFileRegex;
                if (!string.IsNullOrEmpty(directoryRegexStr_Android))
                {
                    directoryRegexStr = directoryRegexStr_Android;
                }
                if (!string.IsNullOrEmpty(fileRegexStr_Android))
                {
                    fileRegexStr = fileRegexStr_Android;
                }
                copyList = Module.UserConfig.Json.PlayerSettings.Android.CopyList;
                break;

            case BuildTarget.iOS:
                string directoryRegexStr_IOS = Module.UserConfig.Json.PlayerSettings.IOS.CopyDirectoryRegex;
                string fileRegexStr_IOS      = Module.UserConfig.Json.PlayerSettings.IOS.CopyFileRegex;
                if (!string.IsNullOrEmpty(directoryRegexStr_IOS))
                {
                    directoryRegexStr = directoryRegexStr_IOS;
                }
                if (!string.IsNullOrEmpty(fileRegexStr_IOS))
                {
                    fileRegexStr = fileRegexStr_IOS;
                }
                copyList = Module.UserConfig.Json.PlayerSettings.IOS.CopyList;
                break;

            default:
                throw new EBPException("意外的平台:" + BuildPlayerOptions.target.ToString());
            }

            Regex directoryRegex = string.IsNullOrEmpty(directoryRegexStr) ? null : new Regex(directoryRegexStr);
            Regex fileRegex      = string.IsNullOrEmpty(fileRegexStr) ? null : new Regex(fileRegexStr);

            using (var copyFileLogWriter = new StreamWriter(logPath)
            {
                AutoFlush = true
            })
            {
                for (int i = 0; i < copyList.Count; i++)
                {
                    if (!copyList[i].Active)
                    {
                        continue;
                    }
                    Module.DisplayProgressBar(string.Format("Copy Directory... ({0}/{1})", i + 1, copyList.Count), copyList[i].SourcePath + " -> " + copyList[i].TargetPath, 0.5f, true);
                    copyFileLogWriter.WriteLine((copyList[i].Revert ? "R " : "D ") + copyList[i].TargetPath);
                    EBPUtility.CopyDirectory(copyList[i].SourcePath, copyList[i].TargetPath, copyList[i].CopyMode, directoryRegex, fileRegex,
                                             (targetPath) =>
                    {
                        copyFileLogWriter.WriteLine("  " + targetPath);
                    });
                }
            }
            EBPUtility.RefreshAssets();
        }