Exemplo n.º 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();

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

                var buildTargetArg =
                    CommandLineUtility.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 =
                    CommandLineUtility.GetCommandLineValue(commandLine, BuildConfigNames.BuildWorkerTypes,
                                                           "UnityClient,UnityGameLogic");

                var wantedWorkerPlatforms = GetWorkerPlatforms(workerTypesArg);

                LocalLaunch.BuildConfig();

                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);
            }
        }
Exemplo n.º 2
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 wantedWorkerTypes = workerTypesArg.Split(',');
                foreach (var wantedWorkerType in wantedWorkerTypes)
                {
                    var buildTargetsForWorker           = GetBuildTargetsForWorkerForEnvironment(wantedWorkerType, buildEnvironment);
                    var buildTargetsMissingBuildSupport = BuildSupportChecker.GetBuildTargetsMissingBuildSupport(buildTargetsForWorker);

                    if (buildTargetsMissingBuildSupport.Length > 0)
                    {
                        throw new BuildFailedException(BuildSupportChecker.ConstructMissingSupportMessage(wantedWorkerType, buildEnvironment, buildTargetsMissingBuildSupport));
                    }
                }

                LocalLaunch.BuildConfig();

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

                throw new BuildFailedException(e);
            }
        }
Exemplo n.º 3
0
        private static void MenuBuild(IEnumerable <WorkerPlatform> platforms, BuildEnvironment environment)
        {
            // Delaying build by a frame to ensure the editor has re-rendered the UI to avoid odd glitches.
            EditorApplication.delayCall += () =>
            {
                LocalLaunch.BuildConfig();

                foreach (var platform in platforms)
                {
                    WorkerBuilder.BuildWorkerForEnvironment(platform, environment);
                }

                Debug.LogFormat("Completed build for {0} target", environment);
            };
        }
Exemplo n.º 4
0
        private static void BuildWorkers(IReadOnlyList <BuildContext> buildContexts)
        {
            var activeBuildTarget      = EditorUserBuildSettings.activeBuildTarget;
            var activeBuildTargetGroup = BuildPipeline.GetBuildTargetGroup(activeBuildTarget);

            if (BuildConfig.GetInstance() == null)
            {
                const string errorMessage =
                    "Could not find an instance of the SpatialOS Build Configuration.\n\nPlease create one via Assets > Create > SpatialOS > SpatialOS Build Configuration.\n\nIf you already have an instance of the SpatialOS Build Configuration in your project, please open it in the Unity Inspector to force the asset to load and retry the build.";

                throw new BuildFailedException(errorMessage);
            }

            if (!Directory.Exists(EditorPaths.PlayerBuildDirectory))
            {
                Directory.CreateDirectory(EditorPaths.PlayerBuildDirectory);
            }

            try
            {
                LocalLaunch.BuildConfig();

                foreach (var buildContext in buildContexts)
                {
                    BuildWorkerWithContext(buildContext);
                }

                Debug.Log($"Completed build for {buildContexts[0].BuildEnvironment} target.");
            }
            catch (Exception e)
            {
                if (e is BuildFailedException)
                {
                    throw;
                }

                throw new BuildFailedException(e);
            }
            finally
            {
                EditorUserBuildSettings.SwitchActiveBuildTarget(activeBuildTargetGroup, activeBuildTarget);
            }
        }
Exemplo n.º 5
0
        private static bool BuildWorkers(string[] workerTypes, BuildEnvironment buildEnvironment, ScriptingImplementation?scriptingBackend = null)
        {
            var activeBuildTarget      = EditorUserBuildSettings.activeBuildTarget;
            var activeBuildTargetGroup = BuildPipeline.GetBuildTargetGroup(activeBuildTarget);

            try
            {
                LocalLaunch.BuildConfig();

                var workerResults = new Dictionary <string, bool>();
                foreach (var wantedWorkerType in workerTypes)
                {
                    var result = BuildWorkerForEnvironment(wantedWorkerType, buildEnvironment, scriptingBackend);
                    workerResults[wantedWorkerType] = result;
                }

                var missingWorkerTypes   = string.Join(" ", workerResults.Keys.Where(k => !workerResults[k]));
                var completedWorkerTypes = string.Join(" ", workerResults.Keys.Where(k => workerResults[k]));

                if (missingWorkerTypes.Length > 0)
                {
                    Debug.LogWarning(
                        $"Completed build for {buildEnvironment} target.\n"
                        + $"Completed builds for: {completedWorkerTypes}\n"
                        + $"Skipped builds for: {missingWorkerTypes}. See above for more information.");
                    return(false);
                }
                else
                {
                    Debug.Log($"Completed build for {buildEnvironment} target.");
                    return(true);
                }
            }
            catch (Exception e)
            {
                throw new BuildFailedException(e);
            }
            finally
            {
                EditorUserBuildSettings.SwitchActiveBuildTarget(activeBuildTargetGroup, activeBuildTarget);
            }
        }
Exemplo n.º 6
0
        private static bool BuildWorkers(
            IEnumerable <string> workerTypes,
            BuildEnvironment buildEnvironment,
            IEnumerable <BuildTarget> buildTargetFilter = null,
            ScriptingImplementation?scriptingBackend    = null)
        {
            var activeBuildTarget      = EditorUserBuildSettings.activeBuildTarget;
            var activeBuildTargetGroup = BuildPipeline.GetBuildTargetGroup(activeBuildTarget);

            if (BuildConfig.GetInstance() == null)
            {
                const string errorMessage =
                    "Could not find an instance of the SpatialOS Build Configuration.\n\nPlease create one via Assets > Create > SpatialOS > SpatialOS Build Configuration.\n\nIf you already have an instance of the SpatialOS Build Configuration in your project, please open it in the Unity Inspector to force the asset to load and retry the build.";

                if (Application.isEditor)
                {
                    EditorApplication.delayCall += () =>
                    {
                        EditorUtility.DisplayDialog("Could not find SpatialOS Build Configuration",
                                                    errorMessage,
                                                    "OK");
                    };
                }

                Debug.LogError(errorMessage);
                return(false);
            }

            try
            {
                LocalLaunch.BuildConfig();

                var workerResults = new Dictionary <string, bool>();
                foreach (var wantedWorkerType in workerTypes)
                {
                    var result = BuildWorkerForEnvironment(wantedWorkerType, buildEnvironment, buildTargetFilter, scriptingBackend);
                    workerResults[wantedWorkerType] = result;
                }

                var missingWorkerTypes   = string.Join(" ", workerResults.Keys.Where(k => !workerResults[k]));
                var completedWorkerTypes = string.Join(" ", workerResults.Keys.Where(k => workerResults[k]));

                if (missingWorkerTypes.Length > 0)
                {
                    Debug.LogWarning(
                        $"Completed build for {buildEnvironment} target.\n"
                        + $"Completed builds for: {completedWorkerTypes}\n"
                        + $"Skipped builds for: {missingWorkerTypes}. See above for more information.");
                    return(false);
                }
                else
                {
                    Debug.Log($"Completed build for {buildEnvironment} target.");
                    return(true);
                }
            }
            catch (Exception e)
            {
                throw new BuildFailedException(e);
            }
            finally
            {
                EditorUserBuildSettings.SwitchActiveBuildTarget(activeBuildTargetGroup, activeBuildTarget);
            }
        }
Exemplo n.º 7
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);
            }
        }