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

Vinnie Falco vinnie at ripple.com
Sun May 4 22:07:17 EDT 2014



> Thanks a lot for the example:


I think my example had some problems. How about this one:

import os
base = Environment(
toolpath=[os.path.join ('src', 'beast', 'site_scons', 'site_tools')],
tools=['default', 'Protoc', 'VSProject'])
source_dir = os.path.join('src', 'ripple', 'proto')
source = os.path.join(source_dir, 'ripple.proto')
derived = base.Protoc([],
source,
PROTOCPROTOPATH=source_dir,
PROTOCOUTDIR=source_dir,
PROTOCPYTHONOUTDIR=None)
env = base.Clone()
for variant in ['debug', 'release']:
variant_dir = os.path.join('build', variant)
env.VariantDir(variant_dir, source_dir)
variant_source = os.path.join(variant_dir,
os.path.split(str(derived[0]))[1])
objects = env.Object(variant_source)
env.Alias(variant, objects)
if variant == 'debug':
env.Default(objects)

Output:

vinnie at vinnie-ubuntu:~/proj/rippled$ scons --tree=all
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
scons: *** [build/debug/ripple.pb.o] Source `build/debug/ripple.pb.cc'
not found, needed by target `build/debug/ripple.pb.o'.
+-build/debug/ripple.pb.o
+-build/debug/ripple.pb.cc
+-/usr/bin/g++


More information about the Scons-users mailing list