示例#1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GDKToolchain"/> class.
 /// </summary>
 /// <param name="platform">The platform.</param>
 /// <param name="architecture">The architecture.</param>
 protected GDKToolchain(GDKPlatform platform, TargetArchitecture architecture)
     : base(platform, architecture, WindowsPlatformToolset.Latest, WindowsPlatformSDK.v10_0_19041_0)
 {
     // Setup system paths
     SystemIncludePaths.Add(Path.Combine(GDK.Instance.RootPath, "GRDK\\GameKit\\Include"));
     SystemLibraryPaths.Add(Path.Combine(GDK.Instance.RootPath, "GRDK\\GameKit\\Lib\\amd64"));
     SystemLibraryPaths.Add(Path.Combine(GDK.Instance.RootPath, "GRDK\\ExtensionLibraries\\Xbox.Services.API.C\\DesignTime\\CommonConfiguration\\Neutral\\Lib\\Release\\" + Toolset));
 }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GDKToolchain"/> class.
        /// </summary>
        /// <param name="platform">The platform.</param>
        /// <param name="architecture">The architecture.</param>
        protected GDKToolchain(GDKPlatform platform, TargetArchitecture architecture)
            : base(platform, architecture, WindowsPlatformBase.GetToolsets().Keys.Where(x => x <= WindowsPlatformToolset.v142).Max(), WindowsPlatformSDK.v10_0_19041_0)
        {
            // Setup system paths
            SystemIncludePaths.Add(Path.Combine(GDK.Instance.RootPath, "GRDK\\GameKit\\Include"));
            SystemLibraryPaths.Add(Path.Combine(GDK.Instance.RootPath, "GRDK\\GameKit\\Lib\\amd64"));
            var xboxServicesPath = Path.Combine(GDK.Instance.RootPath, "GRDK\\ExtensionLibraries\\Xbox.Services.API.C\\DesignTime\\CommonConfiguration\\Neutral\\");

            SystemIncludePaths.Add(xboxServicesPath + "Include");
            SystemLibraryPaths.Add(xboxServicesPath + "Lib\\Release\\" + Toolset);
        }
