protected override void RegisterBuildPlatforms(SDKOutputLevel OutputLevel) { AndroidPlatformSDK SDK = new AndroidPlatformSDK(); SDK.ManageAndValidateSDK(OutputLevel); if ((ProjectFileGenerator.bGenerateProjectFiles == true) || (SDK.HasRequiredSDKsInstalled() == SDKStatus.Valid) || Environment.GetEnvironmentVariable("IsBuildMachine") == "1") { bool bRegisterBuildPlatform = true; FileReference AndroidTargetPlatformFile = FileReference.Combine(UnrealBuildTool.EngineSourceDirectory, "Developer", "Android", "AndroidTargetPlatform", "AndroidTargetPlatform.Build.cs"); if (FileReference.Exists(AndroidTargetPlatformFile) == false) { bRegisterBuildPlatform = false; } if (bRegisterBuildPlatform == true) { // Register this build platform Log.TraceVerbose(" Registering for {0}", UnrealTargetPlatform.Android.ToString()); UEBuildPlatform.RegisterBuildPlatform(new AndroidPlatform(SDK)); UEBuildPlatform.RegisterPlatformWithGroup(UnrealTargetPlatform.Android, UnrealPlatformGroup.Android); } } }
/// <summary> /// Register the platform with the UEBuildPlatform class /// </summary> protected override void RegisterBuildPlatforms(SDKOutputLevel OutputLevel) { HTML5PlatformSDK SDK = new HTML5PlatformSDK(); SDK.ManageAndValidateSDK(OutputLevel); // Make sure the SDK is installed if ((ProjectFileGenerator.bGenerateProjectFiles == true) || (SDK.HasRequiredSDKsInstalled() == SDKStatus.Valid)) { bool bRegisterBuildPlatform = true; // make sure we have the HTML5 files; if not, then this user doesn't really have HTML5 access/files, no need to compile HTML5! FileReference HTML5TargetPlatformFile = FileReference.Combine(UnrealBuildTool.EngineSourceDirectory, "Developer", "HTML5", "HTML5TargetPlatform", "HTML5TargetPlatform.Build.cs"); if (!FileReference.Exists(HTML5TargetPlatformFile)) { bRegisterBuildPlatform = false; Log.TraceWarning("Missing required components (.... HTML5TargetPlatformFile, others here...). Check source control filtering, or try resyncing."); } if (bRegisterBuildPlatform == true) { // Register this build platform for HTML5 Log.TraceVerbose(" Registering for {0}", UnrealTargetPlatform.HTML5.ToString()); UEBuildPlatform.RegisterBuildPlatform(new HTML5Platform(SDK)); if (HTML5Platform.HTML5Architecture == "-win32") { UEBuildPlatform.RegisterPlatformWithGroup(UnrealTargetPlatform.HTML5, UnrealPlatformGroup.Simulator); } else { UEBuildPlatform.RegisterPlatformWithGroup(UnrealTargetPlatform.HTML5, UnrealPlatformGroup.Device); } } } }
protected static void LogAutoSDK(SDKOutputLevel OutputLevel, string Format, params object[] Args) { if (OutputLevel != SDKOutputLevel.Quiet) { Log.WriteLine(LogEventType.Log, Format, Args); } }
protected static void LogAutoSDK(SDKOutputLevel OutputLevel, String Message) { if (OutputLevel != SDKOutputLevel.Quiet) { Log.WriteLine(LogEventType.Log, Message); } }
// Arbitrates between manual SDKs and setting up AutoSDK based on program options and platform preferences. public void ManageAndValidateSDK(SDKOutputLevel OutputLevel) { // do not modify installed manifests if parent process has already set everything up. // this avoids problems with determining IsAutoSDKSafe and doing an incorrect invalidate. if (bAllowAutoSDKSwitching && !HasParentProcessSetupAutoSDK()) { bool bSetSomeSDK = false; bool bHasRequiredManualSDK = HasRequiredManualSDK() == SDKStatus.Valid; if (IsAutoSDKSafe() && (PreferAutoSDK() || !bHasRequiredManualSDK)) { SetupAutoSDK(OutputLevel); bSetSomeSDK = true; } //Setup manual SDK if autoSDK setup was skipped or failed for whatever reason. if (bHasRequiredManualSDK && (HasRequiredAutoSDKInstalled() != SDKStatus.Valid)) { SetupManualSDK(); bSetSomeSDK = true; } if (!bSetSomeSDK) { InvalidateCurrentlyInstalledAutoSDK(); } } if (OutputLevel != SDKOutputLevel.Quiet) { PrintSDKInfo(OutputLevel); } }
/// <summary> /// Attempt to register a build platform, checking whether it is a valid platform in installed builds /// </summary> public void TryRegisterBuildPlatforms(SDKOutputLevel OutputLevel, bool bValidatingPlatforms) { // We need all platforms to be registered when we run -validateplatform command to check SDK status of each if (bValidatingPlatforms || InstalledPlatformInfo.Current.IsValidPlatform(TargetPlatform)) { RegisterBuildPlatforms(OutputLevel); } }
/// <summary> /// Register the platform with the UEBuildPlatform class /// </summary> protected override void RegisterBuildPlatforms(SDKOutputLevel OutputLevel) { MacPlatformSDK SDK = new MacPlatformSDK(); SDK.ManageAndValidateSDK(OutputLevel); // Register this build platform for Mac Log.TraceVerbose(" Registering for {0}", UnrealTargetPlatform.Mac.ToString()); UEBuildPlatform.RegisterBuildPlatform(new MacPlatform(SDK)); UEBuildPlatform.RegisterPlatformWithGroup(UnrealTargetPlatform.Mac, UnrealPlatformGroup.Apple); }
public SDKStatus SetupEnvironmentFromAutoSDK(SDKOutputLevel OutputLevel) { string PlatformSDKRoot = GetPathToPlatformAutoSDKs(); // load environment variables from current SDK if (!SetupEnvironmentFromAutoSDK(PlatformSDKRoot, OutputLevel)) { LogAutoSDK(OutputLevel, "Failed to load environment from required SDK {0}", GetRequiredSDKString()); InvalidateCurrentlyInstalledAutoSDK(); return(SDKStatus.Invalid); } return(SDKStatus.Valid); }
/// <summary> /// Runs batch files if necessary to set up required AutoSDK. /// AutoSDKs are SDKs that have not been setup through a formal installer, but rather come from /// a source control directory, or other local copy. /// </summary> private void SetupAutoSDK(SDKOutputLevel OutputLevel) { if (IsAutoSDKSafe() && PlatformSupportsAutoSDKs() && HasAutoSDKSystemEnabled()) { // run installation for autosdk if necessary. if (HasRequiredAutoSDKInstalled() == SDKStatus.Invalid) { //reset check status so any checking sdk status after the attempted setup will do a real check again. SDKCheckStatus = -1; string AutoSDKRoot = GetPathToPlatformAutoSDKs(); string CurrentSDKString; GetCurrentlyInstalledSDKString(AutoSDKRoot, out CurrentSDKString); // switch over (note that version string can be empty) if (!RunAutoSDKHooks(OutputLevel, AutoSDKRoot, CurrentSDKString, SDKHookType.Uninstall)) { LogAutoSDK(OutputLevel, "Failed to uninstall currently installed SDK {0}", CurrentSDKString); InvalidateCurrentlyInstalledAutoSDK(); return; } // delete Manifest file to avoid multiple uninstalls InvalidateCurrentlyInstalledAutoSDK(); if (!RunAutoSDKHooks(OutputLevel, AutoSDKRoot, GetRequiredSDKString(), SDKHookType.Install, false)) { LogAutoSDK(OutputLevel, "Failed to install required SDK {0}. Attemping to uninstall", GetRequiredSDKString()); RunAutoSDKHooks(OutputLevel, AutoSDKRoot, GetRequiredSDKString(), SDKHookType.Uninstall, false); return; } string EnvVarFile = Path.Combine(AutoSDKRoot, SDKEnvironmentVarsFile); if (!File.Exists(EnvVarFile)) { LogAutoSDK(OutputLevel, "Installation of required SDK {0}. Did not generate Environment file {1}", GetRequiredSDKString(), EnvVarFile); RunAutoSDKHooks(OutputLevel, AutoSDKRoot, GetRequiredSDKString(), SDKHookType.Uninstall, false); return; } SetCurrentlyInstalledAutoSDKString(GetRequiredSDKString()); SetLastRunAutoSDKScriptVersion(GetRequiredScriptVersionString()); } // fixup process environment to match autosdk SetupEnvironmentFromAutoSDK(OutputLevel); } }
/// <summary> /// Register the platform with the UEBuildPlatform class /// </summary> protected override void RegisterBuildPlatforms(SDKOutputLevel OutputLevel) { WindowsPlatformSDK SDK = new WindowsPlatformSDK(); SDK.ManageAndValidateSDK(OutputLevel); // Register this build platform for both Win64 and Win32 Log.TraceVerbose(" Registering for {0}", UnrealTargetPlatform.Win64.ToString()); UEBuildPlatform.RegisterBuildPlatform(new WindowsPlatform(UnrealTargetPlatform.Win64, CppPlatform.Win64, SDK)); UEBuildPlatform.RegisterPlatformWithGroup(UnrealTargetPlatform.Win64, UnrealPlatformGroup.Windows); UEBuildPlatform.RegisterPlatformWithGroup(UnrealTargetPlatform.Win64, UnrealPlatformGroup.Microsoft); Log.TraceVerbose(" Registering for {0}", UnrealTargetPlatform.Win32.ToString()); UEBuildPlatform.RegisterBuildPlatform(new WindowsPlatform(UnrealTargetPlatform.Win32, CppPlatform.Win32, SDK)); UEBuildPlatform.RegisterPlatformWithGroup(UnrealTargetPlatform.Win32, UnrealPlatformGroup.Windows); UEBuildPlatform.RegisterPlatformWithGroup(UnrealTargetPlatform.Win32, UnrealPlatformGroup.Microsoft); }
/// <summary> /// Register the platform with the UEBuildPlatform class /// </summary> protected override void RegisterBuildPlatforms(SDKOutputLevel OutputLevel) { LinuxPlatformSDK SDK = new LinuxPlatformSDK(); SDK.ManageAndValidateSDK(OutputLevel); if ((ProjectFileGenerator.bGenerateProjectFiles == true) || (SDK.HasRequiredSDKsInstalled() == SDKStatus.Valid)) { FileReference LinuxTargetPlatformFile = FileReference.Combine(UnrealBuildTool.EngineSourceDirectory, "Developer", "Linux", "LinuxTargetPlatform", "LinuxTargetPlatform.Build.cs"); if (FileReference.Exists(LinuxTargetPlatformFile)) { // Register this build platform for Linux Log.TraceVerbose(" Registering for {0}", UnrealTargetPlatform.Linux.ToString()); UEBuildPlatform.RegisterBuildPlatform(new LinuxPlatform(SDK)); UEBuildPlatform.RegisterPlatformWithGroup(UnrealTargetPlatform.Linux, UnrealPlatformGroup.Unix); } } }
/// <summary> /// Register the platform with the UEBuildPlatform class /// </summary> protected override void RegisterBuildPlatforms(SDKOutputLevel OutputLevel) { IOSPlatformSDK SDK = new IOSPlatformSDK(); SDK.ManageAndValidateSDK(OutputLevel); // Register this build platform for IOS Log.TraceVerbose(" Registering for {0}", UnrealTargetPlatform.IOS.ToString()); UEBuildPlatform.RegisterBuildPlatform(new IOSPlatform(SDK)); UEBuildPlatform.RegisterPlatformWithGroup(UnrealTargetPlatform.IOS, UnrealPlatformGroup.Unix); UEBuildPlatform.RegisterPlatformWithGroup(UnrealTargetPlatform.IOS, UnrealPlatformGroup.Apple); UEBuildPlatform.RegisterPlatformWithGroup(UnrealTargetPlatform.IOS, UnrealPlatformGroup.IOS); if (IOSPlatform.IOSArchitecture == "-simulator") { UEBuildPlatform.RegisterPlatformWithGroup(UnrealTargetPlatform.IOS, UnrealPlatformGroup.Simulator); } else { UEBuildPlatform.RegisterPlatformWithGroup(UnrealTargetPlatform.IOS, UnrealPlatformGroup.Device); } }
public void PrintSDKInfo(SDKOutputLevel OutputLevel) { if (HasRequiredSDKsInstalled() == SDKStatus.Valid) { bool bHasRequiredManualSDK = HasRequiredManualSDK() == SDKStatus.Valid; if (HasSetupAutoSDK()) { string PlatformSDKRoot = GetPathToPlatformAutoSDKs(); LogAutoSDK(OutputLevel, GetSDKTargetPlatformName() + " using SDK from: " + Path.Combine(PlatformSDKRoot, GetRequiredSDKString())); } else if (bHasRequiredManualSDK) { LogAutoSDK(OutputLevel, this.ToString() + " using manually installed SDK " + GetRequiredSDKString()); } else { LogAutoSDK(OutputLevel, this.ToString() + " setup error. Inform platform team."); } } else { LogAutoSDK(OutputLevel, this.ToString() + " has no valid SDK"); } }
/// <summary> /// Loads environment variables from SDK /// If any commands are added or removed the handling needs to be duplicated in /// TargetPlatformManagerModule.cpp /// </summary> /// <param name="PlatformSDKRoot">absolute path to platform SDK</param> /// <param name="OutputLevel">The output level for diagnostic messages</param> /// <returns>true if succeeded</returns> protected bool SetupEnvironmentFromAutoSDK(string PlatformSDKRoot, SDKOutputLevel OutputLevel) { string EnvVarFile = Path.Combine(PlatformSDKRoot, SDKEnvironmentVarsFile); if (File.Exists(EnvVarFile)) { using (StreamReader Reader = new StreamReader(EnvVarFile)) { List <string> PathAdds = new List <string>(); List <string> PathRemoves = new List <string>(); List <string> EnvVarNames = new List <string>(); List <string> EnvVarValues = new List <string>(); bool bNeedsToWriteAutoSetupEnvVar = true; String PlatformSetupEnvVar = GetPlatformAutoSDKSetupEnvVar(); for (; ;) { string VariableString = Reader.ReadLine(); if (VariableString == null) { break; } string[] Parts = VariableString.Split('='); if (Parts.Length != 2) { LogAutoSDK(OutputLevel, "Incorrect environment variable declaration:"); LogAutoSDK(OutputLevel, VariableString); return(false); } if (String.Compare(Parts[0], "strippath", true) == 0) { PathRemoves.Add(Parts[1]); } else if (String.Compare(Parts[0], "addpath", true) == 0) { PathAdds.Add(Parts[1]); } else { if (String.Compare(Parts[0], PlatformSetupEnvVar) == 0) { bNeedsToWriteAutoSetupEnvVar = false; } // convenience for setup.bat writers. Trim any accidental whitespace from var names/values. EnvVarNames.Add(Parts[0].Trim()); EnvVarValues.Add(Parts[1].Trim()); } } // don't actually set anything until we successfully validate and read all values in. // we don't want to set a few vars, return a failure, and then have a platform try to // build against a manually installed SDK with half-set env vars. for (int i = 0; i < EnvVarNames.Count; ++i) { string EnvVarName = EnvVarNames[i]; string EnvVarValue = EnvVarValues[i]; if (OutputLevel >= SDKOutputLevel.Verbose) { LogAutoSDK(OutputLevel, "Setting variable '{0}' to '{1}'", EnvVarName, EnvVarValue); } Environment.SetEnvironmentVariable(EnvVarName, EnvVarValue); } // actually perform the PATH stripping / adding. String OrigPathVar = Environment.GetEnvironmentVariable("PATH"); String PathDelimiter = UEBuildPlatform.GetPathVarDelimiter(); String[] PathVars = { }; if (!String.IsNullOrEmpty(OrigPathVar)) { PathVars = OrigPathVar.Split(PathDelimiter.ToCharArray()); } else { LogAutoSDK(OutputLevel, "Path environment variable is null during AutoSDK"); } List <String> ModifiedPathVars = new List <string>(); ModifiedPathVars.AddRange(PathVars); // perform removes first, in case they overlap with any adds. foreach (String PathRemove in PathRemoves) { foreach (String PathVar in PathVars) { if (PathVar.IndexOf(PathRemove, StringComparison.OrdinalIgnoreCase) >= 0) { LogAutoSDK(OutputLevel, "Removing Path: '{0}'", PathVar); ModifiedPathVars.Remove(PathVar); } } } // remove all the of ADDs so that if this function is executed multiple times, the paths will be guaranteed to be in the same order after each run. // If we did not do this, a 'remove' that matched some, but not all, of our 'adds' would cause the order to change. foreach (String PathAdd in PathAdds) { foreach (String PathVar in PathVars) { if (String.Compare(PathAdd, PathVar, true) == 0) { LogAutoSDK(OutputLevel, "Removing Path: '{0}'", PathVar); ModifiedPathVars.Remove(PathVar); } } } // perform adds, but don't add duplicates foreach (String PathAdd in PathAdds) { if (!ModifiedPathVars.Contains(PathAdd)) { LogAutoSDK(OutputLevel, "Adding Path: '{0}'", PathAdd); ModifiedPathVars.Add(PathAdd); } } String ModifiedPath = String.Join(PathDelimiter, ModifiedPathVars); Environment.SetEnvironmentVariable("PATH", ModifiedPath); Reader.Close(); // write out env var command so any process using this commandfile will mark itself as having had autosdks set up. // avoids child processes spuriously detecting manualsdks. if (bNeedsToWriteAutoSetupEnvVar) { using (StreamWriter Writer = File.AppendText(EnvVarFile)) { Writer.WriteLine("{0}=1", PlatformSetupEnvVar); } // set the var in the local environment in case this process spawns any others. Environment.SetEnvironmentVariable(PlatformSetupEnvVar, "1"); } // make sure we know that we've modified the local environment, invalidating manual installs for this run. bLocalProcessSetupAutoSDK = true; return(true); } } else { LogAutoSDK(OutputLevel, "Cannot set up environment for {1} because command file {1} does not exist.", PlatformSDKRoot, EnvVarFile); } return(false); }
/// <summary> /// Runs install/uninstall hooks for SDK /// </summary> /// <param name="OutputLevel">The output level for diagnostic messages</param> /// <param name="PlatformSDKRoot">absolute path to platform SDK root</param> /// <param name="SDKVersionString">version string to run for (can be empty!)</param> /// <param name="Hook">which one of hooks to run</param> /// <param name="bHookCanBeNonExistent">whether a non-existing hook means failure</param> /// <returns>true if succeeded</returns> protected virtual bool RunAutoSDKHooks(SDKOutputLevel OutputLevel, string PlatformSDKRoot, string SDKVersionString, SDKHookType Hook, bool bHookCanBeNonExistent = true) { if (!IsAutoSDKSafe()) { Console.ForegroundColor = ConsoleColor.Red; LogAutoSDK(OutputLevel, GetSDKTargetPlatformName() + " attempted to run SDK hook which could have damaged manual SDK install!"); Console.ResetColor(); return(false); } if (SDKVersionString != "") { string SDKDirectory = Path.Combine(PlatformSDKRoot, SDKVersionString); string HookExe = Path.Combine(SDKDirectory, GetHookExecutableName(Hook)); if (File.Exists(HookExe)) { LogAutoSDK(OutputLevel, "Running {0} hook {1}", Hook, HookExe); // run it Process HookProcess = new Process(); HookProcess.StartInfo.WorkingDirectory = SDKDirectory; HookProcess.StartInfo.FileName = HookExe; HookProcess.StartInfo.Arguments = ""; HookProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; // seems to break the build machines? //HookProcess.StartInfo.UseShellExecute = false; //HookProcess.StartInfo.RedirectStandardOutput = true; //HookProcess.StartInfo.RedirectStandardError = true; using (ScopedTimer HookTimer = new ScopedTimer("Time to run hook: ", (OutputLevel >= SDKOutputLevel.Minimal) ? LogEventType.Log : LogEventType.Verbose)) { //installers may require administrator access to succeed. so run as an admmin. HookProcess.StartInfo.Verb = "runas"; HookProcess.Start(); HookProcess.WaitForExit(); } //LogAutoSDK(HookProcess.StandardOutput.ReadToEnd()); //LogAutoSDK(HookProcess.StandardError.ReadToEnd()); if (HookProcess.ExitCode != 0) { LogAutoSDK(OutputLevel, "Hook exited uncleanly (returned {0}), considering it failed.", HookProcess.ExitCode); return(false); } return(true); } else { LogAutoSDK(OutputLevel, "File {0} does not exist", HookExe); } } else { LogAutoSDK(OutputLevel, "Version string is blank for {0}. Can't determine {1} hook.", PlatformSDKRoot, Hook.ToString()); } return(bHookCanBeNonExistent); }
/// <summary> /// Register the platform with the UEBuildPlatform class /// </summary> protected abstract void RegisterBuildPlatforms(SDKOutputLevel OutputLevel);