Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into maint/st_mode
Browse files Browse the repository at this point in the history
  • Loading branch information
bdbaddog committed Dec 6, 2024
2 parents 96a4a99 + 01f77b1 commit 6c976eb
Show file tree
Hide file tree
Showing 41 changed files with 300 additions and 271 deletions.
16 changes: 15 additions & 1 deletion CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
via top-level `from __future__ import annotations`.
- Implemented type hints for Nodes.

From William Deegan:
- Update ninja tool to use ninja.BIN_DIR to find pypi packaged ninja binary.
python ninja package version 1.11.1.2 changed the location and previous
logic no longer worked.
- Added TestSCons.NINJA_BINARY to TestSCons to centralize logic to find ninja binary
- Refactored SCons.Tool.ninja -> SCons.Tool.ninja_tool, and added alias so
env.Tool('ninja') will still work. This avoids conflicting with the pypi module ninja.

From Alex James:
- On Darwin, PermissionErrors are now handled while trying to access
/etc/paths.d. This may occur if SCons is invoked in a sandboxed
Expand Down Expand Up @@ -154,7 +162,13 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
- Minor modernization: make use of stat object's st_mode, st_mtime
and other attributes rather than indexing into stat return.
- Make sure unknown variables from a Variables file are recognized
as such (issue #4645)
as such. Previously only unknowns from the command line were
recognized (issue #4645).
- A Variables object now makes available a "defaulted" attribute,
a list of variable names that were set in the environment with
their values taken from the default in the variable description
(if a variable was set to the same value as the default in one
of the input sources, it is not included in this list).


RELEASE 4.8.1 - Tue, 03 Sep 2024 17:22:20 -0700
Expand Down
16 changes: 16 additions & 0 deletions RELEASE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ CHANGED/ENHANCED EXISTING FUNCTIONALITY
always returns a dict. The default remains to return different
types depending on whether zero, one, or multiple construction

- A Variables object now makes available a "defaulted" attribute,
a list of variable names that were set in the environment with
their values taken from the default in the variable description
(if a variable was set to the same value as the default in one
of the input sources, it is not included in this list).

FIXES
-----

Expand Down Expand Up @@ -143,6 +149,11 @@ FIXES
- Make sure unknown variables from a Variables file are recognized
as such (issue #4645)

- Update ninja tool to use ninja.BIN_DIR to find pypi packaged ninja binary.
python ninja package version 1.11.1.2 changed the location and previous
logic no longer worked.


IMPROVEMENTS
------------

Expand Down Expand Up @@ -199,6 +210,11 @@ DEVELOPMENT

- Implemented type hints for Nodes.

- Added TestSCons.NINJA_BINARY to TestSCons to centralize logic to find ninja binary

- Refactored SCons.Tool.ninja -> SCons.Tool.ninja_tool, and added alias so env.Tool('ninja')
will still work. This avoids conflicting with the pypi module ninja.

Thanks to the following contributors listed below for their contributions to this release.
==========================================================================================
.. code-block:: text
Expand Down
1 change: 1 addition & 0 deletions SCons/Tool/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
'gettext': 'gettext_tool',
'clang++': 'clangxx',
'as': 'asm',
'ninja' : 'ninja_tool'
}


Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@

import SCons
from SCons.Subst import SUBST_CMD
from SCons.Tool.ninja import NINJA_CUSTOM_HANDLERS, NINJA_RULES, NINJA_POOLS
from SCons.Tool.ninja.Globals import __NINJA_RULE_MAPPING
from SCons.Tool.ninja.Utils import get_targets_sources, get_dependencies, get_order_only, get_outputs, get_inputs, \
from SCons.Tool.ninja_tool import NINJA_CUSTOM_HANDLERS, NINJA_RULES, NINJA_POOLS
from SCons.Tool.ninja_tool.Globals import __NINJA_RULE_MAPPING
from SCons.Tool.ninja_tool.Utils import get_targets_sources, get_dependencies, get_order_only, get_outputs, get_inputs, \
get_rule, get_path, generate_command, get_command_env, get_comstr

if TYPE_CHECKING:
Expand All @@ -46,7 +46,7 @@ def register_custom_handler(env, name, handler) -> None:

def register_custom_rule_mapping(env, pre_subst_string, rule) -> None:
"""Register a function to call for a given rule."""
SCons.Tool.ninja.Globals.__NINJA_RULE_MAPPING[pre_subst_string] = rule
__NINJA_RULE_MAPPING[pre_subst_string] = rule


def register_custom_rule(env, rule, command, description: str="", deps=None, pool=None, use_depfile: bool=False, use_response_file: bool=False, response_file_content: str="$rspc") -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,11 @@ def __init__(self, env, ninja_file, ninja_syntax) -> None:
if not self.ninja_bin_path:
# default to using ninja installed with python module
ninja_bin = 'ninja.exe' if env["PLATFORM"] == "win32" else 'ninja'

self.ninja_bin_path = os.path.abspath(os.path.join(
ninja.__file__,
os.pardir,
'data',
'bin',
ninja_bin))
ninja.BIN_DIR, ninja_bin
))

