예제 #1
0
        private void PopulateList()
        {
            Type ti = typeof(BuildPlatform);

            availablePlatformNameList.Clear();
            availablePlatformTypeList.Clear();
            foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies())
            {
                foreach (Type t in asm.GetTypes())
                {
                    if (ti.IsAssignableFrom(t) && ti != t)
                    {
                        BuildPlatform instance = (BuildPlatform)Activator.CreateInstance(t);
                        availablePlatformNameList.Add(instance.platformName);
                        availablePlatformTypeList.Add(t);
                    }
                }
            }
        }
        public override void PerBuildExecute(BuildReleaseType releaseType, BuildPlatform platform, BuildArchitecture architecture, BuildDistribution distribution, System.DateTime buildTime, ref BuildOptions options, string configKey, string buildPath)
        {
            string resolvedInputPath  = BuildProject.ResolvePath(inputPath.Replace("$BUILDPATH", buildPath), releaseType, platform, architecture, distribution, buildTime);
            string resolvedOutputPath = BuildProject.ResolvePath(outputPath.Replace("$BUILDPATH", buildPath), releaseType, platform, architecture, distribution, buildTime);

            switch (operation)
            {
            case Operation.Copy:
                Copy(resolvedInputPath, resolvedOutputPath);
                break;

            case Operation.Move:
                Move(resolvedInputPath, resolvedOutputPath);
                break;

            case Operation.Delete:
                Delete(resolvedInputPath);
                break;
            }

            AssetDatabase.Refresh();
        }
예제 #3
0
        private static void PerformPostBuild(
            BuildReleaseType releaseType,
            BuildPlatform platform,
            BuildArchitecture architecture,
            BuildDistribution distribution,
            DateTime buildTime, ref BuildOptions options, string configKey, string buildPath)
        {
            BuildAction[] buildActions = BuildSettings.postBuildActions.buildActions;
            if (buildActions != null)
            {
                for (int i = 0; i < buildActions.Length; i++)
                {
                    BuildAction action = buildActions[i];

                    // Check if execute method has been overriden.
                    MethodInfo m = action.GetType().GetMethod("PerBuildExecute");
                    if (m.GetBaseDefinition().DeclaringType != m.DeclaringType && action.actionType == BuildAction.ActionType.PerPlatform)
                    {
                        // Check build filter and execute if true.
                        if (action.filter == null || action.filter.Evaluate(releaseType, platform, architecture, distribution, configKey) && action.actionEnabled)
                        {
                            BuildNotificationList.instance.AddNotification(new BuildNotification(
                                                                               BuildNotification.Category.Notification,
                                                                               string.Format("Performing Post-Build Action ({0}/{1}).", i + 1, buildActions.Length), string.Format("{0}: {1}", action.actionName, configKey),
                                                                               true, null));

                            action.PerBuildExecute(releaseType, platform, architecture, distribution, buildTime, ref options, configKey, buildPath);
                        }
                        else
                        {
                            BuildNotificationList.instance.AddNotification(new BuildNotification(
                                                                               BuildNotification.Category.Notification,
                                                                               string.Format("Skipping Post-Build Action ({0}/{1}).", i + 1, buildActions.Length), string.Format("{0}: {1}", action.actionName, configKey),
                                                                               true, null));
                        }
                    }
                }
            }
        }
        private void Build(BuildPlatform platform, BuildArchitecture arch)
        {
            if (!platform.enabled || !arch.enabled)
            {
                return;
            }

            // Resolve build path.
            StringBuilder platformBundlePath = new StringBuilder(Path.Combine(baseBuildPath, innerBuildPath));

            platformBundlePath.Replace("$PLATFORM", BuildProject.SanitizeFolderName(platform.platformName));
            platformBundlePath.Replace("$ARCHITECTURE", BuildProject.SanitizeFolderName(arch.name));

            // Create build destination directory if it does not exist.
            if (!Directory.Exists(platformBundlePath.ToString()))
            {
                Directory.CreateDirectory(platformBundlePath.ToString());
            }

            // Build AssetBundles.
            BuildPipeline.BuildAssetBundles(platformBundlePath.ToString(), options, arch.target);
        }
예제 #5
0
        public static string GenerateDefaultDefines(BuildReleaseType releaseType, BuildPlatform buildPlatform,
                                                    BuildArchitecture arch, BuildDistribution dist)
        {
            List <string> defines = new List <string>();

            if (releaseType != null)
            {
                defines.Add("BUILD_TYPE_" + SanitizeCodeString(releaseType.typeName.ToUpper().Replace(" ", "")));
            }

            if (buildPlatform != null)
            {
                defines.Add("BUILD_PLATFORM_" +
                            SanitizeCodeString(buildPlatform.platformName.ToUpper().Replace(" ", "")));
            }

            if (arch != null)
            {
                defines.Add("BUILD_ARCH_" + SanitizeCodeString(arch.name.ToUpper().Replace(" ", "")));
            }

            if (dist != null)
            {
                defines.Add("BUILD_DIST_" + SanitizeCodeString(dist.distributionName.ToUpper().Replace(" ", "")));
            }

            if (releaseType != null && !string.IsNullOrEmpty(releaseType.customDefines))
            {
                string[] customDefines = releaseType.customDefines.Split(';', ',');
                for (int i = 0; i < customDefines.Length; i++)
                {
                    defines.Add(SanitizeCodeString(customDefines[i]).ToUpper());
                }
            }

            return(string.Join(";", defines.ToArray()));
        }
