/// <summary>
        ///     Build method that is invoked by commandline
        /// </summary>
        public static void Build()
        {
            try
            {
                var commandLine = Environment.GetCommandLineArgs();

                Debug.LogFormat("Want to build with args: {0}", String.Join(", ", commandLine));

                var buildTargetArg =
                    CommandLineUtil.GetCommandLineValue(commandLine, "buildTarget", "local");

                if (string.IsNullOrEmpty(buildTargetArg))
                {
                    // The default above does not get filled when -t parameter is not passed
                    buildTargetArg = BuildEnvironment.Local.ToString();
                    Debug.LogWarningFormat("Using default build target value: \"{0}\".", buildTargetArg);
                }

                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 =
                    CommandLineUtil.GetCommandLineValue(commandLine, ConfigNames.BuildWorkerTypes,
                                                        "UnityClient,UnityWorker");

                var wantedWorkerPlatforms = GetWorkerPlatforms(workerTypesArg);

                SpatialCommands.GenerateBuildConfiguration();

                foreach (var workerPlatform in wantedWorkerPlatforms)
                {
                    BuildWorkerForEnvironment(workerPlatform, buildEnvironment);
                }
            }
            catch (Exception e)
            {
                // Log the exception so it appears in the command line, and rethrow as a BuildFailedException so the build fails.
                Debug.LogException(e);

                if (e is BuildFailedException)
                {
                    throw;
                }

                throw new BuildFailedException(e);
            }
        }
        /// <summary>
        ///     The name(s) of the workers to build. Specify multiple targets by separating them with a comma.
        ///     For example: "UnityClient,UnityWorker".
        /// </summary>
        /// <remarks>
        ///     Currently, the only possible values are "UnityWorker" and "UnityClient".
        ///     Defaults to AllWorkerTypes if the flag is not specified.
        ///     If commandLine is null, defaults to using <code>Environment.GetCommandLineArgs();</code>.
        /// </remarks>
        public static IList <string> GetWorkerTypesToBuild(string[] commandLine = null)
        {
            if (WorkersToBuild != null)
            {
                if (!WorkersToBuild.Any())
                {
                    return(AllWorkerTypes);
                }

                return(WorkersToBuild);
            }


            if (commandLine == null)
            {
                commandLine = Environment.GetCommandLineArgs();
            }

            var commandLineValue = CommandLineUtil.GetCommandLineValue(commandLine, ConfigNames.BuildWorkerTypes, string.Empty);

            if (string.IsNullOrEmpty(commandLineValue))
            {
                return(AllWorkerTypes);
            }

            return(ParseWorkerTypes(commandLineValue));
        }
예제 #3
0
 public static T GetCommandLineValue <T>(IList <string> arguments, string configKey, T defaultValue)
 {
     return(CommandLineUtil.GetCommandLineValue(arguments, configKey, defaultValue));
 }