January 31, 2022
On Friday, 28 January 2022 at 22:55:17 UTC, MoonlightSentinel wrote:
>
> Software:
> - Any VS version (already used 17 and 22 but others should work as well)
> - DM make
>
> Setup for Druntime / Phobos*:
> - Change the VS-related variables in `win64.mak` based on your specific VS installation (because they change with each version)
>   * `VCDIR`
>   * `SDKDIR`
>   * `BINDIR`
>
> Building should then be as simple as running `make -f win64.mak` in each directory (for dmd it simply forwards to `src/build.d`).
>
> ---
>
> Currently using VS 2022 which required the following changes:
>

So I've come up with the following code that will extract those values for me ;-)

// ----

module test;

import std.stdio : writeln;
import std.process : environment;

/+
When building from source on Windows, both "druntime\win64.mak"
and "phobos\win64.mak" require two variables (VCDIR and SDKDIR)
to be set according to the version of Visual Studio you are using.

This code below will provide you with the values for those two variables.

However, for this code to get those variables, you need to run this within
a VS Developer Command Prompt not a normal Command Prompt.
+/

int main()
{
    auto VCDIR = environment.get("VCToolsInstallDir");
    if (VCDIR is null) { return 1;}
    writeln("VCDIR=", VCDIR[0..$-1]); // also removes the trailing backslash

    auto SDKVersion = environment.get("WindowsSDKVersion");
    if (SDKVersion is null) { return 1;}

    auto SDKDIR = environment.get("WindowsSdkDir");
    if (SDKDIR is null) { return 1;}
    writeln("SDKDIR=", SDKDIR ~ "Include\\" ~ SDKVersion[0..$-1]); // also removes the trailing backslash

    return 0;
}

// -----
January 31, 2022
On Sun, Jan 30, 2022 at 10:20:38PM +0000, forkit via Digitalmars-d wrote:
> On Sunday, 30 January 2022 at 20:33:58 UTC, H. S. Teoh wrote:
> > 
> > This should be incorporated into the wiki page so that the next person that comes along can benefit from it.
[...]
> I'm still working on gaining a fuller understanding of all this.
> 
> Also, I don't just want to know 'what', but also 'why'.
[...]

Excellent.  When you find out the 'why's, please update the wiki page to explain it all.


T

-- 
Being able to learn is a great learning; being able to unlearn is a greater learning.
1 2 3 4 5
Next ›   Last »