Esempio 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("WITH_DATABASE_SUPPORT=0");                      //@todo linux: valid?

            // During the native builds, check the system includes as well (check toolchain when cross-compiling?)
            string BaseLinuxPath = SDK.GetBaseLinuxPathForArchitecture(Target.Architecture);

            if (BuildHostPlatform.Current.Platform == UnrealTargetPlatform.Linux && String.IsNullOrEmpty(BaseLinuxPath))
            {
                CompileEnvironment.IncludePaths.SystemIncludePaths.Add(new DirectoryReference("/usr/include"));
            }

            if (CompileEnvironment.bAllowLTCG != LinkEnvironment.bAllowLTCG)
            {
                Log.TraceWarning("Inconsistency between LTCG settings in Compile and Link environments: link one takes priority");
                CompileEnvironment.bAllowLTCG = LinkEnvironment.bAllowLTCG;
            }

            // disable to LTO for modular builds
            if (CompileEnvironment.bAllowLTCG && Target.LinkType != TargetLinkType.Monolithic)
            {
                Log.TraceWarning("LTO (LTCG) for modular builds is not supported, disabling it");
                CompileEnvironment.bAllowLTCG = false;
                LinkEnvironment.bAllowLTCG    = false;
            }

            // link with Linux libraries.
            LinkEnvironment.AdditionalLibraries.Add("pthread");

            // let this class or a sub class do settings specific to that class
            SetUpSpecificEnvironment(CompileEnvironment, LinkEnvironment);
        }
        /// <summary>
        /// Setup the target environment for building
        /// </summary>
        /// <param name="Target">Settings for the target being compiled</param>
        /// <param name="CompileEnvironment">The compile environment for this target</param>
        /// <param name="LinkEnvironment">The link environment for this target</param>
        public override void SetUpEnvironment(ReadOnlyTargetRules Target, CppCompileEnvironment CompileEnvironment, LinkEnvironment LinkEnvironment)
        {
            // During the native builds, check the system includes as well (check toolchain when cross-compiling?)
            string BaseLinuxPath = SDK.GetBaseLinuxPathForArchitecture(Target.Architecture);

            if (BuildHostPlatform.Current.Platform == UnrealTargetPlatform.Linux && String.IsNullOrEmpty(BaseLinuxPath))
            {
                CompileEnvironment.SystemIncludePaths.Add(new DirectoryReference("/usr/include"));
            }

            if (CompileEnvironment.bPGOOptimize != LinkEnvironment.bPGOOptimize)
            {
                throw new BuildException("Inconsistency between PGOOptimize settings in Compile ({0}) and Link ({1}) environments",
                                         CompileEnvironment.bPGOOptimize,
                                         LinkEnvironment.bPGOOptimize
                                         );
            }

            if (CompileEnvironment.bPGOProfile != LinkEnvironment.bPGOProfile)
            {
                throw new BuildException("Inconsistency between PGOProfile settings in Compile ({0}) and Link ({1}) environments",
                                         CompileEnvironment.bPGOProfile,
                                         LinkEnvironment.bPGOProfile
                                         );
            }

            if (CompileEnvironment.bPGOOptimize)
            {
                DirectoryReference BaseDir = UnrealBuildTool.EngineDirectory;
                if (Target.ProjectFile != null)
                {
                    BaseDir = DirectoryReference.FromFile(Target.ProjectFile);
                }
                CompileEnvironment.PGODirectory      = Path.Combine(BaseDir.FullName, "Build", Target.Platform.ToString(), "PGO").Replace('\\', '/') + "/";
                CompileEnvironment.PGOFilenamePrefix = "profile.profdata";

                LinkEnvironment.PGODirectory      = CompileEnvironment.PGODirectory;
                LinkEnvironment.PGOFilenamePrefix = CompileEnvironment.PGOFilenamePrefix;
            }

            // For consistency with other platforms, also enable LTO whenever doing profile-guided optimizations.
            // Obviously both PGI (instrumented) and PGO (optimized) binaries need to have that
            if (CompileEnvironment.bPGOProfile || CompileEnvironment.bPGOOptimize)
            {
                CompileEnvironment.bAllowLTCG = true;
                LinkEnvironment.bAllowLTCG    = true;
            }

            if (CompileEnvironment.bAllowLTCG != LinkEnvironment.bAllowLTCG)
            {
                throw new BuildException("Inconsistency between LTCG settings in Compile ({0}) and Link ({1}) environments",
                                         CompileEnvironment.bAllowLTCG,
                                         LinkEnvironment.bAllowLTCG
                                         );
            }

            // link with Linux libraries.
            LinkEnvironment.SystemLibraries.Add("pthread");

            // let this class or a sub class do settings specific to that class
            SetUpSpecificEnvironment(Target, CompileEnvironment, LinkEnvironment);
        }