if not os.path.exists(self.ninja_bin_path):
# couldn't find it, just give the bin name and hope
# its in the path later
Expand Down Expand Up @@ -398,7 +397,7 @@ def generate(self):
self.rules.update({key: non_rsp_rule})
else:
self.rules.update({key: rule})

self.pools.update(self.env.get(NINJA_POOLS, {}))

content = io.StringIO()
Expand Down Expand Up @@ -435,7 +434,7 @@ def generate(self):
generated_source_files = sorted(
[] if not generated_sources_build else generated_sources_build['implicit']
)

def check_generated_source_deps(build):
return (
build != generated_sources_build
Expand Down Expand Up @@ -464,7 +463,7 @@ def check_generated_source_deps(build):
rule="phony",
implicit=generated_source_files
)

def check_generated_source_deps(build):
return (
not build["rule"] == "INSTALL"
Expand Down Expand Up @@ -661,15 +660,15 @@ def check_generated_source_deps(build):
all_targets = [str(node) for node in NINJA_DEFAULT_TARGETS]
else:
all_targets = list(all_targets)

if len(all_targets) == 0:
all_targets = ["phony_default"]
ninja_sorted_build(
ninja,
outputs=all_targets,
rule="phony",
)

ninja.default([self.ninja_syntax.escape_path(path) for path in sorted(all_targets)])

with NamedTemporaryFile(delete=False, mode='w') as temp_ninja_file:
Expand Down Expand Up @@ -754,7 +753,7 @@ def action_to_ninja_build(self, node, action=None):
# Ninja builders out of being sources of ninja builders but I
# can't fix every DAG problem so we just skip ninja_builders
# if we find one
if SCons.Tool.ninja.NINJA_STATE.ninja_file == str(node):
if SCons.Tool.ninja_tool.NINJA_STATE.ninja_file == str(node):
build = None
elif isinstance(action, SCons.Action.FunctionAction):
build = self.handle_func_action(node, action)
Expand Down
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions SCons/Tool/ninja/Utils.py → SCons/Tool/ninja_tool/Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,14 +413,14 @@ def ninja_stat(_self, path):
"""

try:
return SCons.Tool.ninja.Globals.NINJA_STAT_MEMO[path]
return SCons.Tool.ninja_tool.Globals.NINJA_STAT_MEMO[path]
except KeyError:
try:
result = os.stat(path)
except os.error:
result = None

SCons.Tool.ninja.Globals.NINJA_STAT_MEMO[path] = result
SCons.Tool.ninja_tool.Globals.NINJA_STAT_MEMO[path] = result
return result


Expand All @@ -430,7 +430,7 @@ def ninja_whereis(thing, *_args, **_kwargs):
# Optimize for success, this gets called significantly more often
# when the value is already memoized than when it's not.
try:
return SCons.Tool.ninja.Globals.NINJA_WHEREIS_MEMO[thing]
return SCons.Tool.ninja_tool.Globals.NINJA_WHEREIS_MEMO[thing]
except KeyError:
# TODO: Fix this to respect env['ENV']['PATH']... WPD
# We do not honor any env['ENV'] or env[*] variables in the
Expand All @@ -443,7 +443,7 @@ def ninja_whereis(thing, *_args, **_kwargs):
# with shell quoting is nigh impossible. So I've decided to
# cross that bridge when it's absolutely required.
path = shutil.which(thing)
SCons.Tool.ninja.Globals.NINJA_WHEREIS_MEMO[thing] = path
SCons.Tool.ninja_tool.Globals.NINJA_WHEREIS_MEMO[thing] = path
return path


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

import SCons
import SCons.Script
import SCons.Tool.ninja.Globals
from SCons.Tool.ninja_tool.Globals import ninja_builder_initialized
from SCons.Script import GetOption
from SCons.Util import sanitize_shell_env

Expand Down Expand Up @@ -187,13 +187,13 @@ def ninja_emitter(target, source, env):

def generate(env):
"""Generate the NINJA builders."""
global NINJA_STATE, NINJA_CMDLINE_TARGETS
global NINJA_STATE, NINJA_CMDLINE_TARGETS, ninja_builder_initialized

if 'ninja' not in GetOption('experimental'):
return

if not SCons.Tool.ninja.Globals.ninja_builder_initialized:
SCons.Tool.ninja.Globals.ninja_builder_initialized = True
if not ninja_builder_initialized:
ninja_builder_initialized = True

ninja_add_command_line_options()

Expand Down Expand Up @@ -255,7 +255,7 @@ def ninja_generate_deps(env):
pass
else:
env.Append(CCFLAGS='$CCDEPFLAGS')

env.AddMethod(CheckNinjaCompdbExpand, "CheckNinjaCompdbExpand")

# Provide a way for custom rule authors to easily access command
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 7 additions & 2 deletions SCons/Variables/VariablesTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,24 +659,28 @@ def test_AddOptionUpdatesUnknown(self) -> None:
Get one unknown from args and one from a variables file.
Add these later, making sure they no longer appear in unknowns
after the subsequent Update().
While we're here, test the *defaulted* attribute.
"""
test = TestSCons.TestSCons()
var_file = test.workpath('vars.py')
test.write('vars.py', 'FROMFILE="added"')
opts = SCons.Variables.Variables(files=var_file)
opts.Add('A', 'A test variable', "1")
opts.Add('A', 'A test variable', default="1")
opts.Add('B', 'Test variable B', default="1")
args = {
'A' : 'a',
'ADDEDLATER' : 'notaddedyet',
}
env = Environment()
opts.Update(env,args)
opts.Update(env, args)

r = opts.UnknownVariables()
with self.subTest():
self.assertEqual('notaddedyet', r['ADDEDLATER'])
self.assertEqual('added', r['FROMFILE'])
self.assertEqual('a', env['A'])
self.assertEqual(['B'], opts.defaulted)

opts.Add('ADDEDLATER', 'An option not present initially', "1")
opts.Add('FROMFILE', 'An option from a file also absent', "1")
Expand All @@ -693,6 +697,7 @@ def test_AddOptionUpdatesUnknown(self) -> None:
self.assertEqual('added', env['ADDEDLATER'])
self.assertNotIn('FROMFILE', r)
self.assertEqual('added', env['FROMFILE'])
self.assertEqual(['B'], opts.defaulted)

def test_AddOptionWithAliasUpdatesUnknown(self) -> None:
"""Test updating of the 'unknown' dict (with aliases)"""
Expand Down
Loading

0 comments on commit 6c976eb

Please sign in to comment.