[Scons-users] Builder to perform string substitution on source contents to produce a target file?

M Busche spammymatt94 at yahoo.com
Mon Jun 18 14:57:42 EDT 2012


John,

A few things:

1.  I've downloaded ascend and am looking at SubstInFile.  It appears both useful and educational.  Thankyou.


2.  I think I comprehend the majesty of this statement.  Can d be ANY python object type?

        Depends(target, SCons.Node.Python.Value(d))

BEGIN DOCUMENTATION RANT:

USER GUIDE:  When I wrote my own builder I was aware of the dependency problem introduced by the dictionary but didn't see a way to deal with it.  I read section 5 of the scons user guide (on Nodes):  it only mentions File, Dir and Entry type nodes.  I don't think section 6 (on Dependencies) mentions dependencies beyond file system dependencies either.  I was left with the feeling that that was all there was!  Seems like another example, or perhaps a pointer to some other document that gives a more complete list of Node types and/or dependencies would be appropriate.

MAN PAGE:  I find the man page unwieldy (almost 200 pages of unindexed text) and some sections are quite difficult to decipher even after reading (most of) the User Guide.  The description of the Depends function (which I did read) merely states that both arguments must be a Node, but doesn't hint at the full range of possibilities permitted.  Even now knowing about this special Value Node type, I'm not sure what to grep for to find a section that might give a clue about Scons.Node.Python.Value.


API:  This again is not very tutorial.  It is difficult to see what's important and what's not (as is the case for most API docs).  And it's obviously difficult to find what you're looking for when you're not exactly sure what it is you seek!  Even if I had read the class summary for Node.Python.Value, the text "A class for Python variables, ..." would not have hit me in the head hard enough to make me think this was what I needed.


END RANT

3. Since I posted my original question, I stumbled upon the Substfile method in the scons man page which seems very similar to your SubstInFile.  One obvious difference is that Substfile concatenates multiple source files into one target file -- something I don't find very useful, and in fact cumbersome as it requires I make a separate builder invocation for each source file.  If you are familiar with both builders, can you highlight any other differences for me?  (I.e., are there other reasons you wrote your own version of this builder?)


4.  My own substitution builder does have one useful feature that yours does not:  I can pass multiple source files along with a single Dir type target.  In this case it copies all sources to the target dir (much like a unix cp command).  For this use case, I also have to pass a "strip directory" property (through the environment) that is stripped from the beginning of each source path name before joining it to the target dir.  Any thoughts?


Thanks again,

Matt


----- Original Message -----

From: John Pye <john at curioussymbols.com>
To: M Busche <spammymatt94 at yahoo.com>; "scons-users at scons.org" <scons-users at scons.org>
Cc:
Sent: Monday, June 18, 2012 12:25 AM
Subject: Re: [Scons-users] Builder to perform string substitution on source contents to produce a target file?

The 'SubstInFile' tool is what you need, I think. We use that in our
project, http://ascend4.org/.

Cheers
JP

On Sun, Jun 17, 2012, at 08:50 PM, M Busche wrote:

> QUESTION:

>

> Is there was a standard builder for doing string-replacement processing

> between input and output files?

>

> BACKGROUND:

>

> I have written a builder that reads in a source file, performs a series

> global string substitutions on the file just read (as defined by a

> dictionary defined in the environment), and writes the result to the

> specified target file.  I use this during software packaging to replace

> the string pattern "__VERSION__" in each of my source files with the

> actual software version (which I pull out of my bzr source code control

> system).  I also use it to inject projectName, version, and output

> directory settings into a doxygen configuration file (which is

> subsequently used to produce software docs).  This seems useful enough

> that I thought it might already exist.

>

> Thanks much!

> Matt

>

> _______________________________________________

> Scons-users mailing list

> Scons-users at scons.org

> http://four.pairlist.net/mailman/listinfo/scons-users

--
John Pye
john at curioussymbols.com


More information about the Scons-users mailing list