r1308@dev030 (orig r66461): dweatherford | 2007-10-30 19:18:14 -0700
[amiethrift.git] / lib / py / src / TSCons.py
blobac992faf304828fd0f50334d54db54aa8d714a31
1 #!/usr/bin/env python
3 # Copyright (c) 2006- Facebook
4 # Distributed under the Thrift Software License
6 # See accompanying file LICENSE or visit the Thrift site at:
7 # http://developers.facebook.com/thrift/
9 from os import path
10 from SCons.Builder import Builder
12 def scons_env(env, add=''):
13 opath = path.dirname(path.abspath('$TARGET'))
14 lstr = 'thrift --cpp -o ' + opath + ' ' + add + ' $SOURCE'
15 cppbuild = Builder(action = lstr)
16 env.Append(BUILDERS = {'ThriftCpp' : cppbuild})
18 def gen_cpp(env, dir, file):
19 scons_env(env)
20 suffixes = ['_types.h', '_types.cpp']
21 targets = map(lambda s: 'gen-cpp/' + file + s, suffixes)
22 return env.ThriftCpp(targets, dir+file+'.thrift')