예제 #6
0
        private static bool BuildPlayer(string notification, BuildReleaseType releaseType, BuildPlatform platform, BuildArchitecture architecture, BuildDistribution distribution, DateTime buildTime, BuildOptions options, string configKey)
        {
            bool success = true;

            // Get build options.
            if (releaseType.developmentBuild)
            {
                options |= BuildOptions.Development;
            }
            if (releaseType.allowDebugging)
            {
                options |= BuildOptions.AllowDebugging;
            }
            if (releaseType.enableHeadlessMode)
            {
                options |= BuildOptions.EnableHeadlessMode;
            }

            // Generate build path.
            string buildPath = GenerateBuildPath(BuildSettings.basicSettings.buildPath, releaseType, platform, architecture, distribution, buildTime);
            string exeName   = string.Format(platform.binaryNameFormat, SanitizeFileName(releaseType.productName));

            // Save current user defines, and then set target defines.
            string preBuildDefines = PlayerSettings.GetScriptingDefineSymbolsForGroup(platform.targetGroup);
            string buildDefines    = GenerateDefaultDefines(releaseType, platform, architecture, distribution);

            buildDefines = MergeDefines(preBuildDefines, buildDefines);

            PlayerSettings.SetScriptingDefineSymbolsForGroup(platform.targetGroup, buildDefines);
            //Debug.Log("Build Defines: " + buildDefines);

            // Set bundle info.
            // Unfortunately, there's not a good way to do this pre-5.6 that doesn't break building w/ batch mode.
#if UNITY_5_6_OR_NEWER
            PlayerSettings.SetApplicationIdentifier(platform.targetGroup, releaseType.bundleIndentifier);
#endif

            // Set product name.
            PlayerSettings.companyName = releaseType.companyName;
            PlayerSettings.productName = releaseType.productName;

            // Apply build variant.
            platform.ApplyVariant();

            // Pre-build actions.
            PerformPreBuild(releaseType, platform, architecture, distribution, buildTime, ref options, configKey, buildPath);

            // Generate BuildConstants.
            BuildConstantsGenerator.Generate(buildTime, BuildSettings.productParameters.lastGeneratedVersion, releaseType, platform, architecture, distribution);

            // Refresh scene list to make sure nothing has been deleted or moved.
            releaseType.sceneList.Refresh();

            // Report build starting.
            BuildNotificationList.instance.AddNotification(new BuildNotification(
                                                               BuildNotification.Category.Notification,
                                                               notification, configKey,
                                                               true, null));

            // Build player.
            FileUtil.DeleteFileOrDirectory(buildPath);

            string error = "";
#if UNITY_2018_1_OR_NEWER
            UnityEditor.Build.Reporting.BuildReport buildReport = BuildPipeline.BuildPlayer(releaseType.sceneList.GetSceneFileList(), Path.Combine(buildPath, exeName), architecture.target, options);
            if (buildReport.summary.result == UnityEditor.Build.Reporting.BuildResult.Failed)
            {
                error = buildReport.summary.totalErrors + " occurred.";
            }
#else
            error = BuildPipeline.BuildPlayer(releaseType.sceneList.GetSceneFileList(), Path.Combine(buildPath, exeName), architecture.target, options);
#endif
            if (!string.IsNullOrEmpty(error))
            {
                success = false;

                BuildNotificationList.instance.AddNotification(new BuildNotification(
                                                                   BuildNotification.Category.Error,
                                                                   "Build Failed:", configKey.ToString() + "\n" + error,
                                                                   true, null));
            }

            // Post-build actions.
            PerformPostBuild(releaseType, platform, architecture, distribution, buildTime, ref options, configKey, buildPath);

            // Restore pre-build settings.
            PlayerSettings.SetScriptingDefineSymbolsForGroup(platform.targetGroup, preBuildDefines);

            return(success);
        }
