blob: dce1d01ac5e84453c1434eab110f4210ef8156b9 [file] [log] [blame]
Mark Slee89e2bb82007-03-01 00:20:36 +00001# Copyright (c) 2006- Facebook
2# Distributed under the Thrift Software License
3#
4# See accompanying file LICENSE or visit the Thrift site at:
5# http://developers.facebook.com/thrift/
6
dweatherford65b70752007-10-31 02:18:14 +00007from os import path
Mark Sleee2bd58d2006-10-31 05:09:24 +00008from SCons.Builder import Builder
9
mvaradachari476b7962007-09-17 20:40:16 +000010def scons_env(env, add=''):
dweatherford65b70752007-10-31 02:18:14 +000011 opath = path.dirname(path.abspath('$TARGET'))
12 lstr = 'thrift --cpp -o ' + opath + ' ' + add + ' $SOURCE'
mvaradachari476b7962007-09-17 20:40:16 +000013 cppbuild = Builder(action = lstr)
Mark Sleee2bd58d2006-10-31 05:09:24 +000014 env.Append(BUILDERS = {'ThriftCpp' : cppbuild})
15
16def gen_cpp(env, dir, file):
17 scons_env(env)
18 suffixes = ['_types.h', '_types.cpp']
19 targets = map(lambda s: 'gen-cpp/' + file + s, suffixes)
20 return env.ThriftCpp(targets, dir+file+'.thrift')