/// <summary> /// //该函数内已经确保了日志目录路径存在(但不确保主日志路径存在) /// </summary> /// <returns></returns> public static bool LoadCommonConfig() { try { string[] guids = AssetDatabase.FindAssets(CommonConfigSearchText); if (guids.Length == 0) { throw new EBPException("未能找到本地公共配置文件! 搜索文本:" + CommonConfigSearchText); } CommonConfig.Load(AssetDatabase.GUIDToAssetPath(guids[0])); if (CommonConfig.IsBatchMode) { GenerateLogFolderPath(); //确保没有LogPath参数时也存在日志目录路径 CommonConfig.CurrentLogFolderPath = EBPUtility.GetArgValue("LogPath"); //只有batchmode才开启自定义日志路径 } else //只有非batchmode才开启根目录检查和自动创建 { string rootPath = null; if (!string.IsNullOrEmpty(CommonConfig.Json.PipelineRootPath)) { rootPath = EBPUtility.OpenPipelineRoot(CommonConfig.Json.PipelineRootPath); } if (rootPath == null) { rootPath = EBPUtility.OpenPipelineRoot(); } if (rootPath == null) { return(false); } ChangeRootPath(rootPath); } return(true); } catch (Exception e) { if (CommonConfig.IsBatchMode) { throw new EBPException("加载本地公共配置文件时发生错误:" + e.ToString()); } EditorUtility.DisplayDialog("EazyBuildPipeline", "加载本地公共配置文件时发生错误:" + e.Message + "\n加载路径:" + CommonConfig.JsonPath + "\n请设置正确的文件名以及形如以下所示的配置文件:\n" + new CommonConfig(), "确定"); return(false); } }
public static void Run() { //加载公共基础配置 CommonModule.LoadCommonConfig(); consoleLogWriter = new StreamWriter(Path.Combine(CommonModule.CommonConfig.CurrentLogFolderPath, "UnityConsole.log"), true); consoleLogWriter.AutoFlush = true; Application.logMessageReceived += LogConsole; CommonModule.CommonConfig.Json.PipelineRootPath = EBPUtility.GetArgValue("PipelineRootPath"); MasterControl.Module totalModule = new MasterControl.Module(); //加载和检查每一个模块 string platform = EBPUtility.GetArgValue("Platform"); switch (platform.ToLower()) { case "android": platform = "Android"; break; case "ios": platform = "iOS"; break; } string[] assetTag = new[] { platform, EBPUtility.GetArgValue("Definition").ToUpper(), EBPUtility.GetArgValue("Language").ToUpper() }; var disableModules = EBPUtility.GetArgValuesLower("DisableModule"); bool checkMode = CommonModule.CommonConfig.Args_lower.Contains("--checkmode"); bool prepareMode = CommonModule.CommonConfig.Args_lower.Contains("--prepare"); bool cleanUpBundles = CommonModule.CommonConfig.Args_lower.Contains("--cleanupbundles"); foreach (var runner in totalModule.Runners) { if (disableModules.Contains(runner.BaseModule.ModuleName.ToLower())) { continue; //跳过该模块 } //加载模块配置 runner.BaseModule.LoadAllConfigs(true); //设置Tag runner.BaseModule.BaseModuleStateConfig.BaseJson.CurrentTag = assetTag; //覆盖当前状态配置 switch (runner.BaseModule.ModuleName) { case "SVNUpdate": break; case "AssetPreprocessor": runner.BaseModule.BaseModuleStateConfig.BaseJson.CurrentUserConfigName = EBPUtility.GetTagStr(assetTag) + ".json"; break; case "BundleManager": runner.BaseModule.BaseModuleStateConfig.BaseJson.CurrentUserConfigName = EBPUtility.GetArgValue("BundleConfig") + ".json"; BuildAssetBundleOptions compressOption = BuildAssetBundleOptions.None; switch (EBPUtility.GetArgValue("BundleCompressMode")) { case "Uncompress": compressOption = BuildAssetBundleOptions.UncompressedAssetBundle; break; case "LZMA": compressOption = BuildAssetBundleOptions.None; break; case "LZ4": compressOption = BuildAssetBundleOptions.ChunkBasedCompression; break; } totalModule.BundleManagerModule.ModuleStateConfig.Json.CleanUpBundles = cleanUpBundles; totalModule.BundleManagerModule.ModuleStateConfig.Json.CompressionOption = compressOption; totalModule.BundleManagerModule.ModuleStateConfig.Json.ResourceVersion = int.Parse(EBPUtility.GetArgValue("ResourceVersion")); break; case "PackageManager": runner.BaseModule.BaseModuleStateConfig.BaseJson.CurrentUserConfigName = EBPUtility.GetArgValue("subpackage") + ".json"; totalModule.PackageManagerModule.ModuleStateConfig.Json.ClientVersion = EBPUtility.GetArgValue("ClientVersion") ?? totalModule.PackageManagerModule.ModuleStateConfig.Json.ClientVersion; totalModule.PackageManagerModule.ModuleStateConfig.Json.ResourceVersion = int.Parse(EBPUtility.GetArgValue("ResourceVersion")); break; case "PlayerBuilder": runner.BaseModule.BaseModuleStateConfig.BaseJson.CurrentUserConfigName = EBPUtility.GetArgValue("channel") + ".json"; totalModule.PlayerBuilderModule.ModuleStateConfig.Json.ClientVersion = EBPUtility.GetArgValue("ClientVersion") ?? totalModule.PlayerBuilderModule.ModuleStateConfig.Json.ClientVersion; totalModule.PlayerBuilderModule.ModuleStateConfig.Json.ResourceVersion = int.Parse(EBPUtility.GetArgValue("ResourceVersion")); string buildNum = EBPUtility.GetArgValue("BuildNumber"); if (buildNum != null) { totalModule.PlayerBuilderModule.ModuleStateConfig.Json.BuildNumber = int.Parse(buildNum); } break; default: break; } //加载用户配置 runner.BaseModule.LoadUserConfig(); //覆盖用户配置 switch (runner.BaseModule.ModuleName) { case "SVNUpdate": break; case "AssetPreprocessor": break; case "BundleManager": break; case "PackageManager": break; case "PlayerBuilder": var playerSettings = totalModule.PlayerBuilderModule.UserConfig.Json.PlayerSettings; playerSettings.General.ConfigURL_Game = EBPUtility.GetArgValue("ConfigURL-Game") ?? playerSettings.General.ConfigURL_Game; playerSettings.General.ConfigURL_Language = EBPUtility.GetArgValue("ConfigURL-Language") ?? playerSettings.General.ConfigURL_Language; playerSettings.General.ConfigURL_LanguageVersion = EBPUtility.GetArgValue("ConfigURL-LanguageVersion") ?? playerSettings.General.ConfigURL_LanguageVersion; switch (assetTag[0]) { case "iOS": playerSettings.IOS.BundleID = EBPUtility.GetArgValue("BundleID") ?? playerSettings.IOS.BundleID; break; case "Android": playerSettings.Android.PackageName = EBPUtility.GetArgValue("BundleID") ?? playerSettings.Android.PackageName; break; default: break; } break; default: break; } //检查配置 runner.Check(); } if (prepareMode) { totalModule.SVNUpdateRunner.Run(); totalModule.PlayerBuilderRunner.Prepare(); totalModule.StartLog(); totalModule.Log("[Prepare Successfully]"); totalModule.EndLog(); } else { //运行每一个模块 if (!checkMode) { foreach (var runner in totalModule.Runners) { if (disableModules.Contains(runner.BaseModule.ModuleName.ToLower())) { continue; //跳过该模块 } runner.Run(true); } totalModule.StartLog(); totalModule.Log("[Run Pipeline Successfully]"); totalModule.EndLog(); } } Application.logMessageReceived -= LogConsole; }