예제 #7
0
        public static string ResolvePath(string prototype, BuildReleaseType releaseType, BuildPlatform buildPlatform, BuildArchitecture arch, BuildDistribution dist, DateTime buildTime)
        {
            StringBuilder sb = new StringBuilder(prototype);

            sb.Replace("$YEAR", buildTime.ToString("yyyy"));
            sb.Replace("$MONTH", buildTime.ToString("MM"));
            sb.Replace("$DAY", buildTime.ToString("dd"));
            sb.Replace("$TIME", buildTime.ToString("hhmmss"));

            string archName = arch.name;

            if (buildPlatform.variants != null && buildPlatform.variants.Length > 0)
            {
                archName += "(" + buildPlatform.variantKey + ")";
            }

            sb.Replace("$RELEASE_TYPE", SanitizeFolderName(releaseType.typeName));
            sb.Replace("$PLATFORM", SanitizeFolderName(buildPlatform.platformName));
            sb.Replace("$ARCHITECTURE", SanitizeFolderName(archName));
            sb.Replace("$DISTRIBUTION", SanitizeFolderName(dist != null ? dist.distributionName : BuildConstantsGenerator.NONE));
            sb.Replace("$VERSION", SanitizeFolderName(BuildSettings.productParameters.lastGeneratedVersion));
            sb.Replace("$BUILD", BuildSettings.productParameters.buildCounter.ToString());
            sb.Replace("$PRODUCT_NAME", SanitizeFolderName(releaseType.productName));

            return(sb.ToString());
        }
예제 #8
0
        public static string GenerateBuildPath(string prototype, BuildReleaseType releaseType, BuildPlatform buildPlatform, BuildArchitecture arch, BuildDistribution dist, DateTime buildTime)
        {
            string resolvedProto = ResolvePath(prototype, releaseType, buildPlatform, arch, dist, buildTime);
            string buildPath     = Path.Combine(BuildSettings.basicSettings.baseBuildFolder, resolvedProto);

            buildPath = Path.GetFullPath(buildPath).TrimEnd('\\').TrimEnd('/');


            return(buildPath);
        }
예제 #9
0
        private static bool BuildPlayer(string notification, BuildReleaseType releaseType, BuildPlatform platform, BuildArchitecture architecture, BuildDistribution distribution, DateTime buildTime, BuildOptions options, string configKey)
        {
            bool success = true;

            // Get build options.
            if (releaseType.developmentBuild)
            {
                options |= BuildOptions.Development;
            }
            if (releaseType.allowDebugging)
            {
                options |= BuildOptions.AllowDebugging;
            }

            // Generate build path.
            string buildPath = GenerateBuildPath(BuildSettings.basicSettings.buildPath, releaseType, platform, architecture, distribution, buildTime);
            string exeName   = string.Format(platform.binaryNameFormat, SanitizeFileName(releaseType.productName));

            // Set defines.
            string defines = GenerateDefaultDefines(releaseType, platform, architecture, distribution);

            PlayerSettings.SetScriptingDefineSymbolsForGroup(platform.targetGroup, defines);

            // Pre-build actions.
            PerformPreBuild(releaseType, platform, architecture, distribution, buildTime, ref options, configKey, buildPath);

            // Generate BuildConstants.
            BuildConstantsGenerator.Generate(buildTime, BuildSettings.productParameters.lastGeneratedVersion, releaseType, platform, architecture, distribution);

            // Refresh scene list to make sure nothing has been deleted or moved.
            releaseType.sceneList.Refresh();

            // Report build starting.
            BuildNotificationList.instance.AddNotification(new BuildNotification(
                                                               BuildNotification.Category.Notification,
                                                               notification, configKey,
                                                               true, null));

            // Build player.
            FileUtil.DeleteFileOrDirectory(buildPath);
            string error = BuildPipeline.BuildPlayer(releaseType.sceneList.GetSceneList(), Path.Combine(buildPath, exeName), architecture.target, options);

            if (!string.IsNullOrEmpty(error))
            {
                success = false;

                BuildNotificationList.instance.AddNotification(new BuildNotification(
                                                                   BuildNotification.Category.Error,
                                                                   "Build Failed:", configKey.ToString() + "\n" + error,
                                                                   true, null));
            }

            // Post-build actions.
            PerformPostBuild(releaseType, platform, architecture, distribution, buildTime, ref options, configKey, buildPath);

            return(success);
        }
