Пример #1
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);
        }
Пример #2
0
 /// <summary>
 /// Modify the rules for a newly created module, where the target is a different host platform.
 /// This is not required - but allows for hiding details of a particular platform.
 /// </summary>
 /// <param name="ModuleName">The name of the module</param>
 /// <param name="Rules">The module rules</param>
 /// <param name="Target">The target being build</param>
 public override void ModifyModuleRulesForOtherPlatform(string ModuleName, ModuleRules Rules, ReadOnlyTargetRules Target)
 {
     if (Target.Platform == UnrealTargetPlatform.Win64)
     {
         if (ProjectFileGenerator.bGenerateProjectFiles)
         {
             // Use latest SDK for Intellisense purposes
             WindowsCompiler CompilerForSdkRestriction = Target.HoloLensPlatform.Compiler != WindowsCompiler.Default ? Target.HoloLensPlatform.Compiler : Target.WindowsPlatform.Compiler;
             if (CompilerForSdkRestriction != WindowsCompiler.Default)
             {
                 Version            OutWin10SDKVersion;
                 DirectoryReference OutSdkDir;
                 if (WindowsExports.TryGetWindowsSdkDir(Target.HoloLensPlatform.Win10SDKVersionString, out OutWin10SDKVersion, out OutSdkDir))
                 {
                     Rules.PublicDefinitions.Add(string.Format("WIN10_SDK_VERSION={0}", OutWin10SDKVersion.Build));
                 }
             }
         }
     }
 }
Пример #3
0
        /// <summary>
        /// Modify the rules for a newly created module, where the target is a different host platform.
        /// This is not required - but allows for hiding details of a particular platform.
        /// </summary>
        /// <param name="ModuleName">The name of the module</param>
        /// <param name="Rules">The module rules</param>
        /// <param name="Target">The target being build</param>
        public override void ModifyModuleRulesForOtherPlatform(string ModuleName, ModuleRules Rules, ReadOnlyTargetRules Target)
        {
            // This code has been removed because it causes a full rebuild after generating project files (since response files are overwritten with different defines).
#if false
            if (Target.Platform == UnrealTargetPlatform.Win64)
            {
                if (ProjectFileGenerator.bGenerateProjectFiles)
                {
                    // Use latest SDK for Intellisense purposes
                    WindowsCompiler CompilerForSdkRestriction = Target.HoloLensPlatform.Compiler != WindowsCompiler.Default ? Target.HoloLensPlatform.Compiler : Target.WindowsPlatform.Compiler;
                    if (CompilerForSdkRestriction != WindowsCompiler.Default)
                    {
                        Version            OutWin10SDKVersion;
                        DirectoryReference OutSdkDir;
                        if (WindowsExports.TryGetWindowsSdkDir(Target.HoloLensPlatform.Win10SDKVersionString, out OutWin10SDKVersion, out OutSdkDir))
                        {
                            Rules.PublicDefinitions.Add(string.Format("WIN10_SDK_VERSION={0}", OutWin10SDKVersion.Build));
                        }
                    }
                }
            }
#endif
        }
