[Scons-users] How to treat a directory of stuff as a single node
M Busche
spammymatt94 at yahoo.com
Wed Jan 23 11:43:14 EST 2013
Russel,
Frankly, I should probably do a little more playing on my own before I get more help. But if I may beg your patience, I'll unashamedly ask my question once more in words. If this fails, I'll compose a simple example that clarifies my question.
I have three things I want to happen in sequence.
1. I have a directory named "test" that holds all my test cases. It has several test suites that must be run. Tests are run by an SCONS builder that produces a "success" target file for each suite upon successful completion.
2. I have a packaging script that sets up a gazillion (well maybe about 10 so far) independent scons build rules to copy source files and create directories into a single generated parent directory named, say, "dist". (These operations consist of calls to Mkdir and calls to something called SubstInFile which is very very close to Substfile (see the scons man page). I don't want any of these actions to take place until all tests have completed successfully.
3. I have a Tar build rule that generates the file "dist.tgz" out of the the directory of stuff I created in step 2.
Now what I feel OUGHT to give me all the dependencies I need are these two very simple lines. Sadly, I haven't tried this yet because I've just discovered other more serious problems I need to clean up first.
Depends(Dir("dist"), "test") # where I specifically let scons know that "dist" is a directory since it doesn't initially even exist.
Depends("dist.tgz", Dir("dist"))
I.e., what I WANT this to mean to scons is that (LINE 1) EVERY node under directory "dist" depends upon EVERY node under directory "test"; and that (LINE 2) node "dist.tgz" depends on EVERY node under directory "dist". But I have not yet read anything in the documentation (I've woefully still read very little of the man page) that would suggest this to be true (even though I feel like it ought to be true.) It's inconceivable to me that the makers of scons wouldn't have at least thought about these kinds of things. What exactly is the behavior of these statements?
IF it turns out that the above is not true, then it would seem I'm faced with the much more cumbersome task of manually setting up dependencies between each of my test suite builds, and each of the little itty-bitty file copies and Mkdirs; and also between each of those file copies and Mkdirs, and the tar build itself.
Anyway, I again apologize for asking this question without first trying it. There may not be an issue at all. Still, the behavior of Depends with Dirs seems to have these rich implications that I don't think are even mentioned in the tutorial; and so I feel this is perhaps a good general question none-the-less.
Most Humbly,
Matt
----- Original Message -----
From: Russel Winder <russel at winder.org.uk>
To: M Busche <spammymatt94 at yahoo.com>; SCons users mailing list <scons-users at scons.org>
Cc:
Sent: Wednesday, January 23, 2013 2:42 AM
Subject: Re: [Scons-users] How to treat a directory of stuff as a single node
On Tue, 2013-01-22 at 12:17 -0800, M Busche wrote:
> I'm trying to use SCONS for the first time to handle builds, test, doc
> generation and packaging for a little personal C++ project. I've made
> significant progress, but am having some difficulty with packaging.
> I've written some stuff to first copy my source into a generated
> distribution directory (and replacing __VERSION__ strings found in
> each file with the software version). This works just fine. My
> problem is that I don't want this software packaging process to start
> until all tests have been completed. But because I'm only packaging
> up source code, there's nothing to stop SCONS from deciding to start
> the packing process prior to running tests (or doing anything else at
> all for that matter). So how do I easily get SCONS to see the
> successful completion of my test cases as a dependency of every file
> copy operation and directory creation operation that I use to build up
> the distribution directory?
One route might be top use Depends to connect a product of the
completion of the test sequence to the package, then the package cannot
complete without all the tests having run successfully.
> Now all of my tests are run in a separate directory aptly named
> "test", and successful completion of a suite of test cases does create
> an SCONS target file in that directory structure. So, I presume if I
> explicitly declared the root directory node "test" as a dependency of
> all the copy / Mkdir operations I use to build up my distribution
> directory, that that would guarantee all the test suites finish prior
> to any packaging. (I have not tried this, but it seems like it should
> work.) But this seems cumbersome and awkward. Am I missing
> something? And what if I then wanted to declare some other build
> activity as another prerequisite to software packaging? I'd then have
> to promulgate the corresponding build targets as additional
> dependencies of all those copies and Mkdirs that are at the root of
> the packaging process???
Ideal for the use of Depends since there is a clear result product of
the test that the packaging can depend on.
For the other questions, we are now getting into the territory where
generalities might make things worse. It would help to know more detail
of the project structure and the SConstruct and SConscript files.
> Seems like what I want is some abstract node X (that doesn't
> correspond to any actual file or directory) declared as a dependency
> of each copy / Mkdir operation. Then I can declare other things (like
> test cases) to be dependencies of X. Is there such a thing in SCONS?
Yes, but I am confident there is an easier way.
> Anyway, I'm a noob working in isolation, and I'm quite likely missing
> something to make everything much simpler. (I feel like I'm doing
> more work than I should have to to get my dependencies just right.)
Your feeling implies that there is likely to be a better way; whenever
anything feels like too much work, it probably is, and it is time to
find a better way. To take this further though we need to move from
generalities to specifics, hence the request for more details of the
project. Do you have it on BitBucket, GitHub,…
--
Russel.
=============================================================================
Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder at ekiga.net
41 Buckmaster Road m: +44 7770 465 077 xmpp: russel at winder.org.uk
London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
More information about the Scons-users
mailing list