예제 #10
0
        private string[] RefreshPlatforms(string keyChain, ConfigDictionary refreshedConfigSet, ConfigDictionary prevConfigSet)
        {
            List <string> childKeys = new List <string>();

            List <BuildPlatform> platforms = BuildSettings.platformList.platforms;

            for (int i = 0; i < platforms.Count; i++)
            {
                // Skip if platform is disabled or if it doesn't have any enabled architectures.
                if (!platforms[i].enabled || !platforms[i].atLeastOneArch)
                {
                    continue;
                }

                string        key       = keyChain + "/" + platforms[i].platformName;
                Configuration relConfig = new Configuration();

                // Check for duplicate key.
                if (refreshedConfigSet.ContainsKey(key))
                {
                    continue;
                }

                // Copy previous settings if they exist.
                if (prevConfigSet != null && prevConfigSet.ContainsKey(key))
                {
                    relConfig.enabled = prevConfigSet[key].enabled;
                }

                // Refresh architectures.
                BuildArchitecture[] architectures = platforms[i].architectures;
                if (architectures.Length > 0)
                {
                    relConfig.childKeys = RefreshArchitectures(key, refreshedConfigSet, platforms[i].variantKey, architectures, platforms[i].distributionList.distributions, prevConfigSet);
                }

                // Scan ahead for other versions of this platform with different variants.
                for (int j = i; j < platforms.Count; j++)
                {
                    BuildPlatform otherPlatform = platforms[j];
                    if (otherPlatform.platformName == platforms[i].platformName && otherPlatform.enabled && otherPlatform.atLeastOneArch)
                    {
                        List <string> currentKeys    = new List <string>(relConfig.childKeys);
                        string[]      additionalKeys = RefreshArchitectures(key, refreshedConfigSet, otherPlatform.variantKey, otherPlatform.architectures, otherPlatform.distributionList.distributions, prevConfigSet);

                        for (int k = 0; k < additionalKeys.Length; k++)
                        {
                            if (!currentKeys.Contains(additionalKeys[k]))
                            {
                                currentKeys.Add(additionalKeys[k]);
                            }
                        }

                        relConfig.childKeys = currentKeys.ToArray();
                    }
                }

                // Save configuration.
                refreshedConfigSet.Add(key, relConfig);

                // Add key to list to send back to parent.
                childKeys.Add(key);
            }

            return(childKeys.ToArray());
        }
        public void InitializeErrors()
        {
            AddNotification(new BuildNotification(
                                BuildNotification.Category.Error,
                                "No ReleaseType Found",
                                "At least one ReleaseType is required to perform a build.",
                                false,
                                () => BuildSettings.releaseTypeList.releaseTypes.Length == 0));

            AddNotification(new BuildNotification(
                                BuildNotification.Category.Error,
                                "No Build Platform Found",
                                "At least one Build Platform with one enabled Architecture is required to perform a build.",
                                false,
                                () =>
            {
                bool validError = true;

                int platformCount = BuildSettings.platformList.platforms.Count;
                if (platformCount > 0)
                {
                    for (int i = 0; i < platformCount; i++)
                    {
                        BuildPlatform platform = BuildSettings.platformList.platforms[i];
                        if (platform.enabled && platform.atLeastOneArch)
                        {
                            validError = false;
                            break;
                        }
                    }
                }

                return(validError);
            }));

            AddNotification(new BuildNotification(
                                BuildNotification.Category.Error,
                                "Invalid ReleaseType Name",
                                "One or more ReleaseType names is invalid. They may not be empty or '" + BuildConstantsGenerator.NONE + "'.",
                                false,
                                () =>
            {
                bool validError = false;

                int count = BuildSettings.releaseTypeList.releaseTypes.Length;
                for (int i = 0; i < count; i++)
                {
                    string typeName = BuildSettings.releaseTypeList.releaseTypes[i].typeName.Trim();
                    if (string.IsNullOrEmpty(typeName) ||
                        typeName.Equals(BuildConstantsGenerator.NONE, StringComparison.OrdinalIgnoreCase))
                    {
                        validError = true;
                        break;
                    }
                }

                return(validError);
            }));

            AddNotification(new BuildNotification(
                                BuildNotification.Category.Error,
                                "Invalid Distribution Name",
                                "One or more Distribution names is invalid. They may not be empty or '" + BuildConstantsGenerator.NONE + "'.",
                                false,
                                () =>
            {
                bool validError = false;

                int platformCount = BuildSettings.platformList.platforms.Count;
                for (int i = 0; i < platformCount; i++)
                {
                    BuildPlatform platform = BuildSettings.platformList.platforms[i];
                    int distroCount        = platform.distributionList.distributions.Length;
                    for (int j = 0; j < distroCount; j++)
                    {
                        string distributionName = platform.distributionList.distributions[j].distributionName.Trim();
                        if (string.IsNullOrEmpty(distributionName) ||
                            distributionName.Equals(BuildConstantsGenerator.NONE, StringComparison.OrdinalIgnoreCase))
                        {
                            validError = true;
                            break;
                        }
                    }
                }

                return(validError);
            }));
        }
