Open PathogenDavid opened 3 years ago
For the sake of limiting bus factor, here's WindowsSdkHelper
mentioned above: https://gist.github.com/PathogenDavid/29794af32ac1c88fdd489d27a2debb39
It doesn't actually override what Clang uses using environment variables but instead uses --no-standard-includes
and -isystem
based on the logic Clang uses internally.
Usage looks like this:
// We currently target Windows SDK 10.0.14393.0, which is Windows 10 1607
WindowsSdkHelper sdk = new("10.0.14393.0");
TranslatedLibraryBuilder builder = new()
{
Options = new TranslationOptions()
{
SystemHeadersAreAlwaysOutOfScope = false
}
};
sdk.ConfigureBuilder(builder);
builder.AddFile(sdk.GetHeaderFilePath("um", "Windows.h"));
builder.AddFile(sdk.GetHeaderFilePath("um", "ShellScalingApi.h"));
// ... etc
Right now generator authors can pin to a specific MSVC tool version or Windows SDK version either by:
-vcvars_ver
/-winsdk_version
VCToolsInstallDir
/WindowsSdkDir
environment variables before building the library, IE:However this is not super intuitive or discoverable, it'd be nice if Biohazrd provided official means of specifying a MSVC tools version preference.
We already do this for the Windows SDK in the private Win32 and DirectX generators, see
InfectedWin32.Generator.WindowsSdkHelper
.This would enable a handful of useful features:
When we fix this, we should remove the workaround added in https://github.com/InfectedLibraries/Biohazrd/issues/98 and change things to avoid the affected versions and error if they're the only ones available. (Could probably be a warning, but the issue affects most non-trivial libraries and having it be noticeable is probably better than not.)