/// <summary>
        /// parse runinfo from <paramref name="args"/>, other are ignore
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        public static RunInfo FromArgs(string[] args)
        {
            var info = new RunInfo
            {
                Config = "BuildConfig.json",
                Target = "default",
                Sets   = new Dictionary <string, string>(),
            };


            for (int i = 0; i < args.Length; i++)
            {
                GetConfig(ref info.Config, args[i], "config");
                GetConfig(ref info.Target, args[i], "target");
                if (GetSetting(args[i], "--set=", out var name, out var value))
                {
                    info.Sets.Add(name, value);
                }
            }

            return(info);
        }
        public void DoAll()
        {
            RunInfo = RunInfo.FromArgs();
            Debug.Log($"loading config from {RunInfo.Config}");
            var buildConfig = BuildConfig.FromFile(RunInfo.Config, RunInfo.ToJObject(RunInfo.Sets));
            var target      = buildConfig.Targets.Find(i => i.Name == RunInfo.Target);

            if (target == null)
            {
                var targetNames = string.Join(",", buildConfig.Targets.Select(i => i.Name).ToArray());
                Debug.LogError($"cannot find target {RunInfo.Target}, valid target is [{targetNames}]");
                EditorApplication.Exit(1);
            }
            target.ApplyConfigure();
            var report = BuildPipeline.BuildPlayer(target.BuildPlayerOptions);

            if (report.summary.result == UnityEditor.Build.Reporting.BuildResult.Failed)
            {
                Debug.LogError("Build operation fail, see log for more details");
                EditorApplication.Exit(1);
            }
        }
Esempio n. 3
0
 private void OnEnable()
 {
     RunInfo     = RunInfo.FromArgs();
     BuildConfig = BuildConfig.FromFile(RunInfo.Config);
 }