Ejemplo n.º 1
0
        /// <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("PLATFORM_IOS=1");
            CompileEnvironment.Definitions.Add("PLATFORM_APPLE=1");

            CompileEnvironment.Definitions.Add("WITH_TTS=0");
            CompileEnvironment.Definitions.Add("WITH_SPEECH_RECOGNITION=0");
            CompileEnvironment.Definitions.Add("WITH_DATABASE_SUPPORT=0");
            CompileEnvironment.Definitions.Add("WITH_EDITOR=0");
            CompileEnvironment.Definitions.Add("USE_NULL_RHI=0");
            CompileEnvironment.Definitions.Add("REQUIRES_ALIGNED_INT_ACCESS");

            IOSProjectSettings ProjectSettings = ((IOSPlatform)UEBuildPlatform.GetBuildPlatform(UnrealTargetPlatform.IOS)).ReadProjectSettings(Target.ProjectFile);

            if (ProjectSettings.bNotificationsEnabled)
            {
                CompileEnvironment.Definitions.Add("NOTIFICATIONS_ENABLED=1");
            }
            else
            {
                CompileEnvironment.Definitions.Add("NOTIFICATIONS_ENABLED=0");
            }

            if (Target.Architecture == "-simulator")
            {
                CompileEnvironment.Definitions.Add("WITH_SIMULATOR=1");
            }
            else
            {
                CompileEnvironment.Definitions.Add("WITH_SIMULATOR=0");
            }

            LinkEnvironment.AdditionalFrameworks.Add(new UEBuildFramework("GameKit"));
            LinkEnvironment.AdditionalFrameworks.Add(new UEBuildFramework("StoreKit"));
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="PlatformType"></param>
        /// <param name="SourceFile"></param>
        /// <param name="TargetFile"></param>
        public static void StripSymbols(UnrealTargetPlatform PlatformType, FileReference SourceFile, FileReference TargetFile)
        {
            IOSProjectSettings ProjectSettings = ((IOSPlatform)UEBuildPlatform.GetBuildPlatform(PlatformType)).ReadProjectSettings(null);
            IOSToolChain       ToolChain       = new IOSToolChain(null, ProjectSettings);

            ToolChain.StripSymbols(SourceFile, TargetFile);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets all UnrealHeaderTool binaries (including DLLs if it was not build monolithically)
        /// </summary>
        static VersionedBinary[] GetHeaderToolBinaries()
        {
            var Binaries      = new List <VersionedBinary>();
            var HeaderToolExe = GetHeaderToolPath();

            if (File.Exists(HeaderToolExe))
            {
                Binaries.Add(new VersionedBinary(HeaderToolExe, -1));

                var HeaderToolLocation = Path.GetDirectoryName(HeaderToolExe);
                var Platform           = BuildHostPlatform.Current.Platform;
                var DLLExtension       = UEBuildPlatform.GetBuildPlatform(Platform).GetBinaryExtension(UEBuildBinaryType.DynamicLinkLibrary);
                var DLLSearchPattern   = "UnrealHeaderTool-*" + DLLExtension;
                var HeaderToolDLLs     = Directory.GetFiles(HeaderToolLocation, DLLSearchPattern, SearchOption.TopDirectoryOnly);


                foreach (var Binary in HeaderToolDLLs)
                {
                    Binaries.Add(new VersionedBinary(Binary, BuildHostPlatform.Current.GetDllApiVersion(Binary)));
                }

                var PluginDirectory = Path.Combine("..", "Plugins");
                RecursivelyCollectHeaderToolPlugins(PluginDirectory, DLLSearchPattern, Platform.ToString(), Binaries);
            }
            return(Binaries.ToArray());
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Selects which platforms and build configurations we want in the project file
        /// </summary>
        /// <param name="IncludeAllPlatforms">True if we should include ALL platforms that are supported on this machine.  Otherwise, only desktop platforms will be included.</param>
        /// <param name="SupportedPlatformNames">Output string for supported platforms, returned as comma-separated values.</param>
        protected override void SetupSupportedPlatformsAndConfigurations(bool IncludeAllPlatforms, out string SupportedPlatformNames)
        {
            // Call parent implementation to figure out the actual platforms
            base.SetupSupportedPlatformsAndConfigurations(IncludeAllPlatforms, out SupportedPlatformNames);

            // Certain platforms override the project file format because their debugger add-ins may not yet support the latest
            // version of Visual Studio.  This is their chance to override that.
            foreach (var SupportedPlatform in SupportedPlatforms)
            {
                var BuildPlatform = UEBuildPlatform.GetBuildPlatform(SupportedPlatform, true);
                if (BuildPlatform != null)
                {
                    // Don't worry about platforms that we're missing SDKs for
                    if (BuildPlatform.HasRequiredSDKsInstalled() == SDKStatus.Valid)
                    {
                        // Make sure Visual Studio 2013 project files will work...
                        if (ProjectFileFormat == VCProjectFileFormat.VisualStudio2013)
                        {
                            // ...but only if the user didn't override this via the command-line.
                            if (!UnrealBuildTool.CommandLineContains("-2013"))
                            {
                                // Visual Studio 2013 is not supported by Xbox One debugger add-in yet
                                if (SupportedPlatform == UnrealTargetPlatform.XboxOne)
                                {
                                    Log.TraceInformation("Forcing Visual Studio 2012 projects for Xbox One compatibility (use '-2013' to override.)");
                                    ProjectFileFormat = VCProjectFileFormat.VisualStudio2012;
                                }
                            }
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Executes the tool with the given arguments
        /// </summary>
        /// <param name="Arguments">Command line arguments</param>
        /// <returns>Exit code</returns>
        public override int Execute(CommandLineArguments Arguments)
        {
            // Output a message if there are any arguments that are still unused
            Arguments.ApplyTo(this);
            Arguments.CheckAllArgumentsUsed();

            // If the -AllPlatforms argument is specified, add all the known platforms into the list
            if (bAllPlatforms)
            {
                Platforms.UnionWith(Enum.GetValues(typeof(UnrealTargetPlatform)).OfType <UnrealTargetPlatform>().Where(x => x != UnrealTargetPlatform.Unknown));
            }

            // Output a line for each registered platform
            foreach (UnrealTargetPlatform Platform in Platforms)
            {
                UEBuildPlatform BuildPlatform = UEBuildPlatform.GetBuildPlatform(Platform, true);
                if (BuildPlatform != null && BuildPlatform.HasRequiredSDKsInstalled() == SDKStatus.Valid)
                {
                    Log.TraceInformation("##PlatformValidate: {0} VALID", Platform.ToString());
                }
                else
                {
                    Log.TraceInformation("##PlatformValidate: {0} INVALID", Platform.ToString());
                }
            }
            return(0);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Setup the binaries for this target
        /// </summary>
        protected override void SetupBinaries()
        {
            base.SetupBinaries();

            {
                // Make the editor executable.
                UEBuildBinaryConfiguration Config = new UEBuildBinaryConfiguration(InType: UEBuildBinaryType.Executable,
                                                                                   InOutputFilePaths: OutputPaths,
                                                                                   InIntermediateDirectory: EngineIntermediateDirectory,
                                                                                   bInCreateImportLibrarySeparately: (ShouldCompileMonolithic() ? false : true),
                                                                                   bInAllowExports: !ShouldCompileMonolithic(),
                                                                                   InModuleNames: new List <string>()
                {
                    "Launch"
                });

                if (Platform == UnrealTargetPlatform.Win64 && Configuration != UnrealTargetConfiguration.Shipping)
                {
                    Config.bBuildAdditionalConsoleApp = true;
                }

                AppBinaries.Add(new UEBuildBinaryCPP(this, Config));
            }

            // Add the other modules that we want to compile along with the executable.  These aren't necessarily
            // dependencies to any of the other modules we're building, so we need to opt in to compile them.
            {
                // Modules should properly identify the 'extra modules' they need now.
                // There should be nothing here!
            }

            // Allow the platform to setup binaries
            UEBuildPlatform.GetBuildPlatform(Platform).SetupBinaries(this);
        }
Ejemplo n.º 7
0
        private void GenerateSNDBSIncludeRewriteRules()
        {
            if (!Directory.Exists(IncludeRewriteRulesFile.Directory.FullName))
            {
                Directory.CreateDirectory(IncludeRewriteRulesFile.Directory.FullName);
            }

            List <string> IncludeRewriteRulesText = new List <string>();

            IncludeRewriteRulesText.Add("[computed-include-rules]");
            IncludeRewriteRulesText.Add(@"pattern1=^COMPILED_PLATFORM_HEADER\(\s*([^ ,]+)\)");

            // Get all registered platforms. Most will just use the name as is, but some may have an override so
            // add all distinct entries to the list.
            IEnumerable <UnrealTargetPlatform> Platforms = UEBuildPlatform.GetRegisteredPlatforms();
            List <string> PlatformNames = new List <string>();

            foreach (UnrealTargetPlatform Platform in Platforms)
            {
                UEBuildPlatform PlatformData = UEBuildPlatform.GetBuildPlatform(Platform);
                if (!PlatformNames.Contains(PlatformData.GetPlatformName()))
                {
                    PlatformNames.Add(PlatformData.GetPlatformName());
                }
            }

            IEnumerable <string> PlatformExpansions = PlatformNames.Select(p => String.Format("{0}/{0}$1", p));

            IncludeRewriteRulesText.Add(String.Format("expansions1={0}", String.Join("|", PlatformExpansions)));
            File.WriteAllText(IncludeRewriteRulesFile.FullName, String.Join(Environment.NewLine, IncludeRewriteRulesText));
        }
Ejemplo n.º 8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="InProject"></param>
        /// <param name="Distribution"></param>
        /// <param name="MobileProvision"></param>
        /// <param name="SigningCertificate"></param>
        /// <param name="TeamUUID"></param>
        /// <param name="bAutomaticSigning"></param>
        public static void GetProvisioningData(FileReference InProject, bool Distribution, out string MobileProvision, out string SigningCertificate, out string TeamUUID, out bool bAutomaticSigning)
        {
            IOSProjectSettings ProjectSettings = ((IOSPlatform)UEBuildPlatform.GetBuildPlatform(UnrealTargetPlatform.IOS)).ReadProjectSettings(InProject);

            IOSProvisioningData Data = ((IOSPlatform)UEBuildPlatform.GetBuildPlatform(UnrealTargetPlatform.IOS)).ReadProvisioningData(ProjectSettings, Distribution);

            if (Data == null)
            {
                MobileProvision    = null;
                SigningCertificate = null;
                TeamUUID           = null;
                bAutomaticSigning  = true;
            }
            else
            {
                MobileProvision    = Data.MobileProvision;
                SigningCertificate = Data.SigningCertificate;
                TeamUUID           = Data.TeamUUID;
                if (Data.MobileProvisionName.Contains("*") || ProjectSettings.bAutomaticSigning)
                {
                    bAutomaticSigning = true;
                }
                else
                {
                    bAutomaticSigning = false;
                }
            }
        }
Ejemplo n.º 9
0
        private bool GenerateSNDBSIncludeRewriteRules()
        {
            // Get all registered, distinct platform names.
            var Platforms = UEBuildPlatform.GetRegisteredPlatforms()
                            .Select(Platform => UEBuildPlatform.GetBuildPlatform(Platform).GetPlatformName())
                            .Distinct()
                            .ToList();

            if (Platforms.Count > 0)
            {
                // language=regex
                var Lines = new[]
                {
                    @"pattern1=^COMPILED_PLATFORM_HEADER\(\s*([^ ,]+)\s*\)",
                    $"expansions1={string.Join("|", Platforms.Select(Name => $"{Name}/{Name}$1|{Name}$1"))}",

                    @"pattern2=^COMPILED_PLATFORM_HEADER_WITH_PREFIX\(\s*([^ ,]+)\s*,\s*([^ ,]+)\s*\)",
                    $"expansions2={string.Join("|", Platforms.Select(Name => $"$1/{Name}/{Name}$2|$1/{Name}$2"))}",

                    @"pattern3=^[A-Z]{5}_PLATFORM_HEADER_NAME\(\s*([^ ,]+)\s*\)",
                    $"expansions3={string.Join("|", Platforms.Select(Name => $"{Name}/{Name}$1|{Name}$1"))}",

                    @"pattern4=^[A-Z]{5}_PLATFORM_HEADER_NAME_WITH_PREFIX\(\s*([^ ,]+)\s*,\s*([^ ,]+)\s*\)",
                    $"expansions4={string.Join("|", Platforms.Select(Name => $"$1/{Name}/{Name}$2|$1/{Name}$2"))}"
                };

                File.WriteAllText(IncludeRewriteRulesFile.FullName, string.Join(Environment.NewLine, new[] { "[computed-include-rules]" }.Concat(Lines)));
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 10
0
        public static IUEToolChain GetPlatformToolChain(CPPTargetPlatform Platform)
        {
            UEBuildPlatform        BuildPlatform = UEBuildPlatform.GetBuildPlatform(UEBuildTarget.CPPTargetPlatformToUnrealTargetPlatform(Platform));
            UEBuildPlatformContext Context       = BuildPlatform.CreateContext(null);

            return(Context.CreateToolChain(BuildPlatform.DefaultCppPlatform));
        }
Ejemplo n.º 11
0
        /// <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("PLATFORM_IOS=1");
            CompileEnvironment.Definitions.Add("PLATFORM_APPLE=1");
            CompileEnvironment.Definitions.Add("GLES_SILENCE_DEPRECATION=1");              // suppress GLES "deprecated" warnings until a proper solution is implemented (see UE-65643)

            CompileEnvironment.Definitions.Add("WITH_TTS=0");
            CompileEnvironment.Definitions.Add("WITH_SPEECH_RECOGNITION=0");
            CompileEnvironment.Definitions.Add("WITH_DATABASE_SUPPORT=0");
            CompileEnvironment.Definitions.Add("WITH_EDITOR=0");
            CompileEnvironment.Definitions.Add("USE_NULL_RHI=0");

            IOSProjectSettings ProjectSettings = ((IOSPlatform)UEBuildPlatform.GetBuildPlatform(Target.Platform)).ReadProjectSettings(Target.ProjectFile);

            if (ProjectSettings.bNotificationsEnabled)
            {
                CompileEnvironment.Definitions.Add("NOTIFICATIONS_ENABLED=1");
            }
            else
            {
                CompileEnvironment.Definitions.Add("NOTIFICATIONS_ENABLED=0");
            }
            if (ProjectSettings.bBackgroundFetchEnabled)
            {
                CompileEnvironment.Definitions.Add("BACKGROUNDFETCH_ENABLED=1");
            }
            else
            {
                CompileEnvironment.Definitions.Add("BACKGROUNDFETCH_ENABLED=0");
            }

            CompileEnvironment.Definitions.Add("UE_DISABLE_FORCE_INLINE=" + (ProjectSettings.bDisableForceInline ? "1" : "0"));

            if (Target.Architecture == "-simulator")
            {
                CompileEnvironment.Definitions.Add("WITH_SIMULATOR=1");
            }
            else
            {
                CompileEnvironment.Definitions.Add("WITH_SIMULATOR=0");
            }

            // if the project has an Oodle compression Dll, enable the decompressor on IOS
            if (Target.ProjectFile != null)
            {
                DirectoryReference ProjectDir   = DirectoryReference.GetParentDirectory(Target.ProjectFile);
                string             OodleDllPath = DirectoryReference.Combine(ProjectDir, "Binaries/ThirdParty/Oodle/Mac/libUnrealPakPlugin.dylib").FullName;
                if (File.Exists(OodleDllPath))
                {
                    Log.TraceVerbose("        Registering custom oodle compressor for {0}", UnrealTargetPlatform.IOS.ToString());
                    CompileEnvironment.Definitions.Add("REGISTER_OODLE_CUSTOM_COMPRESSOR=1");
                }
            }

            LinkEnvironment.AdditionalFrameworks.Add(new UEBuildFramework("GameKit"));
            LinkEnvironment.AdditionalFrameworks.Add(new UEBuildFramework("StoreKit"));
            LinkEnvironment.AdditionalFrameworks.Add(new UEBuildFramework("DeviceCheck"));
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Gets UnrealHeaderTool.exe path. Does not care if UnrealheaderTool was build as a monolithic exe or not.
        /// </summary>
        static string GetHeaderToolPath()
        {
            UnrealTargetPlatform Platform = BuildHostPlatform.Current.Platform;
            string ExeExtension           = UEBuildPlatform.GetBuildPlatform(Platform).GetBinaryExtension(UEBuildBinaryType.Executable);
            string HeaderToolExeName      = "UnrealHeaderTool";
            string HeaderToolPath         = Path.Combine("..", "Binaries", Platform.ToString(), HeaderToolExeName + ExeExtension);

            return(HeaderToolPath);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Write project file info in JSON file.
        /// For every combination of <c>UnrealTargetPlatform</c>, <c>UnrealTargetConfiguration</c> and <c>TargetType</c>
        /// will be generated separate JSON file.
        /// Project file will be stored:
        /// For UE4:  {UE4Root}/Engine/Intermediate/ProjectFiles/.Rider/{Platform}/{Configuration}/{TargetType}/{ProjectName}.json
        /// For game: {GameRoot}/Intermediate/ProjectFiles/.Rider/{Platform}/{Configuration}/{TargetType}/{ProjectName}.json
        /// </summary>
        /// <remarks>
        /// * <c>UnrealTargetPlatform.Win32</c> will be always ignored.
        /// * <c>TargetType.Editor</c> will be generated for current platform only and will ignore <c>UnrealTargetConfiguration.Test</c> and <c>UnrealTargetConfiguration.Shipping</c> configurations
        /// * <c>TargetType.Program</c>  will be generated for current platform only and <c>UnrealTargetConfiguration.Development</c> configuration only
        /// </remarks>
        /// <param name="InPlatforms"></param>
        /// <param name="InConfigurations"></param>
        /// <param name="PlatformProjectGenerators"></param>
        /// <returns></returns>
        public override bool WriteProjectFile(List <UnrealTargetPlatform> InPlatforms,
                                              List <UnrealTargetConfiguration> InConfigurations,
                                              PlatformProjectGeneratorCollection PlatformProjectGenerators)
        {
            string             ProjectName       = ProjectFilePath.GetFileNameWithoutAnyExtensions();
            DirectoryReference projectRootFolder = DirectoryReference.Combine(RootPath, ".Rider");
            List <Tuple <FileReference, UEBuildTarget> > fileToTarget = new List <Tuple <FileReference, UEBuildTarget> >();

            foreach (UnrealTargetPlatform Platform in InPlatforms.Where(it => it != UnrealTargetPlatform.Win32))
            {
                foreach (UnrealTargetConfiguration Configuration in InConfigurations)
                {
                    foreach (ProjectTarget ProjectTarget in ProjectTargets)
                    {
                        if (TargetTypes.Any() && !TargetTypes.Contains(ProjectTarget.TargetRules.Type))
                        {
                            continue;
                        }

                        // Skip Programs for all configs except for current platform + Development configuration
                        if (ProjectTarget.TargetRules.Type == TargetType.Program && (BuildHostPlatform.Current.Platform != Platform || Configuration != UnrealTargetConfiguration.Development))
                        {
                            continue;
                        }

                        // Skip Editor for all platforms except for current platform
                        if (ProjectTarget.TargetRules.Type == TargetType.Editor && (BuildHostPlatform.Current.Platform != Platform || (Configuration == UnrealTargetConfiguration.Test || Configuration == UnrealTargetConfiguration.Shipping)))
                        {
                            continue;
                        }

                        DirectoryReference ConfigurationFolder = DirectoryReference.Combine(projectRootFolder, Platform.ToString(), Configuration.ToString());

                        DirectoryReference TargetFolder =
                            DirectoryReference.Combine(ConfigurationFolder, ProjectTarget.TargetRules.Type.ToString());

                        string DefaultArchitecture = UEBuildPlatform
                                                     .GetBuildPlatform(BuildHostPlatform.Current.Platform)
                                                     .GetDefaultArchitecture(ProjectTarget.UnrealProjectFilePath);
                        TargetDescriptor TargetDesc = new TargetDescriptor(ProjectTarget.UnrealProjectFilePath, ProjectTarget.Name,
                                                                           BuildHostPlatform.Current.Platform, UnrealTargetConfiguration.Development,
                                                                           DefaultArchitecture, Arguments);
                        UEBuildTarget BuildTarget = UEBuildTarget.Create(TargetDesc, false, false);
                        FileReference OutputFile  = FileReference.Combine(TargetFolder, $"{ProjectName}.json");
                        fileToTarget.Add(Tuple.Create(OutputFile, BuildTarget));
                    }
                }
            }
            foreach (Tuple <FileReference, UEBuildTarget> tuple in fileToTarget)
            {
                SerializeTarget(tuple.Item1, tuple.Item2);
            }

            return(true);
        }
        /// <summary>
        /// Gets the standard path for an manifest
        /// </summary>
        /// <param name="AppName">The modular app name being built</param>
        /// <param name="Configuration">The target configuration</param>
        /// <param name="Platform">The target platform</param>
        /// <param name="BuildArchitecture">The architecture of the target platform</param>
        /// <param name="bIsGameDirectory"></param>
        /// <returns>Filename for the app receipt</returns>
        public static string GetStandardFileName(string AppName, UnrealTargetPlatform Platform, UnrealTargetConfiguration Configuration, string BuildArchitecture, bool bIsGameDirectory)
        {
            string BaseName = AppName;

            if (Configuration != UnrealTargetConfiguration.Development && !(Configuration == UnrealTargetConfiguration.DebugGame && !bIsGameDirectory))
            {
                BaseName += String.Format("-{0}-{1}", Platform.ToString(), Configuration.ToString());
            }
            if (!String.IsNullOrEmpty(BuildArchitecture) && UEBuildPlatform.GetBuildPlatform(Platform).RequiresArchitectureSuffix())
            {
                BaseName += BuildArchitecture;
            }
            return(String.Format("{0}.modules", BaseName));
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Execute the tool mode
        /// </summary>
        /// <param name="Arguments">Command line arguments</param>
        /// <returns>Exit code</returns>
        public override int Execute(CommandLineArguments Arguments)
        {
            // Apply the arguments
            Arguments.ApplyTo(this);
            Arguments.CheckAllArgumentsUsed();

            // Execute the deploy
            TargetReceipt Receipt = TargetReceipt.Read(ReceiptFile);

            Log.WriteLine(LogEventType.Console, "Deploying {0} {1} {2}...", Receipt.TargetName, Receipt.Platform, Receipt.Configuration);
            UEBuildPlatform.GetBuildPlatform(Receipt.Platform).Deploy(Receipt);

            return((int)CompilationResult.Succeeded);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Writes information about the targets in an assembly to a file
        /// </summary>
        /// <param name="ProjectFile">The project file for the targets being built</param>
        /// <param name="Assembly">The rules assembly for this target</param>
        /// <param name="OutputFile">Output file to write to</param>
        /// <param name="Arguments"></param>
        public static void WriteTargetInfo(FileReference ProjectFile, RulesAssembly Assembly, FileReference OutputFile, CommandLineArguments Arguments)
        {
            // Construct all the targets in this assembly
            List <string> TargetNames = new List <string>();

            Assembly.GetAllTargetNames(TargetNames, false);

            // Write the output file
            DirectoryReference.CreateDirectory(OutputFile.Directory);
            using (JsonWriter Writer = new JsonWriter(OutputFile))
            {
                Writer.WriteObjectStart();
                Writer.WriteArrayStart("Targets");
                foreach (string TargetName in TargetNames)
                {
                    // skip target rules that are platform extension or platform group specializations
                    string[] TargetPathSplit = TargetName.Split(new char[] { '_' }, StringSplitOptions.RemoveEmptyEntries);
                    if (TargetPathSplit.Length > 1 && (UnrealTargetPlatform.IsValidName(TargetPathSplit.Last()) || UnrealPlatformGroup.IsValidName(TargetPathSplit.Last())))
                    {
                        continue;
                    }

                    // Construct the rules object
                    TargetRules TargetRules;
                    try
                    {
                        string Architecture = UEBuildPlatform.GetBuildPlatform(BuildHostPlatform.Current.Platform).GetDefaultArchitecture(ProjectFile);
                        TargetRules = Assembly.CreateTargetRules(TargetName, BuildHostPlatform.Current.Platform, UnrealTargetConfiguration.Development, Architecture, ProjectFile, Arguments);
                    }
                    catch (Exception Ex)
                    {
                        Log.TraceWarning("Unable to construct target rules for {0}", TargetName);
                        Log.TraceVerbose(ExceptionUtils.FormatException(Ex));
                        continue;
                    }

                    // Write the target info
                    Writer.WriteObjectStart();
                    Writer.WriteValue("Name", TargetName);
                    Writer.WriteValue("Path", Assembly.GetTargetFileName(TargetName).ToString());
                    Writer.WriteValue("Type", TargetRules.Type.ToString());
                    Writer.WriteObjectEnd();
                }
                Writer.WriteArrayEnd();
                Writer.WriteObjectEnd();
            }
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Generates a UHTModuleInfo for a particular named module under a directory.
        /// </summary>
        /// <returns>
        public static UHTModuleInfo CreateUHTModuleInfo(IEnumerable <string> HeaderFilenames, UEBuildTarget Target, string ModuleName, DirectoryReference ModuleDirectory, UEBuildModuleType ModuleType)
        {
            var ClassesFolder = DirectoryReference.Combine(ModuleDirectory, "Classes");
            var PublicFolder  = DirectoryReference.Combine(ModuleDirectory, "Public");
            var BuildPlatform = UEBuildPlatform.GetBuildPlatform(Target.Platform);

            var AllClassesHeaders     = new List <FileItem>();
            var PublicUObjectHeaders  = new List <FileItem>();
            var PrivateUObjectHeaders = new List <FileItem>();

            foreach (var Header in HeaderFilenames)
            {
                // Check to see if we know anything about this file.  If we have up-to-date cached information about whether it has
                // UObjects or not, we can skip doing a test here.
                var UObjectHeaderFileItem = FileItem.GetExistingItemByPath(Header);

                if (CPPEnvironment.DoesFileContainUObjects(UObjectHeaderFileItem.AbsolutePath))
                {
                    if (new FileReference(UObjectHeaderFileItem.AbsolutePath).IsUnderDirectory(ClassesFolder))
                    {
                        AllClassesHeaders.Add(UObjectHeaderFileItem);
                    }
                    else if (new FileReference(UObjectHeaderFileItem.AbsolutePath).IsUnderDirectory(PublicFolder))
                    {
                        PublicUObjectHeaders.Add(UObjectHeaderFileItem);
                    }
                    else
                    {
                        PrivateUObjectHeaders.Add(UObjectHeaderFileItem);
                    }
                }
            }

            var Result = new UHTModuleInfo
            {
                ModuleName                  = ModuleName,
                ModuleDirectory             = ModuleDirectory.FullName,
                ModuleType                  = ModuleType.ToString(),
                PublicUObjectClassesHeaders = AllClassesHeaders,
                PublicUObjectHeaders        = PublicUObjectHeaders,
                PrivateUObjectHeaders       = PrivateUObjectHeaders,
                GeneratedCodeVersion        = Target.Rules.GetGeneratedCodeVersion()
            };

            return(Result);
        }
Ejemplo n.º 18
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="InProject"></param>
        /// <param name="Distribution"></param>
        /// <param name="MobileProvision"></param>
        /// <param name="SigningCertificate"></param>
        public static void GetProvisioningData(FileReference InProject, bool Distribution, out string MobileProvision, out string SigningCertificate)
        {
            IOSProjectSettings ProjectSettings = ((TVOSPlatform)UEBuildPlatform.GetBuildPlatform(UnrealTargetPlatform.TVOS)).ReadProjectSettings(InProject);

            IOSProvisioningData Data = ((IOSPlatform)UEBuildPlatform.GetBuildPlatform(UnrealTargetPlatform.TVOS)).ReadProvisioningData(ProjectSettings, Distribution);

            if (Data == null)
            {
                MobileProvision    = null;
                SigningCertificate = null;
            }
            else
            {
                MobileProvision    = Data.MobileProvision;
                SigningCertificate = Data.SigningCertificate;
            }
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Gets all build products produced by this binary
        /// </summary>
        /// <param name="Target">The target being built</param>
        /// <param name="ToolChain">The platform toolchain</param>
        /// <param name="BuildProducts">Mapping of produced build product to type</param>
        /// <param name="bCreateDebugInfo">Whether debug info is enabled for this binary</param>
        public void GetBuildProducts(ReadOnlyTargetRules Target, UEToolChain ToolChain, Dictionary <FileReference, BuildProductType> BuildProducts, bool bCreateDebugInfo)
        {
            // Get the type of build products we're creating
            BuildProductType Type = BuildProductType.RequiredResource;

            switch (Config.Type)
            {
            case UEBuildBinaryType.Executable:
                Type = BuildProductType.Executable;
                break;

            case UEBuildBinaryType.DynamicLinkLibrary:
                Type = BuildProductType.DynamicLibrary;
                break;

            case UEBuildBinaryType.StaticLibrary:
                Type = BuildProductType.StaticLibrary;
                break;
            }

            // Add the primary build products
            string DebugExtension = UEBuildPlatform.GetBuildPlatform(Target.Platform).GetDebugInfoExtension(Target, Config.Type);

            foreach (FileReference OutputFilePath in Config.OutputFilePaths)
            {
                AddBuildProductAndDebugFile(OutputFilePath, Type, DebugExtension, BuildProducts, ToolChain, bCreateDebugInfo);
            }

            // Add the console app, if there is one
            if (Config.Type == UEBuildBinaryType.Executable && Config.bBuildAdditionalConsoleApp)
            {
                foreach (FileReference OutputFilePath in Config.OutputFilePaths)
                {
                    AddBuildProductAndDebugFile(GetAdditionalConsoleAppPath(OutputFilePath), Type, DebugExtension, BuildProducts, ToolChain, bCreateDebugInfo);
                }
            }

            // Add any additional build products from the modules in this binary, including additional bundle resources/dylibs on Mac.
            List <string> Libraries = new List <string>();
            List <UEBuildBundleResource> BundleResources = new List <UEBuildBundleResource>();

            GatherAdditionalResources(Libraries, BundleResources);

            // Add any extra files from the toolchain
            ToolChain.ModifyBuildProducts(Target, this, Libraries, BundleResources, BuildProducts);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Creates a receipt for this binary.
        /// </summary>
        /// <param name="ToolChain">Toolchain for the target platform</param>
        /// <param name="BuildPlatform">Platform that we're building for</param>
        public virtual BuildReceipt MakeReceipt(IUEToolChain ToolChain)
        {
            BuildReceipt Receipt = new BuildReceipt();

            // Get the type of build products we're creating
            BuildProductType Type = BuildProductType.RequiredResource;

            switch (Config.Type)
            {
            case UEBuildBinaryType.Executable:
                Type = BuildProductType.Executable;
                break;

            case UEBuildBinaryType.DynamicLinkLibrary:
                Type = BuildProductType.DynamicLibrary;
                break;

            case UEBuildBinaryType.StaticLibrary:
                Type = BuildProductType.StaticLibrary;
                break;
            }

            // Add the primary build products
            string DebugExtension = UEBuildPlatform.GetBuildPlatform(Target.Platform).GetDebugInfoExtension(Config.Type);

            foreach (string OutputFilePath in Config.OutputFilePaths)
            {
                AddBuildProductAndDebugFile(OutputFilePath, Type, DebugExtension, Receipt);
            }

            // Add the console app, if there is one
            if (Config.Type == UEBuildBinaryType.Executable && Config.bBuildAdditionalConsoleApp)
            {
                foreach (string OutputFilePath in Config.OutputFilePaths)
                {
                    AddBuildProductAndDebugFile(GetAdditionalConsoleAppPath(OutputFilePath), Type, DebugExtension, Receipt);
                }
            }

            // Add any extra files from the toolchain
            ToolChain.AddFilesToReceipt(Receipt, this);
            return(Receipt);
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Returns the standard path to the build receipt for a given target
        /// </summary>
        /// <param name="BaseDir">Base directory for the target being built; either the project directory or engine directory.</param>
        /// <param name="TargetName">The target being built</param>
        /// <param name="Platform">The target platform</param>
        /// <param name="Configuration">The target configuration</param>
        /// <param name="BuildArchitecture">The architecture being built</param>
        /// <returns>Path to the receipt for this target</returns>
        public static FileReference GetDefaultPath(DirectoryReference BaseDir, string TargetName, UnrealTargetPlatform Platform, UnrealTargetConfiguration Configuration, string BuildArchitecture)
        {
            // Get the architecture suffix. Platforms have the option of overriding whether to include this string in filenames.
            string ArchitectureSuffix = "";

            if (!String.IsNullOrEmpty(BuildArchitecture) && UEBuildPlatform.GetBuildPlatform(Platform).RequiresArchitectureSuffix())
            {
                ArchitectureSuffix = BuildArchitecture;
            }

            // Build the output filename
            if (String.IsNullOrEmpty(ArchitectureSuffix) && Configuration == UnrealTargetConfiguration.Development)
            {
                return(FileReference.Combine(BaseDir, "Binaries", Platform.ToString(), String.Format("{0}.target", TargetName)));
            }
            else
            {
                return(FileReference.Combine(BaseDir, "Binaries", Platform.ToString(), String.Format("{0}-{1}-{2}{3}.target", TargetName, Platform.ToString(), Configuration.ToString(), ArchitectureSuffix)));
            }
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Get the default path for a target's version file.
        /// </summary>
        /// <param name="OutputDirectory">The output directory for the executable. For MacOS, this is the directory containing the app bundle.</param>
        /// <param name="TargetName">Name of the target being built</param>
        /// <param name="Platform">Platform the target is being built for</param>
        /// <param name="Configuration">The configuration being built</param>
        /// <param name="Architecture">Architecture of the target being built</param>
        /// <returns>Path to the target's version file</returns>
        public static FileReference GetFileNameForTarget(DirectoryReference OutputDirectory, string TargetName, UnrealTargetPlatform Platform, UnrealTargetConfiguration Configuration, string Architecture)
        {
            // Get the architecture suffix. Platforms have the option of overriding whether to include this string in filenames.
            string ArchitectureSuffix = "";

            if (UEBuildPlatform.GetBuildPlatform(Platform).RequiresArchitectureSuffix())
            {
                ArchitectureSuffix = Architecture;
            }

            // Build the output filename
            if (String.IsNullOrEmpty(ArchitectureSuffix) && Configuration == UnrealTargetConfiguration.Development)
            {
                return(FileReference.Combine(OutputDirectory, String.Format("{0}.version", TargetName)));
            }
            else
            {
                return(FileReference.Combine(OutputDirectory, String.Format("{0}-{1}-{2}{3}.version", TargetName, Platform.ToString(), Configuration.ToString(), ArchitectureSuffix)));
            }
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Gets all build products produced by this binary
        /// </summary>
        /// <param name="ToolChain">The platform toolchain</param>
        /// <param name="BuildProducts">Mapping of produced build product to type</param>
        public virtual void GetBuildProducts(UEToolChain ToolChain, Dictionary <FileReference, BuildProductType> BuildProducts)
        {
            // Get the type of build products we're creating
            BuildProductType Type = BuildProductType.RequiredResource;

            switch (Config.Type)
            {
            case UEBuildBinaryType.Executable:
                Type = BuildProductType.Executable;
                break;

            case UEBuildBinaryType.DynamicLinkLibrary:
                Type = BuildProductType.DynamicLibrary;
                break;

            case UEBuildBinaryType.StaticLibrary:
                Type = BuildProductType.StaticLibrary;
                break;
            }

            // Add the primary build products
            string DebugExtension = UEBuildPlatform.GetBuildPlatform(Target.Platform).GetDebugInfoExtension(Config.Type);

            foreach (FileReference OutputFilePath in Config.OutputFilePaths)
            {
                AddBuildProductAndDebugFile(OutputFilePath, Type, DebugExtension, BuildProducts, ToolChain);
            }

            // Add the console app, if there is one
            if (Config.Type == UEBuildBinaryType.Executable && Config.bBuildAdditionalConsoleApp)
            {
                foreach (FileReference OutputFilePath in Config.OutputFilePaths)
                {
                    AddBuildProductAndDebugFile(GetAdditionalConsoleAppPath(OutputFilePath), Type, DebugExtension, BuildProducts, ToolChain);
                }
            }

            // Add any extra files from the toolchain
            ToolChain.ModifyBuildProducts(this, BuildProducts);
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Writes information about the targets in an assembly to a file
        /// </summary>
        /// <param name="ProjectFile">The project file for the targets being built</param>
        /// <param name="Assembly">The rules assembly for this target</param>
        /// <param name="OutputFile">Output file to write to</param>
        /// <param name="Arguments"></param>
        public static void WriteTargetInfo(FileReference ProjectFile, RulesAssembly Assembly, FileReference OutputFile, CommandLineArguments Arguments)
        {
            // Construct all the targets in this assembly
            List <string> TargetNames = new List <string>();

            Assembly.GetAllTargetNames(TargetNames, false);

            // Write the output file
            DirectoryReference.CreateDirectory(OutputFile.Directory);
            using (JsonWriter Writer = new JsonWriter(OutputFile))
            {
                Writer.WriteObjectStart();
                Writer.WriteArrayStart("Targets");
                foreach (string TargetName in TargetNames)
                {
                    // Construct the rules object
                    TargetRules TargetRules;
                    try
                    {
                        string Architecture = UEBuildPlatform.GetBuildPlatform(BuildHostPlatform.Current.Platform).GetDefaultArchitecture(ProjectFile);
                        TargetRules = Assembly.CreateTargetRules(TargetName, BuildHostPlatform.Current.Platform, UnrealTargetConfiguration.Development, Architecture, ProjectFile, Arguments);
                    }
                    catch (Exception Ex)
                    {
                        Log.TraceWarning("Unable to construct target rules for {0}", TargetName);
                        Log.TraceVerbose(ExceptionUtils.FormatException(Ex));
                        continue;
                    }

                    // Write the target info
                    Writer.WriteObjectStart();
                    Writer.WriteValue("Name", TargetName);
                    Writer.WriteValue("Path", Assembly.GetTargetFileName(TargetName).ToString());
                    Writer.WriteValue("Type", TargetRules.Type.ToString());
                    Writer.WriteObjectEnd();
                }
                Writer.WriteArrayEnd();
                Writer.WriteObjectEnd();
            }
        }
        /**
         *	Register the given platforms UEPlatformProjectGenerator instance
         *
         *	@param	InPlatform			The UnrealTargetPlatform to register with
         *	@param	InProjectGenerator	The UEPlatformProjectGenerator instance to use for the InPlatform
         */
        public static void RegisterPlatformProjectGenerator(UnrealTargetPlatform InPlatform, UEPlatformProjectGenerator InProjectGenerator)
        {
            // Make sure the build platform is legal
            var BuildPlatform = UEBuildPlatform.GetBuildPlatform(InPlatform, true);

            if (BuildPlatform != null)
            {
                if (ProjectGeneratorDictionary.ContainsKey(InPlatform) == true)
                {
                    Log.TraceInformation("RegisterPlatformProjectGenerator Warning: Registering project generator {0} for {1} when it is already set to {2}",
                                         InProjectGenerator.ToString(), InPlatform.ToString(), ProjectGeneratorDictionary[InPlatform].ToString());
                    ProjectGeneratorDictionary[InPlatform] = InProjectGenerator;
                }
                else
                {
                    ProjectGeneratorDictionary.Add(InPlatform, InProjectGenerator);
                }
            }
            else
            {
                Log.TraceVerbose("Skipping project file generator registration for {0} due to no valid BuildPlatform.", InPlatform.ToString());
            }
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Setup the binaries for this target
        /// </summary>
        protected override void SetupBinaries()
        {
            base.SetupBinaries();

            {
                // Make the editor executable.
                UEBuildBinaryConfiguration Config = new UEBuildBinaryConfiguration(InType: UEBuildBinaryType.Executable,
                                                                                   InOutputFilePaths: OutputPaths,
                                                                                   InIntermediateDirectory: EngineIntermediateDirectory,
                                                                                   bInCreateImportLibrarySeparately: (ShouldCompileMonolithic() ? false : true),
                                                                                   bInAllowExports: !ShouldCompileMonolithic(),
                                                                                   InModuleNames: new List <string>()
                {
                    "Launch"
                });

                // This "default" game module is required by the editor executable in case
                // you want to run it in content-only mode.
                if (!ExtraModuleNames.Contains("UE4Game"))
                {
                    ExtraModuleNames.Add("UE4Game");
                }

                AppBinaries.Add(new UEBuildBinaryCPP(this, Config));
            }

            // Add the other modules that we want to compile along with the executable.  These aren't necessarily
            // dependencies to any of the other modules we're building, so we need to opt in to compile them.
            {
                // Modules should properly identify the 'extra modules' they need now.
                // There should be nothing here!
            }

            // Allow the platform to setup binaries
            UEBuildPlatform.GetBuildPlatform(Platform).SetupBinaries(this);
        }
Ejemplo n.º 27
0
        public static List <TargetDescriptor> ParseCommandLine(string[] Arguments, ref FileReference ProjectFile)
        {
            UnrealTargetPlatform      Platform      = UnrealTargetPlatform.Unknown;
            UnrealTargetConfiguration Configuration = UnrealTargetConfiguration.Unknown;
            List <string>             TargetNames   = new List <string>();
            string            Architecture          = null;
            string            RemoteRoot            = null;
            List <OnlyModule> OnlyModules           = new List <OnlyModule>();
            FileReference     ForeignPlugin         = null;
            string            ForceReceiptFileName  = null;

            // If true, the recompile was launched by the editor.
            bool bIsEditorRecompile = false;

            // Settings for creating/using static libraries for the engine
            List <string> PossibleTargetNames = new List <string>();

            for (int ArgumentIndex = 0; ArgumentIndex < Arguments.Length; ArgumentIndex++)
            {
                string Argument = Arguments[ArgumentIndex];
                if (!Argument.StartsWith("-"))
                {
                    UnrealTargetPlatform ParsedPlatform;
                    if (Enum.TryParse(Argument, true, out ParsedPlatform) && ParsedPlatform != UnrealTargetPlatform.Unknown)
                    {
                        if (Platform != UnrealTargetPlatform.Unknown)
                        {
                            throw new BuildException("Multiple platforms specified on command line (first {0}, then {1})", Platform, ParsedPlatform);
                        }
                        Platform = ParsedPlatform;
                        continue;
                    }

                    UnrealTargetConfiguration ParsedConfiguration;
                    if (Enum.TryParse(Argument, true, out ParsedConfiguration) && ParsedConfiguration != UnrealTargetConfiguration.Unknown)
                    {
                        if (Configuration != UnrealTargetConfiguration.Unknown)
                        {
                            throw new BuildException("Multiple configurations specified on command line (first {0}, then {1})", Configuration, ParsedConfiguration);
                        }
                        Configuration = ParsedConfiguration;
                        continue;
                    }

                    PossibleTargetNames.Add(Argument);
                }
                else
                {
                    switch (Arguments[ArgumentIndex].ToUpperInvariant())
                    {
                    case "-MODULE":
                        // Specifies a module to recompile.  Can be specified more than once on the command-line to compile multiple specific modules.
                    {
                        if (ArgumentIndex + 1 >= Arguments.Length)
                        {
                            throw new BuildException("Expected module name after -Module argument, but found nothing.");
                        }
                        string OnlyModuleName = Arguments[++ArgumentIndex];

                        OnlyModules.Add(new OnlyModule(OnlyModuleName));
                    }
                    break;

                    case "-MODULEWITHSUFFIX":
                    {
                        // Specifies a module name to compile along with a suffix to append to the DLL file name.  Can be specified more than once on the command-line to compile multiple specific modules.
                        if (ArgumentIndex + 2 >= Arguments.Length)
                        {
                            throw new BuildException("Expected module name and module suffix -ModuleWithSuffix argument");
                        }

                        string OnlyModuleName   = Arguments[++ArgumentIndex];
                        string OnlyModuleSuffix = Arguments[++ArgumentIndex];

                        OnlyModules.Add(new OnlyModule(OnlyModuleName, OnlyModuleSuffix));
                    }
                    break;

                    case "-PLUGIN":
                    {
                        if (ArgumentIndex + 1 >= Arguments.Length)
                        {
                            throw new BuildException("Expected plugin filename after -Plugin argument, but found nothing.");
                        }
                        if (ForeignPlugin != null)
                        {
                            throw new BuildException("Only one foreign plugin to compile may be specified per invocation");
                        }
                        ForeignPlugin = new FileReference(Arguments[++ArgumentIndex]);
                    }
                    break;

                    case "-RECEIPT":
                    {
                        if (ArgumentIndex + 1 >= Arguments.Length)
                        {
                            throw new BuildException("Expected path to the generated receipt after -Receipt argument, but found nothing.");
                        }

                        ForceReceiptFileName = Arguments[++ArgumentIndex];
                    }
                    break;

                    // -RemoteRoot <RemoteRoot> sets where the generated binaries are CookerSynced.
                    case "-REMOTEROOT":
                        if (ArgumentIndex + 1 >= Arguments.Length)
                        {
                            throw new BuildException("Expected path after -RemoteRoot argument, but found nothing.");
                        }
                        ArgumentIndex++;
                        if (Arguments[ArgumentIndex].StartsWith("xe:\\") == true)
                        {
                            RemoteRoot = Arguments[ArgumentIndex].Substring("xe:\\".Length);
                        }
                        else if (Arguments[ArgumentIndex].StartsWith("devkit:\\") == true)
                        {
                            RemoteRoot = Arguments[ArgumentIndex].Substring("devkit:\\".Length);
                        }
                        break;

                    case "-DEPLOY":
                        // Does nothing at the moment...
                        break;

                    case "-EDITORRECOMPILE":
                    {
                        bIsEditorRecompile = true;
                    }
                    break;

                    default:
                        break;
                    }
                }
            }

            if (Platform == UnrealTargetPlatform.Unknown)
            {
                throw new BuildException("Couldn't find platform name.");
            }
            if (Configuration == UnrealTargetConfiguration.Unknown)
            {
                throw new BuildException("Couldn't determine configuration name.");
            }

            List <TargetDescriptor> Targets = new List <TargetDescriptor>();

            if (PossibleTargetNames.Count > 0)
            {
                // We have possible targets!
                string PossibleTargetName = PossibleTargetNames[0];

                // If Engine is installed, the PossibleTargetName could contain a path
                string TargetName = PossibleTargetName;

                // If a project file was not specified see if we can find one
                if (ProjectFile == null && UProjectInfo.TryGetProjectForTarget(TargetName, out ProjectFile))
                {
                    Log.TraceVerbose("Found project file for {0} - {1}", TargetName, ProjectFile);
                }

                UEBuildPlatform BuildPlatform = UEBuildPlatform.GetBuildPlatform(Platform);

                if (Architecture == null)
                {
                    Architecture = BuildPlatform.GetDefaultArchitecture(ProjectFile);
                }

                Targets.Add(new TargetDescriptor()
                {
                    ProjectFile          = ProjectFile,
                    TargetName           = TargetName,
                    Platform             = Platform,
                    Configuration        = Configuration,
                    Architecture         = Architecture,
                    bIsEditorRecompile   = bIsEditorRecompile,
                    RemoteRoot           = RemoteRoot,
                    OnlyModules          = OnlyModules,
                    ForeignPlugin        = ForeignPlugin,
                    ForceReceiptFileName = ForceReceiptFileName
                });
            }
            if (Targets.Count == 0)
            {
                throw new BuildException("No target name was specified on the command-line.");
            }
            return(Targets);
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Main entry point
        /// </summary>
        /// <param name="Arguments">Command-line arguments</param>
        /// <returns>One of the values of ECompilationResult</returns>
        public override int Execute(CommandLineArguments Arguments)
        {
            Arguments.ApplyTo(this);

            // Create the build configuration object, and read the settings
            BuildConfiguration BuildConfiguration = new BuildConfiguration();

            XmlConfig.ApplyTo(BuildConfiguration);
            Arguments.ApplyTo(BuildConfiguration);

            // Parse all the targets being built
            List <TargetDescriptor> TargetDescriptors = TargetDescriptor.ParseCommandLine(Arguments, BuildConfiguration.bUsePrecompiled, bSkipRulesCompile);

            if (TargetDescriptors.Count == 0)
            {
                throw new BuildException("No targets specified to clean");
            }

            // Also add implicit descriptors for cleaning UnrealBuildTool
            if (!BuildConfiguration.bDoNotBuildUHT)
            {
                const string UnrealHeaderToolTarget = "UnrealHeaderTool";

                // Get a list of project files to clean UHT for
                List <FileReference> ProjectFiles = new List <FileReference>();
                foreach (TargetDescriptor TargetDesc in TargetDescriptors)
                {
                    if (TargetDesc.Name != UnrealHeaderToolTarget && !RemoteMac.HandlesTargetPlatform(TargetDesc.Platform))
                    {
                        if (ProjectFiles.Count == 0)
                        {
                            ProjectFiles.Add(null);
                        }
                        if (TargetDesc.ProjectFile != null && !ProjectFiles.Contains(TargetDesc.ProjectFile))
                        {
                            ProjectFiles.Add(TargetDesc.ProjectFile);
                        }
                    }
                }

                // Add descriptors for cleaning UHT with all these projects
                if (ProjectFiles.Count > 0)
                {
                    UnrealTargetConfiguration Configuration = BuildConfiguration.bForceDebugUnrealHeaderTool ? UnrealTargetConfiguration.Debug : UnrealTargetConfiguration.Development;
                    string Architecture = UEBuildPlatform.GetBuildPlatform(BuildHostPlatform.Current.Platform).GetDefaultArchitecture(null);
                    foreach (FileReference ProjectFile in ProjectFiles)
                    {
                        TargetDescriptors.Add(new TargetDescriptor(ProjectFile, UnrealHeaderToolTarget, BuildHostPlatform.Current.Platform, Configuration, Architecture, null));
                    }
                }
            }

            // Output the list of targets that we're cleaning
            Log.TraceInformation("Cleaning {0} binaries...", StringUtils.FormatList(TargetDescriptors.Select(x => x.Name).Distinct()));

            // Loop through all the targets, and clean them all
            HashSet <FileReference>      FilesToDelete       = new HashSet <FileReference>();
            HashSet <DirectoryReference> DirectoriesToDelete = new HashSet <DirectoryReference>();

            foreach (TargetDescriptor TargetDescriptor in TargetDescriptors)
            {
                // Create the rules assembly
                RulesAssembly RulesAssembly = RulesCompiler.CreateTargetRulesAssembly(TargetDescriptor.ProjectFile, TargetDescriptor.Name, bSkipRulesCompile, BuildConfiguration.bUsePrecompiled, TargetDescriptor.ForeignPlugin);

                // Create the rules object
                ReadOnlyTargetRules Target = new ReadOnlyTargetRules(RulesAssembly.CreateTargetRules(TargetDescriptor.Name, TargetDescriptor.Platform, TargetDescriptor.Configuration, TargetDescriptor.Architecture, TargetDescriptor.ProjectFile, TargetDescriptor.AdditionalArguments));

                // Find the base folders that can contain binaries
                List <DirectoryReference> BaseDirs = new List <DirectoryReference>();
                BaseDirs.Add(UnrealBuildTool.EngineDirectory);
                BaseDirs.Add(UnrealBuildTool.EnterpriseDirectory);
                foreach (FileReference Plugin in Plugins.EnumeratePlugins(Target.ProjectFile))
                {
                    BaseDirs.Add(Plugin.Directory);
                }
                if (Target.ProjectFile != null)
                {
                    BaseDirs.Add(Target.ProjectFile.Directory);
                }

                // If we're running a precompiled build, remove anything under the engine folder
                BaseDirs.RemoveAll(x => RulesAssembly.IsReadOnly(x));

                // Get all the names which can prefix build products
                List <string> NamePrefixes = new List <string>();
                if (Target.Type != TargetType.Program)
                {
                    NamePrefixes.Add(UEBuildTarget.GetAppNameForTargetType(Target.Type));
                }
                NamePrefixes.Add(Target.Name);

                // Get the suffixes for this configuration
                List <string> NameSuffixes = new List <string>();
                if (Target.Configuration == Target.UndecoratedConfiguration)
                {
                    NameSuffixes.Add("");
                }
                NameSuffixes.Add(String.Format("-{0}-{1}", Target.Platform.ToString(), Target.Configuration.ToString()));
                if (!String.IsNullOrEmpty(Target.Architecture))
                {
                    NameSuffixes.AddRange(NameSuffixes.ToArray().Select(x => x + Target.Architecture));
                }

                // Add all the makefiles and caches to be deleted
                FilesToDelete.Add(TargetMakefile.GetLocation(Target.ProjectFile, Target.Name, Target.Platform, Target.Configuration));
                FilesToDelete.UnionWith(SourceFileMetadataCache.GetFilesToClean(Target.ProjectFile));
                FilesToDelete.UnionWith(ActionHistory.GetFilesToClean(Target.ProjectFile, Target.Name, Target.Platform, Target.Type));

                // Add all the intermediate folders to be deleted
                foreach (DirectoryReference BaseDir in BaseDirs)
                {
                    foreach (string NamePrefix in NamePrefixes)
                    {
                        DirectoryReference GeneratedCodeDir = DirectoryReference.Combine(BaseDir, "Intermediate", "Build", Target.Platform.ToString(), NamePrefix, "Inc");
                        if (DirectoryReference.Exists(GeneratedCodeDir))
                        {
                            DirectoriesToDelete.Add(GeneratedCodeDir);
                        }

                        DirectoryReference IntermediateDir = DirectoryReference.Combine(BaseDir, "Intermediate", "Build", Target.Platform.ToString(), NamePrefix, Target.Configuration.ToString());
                        if (DirectoryReference.Exists(IntermediateDir))
                        {
                            DirectoriesToDelete.Add(IntermediateDir);
                        }
                    }
                }

                // List of additional files and directories to clean, specified by the target platform
                List <FileReference>      AdditionalFilesToDelete       = new List <FileReference>();
                List <DirectoryReference> AdditionalDirectoriesToDelete = new List <DirectoryReference>();

                // Add all the build products from this target
                string[] NamePrefixesArray = NamePrefixes.Distinct().ToArray();
                string[] NameSuffixesArray = NameSuffixes.Distinct().ToArray();
                foreach (DirectoryReference BaseDir in BaseDirs)
                {
                    DirectoryReference BinariesDir = DirectoryReference.Combine(BaseDir, "Binaries", Target.Platform.ToString());
                    if (DirectoryReference.Exists(BinariesDir))
                    {
                        UEBuildPlatform.GetBuildPlatform(Target.Platform).FindBuildProductsToClean(BinariesDir, NamePrefixesArray, NameSuffixesArray, AdditionalFilesToDelete, AdditionalDirectoriesToDelete);
                    }
                }

                // Get all the additional intermediate folders created by this platform
                UEBuildPlatform.GetBuildPlatform(Target.Platform).FindAdditionalBuildProductsToClean(Target, AdditionalFilesToDelete, AdditionalDirectoriesToDelete);

                // Add the platform's files and directories to the main list
                FilesToDelete.UnionWith(AdditionalFilesToDelete);
                DirectoriesToDelete.UnionWith(AdditionalDirectoriesToDelete);
            }

            // Delete all the directories, then all the files. By sorting the list of directories before we delete them, we avoid spamming the log if a parent directory is deleted first.
            foreach (DirectoryReference DirectoryToDelete in DirectoriesToDelete.OrderBy(x => x.FullName))
            {
                if (DirectoryReference.Exists(DirectoryToDelete))
                {
                    Log.TraceVerbose("    Deleting {0}{1}...", DirectoryToDelete, Path.DirectorySeparatorChar);
                    try
                    {
                        DirectoryReference.Delete(DirectoryToDelete, true);
                    }
                    catch (Exception Ex)
                    {
                        throw new BuildException(Ex, "Unable to delete {0} ({1})", DirectoryToDelete, Ex.Message.TrimEnd());
                    }
                }
            }

            foreach (FileReference FileToDelete in FilesToDelete.OrderBy(x => x.FullName))
            {
                if (FileReference.Exists(FileToDelete))
                {
                    Log.TraceVerbose("    Deleting " + FileToDelete);
                    try
                    {
                        FileReference.Delete(FileToDelete);
                    }
                    catch (Exception Ex)
                    {
                        throw new BuildException(Ex, "Unable to delete {0} ({1})", FileToDelete, Ex.Message.TrimEnd());
                    }
                }
            }

            // Also clean all the remote targets
            for (int Idx = 0; Idx < TargetDescriptors.Count; Idx++)
            {
                TargetDescriptor TargetDescriptor = TargetDescriptors[Idx];
                if (RemoteMac.HandlesTargetPlatform(TargetDescriptor.Platform))
                {
                    RemoteMac RemoteMac = new RemoteMac(TargetDescriptor.ProjectFile);
                    RemoteMac.Clean(TargetDescriptor);
                }
            }

            return(0);
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Gets all build products produced by this binary
        /// </summary>
        /// <param name="Target">The target being built</param>
        /// <param name="ToolChain">The platform toolchain</param>
        /// <param name="BuildProducts">Mapping of produced build product to type</param>
        /// <param name="bCreateDebugInfo">Whether debug info is enabled for this binary</param>
        public void GetBuildProducts(ReadOnlyTargetRules Target, UEToolChain ToolChain, Dictionary <FileReference, BuildProductType> BuildProducts, bool bCreateDebugInfo)
        {
            // Add all the precompiled outputs
            foreach (UEBuildModuleCPP Module in Modules.OfType <UEBuildModuleCPP>())
            {
                if (Module.Rules.bPrecompile)
                {
                    if (Module.GeneratedCodeDirectory != null && DirectoryReference.Exists(Module.GeneratedCodeDirectory))
                    {
                        foreach (FileReference GeneratedCodeFile in DirectoryReference.EnumerateFiles(Module.GeneratedCodeDirectory))
                        {
                            // Exclude timestamp files, since they're always updated and cause collisions between builds
                            if (!GeneratedCodeFile.GetFileName().Equals("Timestamp", StringComparison.OrdinalIgnoreCase) && !GeneratedCodeFile.HasExtension(".cpp"))
                            {
                                BuildProducts.Add(GeneratedCodeFile, BuildProductType.BuildResource);
                            }
                        }
                    }
                    if (Target.LinkType == TargetLinkType.Monolithic)
                    {
                        FileReference PrecompiledManifestLocation = Module.PrecompiledManifestLocation;
                        BuildProducts.Add(PrecompiledManifestLocation, BuildProductType.BuildResource);

                        PrecompiledManifest ModuleManifest = PrecompiledManifest.Read(PrecompiledManifestLocation);
                        foreach (FileReference OutputFile in ModuleManifest.OutputFiles)
                        {
                            if (!BuildProducts.ContainsKey(OutputFile))
                            {
                                BuildProducts.Add(OutputFile, BuildProductType.BuildResource);
                            }
                        }
                    }
                }
            }

            // Add all the binary outputs
            if (!Target.bDisableLinking)
            {
                // Get the type of build products we're creating
                BuildProductType OutputType = BuildProductType.RequiredResource;
                switch (Type)
                {
                case UEBuildBinaryType.Executable:
                    OutputType = BuildProductType.Executable;
                    break;

                case UEBuildBinaryType.DynamicLinkLibrary:
                    OutputType = BuildProductType.DynamicLibrary;
                    break;

                case UEBuildBinaryType.StaticLibrary:
                    OutputType = BuildProductType.BuildResource;
                    break;
                }

                // Add the primary build products
                string[] DebugExtensions = UEBuildPlatform.GetBuildPlatform(Target.Platform).GetDebugInfoExtensions(Target, Type);
                foreach (FileReference OutputFilePath in OutputFilePaths)
                {
                    AddBuildProductAndDebugFiles(OutputFilePath, OutputType, DebugExtensions, BuildProducts, ToolChain, bCreateDebugInfo);
                }

                // Add the console app, if there is one
                if (Type == UEBuildBinaryType.Executable && bBuildAdditionalConsoleApp)
                {
                    foreach (FileReference OutputFilePath in OutputFilePaths)
                    {
                        AddBuildProductAndDebugFiles(GetAdditionalConsoleAppPath(OutputFilePath), OutputType, DebugExtensions, BuildProducts, ToolChain, bCreateDebugInfo);
                    }
                }

                // Add any additional build products from the modules in this binary, including additional bundle resources/dylibs on Mac.
                List <string> Libraries = new List <string>();
                List <UEBuildBundleResource> BundleResources = new List <UEBuildBundleResource>();
                GatherAdditionalResources(Libraries, BundleResources);

                // Add any extra files from the toolchain
                ToolChain.ModifyBuildProducts(Target, this, Libraries, BundleResources, BuildProducts);
            }
        }
Ejemplo n.º 30
0
 /// <summary>
 /// Check whether the given platform supports XGE
 /// </summary>
 /// <param name="Platform">Platform to check</param>
 /// <returns>True if the platform supports XGE</returns>
 public static bool CanUseXGE(UnrealTargetPlatform Platform)
 {
     return(UEBuildPlatform.IsPlatformAvailable(Platform) && UEBuildPlatform.GetBuildPlatform(Platform).CanUseXGE());
 }