[Scons-users] SCons code generation (e.g. protobuf) and VariantDir

Carl Cerecke carl.cerecke at compacsort.com
Sun May 4 19:36:47 EDT 2014


In the build that I'm responsible for, the .proto files are copied to
the variant dir and the protoc invoked there, rather than creating the
files in the src dir.

It does do a bit of extra work, I suppose, but has the advantage that
per-build protoc options are possible.

Also, in my case, I changed the ProtocAction in protoc.py to an
explicit function which ran protoc in a new process so it would get
the correct LD_LIBRARY_PATH environment variable (which was set
programmatically):

def ProtocAction(target, source, env):
# Use this to pass the LD_LIBRARY_PATH environment variable to the
new process.
# The protobuf_2_5_0.py that is included by a SConscript will set
the LD_LIBRARY_PATH
# environment variable for us.
cmd = env.subst('$PROTOCCOM')+' '+str(source[0])
print cmd
subprocess.check_call(cmd, shell=True)


You might be able to use a similar technique (changing the protoc.py)
to do what you want. Sprinkle some print statements through your
protoc.py to get an idea of what is going wrong, than change the code
to do what you want.

Cheers,
Carl.



On 5 May 2014 10:15, Vinnie Falco <vinnie at ripple.com> wrote:

> I'm working on a project that uses SCons and protocol buffers from

> C++. I learned Python and SCons and added support for variant

> directories. But there's a problem, and one that it seems others have

> had.

>

> My SConstruct invokes a protoc builder on src/ripple.proto to produce

> build/proto/ripple.pb.cc and build/proto/ripple.pb.h. I use

> VariantDir('build/debug/proto', 'build/proto') to establish a variant

> (the real file has 12 variants). But when I call

> env.Object('build/debug/proto/ripple.pb.cc') SCons does not realize

> that it has to first call protoc and produces the error 'ripple.pb.cc

> required for ripple.pb.obj'.

>

> This problem is explained clearly in this old StackOverflow question,

> to which I have added a reputation bounty:

>

> http://stackoverflow.com/questions/16545459/scons-code-generation-and-variantdir

>

> Thoughts?

> _______________________________________________

> Scons-users mailing list

> Scons-users at scons.org

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




--
Carl Cerecke
SENIOR SOFTWARE DEVELOPER
Compac Sorting Equipment Ltd.

M: +64 21 205 0239
F: +64 9 634 4491
Skype: carl-compac


More information about the Scons-users mailing list