[Scons-users] 答复: [scons-users] Replacing Builder while perserving Scanner

Dirk Bächle tshortik at gmx.de
Sun Jun 15 10:53:05 EDT 2014


On 15.06.2014 14:56, yangsc wrote:
>
> Thank you,
>
> I’v read the scanner object, but my problem is *I want to use the 
> default C-Scanner* to proceed my *‘.input’ file* and I *don’t want to 
> write my own scanner because the preprocesser derictive is the same as 
> in C*.
>
> It seems scons have flexibility to write user’s own scanner, but I 
> just want a way to reuse some already existed scanner for *building 
> the dependency graph,* and then use my own builder to build the source 
> file into target file.
>

Thanks a lot for the clarifying comments. I don't see a way to simply 
re-use the existing CScanner, because it it used in a different 
context...you want to call your own Builder, and not simply put 
"*.input" files as sources into a standard Object/Library/Program Builder.
So, the easiest thing for you is probably to use the same approach as 
the "swig.py" Tool, and add your own Scanner as follows:

     import SCons.Scanner
     env = Environment()
     expr = '^[ \t]*#[ \t]*(?:include|import)[ \t]*(<|")([^>"]+)(>|")'
     scanner = SCons.Scanner.ClassicCPP("MyInputScan", ".input", 
"CPPPATH", expr)

     env.Append(SCANNERS = scanner)

     ...

Best regards,

Dirk

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://four.pairlist.net/pipermail/scons-users/attachments/20140615/25a646b2/attachment.html>


More information about the Scons-users mailing list