예제 #12
0
        private static bool BuildPlayer(string notification, BuildReleaseType releaseType, BuildPlatform platform, BuildArchitecture architecture, BuildDistribution distribution, DateTime buildTime, BuildOptions options, string configKey)
        {
            bool success = true;

            // Get build options.获取生成选项。
            if (releaseType.developmentBuild)
            {
                options |= BuildOptions.Development;
            }
            if (releaseType.allowDebugging)
            {
                options |= BuildOptions.AllowDebugging;
            }
            if (releaseType.enableHeadlessMode)
            {
                options |= BuildOptions.EnableHeadlessMode;
            }

            // Generate build path.生成生成路径。
            string buildPath = GenerateBuildPath(BuildSettings.basicSettings.buildPath, releaseType, platform, architecture, distribution, buildTime);
            string binName   = string.Format(architecture.binaryNameFormat, SanitizeFileName(releaseType.productName));

            // Save current user defines, and then set target defines.保存当前用户定义,然后设置目标定义。
            string preBuildDefines = PlayerSettings.GetScriptingDefineSymbolsForGroup(platform.targetGroup);
            string buildDefines    = GenerateDefaultDefines(releaseType, platform, architecture, distribution);

            buildDefines = MergeDefines(preBuildDefines, buildDefines);

            PlayerSettings.SetScriptingDefineSymbolsForGroup(platform.targetGroup, buildDefines);
            //Debug.Log("Build Defines: " + buildDefines);

            // Save current player settings, and then set target settings.保存当前播放机设置,然后设置目标设置。
            string preBuildCompanyName = PlayerSettings.companyName;
            string preBuildProductName = PlayerSettings.productName;

            PlayerSettings.companyName = releaseType.companyName;
            PlayerSettings.productName = releaseType.productName;

            // Set bundle info.设置捆绑信息。
            // Unfortunately, there's not a good way to do this pre-5.6 that doesn't break building w/ batch mode.不幸的是,在5.6之前没有一个好的方法可以不破坏构建w/batch模式。
#if UNITY_5_6_OR_NEWER
            string preBuildBundleIdentifier = PlayerSettings.GetApplicationIdentifier(platform.targetGroup);
            PlayerSettings.SetApplicationIdentifier(platform.targetGroup, releaseType.bundleIndentifier);
#endif

            // Apply build variant.应用生成变量。
            platform.ApplyVariant();

            // Pre-build actions.预构建操作。
            PerformPreBuild(releaseType, platform, architecture, distribution, buildTime, ref options, configKey, buildPath);

            // Generate BuildConstants.生成生成常量。
            BuildConstantsGenerator.Generate(buildTime, BuildSettings.productParameters.lastGeneratedVersion, releaseType, platform, architecture, distribution);

            // Refresh scene list to make sure nothing has been deleted or moved.刷新场景列表以确保未删除或移动任何内容。
            releaseType.sceneList.Refresh();

            // Report build starting.发布生成开始。
            BuildNotificationList.instance.AddNotification(new BuildNotification(
                                                               BuildNotification.Category.Notification,
                                                               notification, configKey,
                                                               true, null));

            // Build player.
            FileUtil.DeleteFileOrDirectory(buildPath);

            string error = "";
#if UNITY_2018_1_OR_NEWER
            //    string[] levels = BuildInfomation.levels;
            /////   Debug.Log("这里才开始生成");

            //string parth = BuildInfomation. Pathlevels+"/Test.exe";

            //    string[]levels = new string[] { "Assets/Scenes/2.unity" };
            string[] levels = BuildInfomation.levels;
            ///\   Debug.Log("这里才开始生成");

            string parth = BuildInfomation.Pathlevels;
            Debug.Log(parth);

            //  Debug.Log("这里才开始生成---"+ BuildInfomation.levels[0].ToString()+"---"+ parth);
            //  Debug.Log(releaseType.sceneList.GetSceneFileList() + "  --AAA--  " + Path.Combine(buildPath, binName)  );
            //  UnityEditor.Build.Reporting.BuildReport buildReport = BuildPipeline.BuildPlayer(levels, @"C:/Users/YNHol/Desktop/00000000000000/Scenes3/Test.exe", BuildTarget.StandaloneWindows, BuildOptions.None);
            UnityEditor.Build.Reporting.BuildReport buildReport = BuildPipeline.BuildPlayer(levels, parth, BuildTarget.WebGL, BuildOptions.None);
            // UnityEditor.Build.Reporting.BuildReport buildReport = BuildPipeline.BuildPlayer(releaseType.sceneList.GetSceneFileList(), Path.Combine(buildPath, binName), architecture.target, options);
            //   Debug.Log(levels[0].ToString() + "__生产___" + parth); ;
            foreach (var item in releaseType.sceneList.GetSceneFileList())
            {
                Debug.Log(item);
            }
            //  Debug.Log("这里生成开始完毕");
            if (buildReport.summary.result == UnityEditor.Build.Reporting.BuildResult.Failed)
            {
                error = buildReport.summary.totalErrors + " occurred.";
            }
#else
            error = BuildPipeline.BuildPlayer(releaseType.sceneList.GetSceneFileList(), Path.Combine(buildPath, binName), architecture.target, options);
#endif
            if (!string.IsNullOrEmpty(error))
            {
                success = false;

                BuildNotificationList.instance.AddNotification(new BuildNotification(
                                                                   BuildNotification.Category.Error,
                                                                   "Build Failed:", configKey.ToString() + "\n" + error,
                                                                   true, null));
            }

            // Post-build actions.
            PerformPostBuild(releaseType, platform, architecture, distribution, buildTime, ref options, configKey, buildPath);

            // Restore pre-build settings.
            PlayerSettings.SetScriptingDefineSymbolsForGroup(platform.targetGroup, preBuildDefines);
            PlayerSettings.companyName = preBuildCompanyName;
            PlayerSettings.productName = preBuildProductName;

#if UNITY_5_6_OR_NEWER
            PlayerSettings.SetApplicationIdentifier(platform.targetGroup, preBuildBundleIdentifier);
#endif
            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            Build_Over_Num++;
            Debug.Log("这里是北京时间:" + System.DateTime.Now + "  完成了___ " + Build_Over_Num + " ___个");

            if (Build_Over_Num < File.ReadAllLines(Application.dataPath + "/Pathlevels.txt", Encoding.Default).Length)
            {
                BuildInfomation.Pathlevels = File.ReadAllLines(Application.dataPath + "/Pathlevels.txt", Encoding.Default)[Build_Over_Num];
                BuildInfomation.levels     = new string[] { File.ReadAllLines(Application.dataPath + "/levels.txt", Encoding.Default)[Build_Over_Num] };
                BuildProject.BuildAll();
            }
            else
            {
                Debug.Log("这里是北京时间:" + System.DateTime.Now + "  全部完成! " + Build_Over_Num + "个");
                Build_Over_Num = 0;
            }

            return(success);
        }
