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

Fixed ninja binary location logic to use ninja.BIN_DIR. #4655

Merged
merged 4 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 6 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ 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 ninja_binary() method to TestSCons to centralize logic to find ninja binary
Copy link
Collaborator

Choose a reason for hiding this comment

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

This looks okay to me (although see the question on the added method itself).


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
7 changes: 7 additions & 0 deletions RELEASE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,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 @@ -196,6 +201,8 @@ DEVELOPMENT

- Implemented type hints for Nodes.

- Added ninja_binary() method to TestSCons to centralize logic to find ninja binary

Thanks to the following contributors listed below for their contributions to this release.
==========================================================================================
.. code-block:: text
Expand Down
19 changes: 9 additions & 10 deletions SCons/Tool/ninja/NinjaState.py
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
9 changes: 1 addition & 8 deletions test/ninja/build_libraries.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

import os

import TestSCons
from TestCmd import IS_WINDOWS, IS_MACOS
from TestSCons import _exe, _lib, lib_, _dll, dll_
Expand All @@ -36,12 +34,7 @@
except ImportError:
test.skip_test("Could not find ninja module. Skipping test.\n")

ninja_bin = os.path.abspath(os.path.join(
ninja.__file__,
os.pardir,
'data',
'bin',
'ninja' + _exe))
ninja_bin = test.ninja_binary()

test.dir_fixture('ninja-fixture')

Expand Down
7 changes: 1 addition & 6 deletions test/ninja/command_line_targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,7 @@
_python_ = TestSCons._python_
_exe = TestSCons._exe

ninja_bin = os.path.abspath(os.path.join(
ninja.__file__,
os.pardir,
'data',
'bin',
'ninja' + _exe))
ninja_bin = test.ninja_binary()

test.dir_fixture('ninja-fixture')

Expand Down
7 changes: 1 addition & 6 deletions test/ninja/copy_function_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,7 @@
_python_ = TestSCons._python_
_exe = TestSCons._exe

ninja_bin = os.path.abspath(os.path.join(
ninja.__file__,
os.pardir,
'data',
'bin',
'ninja' + _exe))
ninja_bin = test.ninja_binary()

test.dir_fixture('ninja-fixture')

Expand Down
4 changes: 1 addition & 3 deletions test/ninja/default_targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@
_python_ = TestSCons._python_
_exe = TestSCons._exe

ninja_bin = os.path.abspath(
os.path.join(ninja.__file__, os.pardir, 'data', 'bin', 'ninja' + _exe)
)
ninja_bin = test.ninja_binary()

test.dir_fixture('ninja-fixture')

Expand Down
5 changes: 2 additions & 3 deletions test/ninja/force_scons_callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@
_python_ = TestSCons._python_
_exe = TestSCons._exe

ninja_bin = os.path.abspath(
os.path.join(ninja.__file__, os.pardir, "data", "bin", "ninja" + _exe)
)
ninja_bin = test.ninja_binary()


test.dir_fixture("ninja-fixture")

Expand Down
7 changes: 1 addition & 6 deletions test/ninja/generate_and_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,7 @@
_python_ = TestSCons._python_
_exe = TestSCons._exe

ninja_bin = os.path.abspath(os.path.join(
ninja.__file__,
os.pardir,
'data',
'bin',
'ninja' + _exe))
ninja_bin = test.ninja_binary()

test.dir_fixture('ninja-fixture')

Expand Down
7 changes: 1 addition & 6 deletions test/ninja/generate_and_build_cxx.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,7 @@
_python_ = TestSCons._python_
_exe = TestSCons._exe

ninja_bin = os.path.abspath(os.path.join(
ninja.__file__,
os.pardir,
'data',
'bin',
'ninja' + _exe))
ninja_bin = test.ninja_binary()

test.dir_fixture('ninja-fixture')

Expand Down
7 changes: 1 addition & 6 deletions test/ninja/generate_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,7 @@
_python_ = TestSCons._python_
_exe = TestSCons._exe

ninja_bin = os.path.abspath(os.path.join(
ninja.__file__,
os.pardir,
'data',
'bin',
'ninja' + _exe))
ninja_bin = test.ninja_binary()

test.dir_fixture('ninja-fixture')

Expand Down
5 changes: 2 additions & 3 deletions test/ninja/generated_sources_alias.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@
_python_ = TestSCons._python_
_exe = TestSCons._exe

ninja_bin = os.path.abspath(os.path.join(
ninja.BIN_DIR,
'ninja' + _exe))
ninja_bin = test.ninja_binary()


test.dir_fixture('ninja-fixture')

Expand Down
7 changes: 1 addition & 6 deletions test/ninja/iterative_speedup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,7 @@
_python_ = TestSCons._python_
_exe = TestSCons._exe

ninja_bin = os.path.abspath(os.path.join(
ninja.__file__,
os.pardir,
'data',
'bin',
'ninja' + _exe))
ninja_bin = test.ninja_binary()

test.dir_fixture('ninja-fixture')

