Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VSOptions: Prepare for setting the INCLUDE env var for importC #15780

Merged
merged 1 commit into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions compiler/src/dmd/vsoptions.d
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,18 @@ public:
return FileName.exists(proposed) ? proposed : null;
}

const(char)* getVCIncludeDir() const
{
const(char)* proposed;

if (VCToolsInstallDir !is null)
proposed = FileName.combine(VCToolsInstallDir, "include");
else if (VCInstallDir !is null)
proposed = FileName.combine(VCInstallDir, "include");

return FileName.exists(proposed) ? proposed : null;
}

/**
* get the path to the universal CRT libraries
* Params:
Expand Down Expand Up @@ -528,6 +540,30 @@ public:
return null;
}

const(char)* getSDKIncludePath() const
{
if (WindowsSdkDir)
{
alias umExists = returnDirIfContainsFile!"um"; // subdir in this case

const sdk = FileName.combine(WindowsSdkDir.toDString, "include");
if (WindowsSdkVersion)
{
if (auto p = umExists(sdk, WindowsSdkVersion.toDString)) // SDK 10.0
return p;
}
// purely speculative
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have any old SDKs on my box, so couldn't verify the subdirs for those.

if (auto p = umExists(sdk, "win8")) // SDK 8.0
return p;
if (auto p = umExists(sdk, "winv6.3")) // SDK 8.1
return p;
if (auto p = umExists(sdk)) // SDK 7.1 or earlier
return p;
}

return null;
}

private:
extern(D):

Expand Down
2 changes: 2 additions & 0 deletions compiler/src/dmd/vsoptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ struct VSOptions
void initialize();
const char *getVCBinDir(bool x64, const char *&addpath) const;
const char *getVCLibDir(bool x64) const;
const char *getVCIncludeDir() const;
const char *getUCRTLibPath(bool x64) const;
const char *getSDKLibPath(bool x64) const;
const char *getSDKIncludePath() const;
};

#endif // _WIN32
Loading