示例#3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="WindowsToolchainBase"/> class.
        /// </summary>
        /// <param name="platform">The platform.</param>
        /// <param name="architecture">The target architecture.</param>
        /// <param name="toolsetVer">The target platform toolset version.</param>
        /// <param name="sdkVer">The target platform SDK version.</param>
        protected WindowsToolchainBase(WindowsPlatformBase platform, TargetArchitecture architecture, WindowsPlatformToolset toolsetVer, WindowsPlatformSDK sdkVer)
            : base(platform, architecture)
        {
            var toolsets = WindowsPlatformBase.GetToolsets();
            var sdks     = WindowsPlatformBase.GetSDKs();

            // Pick the overriden toolset
            if (Configuration.Compiler != null)
            {
                if (Enum.TryParse(Configuration.Compiler, out WindowsPlatformToolset compiler))
                {
                    toolsetVer = compiler;
                }
            }

            // Pick the newest installed Visual Studio version if using the default toolset
            if (toolsetVer == WindowsPlatformToolset.Default)
            {
                if (VisualStudioInstance.HasIDE(VisualStudioVersion.VisualStudio2019))
                {
                    toolsetVer = WindowsPlatformToolset.v142;
                }
                else if (VisualStudioInstance.HasIDE(VisualStudioVersion.VisualStudio2017))
                {
                    toolsetVer = WindowsPlatformToolset.v141;
                }
                else
                {
                    toolsetVer = WindowsPlatformToolset.v140;
                }
            }
            // Pick the latest toolset
            else if (toolsetVer == WindowsPlatformToolset.Latest)
            {
                toolsetVer = toolsets.Keys.Max();
            }

            // Pick the latest SDK
            if (sdkVer == WindowsPlatformSDK.Latest)
            {
                sdkVer = sdks.Keys.Max();
            }

            // Get tools
            Toolset = toolsetVer;
            SDK     = sdkVer;
            if (!toolsets.ContainsKey(Toolset))
            {
                throw new Exception(string.Format("Missing toolset {0} for platform Windows", Toolset));
            }
            if (!sdks.ContainsKey(SDK))
            {
                throw new Exception(string.Format("Missing SDK {0} for platform Windows", SDK));
            }

            // Get the tools paths
            string vcToolPath;

            if (Architecture == TargetArchitecture.x64)
            {
                vcToolPath = WindowsPlatformBase.GetVCToolPath64(Toolset);
            }
            else
            {
                vcToolPath = WindowsPlatformBase.GetVCToolPath32(Toolset);
            }
            _vcToolPath   = vcToolPath;
            _compilerPath = Path.Combine(vcToolPath, "cl.exe");
            _linkerPath   = Path.Combine(vcToolPath, "link.exe");
            _libToolPath  = Path.Combine(vcToolPath, "lib.exe");
            _xdcmakePath  = Path.Combine(vcToolPath, "xdcmake.exe");

            // Add Visual C++ toolset include and library paths
            var vcToolChainDir = toolsets[Toolset];

            SystemIncludePaths.Add(Path.Combine(vcToolChainDir, "include"));
            switch (Toolset)
            {
            case WindowsPlatformToolset.v140:
            {
                switch (Architecture)
                {
                case TargetArchitecture.AnyCPU: break;

                case TargetArchitecture.ARM:
                    SystemLibraryPaths.Add(Path.Combine(vcToolChainDir, "lib", "arm"));
                    break;

                case TargetArchitecture.ARM64:
                    SystemLibraryPaths.Add(Path.Combine(vcToolChainDir, "lib", "arm64"));
                    break;

                case TargetArchitecture.x86:
                    SystemLibraryPaths.Add(Path.Combine(vcToolChainDir, "lib"));
                    break;

                case TargetArchitecture.x64:
                    SystemLibraryPaths.Add(Path.Combine(vcToolChainDir, "lib", "amd64"));
                    break;

                default: throw new InvalidArchitectureException(architecture);
                }

                // When using Visual Studio 2015 toolset and using pre-Windows 10 SDK, find a Windows 10 SDK and add the UCRT include paths
                if (SDK == WindowsPlatformSDK.v8_1)
                {
                    var sdk = sdks.FirstOrDefault(x => x.Key != WindowsPlatformSDK.v8_1);
                    if (sdk.Value == null)
                    {
                        throw new Exception("Combination of Windows Toolset v140 and Windows SDK 8.1 requires the Universal CRT to be installed.");
                    }

                    var    sdkVersionName = WindowsPlatformBase.GetSDKVersion(sdk.Key).ToString();
                    string includeRootDir = Path.Combine(sdk.Value, "include", sdkVersionName);
                    SystemIncludePaths.Add(Path.Combine(includeRootDir, "ucrt"));

                    string libraryRootDir = Path.Combine(sdk.Value, "lib", sdkVersionName);
                    switch (Architecture)
                    {
                    case TargetArchitecture.AnyCPU: break;

                    case TargetArchitecture.ARM:
                        SystemLibraryPaths.Add(Path.Combine(libraryRootDir, "ucrt", "arm"));
                        break;

                    case TargetArchitecture.ARM64:
                        SystemLibraryPaths.Add(Path.Combine(libraryRootDir, "ucrt", "arm64"));
                        break;

                    case TargetArchitecture.x86:
                        SystemLibraryPaths.Add(Path.Combine(libraryRootDir, "ucrt", "x86"));
                        break;

                    case TargetArchitecture.x64:
                        SystemLibraryPaths.Add(Path.Combine(libraryRootDir, "ucrt", "x64"));
                        break;

                    default: throw new InvalidArchitectureException(architecture);
                    }
                }
                break;
            }

            case WindowsPlatformToolset.v141:
            case WindowsPlatformToolset.v142:
            {
                switch (Architecture)
                {
                case TargetArchitecture.AnyCPU: break;

                case TargetArchitecture.ARM:
                    SystemLibraryPaths.Add(Path.Combine(vcToolChainDir, "lib", "arm"));
                    break;

                case TargetArchitecture.ARM64:
                    SystemLibraryPaths.Add(Path.Combine(vcToolChainDir, "lib", "arm64"));
                    break;

                case TargetArchitecture.x86:
                    SystemLibraryPaths.Add(Path.Combine(vcToolChainDir, "lib", "x86"));
                    break;

                case TargetArchitecture.x64:
                    SystemLibraryPaths.Add(Path.Combine(vcToolChainDir, "lib", "x64"));
                    break;

                default: throw new InvalidArchitectureException(architecture);
                }
                break;
            }

            default: throw new ArgumentOutOfRangeException();
            }

            // Add Windows SDK include and library paths
            var windowsSdkDir = sdks[SDK];

            switch (SDK)
            {
            case WindowsPlatformSDK.v8_1:
            {
                string includeRootDir = Path.Combine(windowsSdkDir, "include");
                SystemIncludePaths.Add(Path.Combine(includeRootDir, "shared"));
                SystemIncludePaths.Add(Path.Combine(includeRootDir, "um"));
                SystemIncludePaths.Add(Path.Combine(includeRootDir, "winrt"));
                SystemIncludePaths.Add(Path.Combine(includeRootDir, "ucrt"));

                string libraryRootDir = Path.Combine(windowsSdkDir, "lib", "winv6.3");
                switch (Architecture)
                {
                case TargetArchitecture.AnyCPU: break;

                case TargetArchitecture.ARM:
                {
                    SystemLibraryPaths.Add(Path.Combine(libraryRootDir, "um", "arm"));
                    break;
                }

                case TargetArchitecture.ARM64:
                {
                    SystemLibraryPaths.Add(Path.Combine(libraryRootDir, "um", "arm64"));
                    break;
                }

                case TargetArchitecture.x86:
                {
                    SystemLibraryPaths.Add(Path.Combine(libraryRootDir, "um", "x86"));
                    SystemLibraryPaths.Add(Path.Combine(libraryRootDir, "ucrt", "x86"));
                    var binRootDir = Path.Combine(windowsSdkDir, "bin", "x86");
                    _resourceCompilerPath = Path.Combine(binRootDir, "rc.exe");
                    _makepriPath          = Path.Combine(binRootDir, "makepri.exe");
                    break;
                }

                case TargetArchitecture.x64:
                {
                    SystemLibraryPaths.Add(Path.Combine(libraryRootDir, "um", "x64"));
                    SystemLibraryPaths.Add(Path.Combine(libraryRootDir, "ucrt", "x64"));
                    var binRootDir = Path.Combine(windowsSdkDir, "bin", "x64");
                    _resourceCompilerPath = Path.Combine(binRootDir, "rc.exe");
                    _makepriPath          = Path.Combine(binRootDir, "makepri.exe");
                    break;
                }

                default: throw new InvalidArchitectureException(architecture);
                }
                break;
            }

            case WindowsPlatformSDK.v10_0_10240_0:
            case WindowsPlatformSDK.v10_0_10586_0:
            case WindowsPlatformSDK.v10_0_14393_0:
            case WindowsPlatformSDK.v10_0_15063_0:
            case WindowsPlatformSDK.v10_0_16299_0:
            case WindowsPlatformSDK.v10_0_17134_0:
            case WindowsPlatformSDK.v10_0_17763_0:
            case WindowsPlatformSDK.v10_0_18362_0:
            case WindowsPlatformSDK.v10_0_19041_0:
            {
                var    sdkVersionName = WindowsPlatformBase.GetSDKVersion(SDK).ToString();
                string includeRootDir = Path.Combine(windowsSdkDir, "include", sdkVersionName);
                SystemIncludePaths.Add(Path.Combine(includeRootDir, "ucrt"));
                SystemIncludePaths.Add(Path.Combine(includeRootDir, "shared"));
                SystemIncludePaths.Add(Path.Combine(includeRootDir, "um"));
                SystemIncludePaths.Add(Path.Combine(includeRootDir, "winrt"));

                string libraryRootDir = Path.Combine(windowsSdkDir, "lib", sdkVersionName);
                switch (Architecture)
                {
                case TargetArchitecture.AnyCPU: break;

                case TargetArchitecture.ARM:
                {
                    SystemLibraryPaths.Add(Path.Combine(libraryRootDir, "ucrt", "arm"));
                    SystemLibraryPaths.Add(Path.Combine(libraryRootDir, "um", "arm"));
                    break;
                }

                case TargetArchitecture.ARM64:
                {
                    SystemLibraryPaths.Add(Path.Combine(libraryRootDir, "ucrt", "arm64"));
                    SystemLibraryPaths.Add(Path.Combine(libraryRootDir, "um", "arm64"));
                    break;
                }

                case TargetArchitecture.x86:
                {
                    SystemLibraryPaths.Add(Path.Combine(libraryRootDir, "ucrt", "x86"));
                    SystemLibraryPaths.Add(Path.Combine(libraryRootDir, "um", "x86"));
                    var binRootDir = Path.Combine(windowsSdkDir, "bin", sdkVersionName, "x86");
                    _resourceCompilerPath = Path.Combine(binRootDir, "rc.exe");
                    _makepriPath          = Path.Combine(binRootDir, "makepri.exe");
                    break;
                }

                case TargetArchitecture.x64:
                {
                    SystemLibraryPaths.Add(Path.Combine(libraryRootDir, "ucrt", "x64"));
                    SystemLibraryPaths.Add(Path.Combine(libraryRootDir, "um", "x64"));
                    var binRootDir = Path.Combine(windowsSdkDir, "bin", sdkVersionName, "x64");
                    _resourceCompilerPath = Path.Combine(binRootDir, "rc.exe");
                    _makepriPath          = Path.Combine(binRootDir, "makepri.exe");
                    break;
                }

                default: throw new InvalidArchitectureException(architecture);
                }
                break;
            }

            default: throw new ArgumentOutOfRangeException(nameof(SDK));
            }
        }
