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

Bill Deegan bill at baddogconsulting.com
Fri Aug 3 13:26:27 EDT 2018


Matthew +1 for sorting the emitter!

And actually unless you care about empty directories changing their name,
then having the full path to all the files will yield the same information
(did a directory name change).
-Bill

On Fri, Aug 3, 2018 at 10:08 AM, Matthew Marinets <
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.
>
>
>
> Additionally, from my experience, SCons builders really don’t like taking
> directories as sources.
>
> --If you need a directory path in your command line, it should not come
> straight from $SOURCES
>
> ---Different variables that you define work fine, say $SOURCES_DIR
>
> ---Some SCons tools, particularly Java ones, use a node’s attributes; so
> you’d set a source’s attribute for, say, source_dir, and call it in the
> command with $SOURCE.attributes.source_dir
>
> --If you still want to specify just the sources directory when you call
> your builder, you can do all this calculation automatically in an emitter.
>
>
>
> Example:
>
> MyTool.py:
>
> “””My custom tool”””
>
> Import os
>
>
>
> from my_util import custom_recursive_glob
>
>
>
> def emitter(target, source, env):
>
>                 “””Formats targets and sources;
>
> The sources root directory will be assigned to $SOURCES_DIR,
>
> The actual source files will be used by SCons for dependency checking
>
> ”””
>
>                 assert os.isdir(str(source[0]))
>
>                 env[‘SOURCES_DIR’] = source
>
>                 source = custom_recursive_glob(source, pattern = “*.txt”)
>
>                 return target, source
>
>
>
> def generate(env):
>
>                 env[‘MYBUILDERCOM’] = “ls -lR $SOURCES_DIR > $TARGET”
>
>                 env[‘BUILDERS’][‘MyBuilder’] =
> SCons.Builder.Builder(action = “$MYBUILDERCOM’”, emitter = emitter)
>
>
>
> def exists(env):
>
>                 return True
>
>
>
> SConstruct:
>
> env = Environment(tools = [“MyTool”], toolpath = [“path/to/MyTool”])
>
> # build calls and such
>
>
>
> -Matthew
>
>
>
> *From:* Scons-users <scons-users-bounces at scons.org> *On Behalf Of *Bill
> Deegan
> *Sent:* August 3, 2018 09:52
> *To:* SCons users mailing list <scons-users at scons.org>
> *Subject:* Re: [Scons-users] Recursive directories, and the ignoring of
> filenames.
>
>
>
> And what if you sort the list generated from os.walk? Then the order
> should be consistant...
>
>
>
> On Fri, Aug 3, 2018 at 9:24 AM, Alistair Buxton <a.j.buxton at gmail.com>
> wrote:
>
> On 3 August 2018 at 14:56, Marc Branchaud <marcnarc at xiplink.com> wrote:
>
> > I use os.walk() to make a big list of all the files.
>
> This is affected by the bug I described, as are all methods which
> build a list of filenames and pass it to scons.
>
> Also os.walk ordering is arbitrary so this algorithm has a small
> chance of causing random spurious rebuilds.
>
>
>
> --
> Alistair Buxton
> a.j.buxton at gmail.com
>
> _______________________________________________
> 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/20180803/fc64408f/attachment.html>


More information about the Scons-users mailing list