From 128509b61791d17bc911bd927191404648ac616a Mon Sep 17 00:00:00 2001 From: Ivan Shakhov Date: Sat, 22 Feb 2025 11:44:32 +0100 Subject: [PATCH] Fix project generation logic for Rider to support any OS without MSVC toolchain --- .editorconfig | 4 ++++ methods.py | 25 +++++++++++++++++++------ misc/msvs/props.template | 24 ++++++++++++++++++++++++ misc/msvs/vcxproj.template | 9 +++++---- platform/linuxbsd/msvs.py | 11 +++++++++++ platform/macos/msvs.py | 11 +++++++++++ platform/windows/msvs.py | 8 ++++++-- 7 files changed, 80 insertions(+), 12 deletions(-) create mode 100644 platform/linuxbsd/msvs.py create mode 100644 platform/macos/msvs.py diff --git a/.editorconfig b/.editorconfig index a2f93af3f56a..02fa54f62392 100644 --- a/.editorconfig +++ b/.editorconfig @@ -18,3 +18,7 @@ indent_style = space [*.svg] insert_final_newline = false + +[{*.props,*.vcxproj}] +indent_style = space +indent_size = 2 diff --git a/methods.py b/methods.py index 85fdf1978fb1..a50caa05e2ea 100644 --- a/methods.py +++ b/methods.py @@ -1217,7 +1217,7 @@ def get_dependencies(file, env, exts, headers, sources, others): properties.append( ";%s;" % (x, ";".join(itemlist[x]), x) ) - output = f"bin\\godot{env['PROGSUFFIX']}" + output = os.path.join("bin", f"godot{env['PROGSUFFIX']}") with open("misc/msvs/props.template", "r", encoding="utf-8") as file: props_template = file.read() @@ -1235,6 +1235,7 @@ def get_dependencies(file, env, exts, headers, sources, others): proplist = [str(j) for j in env["CPPPATH"]] proplist += [str(j) for j in env.get("VSHINT_INCLUDES", [])] + proplist += [str(j) for j in get_default_include_paths(env)] props_template = props_template.replace("%%INCLUDES%%", ";".join(proplist)) proplist = env["CCFLAGS"] @@ -1270,17 +1271,17 @@ def get_dependencies(file, env, exts, headers, sources, others): commands = "scons" if len(common_build_prefix) == 0: - commands = "echo Starting SCons && cmd /V /C " + commands + commands = "echo Starting SCons &" + commands else: - common_build_prefix[0] = "echo Starting SCons && cmd /V /C " + common_build_prefix[0] + common_build_prefix[0] = "echo Starting SCons &" + common_build_prefix[0] - cmd = " ^& ".join(common_build_prefix + [" ".join([commands] + common_build_postfix)]) + cmd = " ".join(common_build_prefix + [" ".join([commands] + common_build_postfix)]) props_template = props_template.replace("%%BUILD%%", cmd) - cmd = " ^& ".join(common_build_prefix + [" ".join([commands] + cmd_rebuild)]) + cmd = " ".join(common_build_prefix + [" ".join([commands] + cmd_rebuild)]) props_template = props_template.replace("%%REBUILD%%", cmd) - cmd = " ^& ".join(common_build_prefix + [" ".join([commands] + cmd_clean)]) + cmd = " ".join(common_build_prefix + [" ".join([commands] + cmd_clean)]) props_template = props_template.replace("%%CLEAN%%", cmd) with open( @@ -1554,3 +1555,15 @@ def to_raw_cstring(value: Union[str, List[str]]) -> str: split += [segment] return " ".join(f'R"({x.decode()})"' for x in split) + + +def get_default_include_paths(env): + compiler = env.subst("$CXX") + target = os.path.join(env.Dir("#main").abspath, "main.cpp") + args = [compiler, target, "-x", "c++", "-v"] + ret = subprocess.run(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True) + output = ret.stdout + match = re.search(r"#include <\.\.\.> search starts here:([\S\s]*)End of search list.", output) + if not match: + return [] # msvc case + return [x.strip() for x in match[1].strip().splitlines()] diff --git a/misc/msvs/props.template b/misc/msvs/props.template index 82e3e81f1827..194f7088158a 100644 --- a/misc/msvs/props.template +++ b/misc/msvs/props.template @@ -18,6 +18,30 @@ %%EXTRA_ITEMS%% + + + + $(NMakeOutput) + $(PlatformToolset) + + + + + + + + + + + + + + + + $(NMakePreprocessorDefinitions) + + +