[Scons-users] Recursive directories, and the ignoring of filenames.

Jack Brennen jbrennen at qti.qualcomm.com
Fri Aug 3 14:01:26 EDT 2018

Something like this seems to work for me...  It does assume that you're 
in a reasonably POSIX-like environment with find and sha1sum command 
line utilities.

env['SRCS_DIR'] = 'srcs'
env.Command('dir_summary.txt', '$SRCS_DIR', 'find $SOURCES -type f -exec sha1sum \{\} \; | sort > $TARGET')

built_image = env.Command('built_image', 'dir_summary.txt', 'run_image_builder $SRCS_DIR $TARGET')

The find command will find all of the files under srcs, and create a 
list of sorted message digests tagged with their filenames.  This will 
be run every time you run the build, and will recreate the file 
dir_summary.txt every time.

If dir_summary.txt changes, then the image builder will run and create 
built_time.  If dir_summary.txt does not change, then the image builder 
will not run.

It's a little bit heavyweight, in the sense that it will read every byte 
of every file under the sources directory, but that could be seen as a 
good thing; it will catch changes that "ls -lR" would miss.

On 8/3/2018 10:28 AM, Bill Deegan wrote:
> On Fri, Aug 3, 2018 at 10:25 AM, Alistair Buxton <a.j.buxton at gmail.com 
> <mailto:a.j.buxton at gmail.com>> wrote:
>     On 3 August 2018 at 18:08, Matthew Marinets
>     <Matthew.Marinets at kardium.com
>     <mailto:Matthew.Marinets at kardium.com>> wrote:
>     > To me it sounds more like you just need an emitter.
>     >
>     > The bug you described (as I understood it), is that the built-in
>     SCons
>     > decider is order-sensitive. Saying [“src/a.txt”, “src/b.txt”] is
>     different
>     > from [“src/b.txt”, “src/a.txt”].
>     >
>     > The simple solution, as Bill said, it to just sort your list.
>     You can do
>     > this automatically in an emitter.
>     Then you didn't correctly understand the issue. Go and read it again.
>     The issue is that saying ['a.txt', 'b.txt'] is the same say saying
>     ['a.txt', 'c.txt'] if b.txt and c.txt have the same contents, ie it
>     will NOT trigger a rebuild, even though it should. The way you build
>     the list is 100% irrelevant as this is an internal implementation
>     detail of scons.
> Yes. I understood the issue.
> However you care if:
> 1) the file path changes (if so trigger a rebuild right?)
> 2) the contents of same name file changes (and/or timestamp) if so 
> then rebuild right?
> -Bill
>     -- 
>     Alistair Buxton
>     a.j.buxton at gmail.com <mailto:a.j.buxton at gmail.com>
>     _______________________________________________
>     Scons-users mailing list
>     Scons-users at scons.org <mailto:Scons-users at scons.org>
>     https://pairlist4.pair.net/mailman/listinfo/scons-users
>     <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/20180803/9b724be9/attachment.html>

More information about the Scons-users mailing list