예제 #13
0
        public override void PerBuildExecute(BuildReleaseType releaseType, BuildPlatform platform, BuildArchitecture architecture, BuildDistribution distribution, System.DateTime buildTime, ref BuildOptions options, string configKey, string buildPath)
        {
            // Verify that butler executable exists.
            if (!File.Exists(pathToButlerExe))
            {
                UnityEngine.Debug.LogError("Couldn't find butler.exe file at path \"" + pathToButlerExe + "\", please check provided path");
                return;
            }

            buildPath = Path.GetFullPath(buildPath);

            // Generate build args for the form: butler push {optional args} {build path} {itch username}/{itch game}:{channel}
            StringBuilder scriptArguments = new StringBuilder("push ");

            switch (architecture.target)
            {
#if UNITY_2017_3_OR_NEWER
            case BuildTarget.StandaloneOSX:
#else
            case BuildTarget.StandaloneOSXIntel:
            case BuildTarget.StandaloneOSXIntel64:
            case BuildTarget.StandaloneOSXUniversal:
#endif
            case BuildTarget.StandaloneLinux:
            case BuildTarget.StandaloneLinux64:
            case BuildTarget.StandaloneLinuxUniversal:
                // Fix exe permissions for Linux/OSX.
                scriptArguments.Append("--fix-permissions ");
                break;
            }

            if (useGeneratedBuildVersion)
            {
                // Append generated versions string.
                scriptArguments.Append(string.Format("--userversion \"{0}\" ", BuildSettings.productParameters.lastGeneratedVersion));
            }

            scriptArguments.Append("\"" + buildPath + "\"" + " " + nameOfItchUser + "/" + nameOfItchGame + ":");

            if (architecture.target == BuildTarget.WebGL)
            {
                scriptArguments.Append("web");
            }

            if (!string.IsNullOrEmpty(itchChannelOverride))
            {
                scriptArguments.Append(itchChannelOverride);
            }
            else
            {
                string itchChannel = GetChannelName(architecture.target);
                if (string.IsNullOrEmpty(itchChannel))
                {
                    UnityEngine.Debug.LogWarning("UploadItch: The current BuildTarget doesn't appear to be a standard Itch.IO build target.");
                }

                scriptArguments.Append(itchChannel);
            }

            // UnityEngine.Debug.Log("Would have run itch uploader with following command line: \"" + pathToButlerExe + " " + scriptArguments + "\"");
            RunScript(pathToButlerExe, scriptArguments.ToString());
        }
        public static void Generate(
            DateTime buildTime,
            string currentVersion = "",
            BuildReleaseType currentReleaseType        = null,
            BuildPlatform currentBuildPlatform         = null,
            BuildArchitecture currentBuildArchitecture = null,
            BuildDistribution currentBuildDistribution = null)
        {
            // Find the BuildConstants file.
            string filePath = FindFile();

            if (string.IsNullOrEmpty(filePath))
            {
                return;
            }

            // Cache any current values if needed.
            string versionString     = string.IsNullOrEmpty(currentVersion) ? BuildConstants.version.ToString() : currentVersion;
            string releaseTypeString = currentReleaseType == null?BuildConstants.releaseType.ToString() : SanitizeString(currentReleaseType.typeName);

            string platformString = currentBuildPlatform == null?BuildConstants.platform.ToString() : SanitizeString(currentBuildPlatform.platformName);

            string archString = currentBuildArchitecture == null?BuildConstants.architecture.ToString() : SanitizeString(currentBuildArchitecture.name);

            string distributionString = string.Empty;

            if (currentBuildDistribution == null)
            {
                if (currentReleaseType == null)
                {
                    // No new parameter specified, so use the old value.
                    distributionString = BuildConstants.architecture.ToString();
                }
                else
                {
                    // There are new parameters but no distribution. Should be intentional, so distribution is NONE.
                    distributionString = NONE;
                }
            }
            else
            {
                distributionString = SanitizeString(currentBuildDistribution.distributionName);
            }

            // Delete any existing version.
            if (File.Exists(filePath))
            {
                File.Delete(filePath);
            }

            // Create a buffer that we'll use to check for any duplicated names.
            List <string> enumBuffer = new List <string>();

            using (StreamWriter writer = new StreamWriter(filePath))
            {
                // Start of file and class.
                writer.WriteLine("// This file is auto-generated. Do not modify or move this file.");
                writer.WriteLine();
                writer.WriteLine("public static class BuildConstants");
                writer.WriteLine("{");

                // Write ReleaseType enum.
                writer.WriteLine("    public enum ReleaseType");
                writer.WriteLine("    {");
                writer.WriteLine("        {0},", NONE);
                enumBuffer.Add(NONE);
                foreach (BuildReleaseType releaseType in BuildSettings.releaseTypeList.releaseTypes)
                {
                    string addedString = SanitizeString(releaseType.typeName);

                    if (!enumBuffer.Contains(addedString))
                    {
                        enumBuffer.Add(addedString);
                        writer.WriteLine("        {0},", addedString);
                    }
                }
                writer.WriteLine("    }");
                writer.WriteLine();

                // Validate ReleaseType string.
                if (!enumBuffer.Contains(releaseTypeString))
                {
                    releaseTypeString = NONE;
                }

                // Write Platform enum.
                enumBuffer.Clear();
                writer.WriteLine("    public enum Platform");
                writer.WriteLine("    {");
                writer.WriteLine("        {0},", NONE);
                enumBuffer.Add(NONE);
                foreach (BuildPlatform platform in BuildSettings.platformList.platforms)
                {
                    string addedString = SanitizeString(platform.platformName);

                    if (platform.enabled && !enumBuffer.Contains(addedString))
                    {
                        enumBuffer.Add(addedString);
                        writer.WriteLine("        {0},", addedString);
                    }
                }
                writer.WriteLine("    }");
                writer.WriteLine();

                // Validate Platform string.
                if (!enumBuffer.Contains(platformString))
                {
                    platformString = NONE;
                }

                // Write Architecture enum.
                enumBuffer.Clear();
                writer.WriteLine("    public enum Architecture");
                writer.WriteLine("    {");
                writer.WriteLine("        {0},", NONE);
                enumBuffer.Add(NONE);
                foreach (BuildPlatform platform in BuildSettings.platformList.platforms)
                {
                    if (platform.enabled)
                    {
                        foreach (BuildArchitecture arch in platform.architectures)
                        {
                            string addedString = SanitizeString(arch.name);

                            if (arch.enabled && !enumBuffer.Contains(addedString))
                            {
                                enumBuffer.Add(addedString);
                                writer.WriteLine("        {0},", addedString);
                            }
                        }
                    }
                }
                writer.WriteLine("    }");
                writer.WriteLine();

                // Validate Architecture string.
                if (!enumBuffer.Contains(archString))
                {
                    archString = NONE;
                }

                // Write Distribution enum.
                enumBuffer.Clear();
                writer.WriteLine("    public enum Distribution");
                writer.WriteLine("    {");
                writer.WriteLine("        {0},", NONE);
                enumBuffer.Add(NONE);
                foreach (BuildPlatform platform in BuildSettings.platformList.platforms)
                {
                    if (platform.enabled)
                    {
                        foreach (BuildDistribution dist in platform.distributionList.distributions)
                        {
                            string addedString = SanitizeString(dist.distributionName);

                            if (dist.enabled && !enumBuffer.Contains(addedString))
                            {
                                enumBuffer.Add(addedString);
                                writer.WriteLine("        {0},", addedString);
                            }
                        }
                    }
                }
                writer.WriteLine("    }");
                writer.WriteLine();

                // Validate Distribution string.
                if (!enumBuffer.Contains(distributionString))
                {
                    distributionString = NONE;
                }

                // Write current values.
                writer.WriteLine("    public static readonly System.DateTime buildDate = new System.DateTime({0});", buildTime.Ticks);
                writer.WriteLine("    public const string version = \"{0}\";", versionString);
                writer.WriteLine("    public const ReleaseType releaseType = ReleaseType.{0};", releaseTypeString);
                writer.WriteLine("    public const Platform platform = Platform.{0};", platformString);
                writer.WriteLine("    public const Architecture architecture = Architecture.{0};", archString);
                writer.WriteLine("    public const Distribution distribution = Distribution.{0};", distributionString);

                // End of class.
                writer.WriteLine("}");
                writer.WriteLine();
            }

            // Refresh AssetDatabse so that changes take effect.
            AssetDatabase.Refresh();
        }
 public override void PerBuildExecute(BuildReleaseType releaseType, BuildPlatform platform, BuildArchitecture architecture, BuildDistribution distribution, DateTime buildTime, ref BuildOptions options, string configKey, string buildPath)
 {
     PackagesToRemove.ForEach(id => HandleRequest(Client.Remove(id), id));
     PackagesToAdd.ForEach(id => HandleRequest(Client.Add(id), id));
 }
