[Scons-users] Overriding Object to force global dependency

Greg Ward greg at gerg.ca
Thu Jul 5 16:41:36 EDT 2012


On 05 July 2012, Greg Ward said:

> On 29 June 2012, Pawel Tomulik said:

> > It may be possible to use emitter for your purpose, I think.

> > Dee API docs for SCons.Builder.BuilderBase, especially add_emitter()

> > method. Try something like:

> >

> > def my_emitter(target, source, env):

> > env.Depends(target, 'foo.txt')

> > return target, source

> >

> > env = Environment()

> >

> > env['BUILDERS']['StaticObject'].add_emitter('.c', my_emitter)

> > ob = env.Object('a.c')

>

> Awesome! That worked perfectly right out of the gate.


Argghh. I spoke too soon. When I use this emitter *just* with
StaticObject, it's fine. But I want it on SharedObject as well as
StaticObject. So I did this:

def lbe_emitter(target, source, env):
env.Depends(target, '#dummy-lbe')
return (target, source)

env['BUILDERS']['StaticObject'].add_emitter('.cpp', lbe_emitter)
env['BUILDERS']['SharedObject'].add_emitter('.cpp', lbe_emitter)

("lbe" = "local build environment", which is where our local copies of
GCC, Boost, etc. live.)

But when I do that, SCons thinks all of my shared object files (.os)
are static:

scons: building `buildout/lib/libSystemUtilitiesJNI.so' because it doesn't exist
scons: *** [buildout/lib/libSystemUtilitiesJNI.so] Source file: Tools/Java/com/intelerad/tools/lib/FileVersion.os is static and is not compatible with shared target: buildout/lib/libSystemUtilitiesJNI.so

But that's not true. FileVersion.os was built with a call to
env.SharedObject. The command that built it was

buildout/lbe/bin/g++ -o Tools/Java/com/intelerad/tools/lib/FileVersion.os -c -g -O2 -Wall -m32 -fPIC [...] Tools/Java/com/intelerad/tools/lib/FileVersion.cpp

and the filename is ".os", which I thought was SCons' way of saying
it's a shared object.

I get the same problem if I leave the StaticObject builder alone, i.e. if I just have

env['BUILDERS']['SharedObject'].add_emitter('.cpp', lbe_emitter)

Any clue what's going on here?

Greg


More information about the Scons-users mailing list