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

Stefan Ross stefan at electricimp.com
Thu Nov 19 12:10:06 EST 2015


Hi Bill,

As I said, I was able to do what I needed without this feature.  I was
merely commenting because you requested use-cases where it would be useful.

Thanks

Stefan

On Thu, Nov 19, 2015 at 4:56 PM, Bill Deegan <bill at baddogconsulting.com>
wrote:

> Stefan,
>
> scons --tree=prune should yield the info you're asking about.
> If you want something different, feel free to implement it, create some
> tests for it, and submit a pull request.
>
> -Bill
>
> On Thu, Nov 19, 2015 at 1:07 AM, Stefan Ross <stefan at electricimp.com>
> wrote:
>
>> I also have found myself wanting this feature.  Not because Scons is
>> doing the wrong thing, but because it's helpful when building SConscript
>> files to have this information.  For example, I recently did a big
>> refactoring on a codebase where I wasn't that familiar with the whole
>> codebase, including its dependencies.  So it's possible that I refactored
>> some of the tools out such that nothing depended on them, but there's no
>> easy way to find this out.  I could delete the tool, do a clean, and
>> rebuild, but that's a slow cycle.  Having Scons report such dependencies
>> would be helpful.
>>
>> I had other examples where I had output files with the same name in
>> different directories (I was moving things about).  Sometimes I got
>> confused about which version of the file was being referenced.  I know
>> there are other ways of finding these, but a single command to check if a
>> particular file had any other files depending on it would have been helpful.
>>
>> Thanks
>>
>> Stefan
>>
>> On Wed, Nov 18, 2015 at 11:50 PM, Bill Deegan <bill at baddogconsulting.com>
>> wrote:
>>
>>> scons will do what you are asking without you having to explicitly list
>>> them on  the command line.
>>> If it's doing the wrong thing, file a bug.
>>>
>>> I can't fathom a reason to do what you are asking to do.
>>> Can you supply a reason to your madness so that perhaps we can propose a
>>> way which make sense for scons?
>>>
>>> You can use the --tree=prune output as well to see what depends on what.
>>>
>>> -Bill
>>>
>>> On Wed, Nov 18, 2015 at 3:47 PM, William Blevins <wblevins001 at gmail.com>
>>> wrote:
>>>
>>>>
>>>>
>>>> On Wed, Nov 18, 2015 at 11:16 PM, Abhishek Rai <abhishekrai at gmail.com>
>>>> wrote:
>>>>
>>>>> Thanks for the prompt response William.
>>>>>
>>>>> On Wed, Nov 18, 2015 at 3:06 PM, William Blevins <
>>>>> 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.
>>>>>
>>>>
>>>> dry-run doesn't execute the build statements, so my point here was to
>>>> get the dependency tree output without compiling.  You can then find
>>>> entries in the tree that map to local changes (files shown by git status,
>>>> etc); this of course can give you the final target if you follow the tree
>>>> to the root. You will need a parser for the tree output which shouldn't be
>>>> too complicated, but it might not be efficient either.
>>>>
>>>>
>>>>>
>>>>> >
>>>>> > 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> 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
>>>>> >>
>>>>> >> _______________________________________________
>>>>> >> Scons-users mailing list
>>>>> >> Scons-users at scons.org
>>>>> >> https://pairlist4.pair.net/mailman/listinfo/scons-users
>>>>> >>
>>>>> >
>>>>> >
>>>>> > _______________________________________________
>>>>> > Scons-users mailing list
>>>>> > Scons-users at scons.org
>>>>> > https://pairlist4.pair.net/mailman/listinfo/scons-users
>>>>> >
>>>>>
>>>>> _______________________________________________
>>>>> Scons-users mailing list
>>>>> Scons-users at scons.org
>>>>> https://pairlist4.pair.net/mailman/listinfo/scons-users
>>>>>
>>>>>
>>>>
>>>> _______________________________________________
>>>> Scons-users mailing list
>>>> Scons-users at scons.org
>>>> https://pairlist4.pair.net/mailman/listinfo/scons-users
>>>>
>>>>
>>>
>>> _______________________________________________
>>> Scons-users mailing list
>>> Scons-users at scons.org
>>> https://pairlist4.pair.net/mailman/listinfo/scons-users
>>>
>>>
>>
>> _______________________________________________
>> Scons-users mailing list
>> Scons-users at scons.org
>> https://pairlist4.pair.net/mailman/listinfo/scons-users
>>
>>
>
> _______________________________________________
> Scons-users mailing list
> Scons-users at scons.org
> https://pairlist4.pair.net/mailman/listinfo/scons-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20151119/3dacb504/attachment-0001.html>


More information about the Scons-users mailing list