VS: Fix user workflows with custom user VS configurations

Users can add additional VS project configurations with their own
custom settings, but to support this workflow, we can't rely directly
on $(Platform) and $(Configuration), because VS needs those to be
both unique Configuration|Platform combos, and we need to allow for
different combos of Configuration|Platform to point to the same
scons build configuration.

GodotPlatform and GodotConfiguration properties lets us decouple from
the magic VS properties that we don't control, so users can add
however many Platform|Configuration combos they want and still
point to a specific GodotPlatform|GodotConfiguration build config.
This commit is contained in:
Andreia Gaita 2024-02-12 16:39:58 +01:00
parent 7638a6c981
commit 1d29fb0853
3 changed files with 24 additions and 8 deletions

View File

@ -1367,7 +1367,7 @@ def generate_vs_project(env, original_args, project_name="godot"):
vsconf = f'{target}|{a["platform"]}' vsconf = f'{target}|{a["platform"]}'
break break
condition = "'$(Configuration)|$(Platform)'=='" + vsconf + "'" condition = "'$(GodotConfiguration)|$(GodotPlatform)'=='" + vsconf + "'"
properties.append("<ActiveProjectItemList>;" + ";".join(activeItems) + ";</ActiveProjectItemList>") properties.append("<ActiveProjectItemList>;" + ";".join(activeItems) + ";</ActiveProjectItemList>")
output = f'bin\\godot{env["PROGSUFFIX"]}' output = f'bin\\godot{env["PROGSUFFIX"]}'
@ -1482,6 +1482,13 @@ def generate_vs_project(env, original_args, project_name="godot"):
"</ProjectConfiguration>", "</ProjectConfiguration>",
] ]
properties += [
f"<PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='{godot_target}|{proj_plat}'\">",
f" <GodotConfiguration>{godot_target}</GodotConfiguration>",
f" <GodotPlatform>{proj_plat}</GodotPlatform>",
"</PropertyGroup>",
]
if godot_platform != "windows": if godot_platform != "windows":
configurations += [ configurations += [
f'<ProjectConfiguration Include="editor|{proj_plat}">', f'<ProjectConfiguration Include="editor|{proj_plat}">',
@ -1490,6 +1497,13 @@ def generate_vs_project(env, original_args, project_name="godot"):
"</ProjectConfiguration>", "</ProjectConfiguration>",
] ]
properties += [
f"<PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='editor|{proj_plat}'\">",
f" <GodotConfiguration>editor</GodotConfiguration>",
f" <GodotPlatform>{proj_plat}</GodotPlatform>",
"</PropertyGroup>",
]
p = f"{project_name}.{godot_platform}.{godot_target}.{godot_arch}.generated.props" p = f"{project_name}.{godot_platform}.{godot_target}.{godot_arch}.generated.props"
imports += [ imports += [
f'<Import Project="$(MSBuildProjectDirectory)\\{p}" Condition="Exists(\'$(MSBuildProjectDirectory)\\{p}\')"/>' f'<Import Project="$(MSBuildProjectDirectory)\\{p}" Condition="Exists(\'$(MSBuildProjectDirectory)\\{p}\')"/>'
@ -1502,6 +1516,10 @@ def generate_vs_project(env, original_args, project_name="godot"):
f"{{{proj_uuid}}}.{godot_target}|{sln_plat}.Build.0 = {godot_target}|{proj_plat}", f"{{{proj_uuid}}}.{godot_target}|{sln_plat}.Build.0 = {godot_target}|{proj_plat}",
] ]
# Add an extra import for a local user props file at the end, so users can add more overrides.
imports += [
f'<Import Project="$(MSBuildProjectDirectory)\\{project_name}.vs.user.props" Condition="Exists(\'$(MSBuildProjectDirectory)\\{project_name}.vs.user.props\')"/>'
]
section1 = sorted(section1) section1 = sorted(section1)
section2 = sorted(section2) section2 = sorted(section2)

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="17.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="17.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='%%VSCONF%%'"> <PropertyGroup Condition="'$(GodotConfiguration)|$(GodotPlatform)'=='%%VSCONF%%'">
<NMakeBuildCommandLine>%%BUILD%%</NMakeBuildCommandLine> <NMakeBuildCommandLine>%%BUILD%%</NMakeBuildCommandLine>
<NMakeReBuildCommandLine>%%REBUILD%%</NMakeReBuildCommandLine> <NMakeReBuildCommandLine>%%REBUILD%%</NMakeReBuildCommandLine>
<NMakeCleanCommandLine>%%CLEAN%%</NMakeCleanCommandLine> <NMakeCleanCommandLine>%%CLEAN%%</NMakeCleanCommandLine>

View File

@ -9,23 +9,21 @@
<Keyword>MakeFileProj</Keyword> <Keyword>MakeFileProj</Keyword>
<VCProjectUpgraderObjectName>NoUpgrade</VCProjectUpgraderObjectName> <VCProjectUpgraderObjectName>NoUpgrade</VCProjectUpgraderObjectName>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> %%PROPERTIES%%
%%PROPERTIES%%
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration"> <PropertyGroup Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType> <ConfigurationType>Makefile</ConfigurationType>
<UseOfMfc>false</UseOfMfc> <UseOfMfc>false</UseOfMfc>
<PlatformToolset>v143</PlatformToolset> <PlatformToolset>v143</PlatformToolset>
<OutDir>$(SolutionDir)\bin\$(Platform)\$(Configuration)\</OutDir> <OutDir>$(SolutionDir)\bin\$(GodotPlatform)\$(GodotConfiguration)\</OutDir>
<IntDir>obj\$(Platform)\$(Configuration)\</IntDir> <IntDir>obj\$(GodotPlatform)\$(GodotConfiguration)\</IntDir>
<LayoutDir>$(OutDir)\Layout</LayoutDir> <LayoutDir>$(OutDir)\Layout</LayoutDir>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings"> <ImportGroup Label="ExtensionSettings">
</ImportGroup> </ImportGroup>
<ImportGroup Label="PropertySheets"> <ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(GodotPlatform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(GodotPlatform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup> </ImportGroup>
<PropertyGroup Label="UserMacros" /> <PropertyGroup Label="UserMacros" />
<PropertyGroup> <PropertyGroup>