示例#4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MacToolchain"/> class.
        /// </summary>
        /// <param name="platform">The platform.</param>
        /// <param name="architecture">The target architecture.</param>
        public MacToolchain(MacPlatform platform, TargetArchitecture architecture)
            : base(platform, architecture)
        {
            // Setup tools paths
            if (platform.XCodePath.Contains("/Xcode"))
            {
                // XCode App
                ToolchainPath = Path.Combine(platform.XCodePath, "Toolchains/XcodeDefault.xctoolchain");
                SdkPath       = Path.Combine(platform.XCodePath, "Platforms/MacOSX.platform/Developer");
            }
            else
            {
                // XCode Command Line Tools
                ToolchainPath = SdkPath = platform.XCodePath;
                if (!Directory.Exists(Path.Combine(ToolchainPath, "usr/bin")))
                {
                    throw new Exception("Missing XCode Command Line Tools. Run 'xcode-select --install'.");
                }
            }
            ClangPath    = Path.Combine(ToolchainPath, "usr/bin/clang++");
            LinkerPath   = Path.Combine(ToolchainPath, "usr/bin/clang++");
            ArchiverPath = Path.Combine(ToolchainPath, "usr/bin/libtool");
            ClangVersion = GetClangVersion(ClangPath);
            SdkPath      = Path.Combine(SdkPath, "SDKs");
            var sdks       = Directory.GetDirectories(SdkPath);
            var sdkPrefix  = "MacOSX";
            var bestSdk    = string.Empty;
            var bestSdkVer = new Version(0, 0, 0, 1);

            foreach (var sdk in sdks)
            {
                var name = Path.GetFileName(sdk);
                if (!name.StartsWith(sdkPrefix))
                {
                    continue;
                }
                var versionName = name.Replace(sdkPrefix, "").Replace(".sdk", "");
                if (string.IsNullOrEmpty(versionName))
                {
                    continue;
                }
                if (!versionName.Contains("."))
                {
                    versionName += ".0";
                }
                var version = new Version(versionName);
                if (version > bestSdkVer)
                {
                    bestSdkVer = version;
                    bestSdk    = sdk;
                }
            }
            if (bestSdk.Length == 0)
            {
                throw new Exception("Failed to find any valid SDK for " + sdkPrefix);
            }
            SdkPath = bestSdk;

            // Setup system paths
            //SystemIncludePaths.Add(Path.Combine(ToolchainPath, "usr/include"));
            //SystemIncludePaths.Add(Path.Combine(ToolchainPath, "usr/include/c++/v1"));
            //SystemIncludePaths.Add(Path.Combine(ToolchainPath, "usr/lib/clang", ClangVersion.ToString(3), "include"));
            //SystemIncludePaths.Add(Path.Combine(SdkPath, "usr/include"));
            SystemLibraryPaths.Add(Path.Combine(SdkPath, "usr/lib"));
        }