Пример #4
0
        public override bool PrepTargetForDeployment(TargetReceipt Receipt)
        {
            // Use the project name if possible - InTarget.AppName changes for 'Client'/'Server' builds
            string ProjectName = Receipt.ProjectFile != null?Receipt.ProjectFile.GetFileNameWithoutAnyExtensions() : Receipt.Launch.GetFileNameWithoutExtension();

            Log.TraceInformation("Prepping {0} for deployment to {1}", ProjectName, Receipt.Platform.ToString());
            System.DateTime PrepDeployStartTime = DateTime.UtcNow;

            // Note: TargetReceipt.Read now expands path variables internally.
            TargetReceipt NewReceipt      = null;
            FileReference ReceiptFileName = TargetReceipt.GetDefaultPath(Receipt.ProjectDir != null ? Receipt.ProjectDir : UnrealBuildTool.EngineDirectory, Receipt.TargetName, Receipt.Platform, Receipt.Configuration, "Multi");

            if (!TargetReceipt.TryRead(ReceiptFileName, UnrealBuildTool.EngineDirectory, out NewReceipt))
            {
                NewReceipt = new TargetReceipt(Receipt.ProjectFile, Receipt.TargetName, Receipt.TargetType, Receipt.Platform, Receipt.Configuration, Receipt.Version, "Multi");
            }

            AddWinMDReferencesFromReceipt(Receipt, Receipt.ProjectDir != null ? Receipt.ProjectDir : UnrealBuildTool.EngineDirectory, UnrealBuildTool.EngineDirectory.ParentDirectory.FullName);

            //PrepForUATPackageOrDeploy(InTarget.ProjectFile, InAppName, InTarget.ProjectDirectory.FullName, InTarget.OutputPath.FullName, TargetBuildEnvironment.RelativeEnginePath, false, "", false);
            List <UnrealTargetConfiguration> TargetConfigs = new List <UnrealTargetConfiguration> {
                Receipt.Configuration
            };
            List <string> ExePaths = new List <string> {
                Receipt.Launch.FullName
            };
            string RelativeEnginePath = UnrealBuildTool.EngineDirectory.MakeRelativeTo(DirectoryReference.GetCurrentDirectory());

            WindowsArchitecture Arch = WindowsArchitecture.ARM64;

            if (Receipt.Architecture.ToLower() == "x64")
            {
                Arch = WindowsArchitecture.x64;
            }

            string SDK     = "";
            var    Results = Receipt.AdditionalProperties.Where(x => x.Name == "SDK");

            if (Results.Any())
            {
                SDK = Results.First().Value;
            }
            HoloLensExports.InitWindowsSdkToolPath(SDK);

            string AbsoluteExeDirectory         = Path.GetDirectoryName(ExePaths[0]);
            UnrealTargetPlatform Platform       = UnrealTargetPlatform.HoloLens;
            string        IntermediateDirectory = Path.Combine(Receipt.ProjectDir != null ? Receipt.ProjectDir.FullName : UnrealBuildTool.EngineDirectory.FullName, "Intermediate", "Deploy", WindowsExports.GetArchitectureSubpath(Arch));
            List <string> UpdatedFiles          = new HoloLensManifestGenerator().CreateManifest(Platform, Arch, AbsoluteExeDirectory, IntermediateDirectory, Receipt.ProjectFile, Receipt.ProjectDir != null ? Receipt.ProjectDir.FullName : UnrealBuildTool.EngineDirectory.FullName, TargetConfigs, ExePaths, WinMDReferences);

            PrepForUATPackageOrDeploy(Receipt.ProjectFile, ProjectName, Receipt.ProjectDir != null ? Receipt.ProjectDir.FullName : UnrealBuildTool.EngineDirectory.FullName, Arch, TargetConfigs, ExePaths, RelativeEnginePath, false, "", false);
            MakePackage(Receipt, NewReceipt, Arch, UpdatedFiles);
            CopyDataAndSymbolsBetweenReceipts(Receipt, NewReceipt, Arch);

            NewReceipt.Write(ReceiptFileName, UnrealBuildTool.EngineDirectory);

            // Log out the time taken to deploy...
            double PrepDeployDuration = (DateTime.UtcNow - PrepDeployStartTime).TotalSeconds;

            Log.TraceInformation("HoloLens deployment preparation took {0:0.00} seconds", PrepDeployDuration);

            return(true);
        }