예제 #16
0
        public bool ParseKeychain(string keychain, out BuildReleaseType releaseType, out BuildPlatform platform, out BuildArchitecture architecture, out BuildDistribution distribution)
        {
            bool success = false;

            string[] keys      = keychain.Split('/');
            int      keyCount  = keys.Length;
            int      targetKey = 0;

            releaseType  = null;
            platform     = null;
            architecture = null;
            distribution = null;

            // Parse release type.
            if (keyCount > targetKey)
            {
                for (int i = 0; i < BuildSettings.releaseTypeList.releaseTypes.Length; i++)
                {
                    BuildReleaseType rt = BuildSettings.releaseTypeList.releaseTypes[i];

                    if (keys[targetKey] == rt.typeName)
                    {
                        releaseType = rt;
                        break;
                    }
                }
            }

            if (releaseType == null)
            {
                return(false);
            }

            // Parse platform.
            if (keyCount > ++targetKey)
            {
                // Scan ahead and try to parse a variant key.
                string variantKey = "";
                if (keys[targetKey + 1].Contains("("))
                {
                    int startIndex = keys[targetKey + 1].IndexOf('(');
                    int endIndex   = keys[targetKey + 1].IndexOf(')');
                    variantKey = keys[targetKey + 1].Substring(startIndex + 1, endIndex - startIndex - 1);

                    keys[targetKey + 1] = keys[targetKey + 1].Remove(startIndex).Trim();
                }

                for (int i = 0; i < BuildSettings.platformList.platforms.Count; i++)
                {
                    BuildPlatform p = BuildSettings.platformList.platforms[i];

                    if (keys[targetKey] == p.platformName && p.variantKey == variantKey)
                    {
                        platform = p;
                        break;
                    }
                }
            }

            if (platform == null)
            {
                return(false);
            }

            // Parse architecture.
            if (platform.architectures.Length == 1)
            {
                // Only one architecture, so it won't even appear in dictionary. Just get it directly.
                ++targetKey;
                architecture = platform.architectures[0];
                success      = true;
            }
            else if (keyCount > ++targetKey)
            {
                for (int i = 0; i < platform.architectures.Length; i++)
                {
                    BuildArchitecture arch = platform.architectures[i];

                    if (keys[targetKey] == arch.name)
                    {
                        architecture = arch;
                        success      = true;
                        break;
                    }
                }
            }

            if (architecture == null)
            {
                return(false);
            }

            // TODO: Parse variants.

            // Parse distribution.
            if (keyCount > ++targetKey)
            {
                success = false;
                for (int i = 0; i < platform.distributionList.distributions.Length; i++)
                {
                    BuildDistribution dist = platform.distributionList.distributions[i];

                    if (keys[targetKey] == dist.distributionName)
                    {
                        distribution = dist;
                        success      = true;
                        break;
                    }
                }
            }

            return(success);
        }
