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

Jason Kenny dragon512 at live.com
Fri Aug 3 14:09:14 EDT 2018


Just to chime in here.
I have a recurse glob in Parts you can use.. I have an updated version I have to merge in that uses Glob.
It has to use cases. it allows you to get all the files in some tree of stuff ( with include and exclude patterns). And it has a way to get the node as a set of targets and source nodes, to allow keeping the tree structure. This is useful for copies and for adding files to a zip or some kind of archive builder.
The code is here: https://bitbucket.org/dragon512/parts/src/b256cf29748d3a175302f4b83542fbefba8328a9/parts/pattern.py#lines-28
given you builder you have for the copy you then say something like:
mypattern = env.Pattern(src_dir = "mysub/dir")
trg, src = mypattern.target_source("my/copy/root/dir")
env.CCopyAs(target=trg, source=src)
I know this works fine. At least this might help provide an example to tweak your version with.
Jason
________________________________
From: Scons-users <scons-users-bounces at scons.org> on behalf of Matthew Marinets <Matthew.Marinets at Kardium.com>
Sent: Friday, August 3, 2018 12:51 PM
To: SCons users mailing list
Subject: Re: [Scons-users] Recursive directories, and the ignoring of filenames.

I can't reproduce your bug then.

Using Python 3.6.5;
scons -v:
        script: v3.0.1.74b2c53bc42290e911b334a6b44f187da698a668, 2017/11/14 13:16:53, by bdbaddog on hpmicrodog
        engine: v3.0.1.74b2c53bc42290e911b334a6b44f187da698a668, 2017/11/14 13:16:53, by bdbaddog on hpmicrodog
        engine path: ['C:\\Program Files\\Python36\\scons-3.0.1\\SCons']


I made a Command() builder that Globs all .c files in the src/ directory, and copies them to the build/ directory:

        sources = Glob(pattern = str(src) + '/*.c')
        env.Command(target = [build.File(x.name) for x in sources], source = sources, action = 'cp $SOURCES $TARGET.dir')

First I ran it with src contents:
src/a.c
src/b.c
src/asdf.c

All files were copied, as expected. Running SCons again, the build was not executed as all targets were up to date.

Next, I changed the name of asdf.c to qwer.c.
>scons --debug=explain
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
scons: rebuilding `build\a.c' because:
           `src\asdf.c' is no longer a dependency
           `src\qwer.c' is a new dependency
cp src\a.c src\b.c src\qwer.c build
scons: done building targets.

>scons --debug=explain
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
scons: `.' is up to date.
scons: done building targets.

I think you've misidentified your bug.

I still suspect that it's because you're putting directories in the source / target arguments of a builder; SCons doesn't like that for some reason. Notice that in my example, the sources and targets were all files or lists of files, and to get a directory path in that action, I called $TARGET.dir

-Matthew

-----Original Message-----
From: Scons-users <scons-users-bounces at scons.org> On Behalf Of Alistair Buxton
Sent: August 3, 2018 10:25
To: SCons users mailing list <scons-users at scons.org>
Subject: Re: [Scons-users] Recursive directories, and the ignoring of filenames.

On 3 August 2018 at 18:08, 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.

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.


--
Alistair Buxton
a.j.buxton at gmail.com
_______________________________________________
Scons-users mailing list
Scons-users at scons.org
https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpairlist4.pair.net%2Fmailman%2Flistinfo%2Fscons-users&data=02%7C01%7C%7Cfcf5e69be0764221994008d5f969ce9a%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636689155181964090&sdata=l0UQMu0mZLTlori1hEz6setub05OES69yHBvL8epwpQ%3D&reserved=0
_______________________________________________
Scons-users mailing list
Scons-users at scons.org
https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpairlist4.pair.net%2Fmailman%2Flistinfo%2Fscons-users&data=02%7C01%7C%7Cfcf5e69be0764221994008d5f969ce9a%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636689155181964090&sdata=l0UQMu0mZLTlori1hEz6setub05OES69yHBvL8epwpQ%3D&reserved=0
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20180803/a9cb057c/attachment-0001.html>


More information about the Scons-users mailing list