[Scons-users] Let directory depend on file? (auto generated sources)
Dirk Bächle
tshortik at gmx.de
Wed Dec 3 13:47:36 EST 2014
Hey Stijn,
you're really making some progress there, nice. ;) Find some more tips
below...
On 03.12.2014 11:39, Stijn De Ruyck wrote:
>
> Got it, everything works as expected now!
>
> This is what I have:
>
> import os
>
> import fnmatch
>
> import glob
>
import re
>
> def autogen_emitter(target, source, env):
>
> #TODO: replace with egrep/awk on “namespace” in mst.odl and
> fetch stdout
>
Don't start to "shell out", solve this in Python directly:
fpath = str(source[0])
target = []
if os.path.isfile(fpath):
with open(fpath, "r") as f:
contents = f.read()
re_namespace = re.compile(r"namespace ([^\s]+)")
for m in re_namespace.finditer(contents):
target.append(m.group(1)+".c")
, untested and just to give you a direction.
>
> target = ['source1.c','source2.c'] #don't include the original
> dummy target
>
> return target, source
>
> env = Environment()
>
> env.CacheDir(".sconsCache")
>
> sources = ['hello.c']
>
> autogenBuilder = Builder(
>
> #TODO: replace with call to installModel.sh
>
I would try to get rid of the "installModel.sh". Am I assuming right
that it's not doing anything more than calling your ODLC compiler with a
bunch of options? Then, you should try to write and use a proper ODL
Builder instead...and pass the required flags and sources to it:
env = Environment(tools=['default','odl'])
env['ODLFLAGS'] = ['-whatever','-you','-need']
env.Odl('mst.odl')
env.Program(Glob('*.c'))
This is what it *could* look like...
Best regards,
Dirk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20141203/3b44dd62/attachment-0001.html>
More information about the Scons-users
mailing list