private BuildOptions ConfigureCompression(BuildOptions options) { var choice = 0; if (options.HasFlag(BuildOptions.CompressWithLz4)) { choice = 1; } else if (options.HasFlag(BuildOptions.CompressWithLz4HC)) { choice = 2; } choice = EditorGUILayout.Popup("Compression", choice, style.CompressionOptions); switch (choice) { case 0: options &= ~(BuildOptions.CompressWithLz4 | BuildOptions.CompressWithLz4HC); break; case 1: options |= BuildOptions.CompressWithLz4; break; case 2: options |= BuildOptions.CompressWithLz4HC; break; } return(options); }
private static BuildOptions ConfigurePlatform(BuildTarget target, BuildOptions options) { var headlessSupported = BuildSupportChecker.CanBuildHeadless(target); if (EditorGUILayout.Toggle("Development", options.HasFlag(BuildOptions.Development))) { options |= BuildOptions.Development; } else { // When the `Development flag` is disabled, we also disable the 'Allow Debug' flag to // ensure consistency between UI and BuildOptions flags options &= ~(BuildOptions.Development | BuildOptions.AllowDebugging); } options = ConfigureDebug(options); if (headlessSupported && EditorGUILayout.Toggle("Server build", options.HasFlag(BuildOptions.EnableHeadlessMode))) { options |= BuildOptions.EnableHeadlessMode; } else { options &= ~BuildOptions.EnableHeadlessMode; } return(options); }
bool CheckAssetDirty(BuildDataInputFile file) { NPath path = file.path; if (!path.Exists()) { Console.WriteLine($"Rebuilding Data files because {path} is dirty (deleted)"); return(true); } string contentHash = ""; if (path.Extension == "cs") { var monoScript = AssetDatabase.LoadAssetAtPath <MonoScript>(path.ToString()); if (monoScript != null) { contentHash = monoScript.GetPropertiesHashString(buildOptions.HasFlag(BuildOptions.Development)); } } else { contentHash = AssetDatabase.GetAssetDependencyHash(file.path).ToString(); } if (contentHash != file.contentHash) { Console.WriteLine($"Rebuilding Data files because {path} is dirty (hash)"); return(true); } return(false); }
public string[] OnFilterAssemblies(BuildOptions buildOptions, string[] assemblies) { if (buildOptions.HasFlag(BuildOptions.IncludeTestAssemblies)) { return(assemblies); } return(assemblies.Where(x => ValidateName(x)).ToArray()); }
public BenchmarkBuildTask(FileReference InProjectFile, string InTarget, UnrealTargetPlatform InPlatform, BuildOptions InOptions, string InUBTArgs = "", int CoreCount = 0) { bool IsVanillaUE4 = InProjectFile == null; string ModuleName = IsVanillaUE4 ? "UE4" : InProjectFile.GetFileNameWithoutAnyExtensions(); TaskName = string.Format("{0} {1} {2}", ModuleName, InTarget, InPlatform); Command = new BuildTarget(); Command.ProjectName = IsVanillaUE4 ? null : ModuleName; Command.Platforms = InPlatform.ToString(); Command.Targets = InTarget; Command.NoTools = true; Command.Clean = InOptions.HasFlag(BuildOptions.Clean); Command.UBTArgs = InUBTArgs; bool WithAccel = !InOptions.HasFlag(BuildOptions.NoAcceleration); if (!WithAccel || !SupportsAcceleration) { string Arg = string.Format("No{0}", AccelerationName); Command.UBTArgs += " -" + Arg; TaskModifiers.Add(Arg); Command.Params = new[] { Arg }; // need to also pass it to this if (CoreCount > 0) { TaskModifiers.Add(string.Format("{0}c", CoreCount)); Command.UBTArgs += string.Format(" -MaxParallelActions={0}", CoreCount); } } else { TaskModifiers.Add(AccelerationName); } if (!string.IsNullOrEmpty(InUBTArgs)) { TaskModifiers.Add(InUBTArgs); } }
private static BuildOptions ConfigureDebug(BuildOptions options) { var isDebugEnabled = options.HasFlag(BuildOptions.Development) && options.HasFlag(BuildOptions.AllowDebugging); using (new EditorGUI.DisabledScope(!options.HasFlag(BuildOptions.Development))) { if (EditorGUILayout.Toggle("Allow Debug", isDebugEnabled)) { options |= BuildOptions.AllowDebugging; } else { options &= ~BuildOptions.AllowDebugging; } } return(options); }
public void Build() { string exportFolder; if (!TryGetPackageExportFolder(out exportFolder, promptIfNotDefined: true)) { UnityEngine.Debug.LogError("Could not build " + DefinitionName + " because no export folder was chosen."); return; } if (_trySuffixWithGitHash) { string hash; if (tryGetGitCommitHash(out hash)) { exportFolder = Path.Combine(exportFolder, DefinitionName + "_" + hash); } else { UnityEngine.Debug.LogWarning("Failed to get git hash."); } } string fullPath = Path.Combine( Path.Combine(exportFolder, _definitionName), DefinitionName ); var buildOptions = new BuildPlayerOptions() { scenes = _scenes.Where(s => s != null). Select(s => AssetDatabase.GetAssetPath(s)). ToArray(), options = _options, }; foreach (var target in _targets) { buildOptions.target = target; buildOptions.locationPathName = fullPath + "." + getFileSuffix(target); if (_useSpecificPlayerSettings) { var origFullscreenMode = PlayerSettings.fullScreenMode; var origDefaultWidth = PlayerSettings.defaultScreenWidth; var origDefaultHeight = PlayerSettings.defaultScreenHeight; var origResizableWindow = PlayerSettings.resizableWindow; try { PlayerSettings.fullScreenMode = _playerSettings.fullScreenMode; PlayerSettings.defaultScreenWidth = _playerSettings.defaultScreenWidth; PlayerSettings.defaultScreenHeight = _playerSettings.defaultScreenHeight; PlayerSettings.resizableWindow = _playerSettings.resizableWindow; BuildPipeline.BuildPlayer(buildOptions); } finally { PlayerSettings.fullScreenMode = origFullscreenMode; PlayerSettings.defaultScreenWidth = origDefaultWidth; PlayerSettings.defaultScreenHeight = origDefaultHeight; PlayerSettings.resizableWindow = origResizableWindow; } } else { BuildPipeline.BuildPlayer(buildOptions); } if (_options.HasFlag(BuildOptions.EnableHeadlessMode)) { // The -batchmode flag is the only important part of headless mode // for Windows. The EnableHeadlessMode build option only actually has // an effect on Linux standalone builds. // Here, it's being used to mark the _intention_ of a headless build // for Windows builds. var text = "\"" + _definitionName + ".exe" + "\" -batchmode"; var headlessModeBatPath = Path.Combine(Path.Combine(exportFolder, _definitionName), "Run Headless Mode.bat"); File.WriteAllText(headlessModeBatPath, text); } } Process.Start(exportFolder); }
/// <summary> /// Configure compiler defines /// </summary> public static void ConfigureCompilerDefines(BuildTarget target, BuildOptions opt, List <string> defines = null) { Log.Debug(string.Format("Builder.ConfigureCompilerDefines(target: {0}, opt: {1}) Application.platform={2}", target, opt, Application.platform)); // Basic compiler defines, override on a per target basis. Duplicates will be removed. if (defines == null) { defines = new List <string>(); } // development defines if (opt.HasFlag(BuildOptions.Development)) { defines.Add("JAMMER_DEBUG"); defines.Add("JAMMER_DEBUG_OVERLAY"); defines.Add("JAMER_LOG_DEBUG"); defines.Add("JAMMER_CONSOLE"); defines.Add("JAMMER_DEBUG_RAYCASTS"); } // remove current dupes, more dupes may still be added later defines = defines.Distinct().ToList(); switch (target) { case BuildTarget.tvOS: Log.Debug(string.Format("Builder.ConfigureCompilerDefines() tvOS defines={0}", string.Join(";", defines.Distinct().ToArray()))); PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.tvOS, string.Join(";", defines.Distinct().ToArray())); break; case BuildTarget.iOS: Log.Debug(string.Format("Builder.ConfigureCompilerDefines() iOS defines={0}", string.Join(";", defines.Distinct().ToArray()))); PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.iOS, string.Join(";", defines.Distinct().ToArray())); break; case BuildTarget.StandaloneOSXIntel64: case BuildTarget.StandaloneOSXIntel: case BuildTarget.StandaloneOSXUniversal: case BuildTarget.StandaloneWindows: case BuildTarget.StandaloneWindows64: case BuildTarget.StandaloneLinux: case BuildTarget.StandaloneLinux64: case BuildTarget.StandaloneLinuxUniversal: Log.Debug(string.Format("Builder.ConfigureCompilerDefines() Standalone defines={0}", string.Join(";", defines.Distinct().ToArray()))); PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.Standalone, string.Join(";", defines.Distinct().ToArray())); break; case BuildTarget.Android: Log.Debug(string.Format("Builder.ConfigureCompilerDefines() Android defines={0}", string.Join(";", defines.Distinct().ToArray()))); PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.Android, string.Join(";", defines.Distinct().ToArray())); break; case BuildTarget.WebGL: Log.Debug(string.Format("Builder.ConfigureCompilerDefines() WebGL defines={0}", string.Join(";", defines.Distinct().ToArray()))); PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.WebGL, string.Join(";", defines.Distinct().ToArray())); break; default: Log.Error(string.Format("Builder.ConfigureCompilerDefines(target: {1}, opt: {2}) Unknown target", target, opt)); break; } }