Example #1
0
        /// <summary>
        ///     Build method that is invoked by commandline
        /// </summary>
        // ReSharper disable once UnusedMember.Global
        public static void Build()
        {
            try
            {
                var commandLine    = Environment.GetCommandLineArgs();
                var buildTargetArg = CommandLineUtility.GetCommandLineValue(commandLine, "buildTarget", "local");

                BuildEnvironment buildEnvironment;
                switch (buildTargetArg.ToLower())
                {
                case "cloud":
                    buildEnvironment = BuildEnvironment.Cloud;
                    break;

                case "local":
                    buildEnvironment = BuildEnvironment.Local;
                    break;

                default:
                    throw new BuildFailedException("Unknown build target value: " + buildTargetArg);
                }

                var workerTypesArg =
                    CommandLineUtility.GetCommandLineValue(commandLine, BuildWorkerTypes,
                                                           "UnityClient,UnityGameLogic");

                var desiredWorkerTypes  = workerTypesArg.Split(',');
                var filteredWorkerTypes = BuildSupportChecker.FilterWorkerTypes(buildEnvironment, desiredWorkerTypes);

                if (desiredWorkerTypes.Length != filteredWorkerTypes.Length)
                {
                    throw new BuildFailedException(
                              "Unable to complete build. Missing build support. Check logs for specific errors.");
                }

                ScriptingImplementation scriptingBackend;
                var wantedScriptingBackend =
                    CommandLineUtility.GetCommandLineValue(commandLine, "scriptingBackend", "mono");
                switch (wantedScriptingBackend)
                {
                case "mono":
                    scriptingBackend = ScriptingImplementation.Mono2x;
                    break;

                case "il2cpp":
                    scriptingBackend = ScriptingImplementation.IL2CPP;
                    break;

                default:
                    throw new BuildFailedException("Unknown scripting backend value: " + wantedScriptingBackend);
                }

                LocalLaunch.BuildConfig();

                foreach (var wantedWorkerType in filteredWorkerTypes)
                {
                    BuildWorkerForEnvironment(wantedWorkerType, buildEnvironment, scriptingBackend);
                }
            }
            catch (Exception e)
            {
                Debug.LogException(e);
                if (e is BuildFailedException)
                {
                    throw;
                }

                throw new BuildFailedException(e);
            }
        }