Skip to content

Do not duplicate Tool class creation#4838

Draft
mwichmann wants to merge 1 commit intoSCons:masterfrom
mwichmann:tool-init
Draft

Do not duplicate Tool class creation#4838
mwichmann wants to merge 1 commit intoSCons:masterfrom
mwichmann:tool-init

Conversation

@mwichmann
Copy link
Collaborator

If "default" is part of the tool list, the default.py tool will be run. This calls a function to generate the default tool list, which as a side effect creates a Tool instance for each tool examined. The tool then loops through the returned list, creating a Tool instance for each tool. To alleviate this duplication, the Tool instances are returned in the default list, and if an attempt is made to instantiate a Tool with the name argument being an instance already, it is returned as-is.

In the default tool - use the routine the SCons.Platform module provides for getting the default tool list (DefaultToolList). It does the same thing as default.generate did directly, but this way "we're using the API".

This is pushed as a draft for a chance to review the basic code setup. There is further pending work on SCons/Tool/__init__.py consisting of more docstring, typing annotations and a few very small cleanups, wanted to avoid those obscuring the main point. These can be added when taking this PR out of draft mode, or submitted as a separate PR.

Contributor Checklist:

  • I have created a new test or updated the unit tests to cover the new/changed functionality.
  • I have updated CHANGES.txt and RELEASE.txt (and read the README.rst).
  • I have updated the appropriate documentation

If "default" is part of the tool list, the default.py tool will be run.
This calls a function to generate the default tool list, which as
a side effect creates a Tool instance for each tool examined. The
tool then loops through the returned list, creating a Tool instance
for each tool.  To alleviate this duplication, the Tool instances
are returned in the default list, and if an attempt is made to instantiate
a Tool with the "name" argument being an instance already, it is
returned as-is.

In the default tool - use the routine the SCons.Platform module
provides for getting the default tool list.  It does the same thing as
default.generate did directly, but this way "we're using the API".

Signed-off-by: Mats Wichmann <mats@linux.com>
@mwichmann mwichmann added the Tools Issues related to tools subsystem label Mar 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Tools Issues related to tools subsystem

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant