VS: Don't override user options. Add additional vs hints

Make sure we include any user-specified project settings in our
project definitions, this way users can customize their VS
environment to more closely match what they're building for, and
they better can control debugging and deployment from VS.

Add support for setting VS-only compiler defines, include paths, and
additional linker options, as a hint to VS to use when loading projects
and parsing code. VS would usually know these on non nmake projects,
but for nmake projects we have to tell it about any implicit information
that the compiler has, so it can resolve symbols in the editor.
This commit is contained in:
Andreia Gaita 2024-02-12 13:28:35 +01:00
parent 7638a6c981
commit 1c7167e9ac
2 changed files with 16 additions and 12 deletions

View file

@ -1380,14 +1380,18 @@ def generate_vs_project(env, original_args, project_name="godot"):
props_template = props_template.replace("%%OUTPUT%%", output) props_template = props_template.replace("%%OUTPUT%%", output)
props_template = props_template.replace( proplist = [format_key_value(v) for v in list(env["CPPDEFINES"])]
"%%DEFINES%%", ";".join([format_key_value(v) for v in list(env["CPPDEFINES"])]) proplist += [format_key_value(j) for j in env.get("VSHINT_DEFINES", [])]
) props_template = props_template.replace("%%DEFINES%%", ";".join(proplist))
props_template = props_template.replace("%%INCLUDES%%", ";".join([str(j) for j in env["CPPPATH"]]))
props_template = props_template.replace( proplist = [str(j) for j in env["CPPPATH"]]
"%%OPTIONS%%", proplist += [str(j) for j in env.get("VSHINT_INCLUDES", [])]
" ".join(env["CCFLAGS"]) + " " + " ".join([x for x in env["CXXFLAGS"] if not x.startswith("$")]), props_template = props_template.replace("%%INCLUDES%%", ";".join(proplist))
)
proplist = env["CCFLAGS"]
proplist += [x for x in env["CXXFLAGS"] if not x.startswith("$")]
proplist += [str(j) for j in env.get("VSHINT_OPTIONS", [])]
props_template = props_template.replace("%%OPTIONS%%", " ".join(proplist))
# Windows allows us to have spaces in paths, so we need # Windows allows us to have spaces in paths, so we need
# to double quote off the directory. However, the path ends # to double quote off the directory. However, the path ends

View file

@ -4,13 +4,13 @@
<NMakeBuildCommandLine>%%BUILD%%</NMakeBuildCommandLine> <NMakeBuildCommandLine>%%BUILD%%</NMakeBuildCommandLine>
<NMakeReBuildCommandLine>%%REBUILD%%</NMakeReBuildCommandLine> <NMakeReBuildCommandLine>%%REBUILD%%</NMakeReBuildCommandLine>
<NMakeCleanCommandLine>%%CLEAN%%</NMakeCleanCommandLine> <NMakeCleanCommandLine>%%CLEAN%%</NMakeCleanCommandLine>
<NMakeOutput>%%OUTPUT%%</NMakeOutput> <NMakeOutput Condition="'$(NMakeOutput)' == ''">%%OUTPUT%%</NMakeOutput>
<NMakePreprocessorDefinitions>%%DEFINES%%</NMakePreprocessorDefinitions> <NMakePreprocessorDefinitions>%%DEFINES%%;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
<NMakeIncludeSearchPath>%%INCLUDES%%</NMakeIncludeSearchPath> <NMakeIncludeSearchPath>%%INCLUDES%%;$(NMakeIncludeSearchPath)</NMakeIncludeSearchPath>
<NMakeForcedIncludes>$(NMakeForcedIncludes)</NMakeForcedIncludes> <NMakeForcedIncludes>$(NMakeForcedIncludes)</NMakeForcedIncludes>
<NMakeAssemblySearchPath>$(NMakeAssemblySearchPath)</NMakeAssemblySearchPath> <NMakeAssemblySearchPath>$(NMakeAssemblySearchPath)</NMakeAssemblySearchPath>
<NMakeForcedUsingAssemblies>$(NMakeForcedUsingAssemblies)</NMakeForcedUsingAssemblies> <NMakeForcedUsingAssemblies>$(NMakeForcedUsingAssemblies)</NMakeForcedUsingAssemblies>
<AdditionalOptions>%%OPTIONS%%</AdditionalOptions> <AdditionalOptions>%%OPTIONS%% $(AdditionalOptions)</AdditionalOptions>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="%%CONDITION%%"> <PropertyGroup Condition="%%CONDITION%%">
%%PROPERTIES%% %%PROPERTIES%%