Exemplo n.º 1
0
        private void ExportModuleCpp(UEBuildModuleCPP ModuleCPP, CppCompileEnvironment ModuleCompileEnvironment, JsonWriter Writer)
        {
            Writer.WriteValue("GeneratedCodeDirectory", ModuleCPP.GeneratedCodeDirectory != null ? ModuleCPP.GeneratedCodeDirectory.FullName  : string.Empty);

            ToolchainInfo ModuleToolchainInfo = GenerateToolchainInfo(ModuleCompileEnvironment);

            if (!ModuleToolchainInfo.Equals(RootToolchainInfo))
            {
                Writer.WriteObjectStart("ToolchainInfo");
                foreach (Tuple <string, object> Field in ModuleToolchainInfo.GetDiff(RootToolchainInfo))
                {
                    WriteField(ModuleCPP.Name, Writer, Field);
                }
                Writer.WriteObjectEnd();
            }

            if (ModuleCompileEnvironment.PrecompiledHeaderIncludeFilename != null)
            {
                string CorrectFilePathPch;
                if (ExtractWrappedIncludeFile(ModuleCompileEnvironment.PrecompiledHeaderIncludeFilename, out CorrectFilePathPch))
                {
                    Writer.WriteValue("SharedPCHFilePath", CorrectFilePathPch);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Write C++ toolchain information to JSON writer
        /// </summary>
        /// <param name="Target"></param>
        /// <param name="Writer"></param>
        private void ExportEnvironmentToJson(UEBuildTarget Target, JsonWriter Writer)
        {
            CppCompileEnvironment GlobalCompileEnvironment = Target.CreateCompileEnvironmentForProjectFiles();

            RootToolchainInfo = GenerateToolchainInfo(GlobalCompileEnvironment);

            Writer.WriteObjectStart("ToolchainInfo");
            foreach (Tuple <string, object> Field in RootToolchainInfo.GetFields())
            {
                WriteField(Target.TargetName, Writer, Field);
            }
            Writer.WriteObjectEnd();

            Writer.WriteArrayStart("EnvironmentIncludePaths");
            foreach (DirectoryReference Path in GlobalCompileEnvironment.UserIncludePaths)
            {
                Writer.WriteValue(Path.FullName);
            }
            foreach (DirectoryReference Path in GlobalCompileEnvironment.SystemIncludePaths)
            {
                Writer.WriteValue(Path.FullName);
            }

            if (UEBuildPlatform.IsPlatformInGroup(Target.Platform, UnrealPlatformGroup.Windows))
            {
                foreach (DirectoryReference Path in Target.Rules.WindowsPlatform.Environment.IncludePaths)
                {
                    Writer.WriteValue(Path.FullName);
                }
            }
            else if (UEBuildPlatform.IsPlatformInGroup(Target.Platform, UnrealPlatformGroup.Apple) &&
                     UEBuildPlatform.IsPlatformInGroup(BuildHostPlatform.Current.Platform, UnrealPlatformGroup.Apple))
            {
                // Only generate Apple system include paths when host platform is Apple OS
                // TODO: Fix case when working with MacOS on Windows host platform
                foreach (string Path in AppleHelper.GetAppleSystemIncludePaths(GlobalCompileEnvironment.Architecture, Target.Platform))
                {
                    Writer.WriteValue(Path);
                }
            }
            // TODO: get corresponding includes for Linux

            Writer.WriteArrayEnd();

            Writer.WriteArrayStart("EnvironmentDefinitions");
            foreach (string Definition in GlobalCompileEnvironment.Definitions)
            {
                Writer.WriteValue(Definition);
            }
            Writer.WriteArrayEnd();
        }
Exemplo n.º 3
0
        private ToolchainInfo GenerateToolchainInfo(CppCompileEnvironment CompileEnvironment)
        {
            ToolchainInfo ToolchainInfo = new ToolchainInfo
            {
                CppStandard             = CompileEnvironment.CppStandard,
                Configuration           = CompileEnvironment.Configuration.ToString(),
                bEnableExceptions       = CompileEnvironment.bEnableExceptions,
                bOptimizeCode           = CompileEnvironment.bOptimizeCode,
                bUseInlining            = CompileEnvironment.bUseInlining,
                bUseUnity               = CompileEnvironment.bUseUnity,
                bCreateDebugInfo        = CompileEnvironment.bCreateDebugInfo,
                bIsBuildingLibrary      = CompileEnvironment.bIsBuildingLibrary,
                bUseAVX                 = CompileEnvironment.bUseAVX,
                bIsBuildingDLL          = CompileEnvironment.bIsBuildingDLL,
                bUseDebugCRT            = CompileEnvironment.bUseDebugCRT,
                bUseRTTI                = CompileEnvironment.bUseRTTI,
                bUseStaticCRT           = CompileEnvironment.bUseStaticCRT,
                PrecompiledHeaderAction = CompileEnvironment.PrecompiledHeaderAction.ToString(),
                PrecompiledHeaderFile   = CompileEnvironment.PrecompiledHeaderFile?.ToString(),
                ForceIncludeFiles       = CompileEnvironment.ForceIncludeFiles.Select(Item => Item.ToString()).ToList()
            };

            if (CurrentTarget.Platform.IsInGroup(UnrealPlatformGroup.Windows))
            {
                ToolchainInfo.Architecture = WindowsExports.GetArchitectureSubpath(CurrentTarget.Rules.WindowsPlatform.Architecture);

                WindowsCompiler WindowsPlatformCompiler = CurrentTarget.Rules.WindowsPlatform.Compiler;
                ToolchainInfo.bStrictConformanceMode = WindowsPlatformCompiler >= WindowsCompiler.VisualStudio2017 && CurrentTarget.Rules.WindowsPlatform.bStrictConformanceMode;
                ToolchainInfo.Compiler = WindowsPlatformCompiler.ToString();
            }
            else
            {
                string PlatformName  = $"{CurrentTarget.Platform}Platform";
                object Value         = typeof(ReadOnlyTargetRules).GetProperty(PlatformName)?.GetValue(CurrentTarget.Rules);
                object CompilerField = Value?.GetType().GetProperty("Compiler")?.GetValue(Value);
                if (CompilerField != null)
                {
                    ToolchainInfo.Compiler = CompilerField.ToString();
                }
            }

            return(ToolchainInfo);
        }
        /// <summary>
        /// Write C++ toolchain information to JSON writer
        /// </summary>
        /// <param name="Target"></param>
        /// <param name="Writer"></param>
        private void ExportEnvironmentToJson(UEBuildTarget Target, JsonWriter Writer)
        {
            CppCompileEnvironment GlobalCompileEnvironment = Target.CreateCompileEnvironmentForProjectFiles();

            RootToolchainInfo = GenerateToolchainInfo(GlobalCompileEnvironment);

            Writer.WriteObjectStart("ToolchainInfo");
            foreach (Tuple <string, object> Field in RootToolchainInfo.GetFields())
            {
                WriteField(Target.TargetName, Writer, Field);
            }
            Writer.WriteObjectEnd();

            Writer.WriteArrayStart("EnvironmentIncludePaths");
            foreach (DirectoryReference Path in GlobalCompileEnvironment.UserIncludePaths)
            {
                Writer.WriteValue(Path.FullName);
            }
            foreach (DirectoryReference Path in GlobalCompileEnvironment.SystemIncludePaths)
            {
                Writer.WriteValue(Path.FullName);
            }

            // TODO: get corresponding includes for specific platforms
            if (UEBuildPlatform.IsPlatformInGroup(Target.Platform, UnrealPlatformGroup.Windows))
            {
                foreach (DirectoryReference Path in Target.Rules.WindowsPlatform.Environment.IncludePaths)
                {
                    Writer.WriteValue(Path.FullName);
                }
            }
            Writer.WriteArrayEnd();

            Writer.WriteArrayStart("EnvironmentDefinitions");
            foreach (string Definition in GlobalCompileEnvironment.Definitions)
            {
                Writer.WriteValue(Definition);
            }
            Writer.WriteArrayEnd();
        }