Expand Down
4 changes: 1 addition & 3 deletions test/ninja/mingw_command_generator_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@
_python_ = TestSCons._python_
_exe = TestSCons._exe

ninja_bin = os.path.abspath(os.path.join(
ninja.BIN_DIR,
'ninja' + _exe))
ninja_bin = test.ninja_binary()

test.dir_fixture('ninja-fixture')

Expand Down
4 changes: 1 addition & 3 deletions test/ninja/mingw_depfile_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@
_python_ = TestSCons._python_
_exe = TestSCons._exe

ninja_bin = os.path.abspath(os.path.join(
ninja.BIN_DIR,
'ninja' + _exe))
ninja_bin = test.ninja_binary()

test.dir_fixture('ninja-fixture')

Expand Down
7 changes: 1 addition & 6 deletions test/ninja/mkdir_function_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,7 @@
_python_ = TestSCons._python_
_exe = TestSCons._exe

ninja_bin = os.path.abspath(os.path.join(
ninja.__file__,
os.pardir,
'data',
'bin',
'ninja' + _exe))
ninja_bin = test.ninja_binary()

test.write('SConstruct', """
SetOption('experimental','ninja')
Expand Down
7 changes: 1 addition & 6 deletions test/ninja/multi_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,7 @@
_python_ = TestSCons._python_
_exe = TestSCons._exe

ninja_bin = os.path.abspath(os.path.join(
ninja.__file__,
os.pardir,
'data',
'bin',
'ninja' + _exe))
ninja_bin = test.ninja_binary()

test = TestSCons.TestSCons()

Expand Down
7 changes: 1 addition & 6 deletions test/ninja/ninja_command_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,7 @@
_python_ = TestSCons._python_
_exe = TestSCons._exe

ninja_bin = os.path.abspath(os.path.join(
ninja.__file__,
os.pardir,
'data',
'bin',
'ninja' + _exe))
ninja_bin = test.ninja_binary()

test.dir_fixture('ninja-fixture', 'src')

Expand Down
7 changes: 1 addition & 6 deletions test/ninja/ninja_conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,7 @@
_python_ = TestSCons._python_
_exe = TestSCons._exe

ninja_bin = os.path.abspath(os.path.join(
ninja.__file__,
os.pardir,
'data',
'bin',
'ninja' + _exe))
ninja_bin = test.ninja_binary()

test.dir_fixture('ninja-fixture')

Expand Down
4 changes: 1 addition & 3 deletions test/ninja/ninja_file_deterministic.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@
_python_ = TestSCons._python_
_exe = TestSCons._exe

ninja_bin = os.path.abspath(os.path.join(
ninja.BIN_DIR,
'ninja' + _exe))
ninja_bin = test.ninja_binary()

test.dir_fixture('ninja-fixture')

Expand Down
6 changes: 2 additions & 4 deletions test/ninja/ninja_handle_control_c_rebuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#
"""
This test ensures if ninja gets a control-c (or other interrupting signal) while
regenerating the build.ninja, it doesn't remove the build.ninja leaving it
regenerating the build.ninja, it doesn't remove the build.ninja leaving it
in an unworkable state.
"""
import os
Expand All @@ -41,9 +41,7 @@
_python_ = TestSCons._python_
_exe = TestSCons._exe

ninja_bin = os.path.abspath(
os.path.join(ninja.__file__, os.pardir, "data", "bin", "ninja" + _exe)
)
ninja_bin = test.ninja_binary()

test.dir_fixture("ninja-fixture")

Expand Down
7 changes: 1 addition & 6 deletions test/ninja/no_for_sig_subst.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,7 @@
_python_ = TestSCons._python_
_exe = TestSCons._exe

ninja_bin = os.path.abspath(os.path.join(
ninja.__file__,
os.pardir,
'data',
'bin',
'ninja' + _exe))
ninja_bin = test.ninja_binary()

test.dir_fixture('ninja-fixture')

Expand Down
7 changes: 1 addition & 6 deletions test/ninja/response_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,7 @@
_exe = TestSCons._exe
_obj = TestSCons._obj

ninja_bin = os.path.abspath(os.path.join(
ninja.__file__,
os.pardir,
'data',
'bin',
'ninja' + _exe))
ninja_bin = test.ninja_binary()

test.dir_fixture('ninja-fixture')

Expand Down
7 changes: 1 addition & 6 deletions test/ninja/shell_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,7 @@
_python_ = TestSCons._python_
_exe = TestSCons._exe

ninja_bin = os.path.abspath(os.path.join(
ninja.__file__,
os.pardir,
'data',
'bin',
'ninja' + _exe))
ninja_bin = test.ninja_binary()

test.dir_fixture('ninja-fixture')

Expand Down
4 changes: 1 addition & 3 deletions test/ninja/shutdown_scons_daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@
_python_ = TestSCons._python_
_exe = TestSCons._exe

ninja_bin = os.path.abspath(
os.path.join(ninja.__file__, os.pardir, "data", "bin", "ninja" + _exe)
)
ninja_bin = test.ninja_binary()

test.dir_fixture("ninja-fixture")

Expand Down
Loading
Loading