예제 #17
0
        public bool ParseKeychain(string keychain, out BuildReleaseType releaseType, out BuildPlatform platform, out BuildArchitecture architecture, out BuildDistribution distribution)
        {
            bool success = false;

            string[] keys      = keychain.Split('/');
            int      keyCount  = keys.Length;
            int      targetKey = 0;

            releaseType  = null;
            platform     = null;
            architecture = null;
            distribution = null;

            // Parse release type.
            if (keyCount > targetKey)
            {
                for (int i = 0; i < BuildSettings.releaseTypeList.releaseTypes.Length; i++)
                {
                    BuildReleaseType rt = BuildSettings.releaseTypeList.releaseTypes[i];

                    if (keys[targetKey] == rt.typeName)
                    {
                        releaseType = rt;
                        break;
                    }
                }
            }

            if (releaseType == null)
            {
                return(false);
            }

            // Parse platform.
            if (keyCount > ++targetKey)
            {
                for (int i = 0; i < BuildSettings.platformList.platforms.Length; i++)
                {
                    BuildPlatform p = BuildSettings.platformList.platforms[i];

                    if (keys[targetKey] == p.platformName)
                    {
                        platform = p;
                        break;
                    }
                }
            }

            if (platform == null)
            {
                return(false);
            }

            // Parse architecture.
            if (platform.architectures.Length == 1)
            {
                // Only one architecture, so it won't even appear in dictionary. Just get it directly.
                architecture = platform.architectures[0];
                success      = true;
            }
            else if (keyCount > ++targetKey)
            {
                for (int i = 0; i < platform.architectures.Length; i++)
                {
                    BuildArchitecture arch = platform.architectures[i];

                    if (keys[targetKey] == arch.name)
                    {
                        architecture = arch;
                        success      = true;
                        break;
                    }
                }
            }

            if (architecture == null)
            {
                return(false);
            }

            // TODO: Parse variants.

            // Parse distribution.
            if (keyCount > ++targetKey)
            {
                success = false;
                for (int i = 0; i < platform.distributionList.distributions.Length; i++)
                {
                    BuildDistribution dist = platform.distributionList.distributions[i];

                    if (keys[targetKey] == dist.distributionName)
                    {
                        distribution = dist;
                        success      = true;
                        break;
                    }
                }
            }

            return(success);
        }