From 1c7167e9ac9156e05b25d6b1399c6535e5666018 Mon Sep 17 00:00:00 2001 From: Andreia Gaita Date: Mon, 12 Feb 2024 13:28:35 +0100 Subject: [PATCH] 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. --- methods.py | 20 ++++++++++++-------- misc/msvs/props.template | 8 ++++---- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/methods.py b/methods.py index c22b1f11e46..13b06ad527f 100644 --- a/methods.py +++ b/methods.py @@ -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( - "%%DEFINES%%", ";".join([format_key_value(v) for v in list(env["CPPDEFINES"])]) - ) - props_template = props_template.replace("%%INCLUDES%%", ";".join([str(j) for j in env["CPPPATH"]])) - props_template = props_template.replace( - "%%OPTIONS%%", - " ".join(env["CCFLAGS"]) + " " + " ".join([x for x in env["CXXFLAGS"] if not x.startswith("$")]), - ) + proplist = [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)) + + proplist = [str(j) for j in env["CPPPATH"]] + proplist += [str(j) for j in env.get("VSHINT_INCLUDES", [])] + 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 # to double quote off the directory. However, the path ends diff --git a/misc/msvs/props.template b/misc/msvs/props.template index 9ecd49a25ee..9717c58ba0e 100644 --- a/misc/msvs/props.template +++ b/misc/msvs/props.template @@ -4,13 +4,13 @@ %%BUILD%% %%REBUILD%% %%CLEAN%% - %%OUTPUT%% - %%DEFINES%% - %%INCLUDES%% + %%OUTPUT%% + %%DEFINES%%;$(NMakePreprocessorDefinitions) + %%INCLUDES%%;$(NMakeIncludeSearchPath) $(NMakeForcedIncludes) $(NMakeAssemblySearchPath) $(NMakeForcedUsingAssemblies) - %%OPTIONS%% + %%OPTIONS%% $(AdditionalOptions) %%PROPERTIES%%