// Windows 10 SDK
//------------------------------------------------------------------------------
//
// Detect Windows 10 SDK
//
// We search in the following locations, in order of preference:
//  1) Vendorized in External (side by side with this bff)
//  2) Part of a Windows 10 installation (Program Files)
//
#if file_exists( "10\bin\10.0.26100.0\x64\RC.exe" )
    //
    // Use vendorized toolchain
    //
    .Windows10_SDKBasePath        = '$_CURRENT_BFF_DIR_$\10'
    .Windows10_SDKVersion         = '10.0.26100.0'
#else
    //
    // Use Windows10SDK installation
    //
    #if file_exists( "C:\Program Files (x86)\Windows Kits\10\bin\10.0.26100.0\x64\RC.exe" )
        .Windows10_SDKBasePath        = 'C:\Program Files (x86)\Windows Kits\10'
        .Windows10_SDKVersion         = '10.0.26100.0'
    #else
        //
        // Failed
        //
        Print( '-----------------------------------------------------------------------' )
        Print( '- Unable to auto-detect Windows10SDK - please specify installation manually -' )
        Print( '-----------------------------------------------------------------------' )
        .Windows10_SDKBasePath        = .Set_Path_Here    // <-- Set path here
        .Windows10_SDKVersion         = .Set_Version_Here // <-- Set version here
    #endif
#endif

// Defines
//------------------------------------------------------------------------------
.WindowsSDK_Defines             = ' -DWIN32_LEAN_AND_MEAN'
                                + ' -DWIN32'
                                + ' -D_WIN32'
                                + ' -D__WINDOWS__'
                                + ' -D_HAS_EXCEPTIONS=0'

// Windows 10 SDK
//------------------------------------------------------------------------------
.Windows10_SDK =
[
#if USING_VS2022
    .WindowsSDK_IncludePaths        = ' "/external:I$Windows10_SDKBasePath$/Include/$Windows10_SDKVersion$/ucrt"'
                                    + ' "/external:I$Windows10_SDKBasePath$/Include/$Windows10_SDKVersion$/um"'
                                    + ' "/external:I$Windows10_SDKBasePath$/Include/$Windows10_SDKVersion$/shared"'
#else
    .WindowsSDK_IncludePaths        = ' "-I$Windows10_SDKBasePath$/Include/$Windows10_SDKVersion$/ucrt"'
                                    + ' "-I$Windows10_SDKBasePath$/Include/$Windows10_SDKVersion$/um"'
                                    + ' "-I$Windows10_SDKBasePath$/Include/$Windows10_SDKVersion$/shared"'
#endif
    .WindowsSDK_IncludePaths_RC     = ' "-I$Windows10_SDKBasePath$/Include/$Windows10_SDKVersion$/ucrt"'
                                    + ' "-I$Windows10_SDKBasePath$/Include/$Windows10_SDKVersion$/um"'
                                    + ' "-I$Windows10_SDKBasePath$/Include/$Windows10_SDKVersion$/shared"'

    .WindowsSDK_WinRTAssemblyPath   = '$Windows10_SDKBasePath$/UnionMetadata/$Windows10_SDKVersion$/'

    .CommonCompilerOptions          = .WindowsSDK_IncludePaths
                                    + .WindowsSDK_Defines
                                    + ' -DWIN64'

    .CompilerOptions                = .CommonCompilerOptions
    .CompilerOptionsC               = .CommonCompilerOptions
    .CompilerOptionsDeoptimized     = .CommonCompilerOptions
    .PCHOptions                     = .CommonCompilerOptions
]

.Windows10_SDK_X64 =
[
    Using( .Windows10_SDK )

    .LinkerOptions                  = ' /LIBPATH:"$Windows10_SDKBasePath$/Lib/$Windows10_SDKVersion$/um/x64"'
                                    + ' /LIBPATH:"$Windows10_SDKBasePath$/Lib/$Windows10_SDKVersion$/ucrt/x64"'
                                    + ' /MACHINE:X64'
]
.Windows10_SDK_ARM64 =
[
    Using( .Windows10_SDK )

    .LinkerOptions                  = ' /LIBPATH:"$Windows10_SDKBasePath$/Lib/$Windows10_SDKVersion$/um/arm64"'
                                    + ' /LIBPATH:"$Windows10_SDKBasePath$/Lib/$Windows10_SDKVersion$/ucrt/arm64"'
                                    + ' /MACHINE:ARM64'
]
.Windows10_SDK_X64_ClangCl =
[
    // When using clang-cl, we can use these include paths to suppress compile errors
    // inside system headers (which are full of problems)
    .WindowsSDK_IncludePaths        = ' /imsvc "$Windows10_SDKBasePath$/Include/$Windows10_SDKVersion$/ucrt"'
                                    + ' /imsvc "$Windows10_SDKBasePath$/Include/$Windows10_SDKVersion$/um"'
                                    + ' /imsvc "$Windows10_SDKBasePath$/Include/$Windows10_SDKVersion$/shared"'

    .WindowsSDK_WinRTAssemblyPath   = '$Windows10_SDKBasePath$/UnionMetadata/$Windows10_SDKVersion$/'

    .CommonCompilerOptions          = .WindowsSDK_IncludePaths
                                    + .WindowsSDK_Defines
                                    + ' -DWIN64'

    .CompilerOptions                = .CommonCompilerOptions
    .CompilerOptionsC               = .CommonCompilerOptions
    .CompilerOptionsDeoptimized     = .CommonCompilerOptions
    .PCHOptions                     = .CommonCompilerOptions

    .LinkerOptions                  = ' /LIBPATH:"$Windows10_SDKBasePath$/Lib/$Windows10_SDKVersion$/um/x64"'
                                    + ' /LIBPATH:"$Windows10_SDKBasePath$/Lib/$Windows10_SDKVersion$/ucrt/x64"'
                                    + ' /MACHINE:X64'
]
Compiler( 'ResourceCompiler-Windows10' )
{
    .Executable                 = '$Windows10_SDKBasePath$/Bin/$Windows10_SDKVersion$/x64/RC.exe'
    .CompilerFamily             = 'custom'
}

// PATH environment variable
//------------------------------------------------------------------------------
.WINDOWS_SDK_2019_PATH          = '$Windows10_SDKBasePath$/bin/$Windows10_SDKVersion$/x64'

//------------------------------------------------------------------------------