/// <summary> /// Protected constructor. Used by TVOSProjectSettings. /// </summary> /// <param name="ProjectFile">The project file to read settings for</param> /// <param name="Platform">The platform to read settings for</param> protected IOSProjectSettings(FileReference ProjectFile, UnrealTargetPlatform Platform) { this.ProjectFile = ProjectFile; ConfigCache.ReadSettings(DirectoryReference.FromFile(ProjectFile), Platform, this); BundleIdentifier = BundleIdentifier.Replace("[PROJECT_NAME]", ((ProjectFile != null) ? ProjectFile.GetFileNameWithoutAnyExtensions() : "UE4Game")).Replace("_", ""); }
/// <summary> /// Loads a makefile from disk /// </summary> /// <param name="MakefilePath">Path to the makefile to load</param> /// <param name="ProjectFile">Path to the project file</param> /// <param name="Platform">Platform for this makefile</param> /// <param name="Arguments">Command line arguments for this target</param> /// <param name="ReasonNotLoaded">If the function returns null, this string will contain the reason why</param> /// <returns>The loaded makefile, or null if it failed for some reason. On failure, the 'ReasonNotLoaded' variable will contain information about why</returns> public static TargetMakefile Load(FileReference MakefilePath, FileReference ProjectFile, UnrealTargetPlatform Platform, string[] Arguments, out string ReasonNotLoaded) { using (Timeline.ScopeEvent("Checking dependent timestamps")) { // Check the directory timestamp on the project files directory. If the user has generated project files more recently than the makefile, then we need to consider the file to be out of date FileInfo MakefileInfo = new FileInfo(MakefilePath.FullName); if (!MakefileInfo.Exists) { // Makefile doesn't even exist, so we won't bother loading it ReasonNotLoaded = "no existing makefile"; return(null); } // Check the build version FileInfo BuildVersionFileInfo = new FileInfo(BuildVersion.GetDefaultFileName().FullName); if (BuildVersionFileInfo.Exists && MakefileInfo.LastWriteTime.CompareTo(BuildVersionFileInfo.LastWriteTime) < 0) { Log.TraceLog("Existing makefile is older than Build.version, ignoring it"); ReasonNotLoaded = "Build.version is newer"; return(null); } // @todo ubtmake: This will only work if the directory timestamp actually changes with every single GPF. Force delete existing files before creating new ones? Eh... really we probably just want to delete + create a file in that folder // -> UPDATE: Seems to work OK right now though on Windows platform, maybe due to GUID changes // @todo ubtmake: Some platforms may not save any files into this folder. We should delete + generate a "touch" file to force the directory timestamp to be updated (or just check the timestamp file itself. We could put it ANYWHERE, actually) // Installed Build doesn't need to check engine projects for outdatedness if (!UnrealBuildTool.IsEngineInstalled()) { if (DirectoryReference.Exists(ProjectFileGenerator.IntermediateProjectFilesPath)) { DateTime EngineProjectFilesLastUpdateTime = new FileInfo(ProjectFileGenerator.ProjectTimestampFile).LastWriteTime; if (MakefileInfo.LastWriteTime.CompareTo(EngineProjectFilesLastUpdateTime) < 0) { // Engine project files are newer than makefile Log.TraceLog("Existing makefile is older than generated engine project files, ignoring it"); ReasonNotLoaded = "project files are newer"; return(null); } } } // Check the game project directory too if (ProjectFile != null) { string ProjectFilename = ProjectFile.FullName; FileInfo ProjectFileInfo = new FileInfo(ProjectFilename); if (!ProjectFileInfo.Exists || MakefileInfo.LastWriteTime.CompareTo(ProjectFileInfo.LastWriteTime) < 0) { // .uproject file is newer than makefile Log.TraceLog("Makefile is older than .uproject file, ignoring it"); ReasonNotLoaded = ".uproject file is newer"; return(null); } DirectoryReference MasterProjectRelativePath = ProjectFile.Directory; string GameIntermediateProjectFilesPath = Path.Combine(MasterProjectRelativePath.FullName, "Intermediate", "ProjectFiles"); if (Directory.Exists(GameIntermediateProjectFilesPath)) { DateTime GameProjectFilesLastUpdateTime = new DirectoryInfo(GameIntermediateProjectFilesPath).LastWriteTime; if (MakefileInfo.LastWriteTime.CompareTo(GameProjectFilesLastUpdateTime) < 0) { // Game project files are newer than makefile Log.TraceLog("Makefile is older than generated game project files, ignoring it"); ReasonNotLoaded = "game project files are newer"; return(null); } } } // Check to see if UnrealBuildTool.exe was compiled more recently than the makefile DateTime UnrealBuildToolTimestamp = new FileInfo(Assembly.GetExecutingAssembly().Location).LastWriteTime; if (MakefileInfo.LastWriteTime.CompareTo(UnrealBuildToolTimestamp) < 0) { // UnrealBuildTool.exe was compiled more recently than the makefile Log.TraceLog("Makefile is older than UnrealBuildTool.exe, ignoring it"); ReasonNotLoaded = "UnrealBuildTool.exe is newer"; return(null); } // Check to see if any BuildConfiguration files have changed since the last build List <XmlConfig.InputFile> InputFiles = XmlConfig.FindInputFiles(); foreach (XmlConfig.InputFile InputFile in InputFiles) { FileInfo InputFileInfo = new FileInfo(InputFile.Location.FullName); if (InputFileInfo.LastWriteTime > MakefileInfo.LastWriteTime) { Log.TraceLog("Makefile is older than BuildConfiguration.xml, ignoring it"); ReasonNotLoaded = "BuildConfiguration.xml is newer"; return(null); } } } TargetMakefile Makefile; using (Timeline.ScopeEvent("Loading makefile")) { try { using (BinaryArchiveReader Reader = new BinaryArchiveReader(MakefilePath)) { int Version = Reader.ReadInt(); if (Version != CurrentVersion) { ReasonNotLoaded = "makefile version does not match"; return(null); } Makefile = new TargetMakefile(Reader); } } catch (Exception Ex) { Log.TraceWarning("Failed to read makefile: {0}", Ex.Message); Log.TraceLog("Exception: {0}", Ex.ToString()); ReasonNotLoaded = "couldn't read existing makefile"; return(null); } } using (Timeline.ScopeEvent("Checking makefile validity")) { // Check if the arguments are different if (!Enumerable.SequenceEqual(Makefile.AdditionalArguments, Arguments)) { ReasonNotLoaded = "command line arguments changed"; return(null); } // Check if ini files are newer. Ini files contain build settings too. DirectoryReference ProjectDirectory = DirectoryReference.FromFile(ProjectFile); foreach (ConfigHierarchyType IniType in (ConfigHierarchyType[])Enum.GetValues(typeof(ConfigHierarchyType))) { foreach (FileReference IniFilename in ConfigHierarchy.EnumerateConfigFileLocations(IniType, ProjectDirectory, Platform)) { FileInfo IniFileInfo = new FileInfo(IniFilename.FullName); if (IniFileInfo.LastWriteTimeUtc > Makefile.CreateTimeUtc) { // Ini files are newer than makefile ReasonNotLoaded = "ini files are newer than makefile"; return(null); } } } // Get the current build metadata from the platform string CurrentExternalMetadata = UEBuildPlatform.GetBuildPlatform(Platform).GetExternalBuildMetadata(ProjectFile); if (String.Compare(CurrentExternalMetadata, Makefile.ExternalMetadata, StringComparison.Ordinal) != 0) { Log.TraceLog("Old metadata:\n", Makefile.ExternalMetadata); Log.TraceLog("New metadata:\n", CurrentExternalMetadata); ReasonNotLoaded = "build metadata has changed"; return(null); } } // The makefile is ok ReasonNotLoaded = null; return(Makefile); }
public List <string> CreateManifest(string InManifestName, string InOutputPath, string InIntermediatePath, FileReference InProjectFile, string InProjectDirectory, List <UnrealTargetConfiguration> InTargetConfigs, List <string> InExecutables) { // Verify we can find the SDK. string SDKDirectory = GetSDKDirectory(); if (string.IsNullOrEmpty(SDKDirectory)) { return(null); } // Check parameter values are valid. if (InTargetConfigs.Count != InExecutables.Count) { Log.TraceError("The number of target configurations ({0}) and executables ({1}) passed to manifest generation do not match.", InTargetConfigs.Count, InExecutables.Count); return(null); } if (InTargetConfigs.Count < 1) { Log.TraceError("The number of target configurations is zero, so we cannot generate a manifest."); return(null); } if (!CreateCheckDirectory(InOutputPath)) { Log.TraceError("Failed to create output directory \"{0}\".", InOutputPath); return(null); } if (!CreateCheckDirectory(InIntermediatePath)) { Log.TraceError("Failed to create intermediate directory \"{0}\".", InIntermediatePath); return(null); } OutputPath = InOutputPath; IntermediatePath = InIntermediatePath; ProjectFile = InProjectFile; ProjectPath = InProjectDirectory; UpdatedFilePaths = new List <string>(); // Load up INI settings. We'll use engine settings to retrieve the manifest configuration, but these may reference // values in either game or engine settings, so we'll keep both. GameIni = ConfigCache.ReadHierarchy(ConfigHierarchyType.Game, DirectoryReference.FromFile(InProjectFile), ConfigPlatform); EngineIni = ConfigCache.ReadHierarchy(ConfigHierarchyType.Engine, DirectoryReference.FromFile(InProjectFile), ConfigPlatform); // Load and verify/clean culture list { List <string> CulturesToStageWithDuplicates; GameIni.GetArray("/Script/UnrealEd.ProjectPackagingSettings", "CulturesToStage", out CulturesToStageWithDuplicates); GameIni.GetString("/Script/UnrealEd.ProjectPackagingSettings", "DefaultCulture", out DefaultCulture); if (CulturesToStageWithDuplicates == null || CulturesToStageWithDuplicates.Count < 1) { Log.TraceError("At least one culture must be selected to stage."); return(null); } CulturesToStage = CulturesToStageWithDuplicates.Distinct().ToList(); } if (DefaultCulture == null || DefaultCulture.Length < 1) { DefaultCulture = CulturesToStage[0]; Log.TraceWarning("A default culture must be selected to stage. Using {0}.", DefaultCulture); } if (!CulturesToStage.Contains(DefaultCulture)) { DefaultCulture = CulturesToStage[0]; Log.TraceWarning("The default culture must be one of the staged cultures. Using {0}.", DefaultCulture); } List <string> PerCultureValues; if (EngineIni.GetArray(IniSection_PlatformTargetSettings, "PerCultureResources", out PerCultureValues)) { foreach (string CultureCombinedValues in PerCultureValues) { Dictionary <string, string> SeparatedCultureValues; if (!ConfigHierarchy.TryParse(CultureCombinedValues, out SeparatedCultureValues)) { Log.TraceWarning("Invalid per-culture resource value: {0}", CultureCombinedValues); continue; } string StageId = SeparatedCultureValues["StageId"]; int CultureIndex = CulturesToStage.FindIndex(x => x == StageId); if (CultureIndex >= 0) { CulturesToStage[CultureIndex] = SeparatedCultureValues["CultureId"]; if (DefaultCulture == StageId) { DefaultCulture = SeparatedCultureValues["CultureId"]; } } } } // Only warn if shipping, we can run without translated cultures they're just needed for cert else if (InTargetConfigs.Contains(UnrealTargetConfiguration.Shipping)) { Log.TraceInformation("Staged culture mappings not setup in the editor. See Per Culture Resources in the {0} Target Settings.", Platform.ToString()); } // Clean out the resources intermediate path so that we know there are no stale binary files. string IntermediateResourceDirectory = Path.Combine(IntermediatePath, BuildResourceSubPath); RecursivelyForceDeleteDirectory(IntermediateResourceDirectory); if (!CreateCheckDirectory(IntermediateResourceDirectory)) { Log.TraceError("Could not create directory {0}.", IntermediateResourceDirectory); return(null); } // Construct a single resource writer for the default (no-culture) values string DefaultResourceIntermediatePath = Path.Combine(IntermediateResourceDirectory, "resources.resw"); DefaultResourceWriter = new UEResXWriter(DefaultResourceIntermediatePath); // Construct the ResXWriters for each culture PerCultureResourceWriters = new Dictionary <string, UEResXWriter>(); foreach (string Culture in CulturesToStage) { string IntermediateStringResourcePath = Path.Combine(IntermediateResourceDirectory, Culture); string IntermediateStringResourceFile = Path.Combine(IntermediateStringResourcePath, "resources.resw"); if (!CreateCheckDirectory(IntermediateStringResourcePath)) { Log.TraceWarning("Culture {0} resources not staged.", Culture); CulturesToStage.Remove(Culture); if (Culture == DefaultCulture) { DefaultCulture = CulturesToStage[0]; Log.TraceWarning("Default culture skipped. Using {0} as default culture.", DefaultCulture); } continue; } PerCultureResourceWriters.Add(Culture, new UEResXWriter(IntermediateStringResourceFile)); } // Create the manifest document string IdentityName = null; var ManifestXmlDocument = new XDocument(GetManifest(InTargetConfigs, InExecutables, out IdentityName)); // Export manifest to the intermediate directory then compare the contents to any existing target manifest // and replace if there are differences. string ManifestIntermediatePath = Path.Combine(IntermediatePath, InManifestName); string ManifestTargetPath = Path.Combine(OutputPath, InManifestName); ManifestXmlDocument.Save(ManifestIntermediatePath); CompareAndReplaceModifiedTarget(ManifestIntermediatePath, ManifestTargetPath); ProcessManifest(InTargetConfigs, InExecutables, InManifestName, ManifestTargetPath, ManifestIntermediatePath); // Clean out any resource directories that we aren't staging string TargetResourcePath = Path.Combine(OutputPath, BuildResourceSubPath); if (Directory.Exists(TargetResourcePath)) { List <string> TargetResourceDirectories = new List <string>(Directory.GetDirectories(TargetResourcePath, "*.*", SearchOption.AllDirectories)); foreach (string ResourceDirectory in TargetResourceDirectories) { if (!CulturesToStage.Contains(Path.GetFileName(ResourceDirectory))) { RecursivelyForceDeleteDirectory(ResourceDirectory); } } } // Export the resource tables starting with the default culture string DefaultResourceTargetPath = Path.Combine(OutputPath, BuildResourceSubPath, "resources.resw"); DefaultResourceWriter.Close(); CompareAndReplaceModifiedTarget(DefaultResourceIntermediatePath, DefaultResourceTargetPath); foreach (var Writer in PerCultureResourceWriters) { Writer.Value.Close(); string IntermediateStringResourceFile = Path.Combine(IntermediateResourceDirectory, Writer.Key, "resources.resw"); string TargetStringResourceFile = Path.Combine(OutputPath, BuildResourceSubPath, Writer.Key, "resources.resw"); CompareAndReplaceModifiedTarget(IntermediateStringResourceFile, TargetStringResourceFile); } // Copy all the binary resources into the target directory. CopyResourcesToTargetDir(); // The resource database is dependent on everything else calculated here (manifest, resource string tables, binary resources). // So if any file has been updated we'll need to run the config. if (UpdatedFilePaths.Count > 0) { // Create resource index configuration string PriExecutable = GetMakePriBinaryPath(); string ResourceConfigFile = Path.Combine(IntermediatePath, "priconfig.xml"); bool bEnableAutoResourcePacks = false; EngineIni.GetBool(IniSection_PlatformTargetSettings, "bEnableAutoResourcePacks", out bEnableAutoResourcePacks); // If the game is not going to support language resource packs then merge the culture qualifiers. if (bEnableAutoResourcePacks || CulturesToStage.Count <= 1) { RunExternalProgram(PriExecutable, "createconfig /cf \"" + ResourceConfigFile + "\" /dq " + DefaultCulture + " /o"); } else { RunExternalProgram(PriExecutable, "createconfig /cf \"" + ResourceConfigFile + "\" /dq " + String.Join("_", CulturesToStage) + " /o"); } // Modify configuration to restrict indexing to the Resources directory (saves time and space) XmlDocument PriConfig = new XmlDocument(); PriConfig.Load(ResourceConfigFile); // If the game is not going to support resource packs then remove the autoResourcePackages. if (!bEnableAutoResourcePacks) { XmlNode PackagingNode = PriConfig.SelectSingleNode("/resources/packaging"); PackagingNode.ParentNode.RemoveChild(PackagingNode); } // The previous implementation using startIndexAt="Resources" did not produce the expected ResourceMapSubtree hierarchy, so this manually specifies all resources in a .resfiles instead. string ResourcesResFile = Path.Combine(IntermediatePath, "resources.resfiles"); XmlNode PriIndexNode = PriConfig.SelectSingleNode("/resources/index"); XmlAttribute PriStartIndex = PriIndexNode.Attributes["startIndexAt"]; PriStartIndex.Value = ResourcesResFile; // Swap the default folder indexer-config to a RESFILES indexer-config. XmlElement FolderIndexerConfigNode = PriConfig.SelectSingleNode("/resources/index/indexer-config[@type='folder']") as XmlElement; FolderIndexerConfigNode.SetAttribute("type", "RESFILES"); FolderIndexerConfigNode.RemoveAttribute("foldernameAsQualifier"); FolderIndexerConfigNode.RemoveAttribute("filenameAsQualifier"); PriConfig.Save(ResourceConfigFile); IEnumerable <string> Resources = Directory.EnumerateFiles(Path.Combine(OutputPath, BuildResourceSubPath), "*.*", SearchOption.AllDirectories); System.Text.StringBuilder ResourcesList = new System.Text.StringBuilder(); foreach (string Resource in Resources) { ResourcesList.AppendLine(Resource.Replace(OutputPath, "").TrimStart('\\')); } File.WriteAllText(ResourcesResFile, ResourcesList.ToString()); // Remove previous pri files so we can enumerate which ones are new since the resource generator could produce a file for each staged language. IEnumerable <string> OldPriFiles = Directory.EnumerateFiles(IntermediatePath, "*.pri"); foreach (string OldPri in OldPriFiles) { try { File.Delete(OldPri); } catch (Exception) { Log.TraceError("Could not delete file {0}.", OldPri); } } // Generate the resource index string ResourceLogFile = Path.Combine(IntermediatePath, "ResIndexLog.xml"); string ResourceIndexFile = Path.Combine(IntermediatePath, "resources.pri"); string MakePriCommandLine = "new /pr \"" + OutputPath + "\" /cf \"" + ResourceConfigFile + "\" /mn \"" + ManifestTargetPath + "\" /il \"" + ResourceLogFile + "\" /of \"" + ResourceIndexFile + "\" /o"; if (IdentityName != null) { MakePriCommandLine += " /indexName \"" + IdentityName + "\""; } RunExternalProgram(PriExecutable, MakePriCommandLine); // Remove any existing pri target files that were not generated by this latest update IEnumerable <string> NewPriFiles = Directory.EnumerateFiles(IntermediatePath, "*.pri"); IEnumerable <string> TargetPriFiles = Directory.EnumerateFiles(OutputPath, "*.pri"); foreach (string TargetPri in TargetPriFiles) { if (!NewPriFiles.Contains(TargetPri)) { try { File.Delete(TargetPri); } catch (Exception) { Log.TraceError("Could not remove stale file {0}.", TargetPri); } } } // Stage all the modified pri files to the output directory foreach (string NewPri in NewPriFiles) { string NewResourceIndexFile = Path.Combine(IntermediatePath, Path.GetFileName(NewPri)); string FinalResourceIndexFile = Path.Combine(OutputPath, Path.GetFileName(NewPri)); CompareAndReplaceModifiedTarget(NewResourceIndexFile, FinalResourceIndexFile); } } return(UpdatedFilePaths); }
public static bool UseTegraGraphicsDebugger(FileReference ProjectFile) { if (!HaveTegraGraphicsDebugger.HasValue) { string ProgramsDir = Environment.GetEnvironmentVariable("ProgramFiles(x86)"); string NVDir = ProgramsDir + "/NVIDIA Corporation"; try { string[] TegraDebuggerDirs = Directory.GetDirectories(NVDir, "Tegra Graphics Debugger *"); if (TegraDebuggerDirs.Length > 0) { TegraDebuggerDir = TegraDebuggerDirs[0].Replace('\\', '/'); HaveTegraGraphicsDebugger = true; string[] V = TegraDebuggerDir.Split(' ').Last().Split('.'); TegraDebuggerVersion = new int[2]; TegraDebuggerVersion[0] = Int32.Parse(V[0]); TegraDebuggerVersion[1] = Int32.Parse(V[1]); } else { HaveTegraGraphicsDebugger = false; } } catch (System.IO.IOException) { HaveTegraGraphicsDebugger = false; } } bool bBuild = false; // TODO: do we need this? ConfigHierarchy Ini = ConfigCache.ReadHierarchy(ConfigHierarchyType.Engine, DirectoryReference.FromFile(ProjectFile), UnrealTargetPlatform.Lumin); Ini.GetBool( "/Script/LuminRuntimeSettings.LuminRuntimeSettings", "bBuildWithNvTegraGfxDebugger", out bBuild); return(HaveTegraGraphicsDebugger.Value && bBuild); }
/// <summary> /// Setup the target environment for building /// </summary> /// <param name="Target">Settings for the target being compiled</param> /// <param name="CompileEnvironment">The compile environment for this target</param> /// <param name="LinkEnvironment">The link environment for this target</param> public override void SetUpEnvironment(ReadOnlyTargetRules Target, CppCompileEnvironment CompileEnvironment, LinkEnvironment LinkEnvironment) { // During the native builds, check the system includes as well (check toolchain when cross-compiling?) string BaseLinuxPath = SDK.GetBaseLinuxPathForArchitecture(Target.Architecture); if (BuildHostPlatform.Current.Platform == UnrealTargetPlatform.Linux && String.IsNullOrEmpty(BaseLinuxPath)) { CompileEnvironment.SystemIncludePaths.Add(new DirectoryReference("/usr/include")); } if (CompileEnvironment.bPGOOptimize != LinkEnvironment.bPGOOptimize) { throw new BuildException("Inconsistency between PGOOptimize settings in Compile ({0}) and Link ({1}) environments", CompileEnvironment.bPGOOptimize, LinkEnvironment.bPGOOptimize ); } if (CompileEnvironment.bPGOProfile != LinkEnvironment.bPGOProfile) { throw new BuildException("Inconsistency between PGOProfile settings in Compile ({0}) and Link ({1}) environments", CompileEnvironment.bPGOProfile, LinkEnvironment.bPGOProfile ); } if (CompileEnvironment.bPGOOptimize) { DirectoryReference BaseDir = UnrealBuildTool.EngineDirectory; if (Target.ProjectFile != null) { BaseDir = DirectoryReference.FromFile(Target.ProjectFile); } CompileEnvironment.PGODirectory = Path.Combine(BaseDir.FullName, "Build", Target.Platform.ToString(), "PGO").Replace('\\', '/') + "/"; CompileEnvironment.PGOFilenamePrefix = "profile.profdata"; LinkEnvironment.PGODirectory = CompileEnvironment.PGODirectory; LinkEnvironment.PGOFilenamePrefix = CompileEnvironment.PGOFilenamePrefix; } // For consistency with other platforms, also enable LTO whenever doing profile-guided optimizations. // Obviously both PGI (instrumented) and PGO (optimized) binaries need to have that if (CompileEnvironment.bPGOProfile || CompileEnvironment.bPGOOptimize) { CompileEnvironment.bAllowLTCG = true; LinkEnvironment.bAllowLTCG = true; } if (CompileEnvironment.bAllowLTCG != LinkEnvironment.bAllowLTCG) { throw new BuildException("Inconsistency between LTCG settings in Compile ({0}) and Link ({1}) environments", CompileEnvironment.bAllowLTCG, LinkEnvironment.bAllowLTCG ); } // link with Linux libraries. LinkEnvironment.AdditionalLibraries.Add("pthread"); // let this class or a sub class do settings specific to that class SetUpSpecificEnvironment(Target, CompileEnvironment, LinkEnvironment); }
private void WriteEntitlementsFile(string OutputFilename, FileReference ProjectFile) { // get the settings from the ini file // plist replacements // @todo tvos: Separate TVOS version? ConfigCacheIni Ini = ConfigCacheIni.CreateConfigCacheIni(UnrealTargetPlatform.IOS, "Engine", DirectoryReference.FromFile(ProjectFile)); bool bSupported = false; Ini.GetBool("/Script/IOSRuntimeSettings.IOSRuntimeSettings", "bEnableCloudKitSupport", out bSupported); Directory.CreateDirectory(Path.GetDirectoryName(OutputFilename)); // we need to have something so Xcode will compile, so we just set the get-task-allow, since we know the value, // which is based on distribution or not (true means debuggable) StringBuilder Text = new StringBuilder(); Text.AppendLine("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); Text.AppendLine("<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">"); Text.AppendLine("<plist version=\"1.0\">"); Text.AppendLine("<dict>"); Text.AppendLine(string.Format("\t<key>get-task-allow</key><{0}/>", /*Config.bForDistribution ? "false" : */ "true")); if (bSupported) { Text.AppendLine("\t<key>com.apple.developer.icloud-container-identifiers</key>"); Text.AppendLine("\t<array>"); Text.AppendLine("\t\t<string>iCloud.$(CFBundleIdentifier)</string>"); Text.AppendLine("\t</array>"); Text.AppendLine("\t<key>com.apple.developer.icloud-services</key>"); Text.AppendLine("\t<array>"); Text.AppendLine("\t\t<string>CloudKit</string>"); Text.AppendLine("\t</array>"); } Text.AppendLine("</dict>"); Text.AppendLine("</plist>"); File.WriteAllText(OutputFilename, Text.ToString()); }
/// <summary> /// Setup the target environment for building /// </summary> /// <param name="Target">Settings for the target being compiled</param> /// <param name="CompileEnvironment">The compile environment for this target</param> /// <param name="LinkEnvironment">The link environment for this target</param> public override void SetUpEnvironment(ReadOnlyTargetRules Target, CppCompileEnvironment CompileEnvironment, LinkEnvironment LinkEnvironment) { CompileEnvironment.Definitions.Add("WIN32=1"); if (WindowsPlatform.bUseWindowsSDK10) { // Windows 8 or higher required CompileEnvironment.Definitions.Add("_WIN32_WINNT=0x0602"); CompileEnvironment.Definitions.Add("WINVER=0x0602"); } else { // Windows 7 or higher required CompileEnvironment.Definitions.Add("_WIN32_WINNT=0x0601"); CompileEnvironment.Definitions.Add("WINVER=0x0601"); } CompileEnvironment.Definitions.Add("PLATFORM_WINDOWS=1"); CompileEnvironment.Definitions.Add("DEPTH_32_BIT_CONVERSION=0"); FileReference MorpheusShaderPath = FileReference.Combine(UnrealBuildTool.EngineDirectory, "Shaders", "Private", "PS4", "PostProcessHMDMorpheus.usf"); if (FileReference.Exists(MorpheusShaderPath)) { CompileEnvironment.Definitions.Add("HAS_MORPHEUS=1"); //on PS4 the SDK now handles distortion correction. On PC we will still have to handle it manually, CompileEnvironment.Definitions.Add("MORPHEUS_ENGINE_DISTORTION=1"); } // Add path to Intel math libraries when using ICL based on target platform if (WindowsPlatform.bCompileWithICL) { var Result = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), "IntelSWTools", "compilers_and_libraries", "windows", "compiler", "lib", Target.Platform == UnrealTargetPlatform.Win32 ? "ia32" : "intel64"); if (!Directory.Exists(Result)) { throw new BuildException("ICL was selected but the required math libraries were not found. Could not find: " + Result); } LinkEnvironment.LibraryPaths.Add(Result); } // Explicitly exclude the MS C++ runtime libraries we're not using, to ensure other libraries we link with use the same // runtime library as the engine. bool bUseDebugCRT = Target.Configuration == UnrealTargetConfiguration.Debug && Target.bDebugBuildsActuallyUseDebugCRT; if (!Target.bUseStaticCRT || bUseDebugCRT) { LinkEnvironment.ExcludedLibraries.Add("LIBCMT"); LinkEnvironment.ExcludedLibraries.Add("LIBCPMT"); } if (!Target.bUseStaticCRT || !bUseDebugCRT) { LinkEnvironment.ExcludedLibraries.Add("LIBCMTD"); LinkEnvironment.ExcludedLibraries.Add("LIBCPMTD"); } if (Target.bUseStaticCRT || bUseDebugCRT) { LinkEnvironment.ExcludedLibraries.Add("MSVCRT"); LinkEnvironment.ExcludedLibraries.Add("MSVCPRT"); } if (Target.bUseStaticCRT || !bUseDebugCRT) { LinkEnvironment.ExcludedLibraries.Add("MSVCRTD"); LinkEnvironment.ExcludedLibraries.Add("MSVCPRTD"); } LinkEnvironment.ExcludedLibraries.Add("LIBC"); LinkEnvironment.ExcludedLibraries.Add("LIBCP"); LinkEnvironment.ExcludedLibraries.Add("LIBCD"); LinkEnvironment.ExcludedLibraries.Add("LIBCPD"); //@todo ATL: Currently, only VSAccessor requires ATL (which is only used in editor builds) // When compiling games, we do not want to include ATL - and we can't when compiling games // made with Launcher build due to VS 2012 Express not including ATL. // If more modules end up requiring ATL, this should be refactored into a BuildTarget flag (bNeedsATL) // that is set by the modules the target includes to allow for easier tracking. // Alternatively, if VSAccessor is modified to not require ATL than we should always exclude the libraries. if (Target.LinkType == TargetLinkType.Monolithic && (Target.Type == TargetType.Game || Target.Type == TargetType.Client || Target.Type == TargetType.Server)) { LinkEnvironment.ExcludedLibraries.Add("atl"); LinkEnvironment.ExcludedLibraries.Add("atls"); LinkEnvironment.ExcludedLibraries.Add("atlsd"); LinkEnvironment.ExcludedLibraries.Add("atlsn"); LinkEnvironment.ExcludedLibraries.Add("atlsnd"); } // Add the library used for the delayed loading of DLLs. LinkEnvironment.AdditionalLibraries.Add("delayimp.lib"); //@todo - remove once FB implementation uses Http module if (Target.bCompileAgainstEngine) { // link against wininet (used by FBX and Facebook) LinkEnvironment.AdditionalLibraries.Add("wininet.lib"); } // Compile and link with Win32 API libraries. LinkEnvironment.AdditionalLibraries.Add("rpcrt4.lib"); //LinkEnvironment.AdditionalLibraries.Add("wsock32.lib"); LinkEnvironment.AdditionalLibraries.Add("ws2_32.lib"); LinkEnvironment.AdditionalLibraries.Add("dbghelp.lib"); LinkEnvironment.AdditionalLibraries.Add("comctl32.lib"); LinkEnvironment.AdditionalLibraries.Add("Winmm.lib"); LinkEnvironment.AdditionalLibraries.Add("kernel32.lib"); LinkEnvironment.AdditionalLibraries.Add("user32.lib"); LinkEnvironment.AdditionalLibraries.Add("gdi32.lib"); LinkEnvironment.AdditionalLibraries.Add("winspool.lib"); LinkEnvironment.AdditionalLibraries.Add("comdlg32.lib"); LinkEnvironment.AdditionalLibraries.Add("advapi32.lib"); LinkEnvironment.AdditionalLibraries.Add("shell32.lib"); LinkEnvironment.AdditionalLibraries.Add("ole32.lib"); LinkEnvironment.AdditionalLibraries.Add("oleaut32.lib"); LinkEnvironment.AdditionalLibraries.Add("uuid.lib"); LinkEnvironment.AdditionalLibraries.Add("odbc32.lib"); LinkEnvironment.AdditionalLibraries.Add("odbccp32.lib"); LinkEnvironment.AdditionalLibraries.Add("netapi32.lib"); LinkEnvironment.AdditionalLibraries.Add("iphlpapi.lib"); LinkEnvironment.AdditionalLibraries.Add("setupapi.lib"); // Required for access monitor device enumeration // Windows Vista/7 Desktop Windows Manager API for Slate Windows Compliance LinkEnvironment.AdditionalLibraries.Add("dwmapi.lib"); // IME LinkEnvironment.AdditionalLibraries.Add("imm32.lib"); // For 64-bit builds, we'll forcibly ignore a linker warning with DirectInput. This is // Microsoft's recommended solution as they don't have a fixed .lib for us. if (Target.Platform == UnrealTargetPlatform.Win64) { LinkEnvironment.AdditionalArguments += " /ignore:4078"; } if (Target.Type != TargetType.Editor) { if (!string.IsNullOrEmpty(Target.WindowsPlatform.CompanyName)) { CompileEnvironment.Definitions.Add(String.Format("PROJECT_COMPANY_NAME={0}", SanitizeMacroValue(Target.WindowsPlatform.CompanyName))); } if (!string.IsNullOrEmpty(Target.WindowsPlatform.CopyrightNotice)) { CompileEnvironment.Definitions.Add(String.Format("PROJECT_COPYRIGHT_STRING={0}", SanitizeMacroValue(Target.WindowsPlatform.CopyrightNotice))); } if (!string.IsNullOrEmpty(Target.WindowsPlatform.ProductName)) { CompileEnvironment.Definitions.Add(String.Format("PROJECT_PRODUCT_NAME={0}", SanitizeMacroValue(Target.WindowsPlatform.ProductName))); } if (Target.ProjectFile != null) { CompileEnvironment.Definitions.Add(String.Format("PROJECT_PRODUCT_IDENTIFIER={0}", SanitizeMacroValue(Target.ProjectFile.GetFileNameWithoutExtension()))); } } // Set up default stack size ConfigHierarchy EngineIni = ConfigCache.ReadHierarchy(ConfigHierarchyType.Engine, DirectoryReference.FromFile(Target.ProjectFile), UnrealTargetPlatform.Win64); String TargetSettingsIniPath = "/Script/WindowsTargetPlatform.WindowsTargetSettings"; int IniDefaultStackSize = 0; String StackSizeName = Target.Type == TargetType.Editor ? "DefaultStackSizeEditor" : "DefaultStackSize"; if (EngineIni.GetInt32(TargetSettingsIniPath, StackSizeName, out IniDefaultStackSize)) { LinkEnvironment.DefaultStackSize = IniDefaultStackSize; } int IniDefaultStackSizeCommit = 0; String StackSizeCommitName = Target.Type == TargetType.Editor ? "DefaultStackSizeCommitEditor" : "DefaultStackSizeCommit"; if (EngineIni.GetInt32(TargetSettingsIniPath, StackSizeCommitName, out IniDefaultStackSizeCommit)) { LinkEnvironment.DefaultStackSizeCommit = IniDefaultStackSizeCommit; } LinkEnvironment.ModuleDefinitionFile = Target.WindowsPlatform.ModuleDefinitionFile; }
public override void SetUpProjectEnvironment(UnrealTargetConfiguration Configuration, TargetInfo Target = null) { if (!bInitializedProject) { base.SetUpProjectEnvironment(Configuration, Target); // update the configuration based on the project file // look in ini settings for what platforms to compile for ConfigCacheIni Ini = ConfigCacheIni.CreateConfigCacheIni(Platform, "Engine", DirectoryReference.FromFile(ProjectFile)); string MinVersion = "IOS_8"; if (Ini.GetString("/Script/IOSRuntimeSettings.IOSRuntimeSettings", "MinimumiOSVersion", out MinVersion)) { switch (MinVersion) { case "IOS_61": Log.TraceWarningOnce("IOS 6 is no longer supported in UE4 as 4.11"); RunTimeIOSVersion = "8.0"; break; case "IOS_7": Log.TraceWarningOnce("IOS 7 is no longer supported in UE4 as 4.14"); RunTimeIOSVersion = "8.0"; break; case "IOS_8": RunTimeIOSVersion = "8.0"; break; case "IOS_9": RunTimeIOSVersion = "9.0"; break; case "IOS_10": RunTimeIOSVersion = "10.0"; break; } } bool biPhoneAllowed = true; bool biPadAllowed = true; Ini.GetBool("/Script/IOSRuntimeSettings.IOSRuntimeSettings", "bSupportsIPhone", out biPhoneAllowed); Ini.GetBool("/Script/IOSRuntimeSettings.IOSRuntimeSettings", "bSupportsIPad", out biPadAllowed); if (biPhoneAllowed && biPadAllowed) { RunTimeIOSDevices = "1,2"; } else if (biPadAllowed) { RunTimeIOSDevices = "2"; } else if (biPhoneAllowed) { RunTimeIOSDevices = "1"; } ProjectArches = new List <string>(); bool bBuild = true; if (Ini.GetBool("/Script/IOSRuntimeSettings.IOSRuntimeSettings", "bDevForArmV7", out bBuild) && bBuild) { ProjectArches.Add("armv7"); } if (Ini.GetBool("/Script/IOSRuntimeSettings.IOSRuntimeSettings", "bDevForArm64", out bBuild) && bBuild) { ProjectArches.Add("arm64"); } if (Ini.GetBool("/Script/IOSRuntimeSettings.IOSRuntimeSettings", "bDevForArmV7S", out bBuild) && bBuild) { ProjectArches.Add("armv7s"); } // force armv7 if something went wrong if (ProjectArches.Count == 0) { ProjectArches.Add("armv7"); } NonShippingArchitectures = ProjectArches[0]; for (int Index = 1; Index < ProjectArches.Count; ++Index) { NonShippingArchitectures += "," + ProjectArches[Index]; } ProjectArches.Clear(); if (Ini.GetBool("/Script/IOSRuntimeSettings.IOSRuntimeSettings", "bShipForArmV7", out bBuild) && bBuild) { ProjectArches.Add("armv7"); } if (Ini.GetBool("/Script/IOSRuntimeSettings.IOSRuntimeSettings", "bShipForArm64", out bBuild) && bBuild) { ProjectArches.Add("arm64"); } if (Ini.GetBool("/Script/IOSRuntimeSettings.IOSRuntimeSettings", "bShipForArmV7S", out bBuild) && bBuild) { ProjectArches.Add("armv7s"); } // force armv7 if something went wrong if (ProjectArches.Count == 0) { ProjectArches.Add("armv7"); ProjectArches.Add("arm64"); } ShippingArchitectures = ProjectArches[0]; for (int Index = 1; Index < ProjectArches.Count; ++Index) { ShippingArchitectures += "," + ProjectArches[Index]; } // determine if we need to generate the dsym Ini.GetBool("/Script/IOSRuntimeSettings.IOSRuntimeSettings", "bGeneratedSYMFile", out BuildConfiguration.bGeneratedSYMFile); Ini.GetBool("/Script/IOSRuntimeSettings.IOSRuntimeSettings", "bGeneratedSYMBundle", out BuildConfiguration.bGeneratedSYMBundle); // determie if bitcode should be generated for the shipping code Ini.GetBool("/Script/IOSRuntimeSettings.IOSRuntimeSettings", "bShipForBitcode", out bShipForBitcode); // @todo tvos: We probably want to handle TVOS versions here Ini.GetString("/Script/IOSRuntimeSettings.IOSRuntimeSettings", "AdditionalLinkerFlags", out AdditionalLinkerFlags); Ini.GetString("/Script/IOSRuntimeSettings.IOSRuntimeSettings", "AdditionalShippingLinkerFlags", out AdditionalShippingLinkerFlags); Ini.GetString("/Script/IOSRuntimeSettings.IOSRuntimeSettings", "MobileProvision", out MobileProvision); Ini.GetString("/Script/IOSRuntimeSettings.IOSRuntimeSettings", "SigningCertificate", out SigningCertificate); // bundle identifier Ini.GetString("/Script/IOSRuntimeSettings.IOSRuntimeSettings", "BundleIdentifier", out BundleIdentifier); bInitializedProject = true; } ProvisionData Data = new ProvisionData(); string BundleId = BundleIdentifier.Replace("[PROJECT_NAME]", ((ProjectFile != null) ? ProjectFile.GetFileNameWithoutAnyExtensions() : "UE4Game")).Replace("_", ""); bool bIsTVOS = GetCodesignPlatformName() == "appletvos"; if (!ProvisionCache.ContainsKey(BundleId + " " + bIsTVOS.ToString() + " " + bForDistribtion.ToString())) { Certificate = SigningCertificate; Provision = MobileProvision; if (!string.IsNullOrEmpty(SigningCertificate)) { // verify the certificate Process IPPProcess = new Process(); if (BuildHostPlatform.Current.Platform == UnrealTargetPlatform.Mac) { string IPPCmd = "\"" + UnrealBuildTool.EngineDirectory + "/Binaries/DotNET/IOS/IPhonePackager.exe\" certificates " + ((ProjectFile != null) ? ("\"" + ProjectFile.ToString() + "\"") : "Engine") + " -bundlename " + BundleId + (bForDistribtion ? " -distribution" : ""); IPPProcess.StartInfo.WorkingDirectory = UnrealBuildTool.EngineDirectory.ToString(); IPPProcess.StartInfo.FileName = UnrealBuildTool.EngineDirectory + "/Build/BatchFiles/Mac/RunMono.sh"; IPPProcess.StartInfo.Arguments = IPPCmd; IPPProcess.OutputDataReceived += new DataReceivedEventHandler(IPPDataReceivedHandler); IPPProcess.ErrorDataReceived += new DataReceivedEventHandler(IPPDataReceivedHandler); } else { string IPPCmd = "certificates " + ((ProjectFile != null) ? ("\"" + ProjectFile.ToString() + "\"") : "Engine") + " -bundlename " + BundleId + (bForDistribtion ? " -distribution" : ""); IPPProcess.StartInfo.WorkingDirectory = UnrealBuildTool.EngineDirectory.ToString(); IPPProcess.StartInfo.FileName = UnrealBuildTool.EngineDirectory + "\\Binaries\\DotNET\\IOS\\IPhonePackager.exe"; IPPProcess.StartInfo.Arguments = IPPCmd; IPPProcess.OutputDataReceived += new DataReceivedEventHandler(IPPDataReceivedHandler); IPPProcess.ErrorDataReceived += new DataReceivedEventHandler(IPPDataReceivedHandler); } Utils.RunLocalProcess(IPPProcess); } else { Certificate = bForDistribtion ? "iPhone Distribution" : "iPhone Developer"; bHaveCertificate = true; } if (string.IsNullOrEmpty(MobileProvision) || // no provision specified !File.Exists((BuildHostPlatform.Current.Platform == UnrealTargetPlatform.Mac ? (Environment.GetEnvironmentVariable("HOME") + "/Library/MobileDevice/Provisioning Profiles/") : (Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "/Apple Computer/MobileDevice/Provisioning Profiles/")) + MobileProvision) || // file doesn't exist !bHaveCertificate) // certificate doesn't exist { Certificate = ""; Provision = ""; Log.TraceLog("Provision not specified or not found for " + ((ProjectFile != null) ? ProjectFile.GetFileNameWithoutAnyExtensions() : "UE4Game") + ", searching for compatible match..."); Process IPPProcess = new Process(); if (BuildHostPlatform.Current.Platform == UnrealTargetPlatform.Mac) { string IPPCmd = "\"" + UnrealBuildTool.EngineDirectory + "/Binaries/DotNET/IOS/IPhonePackager.exe\" signing_match " + ((ProjectFile != null) ? ("\"" + ProjectFile.ToString() + "\"") : "Engine") + " -bundlename " + BundleId + (bIsTVOS ? " -tvos" : "") + (bForDistribtion ? " -distribution" : ""); IPPProcess.StartInfo.WorkingDirectory = UnrealBuildTool.EngineDirectory.ToString(); IPPProcess.StartInfo.FileName = UnrealBuildTool.EngineDirectory + "/Build/BatchFiles/Mac/RunMono.sh"; IPPProcess.StartInfo.Arguments = IPPCmd; IPPProcess.OutputDataReceived += new DataReceivedEventHandler(IPPDataReceivedHandler); IPPProcess.ErrorDataReceived += new DataReceivedEventHandler(IPPDataReceivedHandler); } else { string IPPCmd = "signing_match " + ((ProjectFile != null) ? ("\"" + ProjectFile.ToString() + "\"") : "Engine") + " -bundlename " + BundleId + (bIsTVOS ? " -tvos" : "") + (bForDistribtion ? " -distribution" : ""); IPPProcess.StartInfo.WorkingDirectory = UnrealBuildTool.EngineDirectory.ToString(); IPPProcess.StartInfo.FileName = UnrealBuildTool.EngineDirectory + "\\Binaries\\DotNET\\IOS\\IPhonePackager.exe"; IPPProcess.StartInfo.Arguments = IPPCmd; IPPProcess.OutputDataReceived += new DataReceivedEventHandler(IPPDataReceivedHandler); IPPProcess.ErrorDataReceived += new DataReceivedEventHandler(IPPDataReceivedHandler); } Utils.RunLocalProcess(IPPProcess); Log.TraceLog("Provision found for " + ((ProjectFile != null) ? ProjectFile.GetFileNameWithoutAnyExtensions() : "UE4Game") + ", Provision: " + Provision + " Certificate: " + Certificate); } // add to the dictionary Data.MobileProvision = Provision; Data.Certificate = Certificate.Replace("\"", ""); // read the provision to get the UUID string filename = (BuildHostPlatform.Current.Platform == UnrealTargetPlatform.Mac ? (Environment.GetEnvironmentVariable("HOME") + "/Library/MobileDevice/Provisioning Profiles/") : (Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "/Apple Computer/MobileDevice/Provisioning Profiles/")) + Data.MobileProvision; if (File.Exists(filename)) { string AllText = File.ReadAllText(filename); int idx = AllText.IndexOf("<key>UUID</key>"); if (idx > 0) { idx = AllText.IndexOf("<string>", idx); if (idx > 0) { idx += "<string>".Length; Data.UUID = AllText.Substring(idx, AllText.IndexOf("</string>", idx) - idx); } } idx = AllText.IndexOf("<key>com.apple.developer.team-identifier</key>"); if (idx > 0) { idx = AllText.IndexOf("<string>", idx); if (idx > 0) { idx += "<string>".Length; Data.TeamUUID = AllText.Substring(idx, AllText.IndexOf("</string>", idx) - idx); } } } else { Log.TraceLog("No matching provision file was discovered. Please ensure you have a compatible provision installed."); } ProvisionCache.Add(BundleId + " " + bIsTVOS.ToString() + " " + bForDistribtion.ToString(), Data); } else { Data = ProvisionCache[BundleId + " " + bIsTVOS.ToString() + " " + bForDistribtion.ToString()]; } MobileProvision = Data.MobileProvision; SigningCertificate = Data.Certificate; MobileProvisionUUID = Data.UUID; TeamUUID = Data.TeamUUID; }
/// <summary> /// Gets the location of the hot-reload state file for a particular target /// </summary> /// <param name="ProjectFile">Project containing the target</param> /// <param name="TargetName">Name of the target</param> /// <param name="Platform">Platform being built</param> /// <param name="Configuration">Configuration being built</param> /// <param name="Architecture">Architecture being built</param> /// <returns>Location of the hot reload state file</returns> public static FileReference GetLocation(FileReference ProjectFile, string TargetName, UnrealTargetPlatform Platform, UnrealTargetConfiguration Configuration, string Architecture) { DirectoryReference BaseDir = DirectoryReference.FromFile(ProjectFile) ?? UnrealBuildTool.EngineDirectory; return(FileReference.Combine(BaseDir, UEBuildTarget.GetPlatformIntermediateFolder(Platform, Architecture), TargetName, Configuration.ToString(), "HotReload.state")); }
private ConfigHierarchy GetConfigCacheIni(ConfigHierarchyType Type) { // @todo Lumin: So - this is the problem with subclassing a platform currently - ini files. Lumin will use Android ini files // until I finish and get code over from another branch (key letter Q) that allows for insertion of a subclassed ini platform thing return(ConfigCache.ReadHierarchy(Type, DirectoryReference.FromFile(ProjectFile), UnrealTargetPlatform.Android)); }
/// <summary> /// Checks if the editor is currently running and this is a hot-reload /// </summary> public static bool ShouldDoHotReloadFromIDE(BuildConfiguration BuildConfiguration, TargetDescriptor TargetDesc) { // Check if Hot-reload is disabled globally for this project ConfigHierarchy Hierarchy = ConfigCache.ReadHierarchy(ConfigHierarchyType.Engine, DirectoryReference.FromFile(TargetDesc.ProjectFile), TargetDesc.Platform); bool bAllowHotReloadFromIDE; if (Hierarchy.TryGetValue("BuildConfiguration", "bAllowHotReloadFromIDE", out bAllowHotReloadFromIDE) && !bAllowHotReloadFromIDE) { return(false); } if (!BuildConfiguration.bAllowHotReloadFromIDE) { return(false); } // Check if we're using LiveCode instead ConfigHierarchy EditorPerProjectHierarchy = ConfigCache.ReadHierarchy(ConfigHierarchyType.EditorPerProjectUserSettings, DirectoryReference.FromFile(TargetDesc.ProjectFile), TargetDesc.Platform); bool bEnableLiveCode; if (EditorPerProjectHierarchy.GetBool("/Script/LiveCoding.LiveCodingSettings", "bEnabled", out bEnableLiveCode) && bEnableLiveCode) { return(false); } bool bIsRunning = false; // @todo ubtmake: Kind of cheating here to figure out if an editor target. At this point we don't have access to the actual target description, and // this code must be able to execute before we create or load module rules DLLs so that hot reload can work with bUseUBTMakefiles if (TargetDesc.Name.EndsWith("Editor", StringComparison.OrdinalIgnoreCase)) { string EditorBaseFileName = "UE4Editor"; if (TargetDesc.Configuration != UnrealTargetConfiguration.Development) { EditorBaseFileName = String.Format("{0}-{1}-{2}", EditorBaseFileName, TargetDesc.Platform, TargetDesc.Configuration); } FileReference EditorLocation; if (TargetDesc.Platform == UnrealTargetPlatform.Win64) { EditorLocation = FileReference.Combine(UnrealBuildTool.EngineDirectory, "Binaries", "Win64", String.Format("{0}.exe", EditorBaseFileName)); } else if (TargetDesc.Platform == UnrealTargetPlatform.Mac) { EditorLocation = FileReference.Combine(UnrealBuildTool.EngineDirectory, "Binaries", "Mac", String.Format("{0}.app/Contents/MacOS/{0}", EditorBaseFileName)); } else if (TargetDesc.Platform == UnrealTargetPlatform.Linux) { EditorLocation = FileReference.Combine(UnrealBuildTool.EngineDirectory, "Binaries", "Linux", EditorBaseFileName); } else { throw new BuildException("Unknown editor filename for this platform"); } using (Timeline.ScopeEvent("Finding editor processes for hot-reload")) { DirectoryReference EditorRunsDir = DirectoryReference.Combine(UnrealBuildTool.EngineDirectory, "Intermediate", "EditorRuns"); if (!DirectoryReference.Exists(EditorRunsDir)) { return(false); } if (BuildHostPlatform.Current.Platform == UnrealTargetPlatform.Win64) { foreach (FileReference EditorInstanceFile in DirectoryReference.EnumerateFiles(EditorRunsDir)) { int ProcessId; if (!Int32.TryParse(EditorInstanceFile.GetFileName(), out ProcessId)) { FileReference.Delete(EditorInstanceFile); continue; } Process RunningProcess; try { RunningProcess = Process.GetProcessById(ProcessId); } catch { RunningProcess = null; } if (RunningProcess == null) { FileReference.Delete(EditorInstanceFile); continue; } FileReference MainModuleFile; try { MainModuleFile = new FileReference(RunningProcess.MainModule.FileName); } catch { MainModuleFile = null; } if (!bIsRunning && EditorLocation == MainModuleFile) { bIsRunning = true; } } } else { FileInfo[] EditorRunsFiles = new DirectoryInfo(EditorRunsDir.FullName).GetFiles(); BuildHostPlatform.ProcessInfo[] Processes = BuildHostPlatform.Current.GetProcesses(); foreach (FileInfo File in EditorRunsFiles) { int PID; BuildHostPlatform.ProcessInfo Proc = null; if (!Int32.TryParse(File.Name, out PID) || (Proc = Processes.FirstOrDefault(P => P.PID == PID)) == default(BuildHostPlatform.ProcessInfo)) { // Delete stale files (it may happen if editor crashes). File.Delete(); continue; } // Don't break here to allow clean-up of other stale files. if (!bIsRunning) { // Otherwise check if the path matches. bIsRunning = new FileReference(Proc.Filename) == EditorLocation; } } } } } return(bIsRunning); }
public HTML5ToolChain(FileReference InProjectFile) { if (!HTML5SDKInfo.IsSDKInstalled()) { throw new BuildException("HTML5 SDK is not installed; cannot use toolchain."); } // ini configs // - normal ConfigCache w/ UnrealBuildTool.ProjectFile takes all game config ini files // (including project config ini files) // - but, during packaging, if -remoteini is used -- need to use UnrealBuildTool.GetRemoteIniPath() // (note: ConfigCache can take null ProjectFile) string EngineIniPath = UnrealBuildTool.GetRemoteIniPath(); DirectoryReference ProjectDir = !String.IsNullOrEmpty(EngineIniPath) ? new DirectoryReference(EngineIniPath) : DirectoryReference.FromFile(InProjectFile); ConfigHierarchy Ini = ConfigCache.ReadHierarchy(ConfigHierarchyType.Engine, ProjectDir, UnrealTargetPlatform.HTML5); // Ini.GetBool("/Script/HTML5PlatformEditor.HTML5TargetSettings", "EnableSIMD", out enableSIMD); Ini.GetBool("/Script/HTML5PlatformEditor.HTML5TargetSettings", "EnableMultithreading", out enableMultithreading); Ini.GetBool("/Script/HTML5PlatformEditor.HTML5TargetSettings", "OffscreenCanvas", out bMultithreading_UseOffscreenCanvas); Ini.GetBool("/Script/HTML5PlatformEditor.HTML5TargetSettings", "LLVMWasmBackend", out useLLVMwasmBackend); Ini.GetBool("/Script/HTML5PlatformEditor.HTML5TargetSettings", "EnableTracing", out bEnableTracing); if (useLLVMwasmBackend) { libExt = ".a"; // experimental - LLVMWasmBackend } // TODO: remove this "fix" when emscripten supports WASM with SIMD enableSIMD = false; Log.TraceInformation("HTML5ToolChain: EnableSIMD = " + enableSIMD); Log.TraceInformation("HTML5ToolChain: EnableMultithreading " + enableMultithreading); Log.TraceInformation("HTML5ToolChain: OffscreenCanvas " + bMultithreading_UseOffscreenCanvas); Log.TraceInformation("HTML5ToolChain: LLVMWasmBackend " + useLLVMwasmBackend); Log.TraceInformation("HTML5ToolChain: EnableTracing = " + bEnableTracing); PrintOnce = new VerbosePrint(PrintOnceOn); // reset Log.TraceInformation("Setting Emscripten SDK: located in " + HTML5SDKInfo.EMSCRIPTEN_ROOT); string TempDir = HTML5SDKInfo.SetupEmscriptenTemp(); HTML5SDKInfo.SetUpEmscriptenConfigFile(); if (Environment.GetEnvironmentVariable("EMSDK") == null) // If EMSDK is present, Emscripten is already configured by the developer { // If not using preset emsdk, configure our generated .emscripten config, instead of autogenerating one in the user's home directory. Environment.SetEnvironmentVariable("EM_CONFIG", HTML5SDKInfo.DOT_EMSCRIPTEN); Environment.SetEnvironmentVariable("EM_CACHE", HTML5SDKInfo.EMSCRIPTEN_CACHE); Environment.SetEnvironmentVariable("EMCC_TEMP_DIR", TempDir); } Log.TraceInformation("*** Emscripten Config File: " + Environment.GetEnvironmentVariable("EM_CONFIG")); }
public bool UseMobileRendering() { // @todo Lumin: Switch to Lumin once we have sub-platform ini ConfigHierarchy Ini = ConfigCache.ReadHierarchy(ConfigHierarchyType.Engine, DirectoryReference.FromFile(ProjectFile), UnrealTargetPlatform.Android); // go by string bool bUseMobileRendering = true; Ini.GetBool("/Script/LuminRuntimeSettings.LuminRuntimeSettings", "bUseMobileRendering", out bUseMobileRendering); return(bUseMobileRendering); }
/// <summary> /// Gets the location of the makefile for particular target /// </summary> /// <param name="ProjectFile">Project file for the build</param> /// <param name="TargetName">Name of the target being built</param> /// <param name="Platform">The platform that the target is being built for</param> /// <param name="Configuration">The configuration being built</param> /// <returns>Path to the makefile</returns> public static FileReference GetLocation(FileReference ProjectFile, string TargetName, UnrealTargetPlatform Platform, UnrealTargetConfiguration Configuration) { DirectoryReference BaseDirectory = DirectoryReference.FromFile(ProjectFile) ?? UnrealBuildTool.EngineDirectory; return(FileReference.Combine(BaseDirectory, "Intermediate", "Build", Platform.ToString(), TargetName, Configuration.ToString(), "Makefile.bin")); }
public WindowsPlatformContext(UnrealTargetPlatform InPlatform, FileReference InProjectFile) : base(InPlatform, InProjectFile) { if (Platform == UnrealTargetPlatform.Win32) { // ...check if it was supported from a config. ConfigCacheIni Ini = ConfigCacheIni.CreateConfigCacheIni(UnrealTargetPlatform.Win64, "Engine", DirectoryReference.FromFile(ProjectFile)); string MinimumOS; if (Ini.GetString("/Script/WindowsTargetPlatform.WindowsTargetSettings", "MinimumOSVersion", out MinimumOS)) { if (string.IsNullOrEmpty(MinimumOS) == false) { SupportWindowsXP = MinimumOS == "MSOS_XP"; } } } }
private ConfigHierarchy GetConfigCacheIni(ConfigHierarchyType Type) { return(ConfigCache.ReadHierarchy(Type, DirectoryReference.FromFile(ProjectFile), UnrealTargetPlatform.Lumin)); }
public override void ValidateTarget(TargetRules Target) { // WindowsTargetRules are reused for HoloLens, so that build modules can keep the model that reuses "windows" configs for most cases // That means overriding those settings here that need to be adjusted for HoloLens // Compiler version and pix flags must be reloaded from the HoloLens hive // Currently BP-only projects don't load build-related settings from their remote ini when building UE4Game.exe // (see TargetRules.cs, where the possibly-null project directory is passed to ConfigCache.ReadSettings). // It's important for HoloLens that we *do* use the project-specific settings when building (VS 2017 vs 2015 and // retail Windows Store are both examples). Possibly this should be done on all platforms? But in the interest // of not changing behavior on other platforms I'm limiting the scope. DirectoryReference IniDirRef = DirectoryReference.FromFile(Target.ProjectFile); if (IniDirRef == null && !string.IsNullOrEmpty(UnrealBuildTool.GetRemoteIniPath())) { IniDirRef = new DirectoryReference(UnrealBuildTool.GetRemoteIniPath()); } // Stash the current compiler choice (accounts for command line) in case ReadSettings reverts it to default WindowsCompiler CompilerBeforeReadSettings = Target.HoloLensPlatform.Compiler; ConfigCache.ReadSettings(IniDirRef, Platform, Target.HoloLensPlatform); if (Target.HoloLensPlatform.Compiler == WindowsCompiler.Default) { if (CompilerBeforeReadSettings != WindowsCompiler.Default) { // Previous setting was more specific, use that Target.HoloLensPlatform.Compiler = CompilerBeforeReadSettings; } else { Target.HoloLensPlatform.Compiler = WindowsPlatform.GetDefaultCompiler(Target.ProjectFile); } } if (!Target.bGenerateProjectFiles) { Log.TraceInformationOnce("Using {0} architecture for deploying to HoloLens device", Target.HoloLensPlatform.Architecture); } Target.WindowsPlatform.Compiler = Target.HoloLensPlatform.Compiler; Target.WindowsPlatform.Architecture = Target.HoloLensPlatform.Architecture; Target.WindowsPlatform.bPixProfilingEnabled = Target.HoloLensPlatform.bPixProfilingEnabled; Target.WindowsPlatform.bUseWindowsSDK10 = true; Target.bDeployAfterCompile = true; Target.bCompileNvCloth = false; // requires CUDA // Disable Simplygon support if compiling against the NULL RHI. if (Target.GlobalDefinitions.Contains("USE_NULL_RHI=1")) { Target.bCompileSpeedTree = false; } // Use shipping binaries to avoid dependency on nvToolsExt which fails WACK. if (Target.Configuration == UnrealTargetConfiguration.Shipping) { Target.bUseShippingPhysXLibraries = true; } // Be resilient to SDKs being uninstalled but still referenced in the INI file VersionNumber SelectedWindowsSdkVersion; DirectoryReference SelectedWindowsSdkDir; if (!WindowsPlatform.TryGetWindowsSdkDir(Target.HoloLensPlatform.Win10SDKVersionString, out SelectedWindowsSdkVersion, out SelectedWindowsSdkDir)) { Target.HoloLensPlatform.Win10SDKVersionString = "Latest"; } // Initialize the VC environment for the target, and set all the version numbers to the concrete values we chose. VCEnvironment Environment = VCEnvironment.Create(Target.WindowsPlatform.Compiler, Platform, Target.WindowsPlatform.Architecture, Target.WindowsPlatform.CompilerVersion, Target.HoloLensPlatform.Win10SDKVersionString, null); Target.WindowsPlatform.Environment = Environment; Target.WindowsPlatform.Compiler = Environment.Compiler; Target.WindowsPlatform.CompilerVersion = Environment.CompilerVersion.ToString(); Target.WindowsPlatform.WindowsSdkVersion = Environment.WindowsSdkVersion.ToString(); // Windows 10 SDK version // Auto-detect latest compatible by default (recommended), allow for explicit override if necessary // Validate that the SDK isn't too old, and that the combination of VS and SDK is supported. Target.HoloLensPlatform.Win10SDKVersion = new Version(Environment.WindowsSdkVersion.ToString()); if (!Target.bGenerateProjectFiles) { Log.TraceInformationOnce("Building using Windows SDK version {0} for HoloLens", Target.HoloLensPlatform.Win10SDKVersion); if (Target.HoloLensPlatform.Win10SDKVersion < MinimumSDKVersionRecommended) { Log.TraceWarning("Your Windows SDK version {0} is older than the minimum recommended version ({1}) for HoloLens. Consider upgrading.", Target.HoloLensPlatform.Win10SDKVersion, MinimumSDKVersionRecommended); } else if (Target.HoloLensPlatform.Win10SDKVersion > MaximumSDKVersionTested) { Log.TraceInformationOnce("Your Windows SDK version ({0}) for HoloLens is newer than the highest tested with this version of UBT ({1}). This is probably fine, but if you encounter issues consider using an earlier SDK.", Target.HoloLensPlatform.Win10SDKVersion, MaximumSDKVersionTested); } } HoloLensExports.InitWindowsSdkToolPath(Target.HoloLensPlatform.Win10SDKVersion.ToString()); }
/// <summary> /// Setup the target environment for building /// </summary> /// <param name="InBuildTarget"> The target being built</param> public override void SetUpEnvironment(UEBuildTarget InBuildTarget) { InBuildTarget.GlobalCompileEnvironment.Config.Definitions.Add("PLATFORM_IOS=1"); InBuildTarget.GlobalCompileEnvironment.Config.Definitions.Add("PLATFORM_APPLE=1"); InBuildTarget.GlobalCompileEnvironment.Config.Definitions.Add("WITH_TTS=0"); InBuildTarget.GlobalCompileEnvironment.Config.Definitions.Add("WITH_SPEECH_RECOGNITION=0"); InBuildTarget.GlobalCompileEnvironment.Config.Definitions.Add("WITH_DATABASE_SUPPORT=0"); InBuildTarget.GlobalCompileEnvironment.Config.Definitions.Add("WITH_EDITOR=0"); InBuildTarget.GlobalCompileEnvironment.Config.Definitions.Add("USE_NULL_RHI=0"); InBuildTarget.GlobalCompileEnvironment.Config.Definitions.Add("REQUIRES_ALIGNED_INT_ACCESS"); ConfigCacheIni Ini = ConfigCacheIni.CreateConfigCacheIni(UnrealTargetPlatform.IOS, "Engine", DirectoryReference.FromFile(ProjectFile)); Ini.GetBool("/Script/IOSRuntimeSettings.IOSRuntimeSettings", "bEnableRemoteNotificationsSupport", out bNotificationsEnabled); if (bNotificationsEnabled) { InBuildTarget.GlobalCompileEnvironment.Config.Definitions.Add("NOTIFICATIONS_ENABLED"); } if (GetActiveArchitecture() == "-simulator") { InBuildTarget.GlobalCompileEnvironment.Config.Definitions.Add("WITH_SIMULATOR=1"); } // we assume now we are building with IOS8 or later if (UEBuildConfiguration.bCompileAgainstEngine) { InBuildTarget.GlobalCompileEnvironment.Config.Definitions.Add("HAS_METAL=1"); InBuildTarget.ExtraModuleNames.Add("MetalRHI"); } else { InBuildTarget.GlobalCompileEnvironment.Config.Definitions.Add("HAS_METAL=0"); } InBuildTarget.GlobalLinkEnvironment.Config.AdditionalFrameworks.Add(new UEBuildFramework("GameKit")); InBuildTarget.GlobalLinkEnvironment.Config.AdditionalFrameworks.Add(new UEBuildFramework("StoreKit")); }
public HTML5ToolChain(FileReference InProjectFile) : base(CppPlatform.HTML5) { if (!HTML5SDKInfo.IsSDKInstalled()) { throw new BuildException("HTML5 SDK is not installed; cannot use toolchain."); } // ini configs // - normal ConfigCache w/ UnrealBuildTool.ProjectFile takes all game config ini files // (including project config ini files) // - but, during packaging, if -remoteini is used -- need to use UnrealBuildTool.GetRemoteIniPath() // (note: ConfigCache can take null ProjectFile) string EngineIniPath = UnrealBuildTool.GetRemoteIniPath(); DirectoryReference ProjectDir = !String.IsNullOrEmpty(EngineIniPath) ? new DirectoryReference(EngineIniPath) : DirectoryReference.FromFile(InProjectFile); ConfigHierarchy Ini = ConfigCache.ReadHierarchy(ConfigHierarchyType.Engine, ProjectDir, UnrealTargetPlatform.HTML5); // Ini.GetBool("/Script/HTML5PlatformEditor.HTML5TargetSettings", "EnableSIMD", out enableSIMD); // Ini.GetBool("/Script/HTML5PlatformEditor.HTML5TargetSettings", "EnableMultithreading", out enableMultithreading); Ini.GetBool("/Script/HTML5PlatformEditor.HTML5TargetSettings", "EnableTracing", out bEnableTracing); // TODO: remove this "fix" when emscripten supports (SIMD & pthreads) + WASM enableSIMD = false; // TODO: double check Engine/Source/Runtime/Core/Private/HTML5/HTML5PlatformProcess.cpp::SupportsMultithreading() enableMultithreading = false; Log.TraceInformation("HTML5ToolChain: EnableSIMD = " + enableSIMD); Log.TraceInformation("HTML5ToolChain: EnableMultithreading " + enableMultithreading); Log.TraceInformation("HTML5ToolChain: EnableTracing = " + bEnableTracing); PrintOnce = new VerbosePrint(PrintOnceOn); // reset }
private bool SetupGraphicsDebugger(ReadOnlyTargetRules Target, CppCompileEnvironment CompileEnvironment, LinkEnvironment LinkEnvironment) { string AndroidGraphicsDebugger; ConfigHierarchy Ini = ConfigCache.ReadHierarchy(ConfigHierarchyType.Engine, DirectoryReference.FromFile(Target.ProjectFile), UnrealTargetPlatform.Android); Ini.GetString("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "AndroidGraphicsDebugger", out AndroidGraphicsDebugger); if (AndroidGraphicsDebugger.ToLower() == "renderdoc") { string RenderDocPath; AndroidPlatformSDK.GetPath(Ini, "/Script/AndroidRuntimeSettings.AndroidRuntimeSettings", "RenderDocPath", out RenderDocPath); string RenderDocLibPath = Path.Combine(RenderDocPath, @"android\lib\armeabi-v7a"); if (Directory.Exists(RenderDocLibPath)) { LinkEnvironment.LibraryPaths.Add(RenderDocLibPath); LinkEnvironment.AdditionalLibraries.Add("VkLayer_RenderDoc"); return(true); } } return(false); }
static bool bEnableTracing = false; // Debug option public HTML5ToolChain(FileReference InProjectFile) : base(CppPlatform.HTML5, WindowsCompiler.VisualStudio2015) { if (!HTML5SDKInfo.IsSDKInstalled()) { throw new BuildException("HTML5 SDK is not installed; cannot use toolchain."); } // ini configs // - normal ConfigCache w/ UnrealBuildTool.ProjectFile takes all game config ini files // (including project config ini files) // - but, during packaging, if -remoteini is used -- need to use UnrealBuildTool.GetRemoteIniPath() // (note: ConfigCache can take null ProjectFile) string EngineIniPath = UnrealBuildTool.GetRemoteIniPath(); DirectoryReference ProjectDir = !String.IsNullOrEmpty(EngineIniPath) ? new DirectoryReference(EngineIniPath) : DirectoryReference.FromFile(InProjectFile); ConfigHierarchy Ini = ConfigCache.ReadHierarchy(ConfigHierarchyType.Engine, ProjectDir, UnrealTargetPlatform.HTML5); // these will be going away... bool targetingAsmjs = false; // inverted check bool targetWebGL1 = false; // inverted check if (Ini.GetBool("/Script/HTML5PlatformEditor.HTML5TargetSettings", "TargetAsmjs", out targetingAsmjs)) { targetingWasm = !targetingAsmjs; } if (Ini.GetBool("/Script/HTML5PlatformEditor.HTML5TargetSettings", "TargetWebGL1", out targetWebGL1)) { targetWebGL2 = !targetWebGL1; } Ini.GetBool("/Script/HTML5PlatformEditor.HTML5TargetSettings", "EnableSIMD", out enableSIMD); Ini.GetBool("/Script/HTML5PlatformEditor.HTML5TargetSettings", "EnableMultithreading", out enableMultithreading); Ini.GetBool("/Script/HTML5PlatformEditor.HTML5TargetSettings", "EnableTracing", out bEnableTracing); Log.TraceInformation("HTML5ToolChain: TargetWasm = " + targetingWasm); Log.TraceInformation("HTML5ToolChain: TargetWebGL2 = " + targetWebGL2); Log.TraceInformation("HTML5ToolChain: EnableSIMD = " + enableSIMD); Log.TraceInformation("HTML5ToolChain: EnableMultithreading " + enableMultithreading); Log.TraceInformation("HTML5ToolChain: EnableTracing = " + bEnableTracing); // TODO: remove this "fix" when emscripten supports (SIMD & pthreads) + WASM if (targetingWasm) { enableSIMD = false; // TODO: double check Engine/Source/Runtime/Core/Private/HTML5/HTML5PlatformProcess.cpp::SupportsMultithreading() enableMultithreading = false; } }