Пример #5
0
        private void MakePackage(TargetReceipt Receipt, TargetReceipt NewReceipt, WindowsArchitecture Architecture, List <string> UpdatedFiles)
        {
            string OutputName             = String.Format("{0}_{1}_{2}_{3}", Receipt.TargetName, Receipt.Platform, Receipt.Configuration, WindowsExports.GetArchitectureSubpath(Architecture));
            string IntermediateDirectory  = Path.Combine(Receipt.ProjectDir != null ? Receipt.ProjectDir.FullName : UnrealBuildTool.EngineDirectory.FullName, "Intermediate", "Deploy", WindowsExports.GetArchitectureSubpath(Architecture));
            string OutputDirectory        = Receipt.Launch.Directory.FullName;
            string OutputAppX             = Path.Combine(OutputDirectory, OutputName + ".appx");
            string SigningCertificate     = @"Build\HoloLens\SigningCertificate.pfx";
            string SigningCertificatePath = Path.Combine(Receipt.ProjectDir != null ? Receipt.ProjectDir.FullName : UnrealBuildTool.EngineDirectory.FullName, SigningCertificate);

            string MapFilename = Path.Combine(IntermediateDirectory, OutputName + ".pkgmap");
            var    LocalRoot   = Receipt.ProjectDir;
            var    EngineRoot  = UnrealBuildTool.RootDirectory;
            var    AddedFiles  = new Dictionary <string, string>();
            bool   PackageFileNeedToBeUpdated = !File.Exists(OutputAppX);

            DateTime AppXTime = DateTime.Now;

            PackageFileNeedToBeUpdated = true;

            if (!PackageFileNeedToBeUpdated)
            {
                AppXTime = File.GetLastWriteTimeUtc(OutputAppX);
            }

            {
                foreach (var Product in Receipt.BuildProducts)
                {
                    if (Product.Type == BuildProductType.Executable || Product.Type == BuildProductType.DynamicLibrary || Product.Type == BuildProductType.RequiredResource)
                    {
                        string Filename;
                        if (AddedFiles.ContainsKey(Product.Path.FullName))
                        {
                            continue;
                        }

                        if (LocalRoot != null && Product.Path.IsUnderDirectory(LocalRoot))
                        {
                            Filename = Product.Path.MakeRelativeTo(LocalRoot.ParentDirectory);
                        }
                        else if (Product.Path.IsUnderDirectory(EngineRoot))
                        {
                            Filename = Product.Path.MakeRelativeTo(EngineRoot);
                        }
                        else
                        {
                            throw new BuildException("Failed to parse target receipt file.  See log for details.");
                        }

                        AddedFiles.Add(Product.Path.FullName, Filename);
                    }
                }

                foreach (var Dep in Receipt.RuntimeDependencies)
                {
                    if (Dep.Type == StagedFileType.NonUFS)
                    {
                        if (AddedFiles.ContainsKey(Dep.Path.FullName))
                        {
                            continue;
                        }

                        string Filename;
                        if (LocalRoot != null && Dep.Path.IsUnderDirectory(LocalRoot))
                        {
                            Filename = Dep.Path.MakeRelativeTo(LocalRoot.ParentDirectory);
                        }
                        else if (Dep.Path.IsUnderDirectory(EngineRoot))
                        {
                            Filename = Dep.Path.MakeRelativeTo(EngineRoot);
                        }
                        else
                        {
                            throw new BuildException("Failed to parse target receipt file.  See log for details.");
                        }

                        AddedFiles.Add(Dep.Path.FullName, Filename);
                    }
                }
            }

            string ManifestName = String.Format("AppxManifest_{0}.xml", WindowsExports.GetArchitectureSubpath(Architecture));

            AddedFiles.Add(Path.Combine(OutputDirectory, ManifestName), "AppxManifest.xml");

            //manually add resources
            string PriFileName = String.Format("resources_{0}.pri", WindowsExports.GetArchitectureSubpath(Architecture));

            AddedFiles.Add(Path.Combine(OutputDirectory, PriFileName), "resources.pri");
            {
                DirectoryReference ResourceFolder = DirectoryReference.Combine(Receipt.Launch.Directory, WindowsExports.GetArchitectureSubpath(Architecture));
                foreach (var ResourcePath in UpdatedFiles)
                {
                    var ResourceFile = new FileReference(ResourcePath);

                    if (ResourceFile.IsUnderDirectory(ResourceFolder))
                    {
                        AddedFiles.Add(ResourceFile.FullName, ResourceFile.MakeRelativeTo(ResourceFolder));
                    }
                    else
                    {
                        Log.TraceError("Wrong path to resource \'{0}\', the resource should be in \'{1}\'", ResourceFile.FullName, ResourceFolder.FullName);
                        throw new BuildException("Failed to generate AppX file.  See log for details.");
                    }
                }
            }


            FileReference SourceNetworkManifestPath = new FileReference(Path.Combine(OutputDirectory, "NetworkManifest.xml"));

            if (FileReference.Exists(SourceNetworkManifestPath))
            {
                AddedFiles.Add(SourceNetworkManifestPath.FullName, "NetworkManifest.xml");
            }
            FileReference SourceXboxConfigPath = new FileReference(Path.Combine(OutputDirectory, "xboxservices.config"));

            if (FileReference.Exists(SourceXboxConfigPath))
            {
                AddedFiles.Add(SourceXboxConfigPath.FullName, "xboxservices.config");
            }

            do
            {
                if (PackageFileNeedToBeUpdated)
                {
                    break;
                }

                if (!File.Exists(MapFilename))
                {
                    PackageFileNeedToBeUpdated = true;
                    break;
                }
                string[] lines      = File.ReadAllLines(MapFilename, Encoding.UTF8);
                int      filesCount = 0;

                foreach (var line in lines)
                {
                    if (line[0] == '[')
                    {
                        continue;
                    }

                    string[] files = line.Split('\t');

                    if (files.Length != 2)
                    {
                        PackageFileNeedToBeUpdated = true;
                        break;
                    }

                    files[0] = files[0].Trim('\"');
                    files[1] = files[1].Trim('\"');

                    if (!AddedFiles.ContainsKey(files[0]))
                    {
                        PackageFileNeedToBeUpdated = true;
                        break;
                    }

                    if (AddedFiles[files[0]] != files[1])
                    {
                        PackageFileNeedToBeUpdated = true;
                        break;
                    }

                    if (File.GetLastWriteTimeUtc(files[0]).CompareTo(AppXTime) >= 0)
                    {
                        PackageFileNeedToBeUpdated = true;
                        break;
                    }

                    ++filesCount;
                }

                if (PackageFileNeedToBeUpdated)
                {
                    break;
                }

                if (filesCount != AddedFiles.Count)
                {
                    PackageFileNeedToBeUpdated = true;
                    break;
                }

                if (File.Exists(SigningCertificatePath) && File.GetLastWriteTimeUtc(SigningCertificatePath).CompareTo(AppXTime) >= 0)
                {
                    PackageFileNeedToBeUpdated = true;
                    break;
                }
            }while(false);

            if (!PackageFileNeedToBeUpdated)
            {
                NewReceipt.BuildProducts.Add(new BuildProduct(new FileReference(OutputAppX), BuildProductType.Package));
                return;
            }

            try
            {
                DeployHelper_DeleteFile(OutputAppX);
            }
            catch (Exception exceptionMessage)
            {
                Log.TraceError("Failed to delete {0} from deployment: {1}", OutputAppX, exceptionMessage);
                throw new BuildException("Failed to generate AppX file.  See log for details.");
            }

            var AppXRecipeBuiltFiles = new StringBuilder();

            AppXRecipeBuiltFiles.AppendLine(@"[Files]");
            foreach (var f in AddedFiles)
            {
                AppXRecipeBuiltFiles.AppendLine(String.Format("\"{0}\"\t\"{1}\"", f.Key, f.Value));
            }
            File.WriteAllText(MapFilename, AppXRecipeBuiltFiles.ToString(), Encoding.UTF8);

            NewReceipt.BuildProducts.Add(new BuildProduct(new FileReference(MapFilename), BuildProductType.MapFile));
        }
        /// <summary>
        /// Sets up the standard compile environment for the toolchain
        /// </summary>
        private void SetupEnvironment(UnrealTargetPlatform Platform)
        {
            // Add the standard Visual C++ include paths
            IncludePaths.Add(DirectoryReference.Combine(ToolChainDir, "INCLUDE"));
            string ArchFolder = WindowsExports.GetArchitectureSubpath(Architecture);

            // Add the standard Visual C++ library paths
            if (ToolChain >= WindowsCompiler.VisualStudio2017)
            {
                if (Platform == UnrealTargetPlatform.HoloLens)
                {
                    LibraryPaths.Add(DirectoryReference.Combine(ToolChainDir, "lib", ArchFolder, "store"));
                }
                else
                {
                    LibraryPaths.Add(DirectoryReference.Combine(ToolChainDir, "lib", ArchFolder));
                }
            }
            else
            {
                DirectoryReference LibsPath = DirectoryReference.Combine(ToolChainDir, "LIB");
                if (Platform == UnrealTargetPlatform.HoloLens)
                {
                    LibsPath = DirectoryReference.Combine(LibsPath, "store");
                }

                if (Architecture == WindowsArchitecture.x64)
                {
                    LibsPath = DirectoryReference.Combine(LibsPath, "amd64");
                }
                else if (Architecture == WindowsArchitecture.ARM32)
                {
                    LibsPath = DirectoryReference.Combine(LibsPath, "arm");
                }

                LibraryPaths.Add(LibsPath);
            }

            // If we're on Visual Studio 2015 and using pre-Windows 10 SDK, we need to find a Windows 10 SDK and add the UCRT include paths
            if (ToolChain >= WindowsCompiler.VisualStudio2015_DEPRECATED && WindowsSdkVersion < new VersionNumber(10))
            {
                KeyValuePair <VersionNumber, DirectoryReference> Pair = WindowsPlatform.FindUniversalCrtDirs().OrderByDescending(x => x.Key).FirstOrDefault();
                if (Pair.Key == null || Pair.Key < new VersionNumber(10))
                {
                    throw new BuildException("{0} requires the Universal CRT to be installed.", WindowsPlatform.GetCompilerName(ToolChain));
                }

                DirectoryReference IncludeRootDir = DirectoryReference.Combine(Pair.Value, "include", Pair.Key.ToString());
                IncludePaths.Add(DirectoryReference.Combine(IncludeRootDir, "ucrt"));

                DirectoryReference LibraryRootDir = DirectoryReference.Combine(Pair.Value, "lib", Pair.Key.ToString());
                LibraryPaths.Add(DirectoryReference.Combine(LibraryRootDir, "ucrt", ArchFolder));
            }

            // Add the NETFXSDK include path. We need this for SwarmInterface.
            DirectoryReference NetFxSdkDir;

            if (WindowsPlatform.TryGetNetFxSdkInstallDir(out NetFxSdkDir))
            {
                IncludePaths.Add(DirectoryReference.Combine(NetFxSdkDir, "include", "um"));
                LibraryPaths.Add(DirectoryReference.Combine(NetFxSdkDir, "lib", "um", ArchFolder));
            }

            // Add the Windows SDK paths
            if (WindowsSdkVersion >= new VersionNumber(10))
            {
                DirectoryReference IncludeRootDir = DirectoryReference.Combine(WindowsSdkDir, "include", WindowsSdkVersion.ToString());
                IncludePaths.Add(DirectoryReference.Combine(IncludeRootDir, "ucrt"));
                IncludePaths.Add(DirectoryReference.Combine(IncludeRootDir, "shared"));
                IncludePaths.Add(DirectoryReference.Combine(IncludeRootDir, "um"));
                IncludePaths.Add(DirectoryReference.Combine(IncludeRootDir, "winrt"));

                DirectoryReference LibraryRootDir = DirectoryReference.Combine(WindowsSdkDir, "lib", WindowsSdkVersion.ToString());
                LibraryPaths.Add(DirectoryReference.Combine(LibraryRootDir, "ucrt", ArchFolder));
                LibraryPaths.Add(DirectoryReference.Combine(LibraryRootDir, "um", ArchFolder));
            }
            else
            {
                DirectoryReference IncludeRootDir = DirectoryReference.Combine(WindowsSdkDir, "include");
                IncludePaths.Add(DirectoryReference.Combine(IncludeRootDir, "shared"));
                IncludePaths.Add(DirectoryReference.Combine(IncludeRootDir, "um"));
                IncludePaths.Add(DirectoryReference.Combine(IncludeRootDir, "winrt"));

                DirectoryReference LibraryRootDir = DirectoryReference.Combine(WindowsSdkDir, "lib", "winv6.3");
                LibraryPaths.Add(DirectoryReference.Combine(LibraryRootDir, "um", ArchFolder));
            }
        }
        /// <summary>
        /// Gets the path to the tool binaries.
        /// </summary>
        /// <param name="Compiler">The compiler version</param>
        /// <param name="VCToolChainDir">Base directory for the VC toolchain</param>
        /// <param name="Architecture">Target Architecture</param>
        /// <returns>Directory containing the 32-bit toolchain binaries</returns>
        static DirectoryReference GetVCToolPath(WindowsCompiler Compiler, DirectoryReference VCToolChainDir, WindowsArchitecture Architecture)
        {
            if (Compiler >= WindowsCompiler.VisualStudio2017)
            {
                FileReference NativeCompilerPath = FileReference.Combine(VCToolChainDir, "bin", "HostX64", WindowsExports.GetArchitectureSubpath(Architecture), "cl.exe");
                if (FileReference.Exists(NativeCompilerPath))
                {
                    return(NativeCompilerPath.Directory);
                }

                FileReference CrossCompilerPath = FileReference.Combine(VCToolChainDir, "bin", "HostX86", WindowsExports.GetArchitectureSubpath(Architecture), "cl.exe");
                if (FileReference.Exists(CrossCompilerPath))
                {
                    return(CrossCompilerPath.Directory);
                }
            }
            else
            {
                if (Architecture == WindowsArchitecture.x86)
                {
                    FileReference CompilerPath = FileReference.Combine(VCToolChainDir, "bin", "cl.exe");
                    if (FileReference.Exists(CompilerPath))
                    {
                        return(CompilerPath.Directory);
                    }
                }
                else if (Architecture == WindowsArchitecture.x64)
                {
                    // Use the native 64-bit compiler if present
                    FileReference NativeCompilerPath = FileReference.Combine(VCToolChainDir, "bin", "amd64", "cl.exe");
                    if (FileReference.Exists(NativeCompilerPath))
                    {
                        return(NativeCompilerPath.Directory);
                    }

                    // Otherwise use the amd64-on-x86 compiler. VS2012 Express only includes the latter.
                    FileReference CrossCompilerPath = FileReference.Combine(VCToolChainDir, "bin", "x86_amd64", "cl.exe");
                    if (FileReference.Exists(CrossCompilerPath))
                    {
                        return(CrossCompilerPath.Directory);
                    }
                }
                else if (Architecture == WindowsArchitecture.ARM32)
                {
                    // Use the native 64-bit compiler if present
                    FileReference NativeCompilerPath = FileReference.Combine(VCToolChainDir, "bin", "amd64_arm", "cl.exe");
                    if (FileReference.Exists(NativeCompilerPath))
                    {
                        return(NativeCompilerPath.Directory);
                    }

                    // Otherwise use the amd64-on-x86 compiler. VS2012 Express only includes the latter.
                    FileReference CrossCompilerPath = FileReference.Combine(VCToolChainDir, "bin", "x86_arm", "cl.exe");
                    if (FileReference.Exists(CrossCompilerPath))
                    {
                        return(CrossCompilerPath.Directory);
                    }
                }
            }

            throw new BuildException("No required compiler toolchain found in {0}", VCToolChainDir);
        }
