SCons / scons

SCons - a software construction tool
http://scons.org
MIT License
2.06k stars 315 forks source link

Add a way to for a Builder() to specify it's sources should not be scanned. #3938

Open dragon512 opened 3 years ago

dragon512 commented 3 years ago

Describe the Feature The enhancement is to add a NullScanner to SCons.

When defining a builder the user can add a source_scanner or target_scanner to control how a given target or source node should be scanned. If a scanner is not provided SCons will look at the extension of the file and try to scan it with a global scanner. This can cause unwanted side effects to the build time as time is wasted looking for implicated dependencies that do not affect the action of the given builder.

For example:

One could make a .7z builder that would add provided sources file to a package (another example might also be a manifest file generator or rpm.spec generator). If this builder does not provide a source_scanner and the sources are a set of .c and or .h files, SCons will try to scan for #include statements in the source and add these as implicit depends on the target of the builder. This has two negative effects. 1) time is wasted on scanning the files for implicit depends that have to affect the final target output. 2) changes in the implicit depends can cause rebuilds of the targets when in reality they have to effect on the target.

SCons does not provide a clear way to say I want this builder scanner to:

  1. use the default global scanner
  2. Do not scan at all

At the moment it is common to not add a scanner to a builder. This practice means a lot of builders can waste a lot of time scanning files that they should not. For a user to define logic to not scan, currently mean that user has to define something like this:

NullScanner = SCons.Script.Scanner(function=lambda *lst, **kw: [], name="NullScanner")

It would be ideal for this to be defined in SCons so it can be reused to allow a clear and definable way to say do not scan the nodes.

It also might be nice to define an object to make explicit when defining a builder that this builder will use the global scanner. This will help clarify the intent of the builder to others

bdbaddog commented 2 years ago

3974 was a duplicate

mwichmann commented 1 year ago

Any fresh thoughts on this?