Do not duplicate Tool class creation#4838
Draft
mwichmann wants to merge 1 commit intoSCons:masterfrom
Draft
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
If "default" is part of the tool list, the
default.pytool will be run. This calls a function to generate the default tool list, which as a side effect creates aToolinstance for each tool examined. The tool then loops through the returned list, creating aToolinstance for each tool. To alleviate this duplication, theToolinstances are returned in the default list, and if an attempt is made to instantiate aToolwith thenameargument being an instance already, it is returned as-is.In the default tool - use the routine the
SCons.Platformmodule provides for getting the default tool list (DefaultToolList). It does the same thing asdefault.generatedid 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__.pyconsisting 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:
CHANGES.txtandRELEASE.txt(and read theREADME.rst).