Skip to content

Commit

Permalink
SCons: Specify tools for remaining platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
Repiteo committed Jan 26, 2025
1 parent e549802 commit b289a3d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 21 deletions.
3 changes: 3 additions & 0 deletions methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,9 @@ def non_serializable(obj):
with open(".scons_env.json", "w", encoding="utf-8", newline="\n") as f:
dump(env.Dictionary(), f, indent=4, default=non_serializable)

print(env["TOOLS"])
env.Exit(123)


# Custom Visual Studio project generation logic that supports any platform that has a msvs.py
# script, so Visual Studio can be used to run scons for any platform, with the right defines per target.
Expand Down
44 changes: 23 additions & 21 deletions platform/windows/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,12 @@ def detect_build_env_arch():


def get_tools(env: "SConsEnvironment"):
if os.name != "nt" or env["use_mingw"]:
if os.name != "nt" or env.get("use_mingw"):
return ["mingw"]
else:
return ["default"]
if env.get("msvc_version"):
env["MSVC_VERSION"] = env["msvc_version"]
return ["msvc", "mslink", "mslib", "mssdk"]


def get_opts():
Expand Down Expand Up @@ -285,25 +287,25 @@ def setup_msvc_auto(env: "SConsEnvironment"):
else:
env["TARGET_ARCH"] = env["arch"]

# The env may have already been set up with default MSVC tools, so
# reset a few things so we can set it up with the tools we want.
# (Ideally we'd decide on the tool config before configuring any
# environment, and just set the env up once, but this function runs
# on an existing env so this is the simplest way.)
env["MSVC_SETUP_RUN"] = False # Need to set this to re-run the tool
env["MSVS_VERSION"] = None
env["MSVC_VERSION"] = None

if "msvc_version" in env:
env["MSVC_VERSION"] = env["msvc_version"]
env.Tool("msvc")
env.Tool("mssdk") # we want the MS SDK

# Re-add potentially overwritten flags.
env.AppendUnique(CCFLAGS=env.get("ccflags", "").split())
env.AppendUnique(CXXFLAGS=env.get("cxxflags", "").split())
env.AppendUnique(CFLAGS=env.get("cflags", "").split())
env.AppendUnique(RCFLAGS=env.get("rcflags", "").split())
# # The env may have already been set up with default MSVC tools, so
# # reset a few things so we can set it up with the tools we want.
# # (Ideally we'd decide on the tool config before configuring any
# # environment, and just set the env up once, but this function runs
# # on an existing env so this is the simplest way.)
# env["MSVC_SETUP_RUN"] = False # Need to set this to re-run the tool
# env["MSVS_VERSION"] = None
# env["MSVC_VERSION"] = None

# if "msvc_version" in env:
# env["MSVC_VERSION"] = env["msvc_version"]
# env.Tool("msvc")
# env.Tool("mssdk") # we want the MS SDK

# # Re-add potentially overwritten flags.
# env.AppendUnique(CCFLAGS=env.get("ccflags", "").split())
# env.AppendUnique(CXXFLAGS=env.get("cxxflags", "").split())
# env.AppendUnique(CFLAGS=env.get("cflags", "").split())
# env.AppendUnique(RCFLAGS=env.get("rcflags", "").split())

# Note: actual compiler version can be found in env['MSVC_VERSION'], e.g. "14.1" for VS2015
print("Using SCons-detected MSVC version %s, arch %s" % (env["MSVC_VERSION"], env["arch"]))
Expand Down

0 comments on commit b289a3d

Please sign in to comment.