[Scons-users] Finding targets which depend on a source file

Paweł Tomulik ptomulik at meil.pw.edu.pl
Wed Nov 18 18:32:58 EST 2015


W dniu 19.11.2015 o 00:16, Abhishek Rai pisze:
> Thanks for the prompt response William.
> 
> On Wed, Nov 18, 2015 at 3:06 PM, William Blevins <wblevins001 at gmail.com
> <mailto:wblevins001 at gmail.com>> wrote:
>>
>> SCons already only builds targets that are not up-to-date, so what is
> the point of this script per say? I assume that you are always starting
> from a fresh repository clone of some kind?
> 
> Yes.  In our git repository, we pull code from the origin several times
> every day.  After each pull, as far as scons goes, several build targets
> become out of date, causing it to rebuild them when we try to build all
> targets.  In our environment, it's safe to assume that code pulled from
> origin passes all builds and tests, therefore rebuilding locally is an
> overkill.
> 
>>
>> The SCons paradigm generally maps Targets to Dependencies (Sources),
> so you would need to work backwards.  You might be able to get this
> information from "scons --dry-run --tree=<option>" with a clever parser,
> but this will require that SCons scan all the files even though it might
> not build targets.
> 
> The --dry-run option unfortunately suffers from the similar limitation -
> it finds that most targets are out of date, including those unaffected
> by local changes.
> 
>>
>> I am not sure if there is a better way.
>>
>> V/R,
>> William
> 
> Thanks!
> Abhishek
> 
>>
>> On Wed, Nov 18, 2015 at 10:53 PM, Abhishek Rai <abhishekrai at gmail.com
> <mailto:abhishekrai at gmail.com>> wrote:
>>>
>>> Hello,
>>>
>>> Is there any way in scons to list all targets which depend on a given
> source file?
>>>
>>> In the code base that I'm working on, we have a "pre-commit" script
> which verifies whether the changes in the commit break any targets. 
> Currently, this script tries to build all targets.  Of course, some
> targets may not need rebuilding if the corresponding source files
> haven't changed since the previous build.  But given the dynamic nature
> of the code base, each run of the pre-commit script ends up building
> nearly all targets even if that commit affects only a small number of them.
>>>
>>> Having the ability to list all targets derived from a given source
> file will give us the ability to list out these targets first, and then
> only build those targets as part of the pre-commit workflow.
>>>
>>> Thanks!
>>> Abhishek
>>>
>>> _______________________________________________


To me it simply looks like "scons doesn't work as I expect", which of
course might be true. If it builds so many targets after repo update,
then they probably got affected by repo update. If SCons really rebuilds
your targets which actually shouldn't be rebuilt, then it may be scons bug.

Could you share information what kind of targets it mostly rebuilds,
which in your opinion shouldn't be rebuild. And scons version you use?


-- 
Pawel Tomulik


More information about the Scons-users mailing list