Пример #8
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)
        {
            // Add Win10 SDK pieces - moved here since it allows better control over SDK version
            string Win10SDKRoot = Target.WindowsPlatform.WindowsSdkDir;

            // Include paths
            CompileEnvironment.SystemIncludePaths.Add(new DirectoryReference(string.Format(@"{0}\Include\{1}\ucrt", Win10SDKRoot, Target.HoloLensPlatform.Win10SDKVersion)));
            CompileEnvironment.SystemIncludePaths.Add(new DirectoryReference(string.Format(@"{0}\Include\{1}\um", Win10SDKRoot, Target.HoloLensPlatform.Win10SDKVersion)));
            CompileEnvironment.SystemIncludePaths.Add(new DirectoryReference(string.Format(@"{0}\Include\{1}\shared", Win10SDKRoot, Target.HoloLensPlatform.Win10SDKVersion)));
            CompileEnvironment.SystemIncludePaths.Add(new DirectoryReference(string.Format(@"{0}\Include\{1}\winrt", Win10SDKRoot, Target.HoloLensPlatform.Win10SDKVersion)));

            // Library paths
            // @MIXEDREALITY_CHANGE : BEGIN TODO: change to arm.
            string LibArchitecture = WindowsExports.GetArchitectureSubpath(Target.HoloLensPlatform.Architecture);

            LinkEnvironment.SystemLibraryPaths.Add(new DirectoryReference(string.Format(@"{0}\Lib\{1}\ucrt\{2}", Win10SDKRoot, Target.HoloLensPlatform.Win10SDKVersion, LibArchitecture)));
            LinkEnvironment.SystemLibraryPaths.Add(new DirectoryReference(string.Format(@"{0}\Lib\{1}\um\{2}", Win10SDKRoot, Target.HoloLensPlatform.Win10SDKVersion, LibArchitecture)));

            // Reference (WinMD) paths
            // Only Foundation and Universal are referenced by default.
            List <string> AlwaysReferenceContracts = new List <string>();

            AlwaysReferenceContracts.Add("Windows.Foundation.FoundationContract");
            AlwaysReferenceContracts.Add("Windows.Foundation.UniversalApiContract");
            ExpandWinMDReferences(Target, Win10SDKRoot, Target.HoloLensPlatform.Win10SDKVersion.ToString(), ref AlwaysReferenceContracts);

            StringBuilder WinMDReferenceArguments = new StringBuilder();

            foreach (string WinMDReference in AlwaysReferenceContracts)
            {
                WinMDReferenceArguments.AppendFormat(@" /FU""{0}""", WinMDReference);
            }
            CompileEnvironment.AdditionalArguments += WinMDReferenceArguments;

            CompileEnvironment.Definitions.Add("EXCEPTIONS_DISABLED=0");

            CompileEnvironment.Definitions.Add("_WIN32_WINNT=0x0A00");
            CompileEnvironment.Definitions.Add("WINVER=0x0A00");

            CompileEnvironment.Definitions.Add("PLATFORM_HOLOLENS=1");
            CompileEnvironment.Definitions.Add("HOLOLENS=1");

            CompileEnvironment.Definitions.Add("WINAPI_FAMILY=WINAPI_FAMILY_APP");
            CompileEnvironment.Definitions.Add("PLATFORM_MICROSOFT=1");

            // No D3DX on HoloLens!
            CompileEnvironment.Definitions.Add("NO_D3DX_LIBS=1");

            if (Target.HoloLensPlatform.bBuildForRetailWindowsStore)
            {
                CompileEnvironment.Definitions.Add("USING_RETAIL_WINDOWS_STORE=1");
            }
            else
            {
                CompileEnvironment.Definitions.Add("USING_RETAIL_WINDOWS_STORE=0");
            }

            CompileEnvironment.Definitions.Add("WITH_D3D12_RHI=0");

            LinkEnvironment.AdditionalArguments += "/NODEFAULTLIB";
            //CompileEnvironment.AdditionalArguments += " /showIncludes";

            LinkEnvironment.SystemLibraries.Add("windowsapp.lib");

            CompileEnvironment.Definitions.Add(string.Format("WIN10_SDK_VERSION={0}", Target.HoloLensPlatform.Win10SDKVersion.Build));

            LinkEnvironment.SystemLibraries.Add("dloadhelper.lib");
            LinkEnvironment.SystemLibraries.Add("ws2_32.lib");

            if (CompileEnvironment.bUseDebugCRT)
            {
                LinkEnvironment.SystemLibraries.Add("vccorlibd.lib");
                LinkEnvironment.SystemLibraries.Add("ucrtd.lib");
                LinkEnvironment.SystemLibraries.Add("vcruntimed.lib");
                LinkEnvironment.SystemLibraries.Add("msvcrtd.lib");
                LinkEnvironment.SystemLibraries.Add("msvcprtd.lib");
            }
            else
            {
                LinkEnvironment.SystemLibraries.Add("vccorlib.lib");
                LinkEnvironment.SystemLibraries.Add("ucrt.lib");
                LinkEnvironment.SystemLibraries.Add("vcruntime.lib");
                LinkEnvironment.SystemLibraries.Add("msvcrt.lib");
                LinkEnvironment.SystemLibraries.Add("msvcprt.lib");
            }
            LinkEnvironment.SystemLibraries.Add("legacy_stdio_wide_specifiers.lib");
            LinkEnvironment.SystemLibraries.Add("uuid.lib");
        }