The default "Output Directory" for the generated vcxproj is "$(SolutionDir)$(Configuration)\".
IMHO it is wrong because you may want multiple solutions referencing the same project files while keeping the binaries in the same directory.
I would put instead "$(ProjectDir)$(Configuration)\".
Anyway, I tried to change it in several ways with no luck:
Is there any other workaround to impose the desired Output Directory?
Thanks!
maybe cc/ @refack
Currently it's hardcoded https://github.com/nodejs/node-gyp/blob/master/gyp/pylib/gyp/generator/msvs.py#L1421
We can discuss a patch to GYP, but I would like to understand the use case better 🤔
Isn't that just a hardcoded default? Can OutputDirectory be set in binding.gyp under msvs_configuration_attributes?
@refack I believe the use-case is quite common.
Gyp generates the folder with the project, solution and binaries, therefore I need to avoid to put there anything that is hand-made, otherwise it can be lost.
The advantages in having another solution are many:
Basically I just need to have one or more custom solution files, that may be kept outside the directory structure that will be deleted/re-created by Gyp, but without moving the binaries which is disturbing because of any other relative path management or post-build actions you run.
Said that, it would be nice to specify the "Output Directory" directly in the gyp file so that anyone can get control over it. This way you may leave the default to the current value to avoid breaking any existing code.
Thanks
@richardlau Could you please provide me a link with the msvs_configuration_attributes documentation?
Even if it looks like it cannot be used for my purpose (Output Directory is hadcoded) it may be useful for other options.
Thanks
Could you please provide me a link with the msvs_configuration_attributes documentation?
The docs are not-amazing, but not completely useless 🤷♂️ https://gyp.gsrc.io/docs/LanguageSpecification.md#Generated-Visual-Studio-vcproj-Files
@refack I already read that page but I have no clue on how customize that part.
Reading many threads in the Issues I tried to use the props and vsprops files with no luck at all.
Others tried to customize the Output Directory before me without success. Since the props and vsprops files are applied in a specific order, I guess my customizations gets overriden by the vcxproj itself.
Anyway, if you can provide working samples of gyp files, I would be more than happy to give a try.
thank you
Anyway, if you can provide working samples of gyp files, I would be more than happy to give a try.
One of GYP's test manipulates OutputDirectory — https://github.com/refack/GYP/blob/master/test/builddir/src/builddir.gypi
To run the following (fill in the
set PYTHONPATH=<GYP_DIR>\test\lib
set PRESERVE=1
set PYTHONUNBUFFERED=1
set TESTGYP_FORMAT=msvs
set GYP_BUILD_TOOL=<PATH_TO_VS>\MSBuild\15.0\Bin\MSBuild.exe
cd <GYP_DIR>
python.exe test/builddir/gyptest-default.py
Now, I'm not sure how well this works for node-gyp but worth a try
@raffaeler I don't have any links; I just read the gyp source that @refack posted.
A quick Google search throws up https://github.com/haywire/haywire/blob/master/common.gypi as an example. I won't be able to test on a development box until Monday.
@refack @richardlau
I guess I am missing something basic, because I tried both the samples you posted (specifying a gypi file with an include in my gyp) but every time I run node-gyp configure and node-gyp rebuild I always see the Output Directory se to $(SolutionDir)$(Configuration)\
Now, I'm not sure how well this works for node-gyp but worth a try
I guess I am missing something basic, because I tried both the samples you posted (specifying a gypi file with an include in my gyp) but every time I run node-gyp configure and node-gyp rebuild I always see the Output Directory se to $(SolutionDir)$(Configuration)\
So node-gyp is a wrapper around GYP and I was afraid it might override the options in the .gyp files. I think the "offending" point is https://github.com/nodejs/node-gyp/blob/master/lib/configure.js#L308
So node-gyp is a wrapper around GYP and I was afraid it might override the options in the .gyp files. I think the "offending" point is https://github.com/nodejs/node-gyp/blob/master/lib/configure.js#L308
@refack The link specifies the "build" directory where the vcxproj and sln files are created.
My request is different. I need to change the Output Directory written inside the vcxproj file.
From @richardlau link I understood that my binding.gyp file can specify the include directive referencing a gypi file.
But I still can't get the msvs_configuration_attributes working. The syntax to override the Output Directory in not clear too (what does this mean: '<(DEPTH)\\builddir/Default' ?).
@raffaeler try adding this to your targets (or try to add a 'target_defaults': { } section)
'msvs_configuration_attributes': {
'OutputDirectory': '$(ProjectDir)$(Configuration)',
}
I got the follwing in the vcxproj files:
<PropertyGroup>
<ExecutablePath>$(ExecutablePath);$(MSBuildProjectDirectory)\..\bin\;$(MSBuildProjectDirectory)\..\bin\</ExecutablePath>
<IgnoreImportLibrary>true</IgnoreImportLibrary>
<IntDir>$(Configuration)\obj\$(ProjectName)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
<OutDir>$(ProjectDir)$(Configuration)\</OutDir>
<TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.node</TargetExt>
<TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.node</TargetExt>
<TargetExt Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.node</TargetExt>
<TargetExt Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.node</TargetExt>
<TargetName>$(ProjectName)</TargetName>
<TargetPath>$(OutDir)\$(ProjectName).node</TargetPath>
</PropertyGroup>
I played a little bit, best results come with:
{
"target_defaults": {
"msvs_configuration_attributes": {
"OutputDirectory": "$(MSBuildProjectName)\\$(Configuration)"
}
},
"targets": {
"..."
}
}
@refack Thank you, it worked!
I didn't know the msvs_configuration_attributes could be added to the config.gyp target :)
And I don't get why it did not work inside the gypi included file
The docs definitely need a lot of work :) :)
@raffaeler glad I could help.
Generally this issue should have gone to either to https://groups.google.com/forum/#!forum/gyp-developer or to https://github.com/nodejs/help/issues/.
I'm closing this issue, feel free to reopen if you find any followup problems with node-gyp itself.
Most helpful comment
@raffaeler try adding this to your targets (or try to add a
'target_defaults': { }section)I got the follwing in the
vcxprojfiles: