Skip to content

Commit

Permalink
Merge pull request #91080 from Repiteo/scons/scons_ver-variable
Browse files Browse the repository at this point in the history
SCons: `scons_version` to environment variable
  • Loading branch information
akien-mga committed Apr 24, 2024
2 parents c7f56d3 + fd2ab72 commit fdd159d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
14 changes: 6 additions & 8 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ from types import ModuleType
from collections import OrderedDict
from importlib.util import spec_from_file_location, module_from_spec
from SCons import __version__ as scons_raw_version
from SCons.Script.SConscript import SConsEnvironment

scons_ver = SConsEnvironment._get_major_minor_revision(scons_raw_version)

# Explicitly resolve the helper modules, this is done to avoid clash with
# modules of the same name that might be randomly added (e.g. someone adding
Expand Down Expand Up @@ -134,6 +131,7 @@ if "TERM" in os.environ: # Used for colored output.
env.disabled_modules = []
env.module_version_string = ""
env.msvc = False
env.scons_version = env._get_major_minor_revision(scons_raw_version)

env.__class__.disable_module = methods.disable_module

Expand Down Expand Up @@ -172,7 +170,7 @@ if profile:
opts = Variables(customs, ARGUMENTS)

# Target build options
if scons_ver >= (4, 3):
if env.scons_version >= (4, 3):
opts.Add(["platform", "p"], "Target platform (%s)" % "|".join(platform_list), "")
else:
opts.Add("platform", "Target platform (%s)" % "|".join(platform_list), "")
Expand Down Expand Up @@ -294,7 +292,7 @@ if env["import_env_vars"]:

selected_platform = env["platform"]

if scons_ver < (4, 3) and not selected_platform:
if env.scons_version < (4, 3) and not selected_platform:
selected_platform = env["p"]

if selected_platform == "":
Expand Down Expand Up @@ -983,16 +981,16 @@ if env["vsproj"]:
env.vs_incs = []
env.vs_srcs = []

if env["compiledb"] and scons_ver < (4, 0, 0):
if env["compiledb"] and env.scons_version < (4, 0, 0):
# Generating the compilation DB (`compile_commands.json`) requires SCons 4.0.0 or later.
print("The `compiledb=yes` option requires SCons 4.0 or later, but your version is %s." % scons_raw_version)
Exit(255)
if scons_ver >= (4, 0, 0):
if env.scons_version >= (4, 0, 0):
env.Tool("compilation_db")
env.Alias("compiledb", env.CompilationDatabase())

if env["ninja"]:
if scons_ver < (4, 2, 0):
if env.scons_version < (4, 2, 0):
print("The `ninja=yes` option requires SCons 4.2 or later, but your version is %s." % scons_raw_version)
Exit(255)

Expand Down
10 changes: 3 additions & 7 deletions methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -763,19 +763,15 @@ def detect_visual_c_compiler_version(tools_env):
def find_visual_c_batch_file(env):
from SCons.Tool.MSCommon.vc import get_default_version, get_host_target, find_batch_file, find_vc_pdir

# Syntax changed in SCons 4.4.0.
from SCons import __version__ as scons_raw_version

scons_ver = env._get_major_minor_revision(scons_raw_version)

msvc_version = get_default_version(env)

if scons_ver >= (4, 4, 0):
# Syntax changed in SCons 4.4.0.
if env.scons_version >= (4, 4, 0):
(host_platform, target_platform, _) = get_host_target(env, msvc_version)
else:
(host_platform, target_platform, _) = get_host_target(env)

if scons_ver < (4, 6, 0):
if env.scons_version < (4, 6, 0):
return find_batch_file(env, msvc_version, host_platform, target_platform)[0]

# Scons 4.6.0+ removed passing env, so we need to get the product_dir ourselves first,
Expand Down

0 comments on commit fdd159d

Please sign in to comment.