-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
win,build: add Visual Studio 2017 support #11867
Conversation
Add support for creating VS2017 projects to gyp.
Add support for Visual Studio 2017. A C# script, compiled and executed by PowerShell, is used to query the COM server about the location of VS installation and installed SDK version, filtering installations that miss the required components.
351bfbb
to
a1d8608
Compare
else | ||
continue; | ||
|
||
Console.WriteLine(String.Format(" - Found {0}", id)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
onsole.WriteLine(String.Format(" - Found {0}", id)); [](start = 17, length = 53)
unreachable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is reached when any of the if conditions above is true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, ofcourse. I misread the code.
tools/Find-VS2017.cs
Outdated
if (Win10SDKVer > 0) | ||
{ | ||
Console.WriteLine(" - Using this installation with Windows 10 SDK"); | ||
string[] lines = { String.Format("set \"VS2017_INSTALL={0}\"", path), String.Format("set \"VS2017_SDK=10.0.{0}.0\"", Win10SDKVer) }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"set "VS2017_INSTALL={0}"" [](start = 53, length = 28)
Have a string variable for this and resuse it below as well.
@@ -2662,6 +2662,15 @@ def _GetMSBuildGlobalProperties(spec, guid, gyp_file_name): | |||
else: | |||
properties[0].append(['ApplicationType', 'Windows Store']) | |||
|
|||
msvs_windows_sdk_version = None | |||
if msvs_windows_sdk_version == None and version.ShortName() == '2017': | |||
vs2017_sdk = '10.0.14393.0' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
10.0.14393.0 [](start = 18, length = 12)
I didn't follow your changes in gyp, but is this always safe to consider this as default version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may not always be installed, but is the one selected by the installer when the "Desktop development with C++" workload is selected, so it should be the most common one. If it is not installed, compilation will fail later, but it's better than failing here unconditionally. Should this be something else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't mind keeping this version. I just wanted to know where this came from.
In reply to: 106287872 [](ancestors = 106287872)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather see an early fail then use an arbitrary default.
P.S. When "Windows Creators Edition" will be released the default version will be 10.0.15052.*
if msvs_windows_sdk_version == None and version.ShortName() == '2017': | ||
vs2017_sdk = '10.0.14393.0' | ||
vs2017_sdk = os.environ.get('vs2017_sdk', vs2017_sdk) | ||
if vs2017_sdk: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vs2017_sdk [](start = 7, length = 10)
Correct me, but this will always be true, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know of a way to set an empty variable in cmd
, but it's possible that the variable is set from another program that calls this. Something like os.environ['vs2017_sdk'] = ''
in python or empty variable when using gitbash.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, AFAIK, there is not way to set empty variable in cmd
. Empty variable is equivalent of not defining environment variable. Python, definitely you could do that in which case the check makes sense.
vs2017_sdk = os.environ.get('vs2017_sdk', vs2017_sdk) | ||
if vs2017_sdk: | ||
msvs_windows_sdk_version = vs2017_sdk | ||
if msvs_windows_sdk_version: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
msvs_windows_sdk_version [](start = 5, length = 24)
and probably this as well will always be true?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Following from above, can be false.
public static void Query() | ||
{ | ||
ISetupConfiguration query = new SetupConfiguration(); | ||
ISetupConfiguration2 query2 = (ISetupConfiguration2)query; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use var
to prevent redundancy?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're trying to support Windows 7/2008R2 with the tools that it ships with by default, that means C# version 2. var
was only introduced in version 3.
Updated. @kunalspathak @seishun thanks for your reviews! |
LGTM |
|
{ | ||
Console.WriteLine(" - Using this installation with Windows 8.1 SDK"); | ||
string[] lines = { setPath, "set \"VS2017_SDK=8.1\"" }; | ||
System.IO.File.WriteAllLines(@"Set_VS2017.bat", lines); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This smell bad...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be done differently?
uses_vcxproj=True, | ||
path=path, | ||
sdk_based=sdk_based, | ||
default_toolset='v141'), | ||
'2015': VisualStudioVersion('2015', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this is a de-novo patch, not based on the strategy in node-gyp:configure.js
.
Could be done in configure
which generates node.gypi
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Node-gyp is very adverse to floating patches, but that is not the case here. I'd rather have the floating patch and not hack gyp. This patch is small enough to be reviewed here, and contained in a git commit so it can be easily reverted if a different approach lands upstream.
@rem Look for Visual Studio 2015 | ||
:vc-set-2015 | ||
if defined target_env if "%target_env%" NEQ "vc2015" goto msbuild-not-found |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This breaks the current usage. vcbuild.bat
should work with no arguments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vcbuild.bat
works with no arguments. This only takes effect if the user wants to select a specific version of VS to use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, missed the if defined target_env
@refack thanks for your review!
Note there are two versions of gyp in this repository, one under
I'd rather use this trimmed down version that is easier to maintain here. It should need very little changes. What bugs do you see here?
What do you mean, instead of |
On Mon, Mar 20, 2017 at 11:18 PM, João Reis ***@***.***> wrote:
@refack <https://github.com/refack> thanks for your review!
1. I think that cherry picking changes from node-gyp/gyp is gonna be a
PITA.
Note there are two versions of gyp in this repository, one under
deps/npm/node_modules/node-gyp/gyp and another under tools/gyp. They are
already different and separately maintained (the first is maintained in
node-gyp).
I'm suggesting to merge them
1. Anyway you should at least use my new GetVS2017Configuration.cs it
has quite a bit of traction, and has a few bugs solved.
I'd rather use this trimmed down version that is easier to maintain here.
It should need very little changes. What bugs do you see here?
New version has been trimmed down (based some by your feedback)
https://github.com/node4good/msvs-com-helper
1. I think you should run vcvarsall.bat as msbuild.exe would fail
otherwise.
What do you mean, instead of VsDevCmd.bat? I did not find any advantage
of one over the other, only that vcvarsall.bat was not present in the RC
version. msbuild.exe does not fail for me, does it for you? Can you paste
your output (or make a gist perhaps, if it's big)?
Not instead, just sooner. Now it's only run before `build` I suggest
running it before `configure` and use it's ENV for downstream decisions.
… —
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#11867 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAF6sz3KJ6Y4Y5xOU554OgM1W3_AO-Z2ks5rn0F8gaJpZM4MeMB8>
.
|
It is run before configure. It is run in line 160, configure is in 208 and build in 220. Did I misunderstood? |
Sorry I didn't follow the code flow correctly, I thought |
@joaocgreis now that we have VS2017 in upstream |
This uses the same method that landed in node-gyp in nodejs/node-gyp#1130, using PowerShell to compile and execute a C# script that queries the COM server installed by Visual Studio 2017. The script is almost the same as the one in node-gyp, but adapted to generate a small
.bat
file that sets environment variables instead of JSON output.A backport of the Gyp patch under review in https://chromium-review.googlesource.com/c/433540 is included (cherry-picked from #11084). This is a different approach than the one used in node-gyp. There, gyp is forced to use VS2015 (generating projects that are compatible with 2017), but to do that here would require deeper changes in configure. Since we already have a few more floating patches, adding this seems cleaner and easier to maintain to me.
cc @nodejs/platform-windows @nodejs/build
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
Windows, build.