/// <summary> /// Read a receipt from disk. /// </summary> /// <param name="Location">Filename to read from</param> public static TargetReceipt Read(FileReference Location) { return(Read(Location, UnrealBuildTool.EngineDirectory)); }
/// <summary> /// Try to read a receipt from disk, failing gracefully if it can't be read. /// </summary> /// <param name="Location">Filename to read from</param> /// <param name="Receipt">If successful, the receipt that was read</param> /// <returns>True if successful</returns> public static bool TryRead(FileReference Location, out TargetReceipt Receipt) { return(TryRead(Location, UnrealBuildTool.EngineDirectory, out Receipt)); }
public override FileItem LinkFiles(LinkEnvironment LinkEnvironment, bool bBuildImportLibraryOnly) { if (LinkEnvironment.Config.bIsBuildingDotNetAssembly) { return(FileItem.GetItemByFileReference(LinkEnvironment.Config.OutputFilePath)); } bool bIsBuildingLibrary = LinkEnvironment.Config.bIsBuildingLibrary || bBuildImportLibraryOnly; bool bIncludeDependentLibrariesInLibrary = bIsBuildingLibrary && LinkEnvironment.Config.bIncludeDependentLibrariesInLibrary; // Create an action that invokes the linker. Action LinkAction = new Action(ActionType.Link); LinkAction.WorkingDirectory = UnrealBuildTool.EngineSourceDirectory.FullName; LinkAction.CommandPath = GetVCToolPath( LinkEnvironment.Config.Target.Platform, LinkEnvironment.Config.Target.Configuration, bIsBuildingLibrary ? "lib" : "link"); // Get link arguments. LinkAction.CommandArguments = bIsBuildingLibrary ? GetLibArguments(LinkEnvironment) : GetLinkArguments(LinkEnvironment); // Tell the action that we're building an import library here and it should conditionally be // ignored as a prerequisite for other actions LinkAction.bProducesImportLibrary = bBuildImportLibraryOnly || LinkEnvironment.Config.bIsBuildingDLL; // If we're only building an import library, add the '/DEF' option that tells the LIB utility // to simply create a .LIB file and .EXP file, and don't bother validating imports if (bBuildImportLibraryOnly) { LinkAction.CommandArguments += " /DEF"; // Ensure that the import library references the correct filename for the linked binary. LinkAction.CommandArguments += string.Format(" /NAME:\"{0}\"", LinkEnvironment.Config.OutputFilePath.GetFileName()); } if (!LinkEnvironment.Config.bIsBuildingLibrary || (LinkEnvironment.Config.bIsBuildingLibrary && bIncludeDependentLibrariesInLibrary)) { // Add the library paths to the argument list. foreach (string LibraryPath in LinkEnvironment.Config.LibraryPaths) { LinkAction.CommandArguments += string.Format(" /LIBPATH:\"{0}\"", LibraryPath); } // Add the excluded default libraries to the argument list. foreach (string ExcludedLibrary in LinkEnvironment.Config.ExcludedLibraries) { LinkAction.CommandArguments += string.Format(" /NODEFAULTLIB:\"{0}\"", ExcludedLibrary); } } // For targets that are cross-referenced, we don't want to write a LIB file during the link step as that // file will clobber the import library we went out of our way to generate during an earlier step. This // file is not needed for our builds, but there is no way to prevent MSVC from generating it when // linking targets that have exports. We don't want this to clobber our LIB file and invalidate the // existing timstamp, so instead we simply emit it with a different name FileReference ImportLibraryFilePath = FileReference.Combine(LinkEnvironment.Config.IntermediateDirectory, LinkEnvironment.Config.OutputFilePath.GetFileNameWithoutExtension() + ".lib"); if (LinkEnvironment.Config.bIsCrossReferenced && !bBuildImportLibraryOnly) { ImportLibraryFilePath += ".suppressed"; } FileItem OutputFile; if (bBuildImportLibraryOnly) { OutputFile = FileItem.GetItemByFileReference(ImportLibraryFilePath); } else { OutputFile = FileItem.GetItemByFileReference(LinkEnvironment.Config.OutputFilePath); OutputFile.bNeedsHotReloadNumbersDLLCleanUp = LinkEnvironment.Config.bIsBuildingDLL; } LinkAction.ProducedItems.Add(OutputFile); LinkAction.StatusDescription = Path.GetFileName(OutputFile.AbsolutePath); // Add the input files to a response file, and pass the response file on the command-line. List <string> InputFileNames = new List <string>(); foreach (FileItem InputFile in LinkEnvironment.InputFiles) { InputFileNames.Add(string.Format("\"{0}\"", InputFile.AbsolutePath)); LinkAction.PrerequisiteItems.Add(InputFile); } if (!bBuildImportLibraryOnly) { // Add input libraries as prerequisites, too! foreach (FileItem InputLibrary in LinkEnvironment.InputLibraries) { InputFileNames.Add(string.Format("\"{0}\"", InputLibrary.AbsolutePath)); LinkAction.PrerequisiteItems.Add(InputLibrary); } } if (!bIsBuildingLibrary || (LinkEnvironment.Config.bIsBuildingLibrary && bIncludeDependentLibrariesInLibrary)) { foreach (string AdditionalLibrary in LinkEnvironment.Config.AdditionalLibraries) { InputFileNames.Add(string.Format("\"{0}\"", AdditionalLibrary)); // If the library file name has a relative path attached (rather than relying on additional // lib directories), then we'll add it to our prerequisites list. This will allow UBT to detect // when the binary needs to be relinked because a dependent external library has changed. //if( !String.IsNullOrEmpty( Path.GetDirectoryName( AdditionalLibrary ) ) ) { LinkAction.PrerequisiteItems.Add(FileItem.GetItemByPath(AdditionalLibrary)); } } } // Create a response file for the linker FileReference ResponseFileName = GetResponseFileName(LinkEnvironment, OutputFile); // Never create response files when we are only generating IntelliSense data if (!ProjectFileGenerator.bGenerateProjectFiles) { ResponseFile.Create(ResponseFileName, InputFileNames); } LinkAction.CommandArguments += string.Format(" @\"{0}\"", ResponseFileName); // Add the output file to the command-line. LinkAction.CommandArguments += string.Format(" /OUT:\"{0}\"", OutputFile.AbsolutePath); if (bBuildImportLibraryOnly || (LinkEnvironment.Config.bHasExports && !bIsBuildingLibrary)) { // An export file is written to the output directory implicitly; add it to the produced items list. FileReference ExportFilePath = ImportLibraryFilePath.ChangeExtension(".exp"); FileItem ExportFile = FileItem.GetItemByFileReference(ExportFilePath); LinkAction.ProducedItems.Add(ExportFile); } if (!bIsBuildingLibrary) { // There is anything to export if (LinkEnvironment.Config.bHasExports // Shipping monolithic builds don't need exports && (!((LinkEnvironment.Config.Target.Configuration == CPPTargetConfiguration.Shipping) && (LinkEnvironment.bShouldCompileMonolithic != false)))) { // Write the import library to the output directory for nFringe support. FileItem ImportLibraryFile = FileItem.GetItemByFileReference(ImportLibraryFilePath); LinkAction.CommandArguments += string.Format(" /IMPLIB:\"{0}\"", ImportLibraryFilePath); LinkAction.ProducedItems.Add(ImportLibraryFile); } if (LinkEnvironment.Config.bCreateDebugInfo) { // Write the PDB file to the output directory. { FileReference PDBFilePath = FileReference.Combine(LinkEnvironment.Config.OutputDirectory, Path.GetFileNameWithoutExtension(OutputFile.AbsolutePath) + ".pdb"); FileItem PDBFile = FileItem.GetItemByFileReference(PDBFilePath); LinkAction.CommandArguments += string.Format(" /PDB:\"{0}\"", PDBFilePath); LinkAction.ProducedItems.Add(PDBFile); } // Write the MAP file to the output directory. #if false if (true) { FileReference MAPFilePath = FileReference.Combine(LinkEnvironment.Config.OutputDirectory, Path.GetFileNameWithoutExtension(OutputFile.AbsolutePath) + ".map"); FileItem MAPFile = FileItem.GetItemByFileReference(MAPFilePath); LinkAction.CommandArguments += string.Format(" /MAP:\"{0}\"", MAPFilePath); LinkAction.ProducedItems.Add(MAPFile); } #endif } // Add the additional arguments specified by the environment. LinkAction.CommandArguments += LinkEnvironment.Config.AdditionalArguments; } Log.TraceVerbose(" Linking: " + LinkAction.StatusDescription); Log.TraceVerbose(" Command: " + LinkAction.CommandArguments); // Only execute linking on the local PC. LinkAction.bCanExecuteRemotely = false; return(OutputFile); }
/// <summary> /// Copy constructor /// </summary> /// <param name="InOther">Runtime dependency to copy settings from</param> public RuntimeDependency(RuntimeDependency InOther) { Path = InOther.Path; Type = InOther.Type; }
protected IOSProvisioningData(IOSProjectSettings ProjectSettings, bool bIsTVOS, bool bForDistribtion) { SigningCertificate = ProjectSettings.SigningCertificate; MobileProvision = ProjectSettings.MobileProvision; FileReference ProjectFile = ProjectSettings.ProjectFile; 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 " + ProjectSettings.BundleIdentifier + (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 " + ProjectSettings.BundleIdentifier + (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 { SigningCertificate = 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 { SigningCertificate = ""; MobileProvision = ""; 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 " + ProjectSettings.BundleIdentifier + (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 " + ProjectSettings.BundleIdentifier + (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: " + MobileProvision + " Certificate: " + SigningCertificate); } // add to the dictionary SigningCertificate = SigningCertificate.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/")) + MobileProvision; if (File.Exists(filename)) { byte[] AllBytes = File.ReadAllBytes(filename); uint StartIndex = (uint)AllBytes.Length; uint EndIndex = (uint)AllBytes.Length; for (uint i = 0; i + 4 < AllBytes.Length; i++) { if (AllBytes[i] == '<' && AllBytes[i + 1] == '?' && AllBytes[i + 2] == 'x' && AllBytes[i + 3] == 'm' && AllBytes[i + 4] == 'l') { StartIndex = i; break; } } if (StartIndex < AllBytes.Length) { for (uint i = StartIndex; i + 7 < AllBytes.Length; i++) { if (AllBytes[i] == '<' && AllBytes[i + 1] == '/' && AllBytes[i + 2] == 'p' && AllBytes[i + 3] == 'l' && AllBytes[i + 4] == 'i' && AllBytes[i + 5] == 's' && AllBytes[i + 6] == 't' && AllBytes[i + 7] == '>') { EndIndex = i + 7; break; } } } if (StartIndex < AllBytes.Length && EndIndex < AllBytes.Length) { byte[] TextBytes = new byte[EndIndex - StartIndex]; Buffer.BlockCopy(AllBytes, (int)StartIndex, TextBytes, 0, (int)(EndIndex - StartIndex)); string AllText = Encoding.UTF8.GetString(TextBytes); int idx = AllText.IndexOf("<key>UUID</key>"); if (idx > 0) { idx = AllText.IndexOf("<string>", idx); if (idx > 0) { idx += "<string>".Length; MobileProvisionUUID = 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; TeamUUID = AllText.Substring(idx, AllText.IndexOf("</string>", idx) - idx); } } idx = AllText.IndexOf("<key>Name</key>"); if (idx > 0) { idx = AllText.IndexOf("<string>", idx); if (idx > 0) { idx += "<string>".Length; MobileProvisionName = AllText.Substring(idx, AllText.IndexOf("</string>", idx) - idx); } } } if (string.IsNullOrEmpty(MobileProvisionUUID) || string.IsNullOrEmpty(TeamUUID)) { MobileProvision = null; SigningCertificate = null; Log.TraceLog("Failed to parse the mobile provisioning profile."); } } else { Log.TraceLog("No matching provision file was discovered. Please ensure you have a compatible provision installed."); } }
protected virtual IOSProjectSettings CreateProjectSettings(FileReference ProjectFile) { return(new IOSProjectSettings(ProjectFile)); }
/// <summary> /// Get the default path to the build.version file on disk /// </summary> /// <returns>Path to the Build.version file</returns> public static FileReference GetDefaultFileName() { return(FileReference.Combine(UnrealBuildTool.EngineDirectory, "Build", "Build.version")); }
/// <summary> /// Constructor /// </summary> /// <param name="ProjectFile">The project file to read settings for</param> public IOSProjectSettings(FileReference ProjectFile) : this(ProjectFile, UnrealTargetPlatform.IOS) { }
/// <summary> /// Get the project folder for the given project name /// </summary> /// <param name="InProjectName">Name of the project of interest</param> /// <param name="OutProjectFileName">The project filename</param> /// <returns>True if the target was found</returns> public static bool TryGetProjectFileName(string InProjectName, out FileReference OutProjectFileName) { return(ShortProjectNameDictionary.TryGetValue(InProjectName, out OutProjectFileName)); }
/// <summary> /// Reads dependencies from the given file. /// </summary> /// <param name="InputFile">The file to read from</param> /// <returns>List of included dependencies</returns> static List <FileItem> ReadDependenciesFile(FileReference InputFile) { if (InputFile.HasExtension(".txt")) { string[] Lines = FileReference.ReadAllLines(InputFile); HashSet <FileItem> DependencyItems = new HashSet <FileItem>(); foreach (string Line in Lines) { if (Line.Length > 0) { // Ignore *.tlh and *.tli files generated by the compiler from COM DLLs if (!Line.EndsWith(".tlh", StringComparison.OrdinalIgnoreCase) && !Line.EndsWith(".tli", StringComparison.OrdinalIgnoreCase)) { DependencyItems.Add(FileItem.GetItemByPath(Line)); } } } return(DependencyItems.ToList()); } else if (InputFile.HasExtension(".d")) { string Text = FileReference.ReadAllText(InputFile); List <string> Tokens = new List <string>(); StringBuilder Token = new StringBuilder(); for (int Idx = 0; TryReadMakefileToken(Text, ref Idx, Token);) { Tokens.Add(Token.ToString()); } int TokenIdx = 0; while (TokenIdx < Tokens.Count && Tokens[TokenIdx] == "\n") { TokenIdx++; } if (TokenIdx + 1 >= Tokens.Count || Tokens[TokenIdx + 1] != ":") { throw new BuildException("Unable to parse dependency file"); } TokenIdx += 2; List <FileItem> NewDependencyFiles = new List <FileItem>(); for (; TokenIdx < Tokens.Count && Tokens[TokenIdx] != "\n"; TokenIdx++) { NewDependencyFiles.Add(FileItem.GetItemByPath(Tokens[TokenIdx])); } while (TokenIdx < Tokens.Count && Tokens[TokenIdx] == "\n") { TokenIdx++; } if (TokenIdx != Tokens.Count) { throw new BuildException("Unable to parse dependency file"); } return(NewDependencyFiles); } else { throw new BuildException("Unknown dependency list file type: {0}", InputFile); } }
/// <summary> /// Get the project folder for the given target name /// </summary> /// <param name="InTargetName">Name of the target of interest</param> /// <param name="OutProjectFileName">The project filename</param> /// <returns>True if the target was found</returns> public static bool TryGetProjectForTarget(string InTargetName, out FileReference OutProjectFileName) { return(TargetToProjectDictionary.TryGetValue(InTargetName, out OutProjectFileName)); }
/// <summary> /// Constructor /// </summary> /// <param name="InitFilePath">Path to the source file on disk</param> /// <param name="InitRelativeBaseFolder">The directory on this the path within the project will be relative to</param> public SourceFile(FileReference InReference, DirectoryReference InBaseFolder) { Reference = InReference; BaseFolder = InBaseFolder; }
/// <summary> /// Allocates a generator-specific source file object /// </summary> /// <param name="InitFilePath">Path to the source file on disk</param> /// <param name="InitProjectSubFolder">Optional sub-folder to put the file in. If empty, this will be determined automatically from the file's path relative to the project file</param> /// <returns>The newly allocated source file object</returns> public virtual SourceFile AllocSourceFile(FileReference InitFilePath, DirectoryReference InitProjectSubFolder = null) { return(new SourceFile(InitFilePath, InitProjectSubFolder)); }
/// <summary> /// Constructs a new project file object /// </summary> /// <param name="InitFilePath">The path to the project file, relative to the master project file</param> protected ProjectFile(FileReference InProjectFilePath) { ProjectFilePath = InProjectFilePath; ShouldBuildByDefaultForSolutionTargets = true; }
/// <summary> /// Read a receipt from disk. /// </summary> /// <param name="Location">Filename to read from</param> /// <param name="EngineDir">Engine directory for expanded variables</param> /// <param name="ProjectDir">Project directory for expanded variables</param> public static TargetReceipt Read(FileReference Location, DirectoryReference EngineDir, DirectoryReference ProjectDir) { JsonObject RawObject = JsonObject.Read(Location); // Read the initial fields string TargetName = RawObject.GetStringField("TargetName"); UnrealTargetPlatform Platform = RawObject.GetEnumField <UnrealTargetPlatform>("Platform"); UnrealTargetConfiguration Configuration = RawObject.GetEnumField <UnrealTargetConfiguration>("Configuration"); // Try to read the build version BuildVersion Version; if (!BuildVersion.TryParse(RawObject.GetObjectField("Version"), out Version)) { throw new JsonParseException("Invalid 'Version' field"); } // Create the receipt TargetReceipt Receipt = new TargetReceipt(TargetName, Platform, Configuration, Version); // Read the build products JsonObject[] BuildProductObjects; if (RawObject.TryGetObjectArrayField("BuildProducts", out BuildProductObjects)) { foreach (JsonObject BuildProductObject in BuildProductObjects) { string Path; BuildProductType Type; if (BuildProductObject.TryGetStringField("Path", out Path) && BuildProductObject.TryGetEnumField("Type", out Type)) { FileReference File = ExpandPathVariables(Path, EngineDir, ProjectDir); string Module; BuildProductObject.TryGetStringField("Module", out Module); Receipt.AddBuildProduct(File, Type); } } } // Read the runtime dependencies JsonObject[] RuntimeDependencyObjects; if (RawObject.TryGetObjectArrayField("RuntimeDependencies", out RuntimeDependencyObjects)) { foreach (JsonObject RuntimeDependencyObject in RuntimeDependencyObjects) { string Path; if (RuntimeDependencyObject.TryGetStringField("Path", out Path)) { FileReference File = ExpandPathVariables(Path, EngineDir, ProjectDir); StagedFileType Type; if (!RuntimeDependencyObject.TryGetEnumField("Type", out Type)) { // Previous format included an optional IgnoreIfMissing flag, which was only used for debug files. We can explicitly reference them as DebugNonUFS files now. bool bIgnoreIfMissing; if (RuntimeDependencyObject.TryGetBoolField("IgnoreIfMissing", out bIgnoreIfMissing)) { bIgnoreIfMissing = false; } Type = bIgnoreIfMissing? StagedFileType.DebugNonUFS : StagedFileType.NonUFS; } Receipt.RuntimeDependencies.Add(File, Type); } } } // Read the additional properties JsonObject[] AdditionalPropertyObjects; if (RawObject.TryGetObjectArrayField("AdditionalProperties", out AdditionalPropertyObjects)) { foreach (JsonObject AdditionalPropertyObject in AdditionalPropertyObjects) { string Name; if (AdditionalPropertyObject.TryGetStringField("Name", out Name)) { string Value; if (AdditionalPropertyObject.TryGetStringField("Value", out Value)) { Receipt.AdditionalProperties.Add(new ReceiptProperty(Name, Value)); } } } } return(Receipt); }
/// <summary> /// /// </summary> /// <param name="SourceFile"></param> /// <param name="TargetFile"></param> public static void StripSymbols(FileReference SourceFile, FileReference TargetFile) { LuminToolChain ToolChain = new LuminToolChain(null); ToolChain.StripSymbols(SourceFile, TargetFile); }
/// <summary> /// Constructor. /// </summary> /// <param name="InPath">Path to the build product</param> /// <param name="InType">Type of the build product</param> public BuildProduct(FileReference InPath, BuildProductType InType) { Path = InPath; Type = InType; }
/// <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> /// Copy constructor. /// </summary> /// <param name="Other">Build product to copy settings from</param> public BuildProduct(BuildProduct Other) { Path = Other.Path; Type = Other.Type; }
// The current architecture - affects everything about how UBT operates on IOS public override string GetDefaultArchitecture(FileReference ProjectFile) { return(IOSArchitecture); }
public TVOSProjectSettings(FileReference ProjectFile) : base(ProjectFile, UnrealTargetPlatform.TVOS) { }
public override CPPOutput CompileCPPFiles(UEBuildTarget Target, CPPEnvironment CompileEnvironment, List <FileItem> SourceFiles, string ModuleName) { string Arguments = GetCLArguments_Global(CompileEnvironment); // Add include paths to the argument list. foreach (string IncludePath in CompileEnvironment.Config.CPPIncludeInfo.IncludePaths) { Arguments += string.Format(" /I \"{0}\"", IncludePath); } foreach (string IncludePath in CompileEnvironment.Config.CPPIncludeInfo.SystemIncludePaths) { Arguments += string.Format(" /I \"{0}\"", IncludePath); } if ((CompileEnvironment.Config.CLRMode == CPPCLRMode.CLREnabled) || (WinRTPlatform.ShouldCompileWinRT() == true)) { // Add .NET framework assembly paths. This is needed so that C++/CLI projects // can reference assemblies with #using, without having to hard code a path in the // .cpp file to the assembly's location. foreach (string AssemblyPath in CompileEnvironment.Config.SystemDotNetAssemblyPaths) { Arguments += string.Format(" /AI \"{0}\"", AssemblyPath); } // Add explicit .NET framework assembly references foreach (string AssemblyName in CompileEnvironment.Config.FrameworkAssemblyDependencies) { Arguments += string.Format(" /FU \"{0}\"", AssemblyName); } // Add private assembly references foreach (PrivateAssemblyInfo CurAssemblyInfo in CompileEnvironment.PrivateAssemblyDependencies) { Arguments += string.Format(" /FU \"{0}\"", CurAssemblyInfo.FileItem.AbsolutePath); } } else { foreach (string AssemblyPath in CompileEnvironment.Config.SystemDotNetAssemblyPaths) { Arguments += string.Format(" /AI \"{0}\"", AssemblyPath); } // Add explicit .NET framework assembly references foreach (string AssemblyName in CompileEnvironment.Config.FrameworkAssemblyDependencies) { Arguments += string.Format(" /FU \"{0}\"", AssemblyName); } } // Add preprocessor definitions to the argument list. foreach (string Definition in CompileEnvironment.Config.Definitions) { Arguments += string.Format(" /D \"{0}\"", Definition); } // Log.TraceInformation("Compile Arguments for {0}:", ModuleName); // Log.TraceInformation(Arguments); var BuildPlatform = UEBuildPlatform.GetBuildPlatformForCPPTargetPlatform(CompileEnvironment.Config.Target.Platform); // Create a compile action for each source file. CPPOutput Result = new CPPOutput(); foreach (FileItem SourceFile in SourceFiles) { Action CompileAction = new Action(ActionType.Compile); string FileArguments = ""; bool bIsPlainCFile = Path.GetExtension(SourceFile.AbsolutePath).ToUpperInvariant() == ".C"; // Add the C++ source file and its included files to the prerequisite item list. AddPrerequisiteSourceFile(Target, BuildPlatform, CompileEnvironment, SourceFile, CompileAction.PrerequisiteItems); // If this is a CLR file then make sure our dependent assemblies are added as prerequisites if (CompileEnvironment.Config.CLRMode == CPPCLRMode.CLREnabled) { foreach (PrivateAssemblyInfo CurPrivateAssemblyDependency in CompileEnvironment.PrivateAssemblyDependencies) { CompileAction.PrerequisiteItems.Add(CurPrivateAssemblyDependency.FileItem); } } if (CompileEnvironment.Config.PrecompiledHeaderAction == PrecompiledHeaderAction.Create) { // Generate a CPP File that just includes the precompiled header. string PCHCPPFilename = "PCH." + CompileEnvironment.Config.PrecompiledHeaderIncludeFilename.GetFileName() + ".cpp"; FileReference PCHCPPPath = FileReference.Combine(CompileEnvironment.Config.OutputDirectory, PCHCPPFilename); FileItem PCHCPPFile = FileItem.CreateIntermediateTextFile( PCHCPPPath, string.Format("#include \"{0}\"\r\n", CompileEnvironment.Config.PrecompiledHeaderIncludeFilename) ); // Make sure the original source directory the PCH header file existed in is added as an include // path -- it might be a private PCH header and we need to make sure that its found! string OriginalPCHHeaderDirectory = Path.GetDirectoryName(SourceFile.AbsolutePath); FileArguments += string.Format(" /I \"{0}\"", OriginalPCHHeaderDirectory); var PCHExtension = UEBuildPlatform.GetBuildPlatform(UnrealTargetPlatform.WinRT).GetBinaryExtension(UEBuildBinaryType.PrecompiledHeader); // Add the precompiled header file to the produced items list. FileItem PrecompiledHeaderFile = FileItem.GetItemByFileReference( FileReference.Combine( CompileEnvironment.Config.OutputDirectory, Path.GetFileName(SourceFile.AbsolutePath) + PCHExtension ) ); CompileAction.ProducedItems.Add(PrecompiledHeaderFile); Result.PrecompiledHeaderFile = PrecompiledHeaderFile; // Add the parameters needed to compile the precompiled header file to the command-line. FileArguments += string.Format(" /Yc\"{0}\"", CompileEnvironment.Config.PrecompiledHeaderIncludeFilename); FileArguments += string.Format(" /Fp\"{0}\"", PrecompiledHeaderFile.AbsolutePath); FileArguments += string.Format(" \"{0}\"", PCHCPPFile.AbsolutePath); // If we're creating a PCH that will be used to compile source files for a library, we need // the compiled modules to retain a reference to PCH's module, so that debugging information // will be included in the library. This is also required to avoid linker warning "LNK4206" // when linking an application that uses this library. if (CompileEnvironment.Config.bIsBuildingLibrary) { // NOTE: The symbol name we use here is arbitrary, and all that matters is that it is // unique per PCH module used in our library string FakeUniquePCHSymbolName = CompileEnvironment.Config.PrecompiledHeaderIncludeFilename.GetFileNameWithoutExtension(); FileArguments += string.Format(" /Yl{0}", FakeUniquePCHSymbolName); } CompileAction.StatusDescription = PCHCPPFilename; } else { if (CompileEnvironment.Config.PrecompiledHeaderAction == PrecompiledHeaderAction.Include) { CompileAction.bIsUsingPCH = true; CompileAction.PrerequisiteItems.Add(CompileEnvironment.PrecompiledHeaderFile); FileArguments += string.Format(" /Yu\"{0}\"", CompileEnvironment.Config.PCHHeaderNameInCode); FileArguments += string.Format(" /Fp\"{0}\"", CompileEnvironment.PrecompiledHeaderFile.AbsolutePath); // Is it unsafe to always force inclusion? Clang is doing it, and .generated.cpp files // won't work otherwise, because they're not located in the context of the module, // so they can't access the module's PCH without an absolute path. //if (CompileEnvironment.Config.bForceIncludePrecompiledHeader) { // Force include the precompiled header file. This is needed because we may have selected a // precompiled header that is different than the first direct include in the C++ source file, but // we still need to make sure that our precompiled header is the first thing included! FileArguments += string.Format(" /FI\"{0}\"", CompileEnvironment.Config.PCHHeaderNameInCode); } } // Add the source file path to the command-line. FileArguments += string.Format(" \"{0}\"", SourceFile.AbsolutePath); CompileAction.StatusDescription = Path.GetFileName(SourceFile.AbsolutePath); } var ObjectFileExtension = UEBuildPlatform.GetBuildPlatform(UnrealTargetPlatform.WinRT).GetBinaryExtension(UEBuildBinaryType.Object); // Add the object file to the produced item list. FileItem ObjectFile = FileItem.GetItemByFileReference( FileReference.Combine( CompileEnvironment.Config.OutputDirectory, Path.GetFileName(SourceFile.AbsolutePath) + ObjectFileExtension ) ); CompileAction.ProducedItems.Add(ObjectFile); Result.ObjectFiles.Add(ObjectFile); FileArguments += string.Format(" /Fo\"{0}\"", ObjectFile.AbsolutePath); // create PDBs per-file when not using debug info, otherwise it will try to share a PDB file, which causes // PCH creation to be serial rather than parallel (when debug info is disabled) // See https://udn.epicgames.com/lists/showpost.php?id=50619&list=unprog3 if (!CompileEnvironment.Config.bCreateDebugInfo || BuildConfiguration.bUsePDBFiles) { string PDBFileName; bool bActionProducesPDB = false; // All files using the same PCH are required to share a PDB. if (CompileEnvironment.Config.PrecompiledHeaderAction == PrecompiledHeaderAction.Include) { PDBFileName = CompileEnvironment.Config.PrecompiledHeaderIncludeFilename.GetFileName(); } // Files creating a PCH or ungrouped C++ files use a PDB per file. else if (CompileEnvironment.Config.PrecompiledHeaderAction == PrecompiledHeaderAction.Create || !bIsPlainCFile) { PDBFileName = Path.GetFileName(SourceFile.AbsolutePath); bActionProducesPDB = true; } // Group all plain C files that doesn't use PCH into the same PDB else { PDBFileName = "MiscPlainC"; } // Specify the PDB file that the compiler should write to. FileItem PDBFile = FileItem.GetItemByFileReference( FileReference.Combine( CompileEnvironment.Config.OutputDirectory, PDBFileName + ".pdb" ) ); FileArguments += string.Format(" /Fd\"{0}\"", PDBFile.AbsolutePath); // Only use the PDB as an output file if we want PDBs and this particular action is // the one that produces the PDB (as opposed to no debug info, where the above code // is needed, but not the output PDB, or when multiple files share a single PDB, so // only the action that generates it should count it as output directly) if (BuildConfiguration.bUsePDBFiles && bActionProducesPDB) { CompileAction.ProducedItems.Add(PDBFile); Result.DebugDataFiles.Add(PDBFile); } } // Add C or C++ specific compiler arguments. if (bIsPlainCFile) { FileArguments += GetCLArguments_C(); } else { FileArguments += GetCLArguments_CPP(CompileEnvironment); } CompileAction.WorkingDirectory = UnrealBuildTool.EngineSourceDirectory.FullName; CompileAction.CommandPath = GetVCToolPath(CompileEnvironment.Config.Target.Platform, CompileEnvironment.Config.Target.Configuration, "cl"); CompileAction.CommandArguments = Arguments + FileArguments + CompileEnvironment.Config.AdditionalArguments; CompileAction.StatusDescription = string.Format("{0}", Path.GetFileName(SourceFile.AbsolutePath)); // Don't farm out creation of precomputed headers as it is the critical path task. CompileAction.bCanExecuteRemotely = CompileEnvironment.Config.PrecompiledHeaderAction != PrecompiledHeaderAction.Create; // @todo: XGE has problems remote compiling C++/CLI files that use .NET Framework 4.0 if (CompileEnvironment.Config.CLRMode == CPPCLRMode.CLREnabled) { CompileAction.bCanExecuteRemotely = false; } } return(Result); }
public new TVOSProjectSettings ReadProjectSettings(FileReference ProjectFile) { return((TVOSProjectSettings)base.ReadProjectSettings(ProjectFile)); }
/// <summary> /// Constructor /// </summary> /// <param name="InPath">Path to the runtime dependency</param> /// <param name="InType">How to stage the given path</param> public RuntimeDependency(FileReference InPath, StagedFileType InType = StagedFileType.NonUFS) { Path = InPath; Type = InType; }
protected override IOSProjectSettings CreateProjectSettings(FileReference ProjectFile) { return(new TVOSProjectSettings(ProjectFile)); }
/// <summary> /// Add a runtime dependency to the list /// </summary> /// <param name="InPath">Path to the runtime dependency. May include wildcards.</param> /// <param name="InType">How to stage this file</param> public void Add(FileReference InPath, StagedFileType InType) { Add(new RuntimeDependency(InPath, InType)); }
/// <summary> /// /// </summary> /// <param name="ProjectFile"></param> /// <returns></returns> public static IAndroidToolChain CreateToolChain(FileReference ProjectFile) { return(new LuminToolChain(ProjectFile)); }
/// <summary> /// Read a receipt from disk. /// </summary> /// <param name="Location">Filename to read from</param> /// <param name="EngineDir">Engine directory for expanded variables</param> public static TargetReceipt Read(FileReference Location, DirectoryReference EngineDir) { JsonObject RawObject = JsonObject.Read(Location); // Read the initial fields string TargetName = RawObject.GetStringField("TargetName"); TargetType TargetType = RawObject.GetEnumField <TargetType>("TargetType"); UnrealTargetPlatform Platform = UnrealTargetPlatform.Parse(RawObject.GetStringField("Platform")); UnrealTargetConfiguration Configuration = RawObject.GetEnumField <UnrealTargetConfiguration>("Configuration"); // Try to read the build version BuildVersion Version; if (!BuildVersion.TryParse(RawObject.GetObjectField("Version"), out Version)) { throw new JsonParseException("Invalid 'Version' field"); } // Read the project path FileReference ProjectFile; string RelativeProjectFile; if (RawObject.TryGetStringField("Project", out RelativeProjectFile)) { ProjectFile = FileReference.Combine(Location.Directory, RelativeProjectFile); } else { ProjectFile = null; } // Read the launch executable string Architecture; if (!RawObject.TryGetStringField("Architecture", out Architecture)) { Architecture = ""; } // Create the receipt TargetReceipt Receipt = new TargetReceipt(ProjectFile, TargetName, TargetType, Platform, Configuration, Version, Architecture); // Get the project directory DirectoryReference ProjectDir = Receipt.ProjectDir; // Read the launch executable string Launch; if (RawObject.TryGetStringField("Launch", out Launch)) { Receipt.Launch = ExpandPathVariables(Launch, EngineDir, ProjectDir); } // Read the build products JsonObject[] BuildProductObjects; if (RawObject.TryGetObjectArrayField("BuildProducts", out BuildProductObjects)) { foreach (JsonObject BuildProductObject in BuildProductObjects) { string Path; BuildProductType Type; if (BuildProductObject.TryGetStringField("Path", out Path) && BuildProductObject.TryGetEnumField("Type", out Type)) { FileReference File = ExpandPathVariables(Path, EngineDir, ProjectDir); string Module; BuildProductObject.TryGetStringField("Module", out Module); Receipt.AddBuildProduct(File, Type); } } } // Read the runtime dependencies JsonObject[] RuntimeDependencyObjects; if (RawObject.TryGetObjectArrayField("RuntimeDependencies", out RuntimeDependencyObjects)) { foreach (JsonObject RuntimeDependencyObject in RuntimeDependencyObjects) { string Path; if (RuntimeDependencyObject.TryGetStringField("Path", out Path)) { FileReference File = ExpandPathVariables(Path, EngineDir, ProjectDir); StagedFileType Type; if (!RuntimeDependencyObject.TryGetEnumField("Type", out Type)) { // Previous format included an optional IgnoreIfMissing flag, which was only used for debug files. We can explicitly reference them as DebugNonUFS files now. bool bIgnoreIfMissing; if (RuntimeDependencyObject.TryGetBoolField("IgnoreIfMissing", out bIgnoreIfMissing)) { bIgnoreIfMissing = false; } Type = bIgnoreIfMissing? StagedFileType.DebugNonUFS : StagedFileType.NonUFS; } Receipt.RuntimeDependencies.Add(File, Type); } } } // Read the enabled/disabled plugins JsonObject[] PluginObjects; if (RawObject.TryGetObjectArrayField("Plugins", out PluginObjects)) { foreach (JsonObject PluginObject in PluginObjects) { string PluginName; if (PluginObject.TryGetStringField("Name", out PluginName)) { bool PluginEnabled; if (PluginObject.TryGetBoolField("Enabled", out PluginEnabled)) { Receipt.PluginNameToEnabledState.Add(PluginName, PluginEnabled); } } } } // Read the additional properties JsonObject[] AdditionalPropertyObjects; if (RawObject.TryGetObjectArrayField("AdditionalProperties", out AdditionalPropertyObjects)) { foreach (JsonObject AdditionalPropertyObject in AdditionalPropertyObjects) { string Name; if (AdditionalPropertyObject.TryGetStringField("Name", out Name)) { string Value; if (AdditionalPropertyObject.TryGetStringField("Value", out Value)) { Receipt.AdditionalProperties.Add(new ReceiptProperty(Name, Value)); } } } } return(Receipt); }
/// <summary> /// /// </summary> /// <param name="ProjectFile"></param> /// <returns></returns> public static ILuminDeploy CreateDeploymentHandler(FileReference ProjectFile) { return(new UEDeployLumin(ProjectFile)); }
private static void SetupBuildEnvironment() { if (!Utils.IsRunningOnMono) { string VS2015Path = GetMsDevExe(WindowsCompiler.VisualStudio2015); if (VS2015Path != null) { MsDev14Exe = new UnrealBuildTool.FileReference(GetMsDevExe(WindowsCompiler.VisualStudio2015)); MsBuildExe = new UnrealBuildTool.FileReference(GetMsBuildExe(WindowsCompiler.VisualStudio2015)); } // ================================================================================ // ThirdPartyNotUE // NOTE: these are Windows executables if (BuildHostPlatform.Current.Platform == UnrealTargetPlatform.Win64) { DirectoryReference ThirdPartyNotUERootDirectory = DirectoryReference.Combine(CommandUtils.RootDirectory, "Engine", "Extras", "ThirdPartyNotUE"); string CMakePath = DirectoryReference.Combine(ThirdPartyNotUERootDirectory, "CMake", "bin").ToString(); string MakePath = DirectoryReference.Combine(ThirdPartyNotUERootDirectory, "GNU_Make", "make-3.81", "bin").ToString(); string PrevPath = Environment.GetEnvironmentVariable("PATH"); // mixing bundled make and cygwin make is no good. Try to detect and remove cygwin paths. string PathWithoutCygwin = RemoveOtherMakeFromPath(PrevPath); Environment.SetEnvironmentVariable("PATH", CMakePath + ";" + MakePath + ";" + PathWithoutCygwin); Environment.SetEnvironmentVariable("PATH", CMakePath + ";" + MakePath + ";" + Environment.GetEnvironmentVariable("PATH")); Log("set {0}={1}", "PATH", Environment.GetEnvironmentVariable("PATH")); } // ================================================================================ // HTML5 // FIXME: only run this if GetTargetPlatforms() contains HTML5 // override BuildConfiguration defaults - so we can use HTML5SDKInfo BuildConfiguration.RelativeEnginePath = "Engine/"; string EngineSourceDir = GetProjectDirectory(PhysXTargetLib.PhysX, new TargetPlatformData(UnrealTargetPlatform.HTML5)).ToString(); EngineSourceDir = Regex.Replace(EngineSourceDir, @"\\" , "/"); EngineSourceDir = Regex.Replace(EngineSourceDir, ".*Engine/" , ""); BuildConfiguration.BaseIntermediateFolder = Regex.Replace(EngineSourceDir, "/HTML5" , ""); if (!HTML5SDKInfo.IsSDKInstalled()) { throw new AutomationException("EMSCRIPTEN SDK TOOLCHAIN NOT FOUND..."); } // warm up emscripten config file HTML5SDKInfo.SetUpEmscriptenConfigFile(); Environment.SetEnvironmentVariable("PATH", Environment.GetEnvironmentVariable("EMSCRIPTEN") + ";" + Environment.GetEnvironmentVariable("NODEPATH") + ";" + Environment.GetEnvironmentVariable("LLVM") + ";" + Path.GetDirectoryName(HTML5SDKInfo.Python()) + ";" + Environment.GetEnvironmentVariable("PATH")); //Log("set {0}={1}", "PATH", Environment.GetEnvironmentVariable("PATH")); } }
/// <summary> /// Compiles the module, and returns a list of files output by the compiler. /// </summary> public virtual List <FileItem> Compile(ReadOnlyTargetRules Target, UEToolChain ToolChain, CppCompileEnvironment CompileEnvironment, FileReference SingleFileToCompile, ISourceFileWorkingSet WorkingSet, IActionGraphBuilder Graph) { // Generate type libraries for Windows foreach (ModuleRules.TypeLibrary TypeLibrary in Rules.TypeLibraries) { FileReference OutputFile = FileReference.Combine(IntermediateDirectory, TypeLibrary.Header); ToolChain.GenerateTypeLibraryHeader(CompileEnvironment, TypeLibrary, OutputFile, Graph); } return(new List <FileItem>()); }