Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build options configuration for Visual Studio projects #79238

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,7 @@ if selected_platform in platform_list:
print("Error: The `vsproj` option is only usable on Windows with Visual Studio.")
Exit(255)
env["CPPPATH"] = [Dir(path) for path in env["CPPPATH"]]
methods.generate_vs_project(env, GetOption("num_jobs"), env["vsproj_name"])
methods.generate_vs_project(env, ARGUMENTS, env["vsproj_name"])
methods.generate_cpp_hint_file("cpp.hint")

# Check for the existence of headers
Expand Down
35 changes: 13 additions & 22 deletions methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -776,8 +776,18 @@ def add_to_vs_project(env, sources):
env.vs_srcs += [basename + ".cpp"]


def generate_vs_project(env, num_jobs, project_name="godot"):
def generate_vs_project(env, original_args, project_name="godot"):
batch_file = find_visual_c_batch_file(env)
filtered_args = original_args.copy()
# Ignore the "vsproj" option to not regenerate the VS project on every build
filtered_args.pop("vsproj", None)
# The "platform" option is ignored because only the Windows platform is currently supported for VS projects
filtered_args.pop("platform", None)
Comment on lines +784 to +785
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine for now, but we might want to look into supporting generating a VS project for other platforms.

Notably we should have a GDK port for Windows eventually, and console ports also typically require using Visual Studio.

# The "target" option is ignored due to the way how targets configuration is performed for VS projects (there is a separate project configuration for each target)
filtered_args.pop("target", None)
# The "progress" option is ignored as the current compilation progress indication doesn't work in VS
filtered_args.pop("progress", None)

if batch_file:

class ModuleConfigs(Mapping):
Expand Down Expand Up @@ -853,29 +863,10 @@ def build_commandline(self, commands):
"platform=windows",
f"target={configuration_getter}",
"progress=no",
"-j%s" % num_jobs,
]

if env["dev_build"]:
common_build_postfix.append("dev_build=yes")

if env["dev_mode"]:
common_build_postfix.append("dev_mode=yes")

elif env["tests"]:
common_build_postfix.append("tests=yes")

if env["custom_modules"]:
common_build_postfix.append("custom_modules=%s" % env["custom_modules"])

if env["windows_subsystem"] == "console":
common_build_postfix.append("windows_subsystem=console")

if env["precision"] == "double":
common_build_postfix.append("precision=double")

if env["incremental_link"]:
common_build_postfix.append("incremental_link=yes")
for arg, value in filtered_args.items():
common_build_postfix.append(f"{arg}={value}")

result = " ^& ".join(common_build_prefix + [" ".join([commands] + common_build_postfix)])
return result
Expand Down