Mark Slee | 89e2bb8 | 2007-03-01 00:20:36 +0000 | [diff] [blame] | 1 | # 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 | |
dweatherford | 65b7075 | 2007-10-31 02:18:14 +0000 | [diff] [blame] | 7 | from os import path |
Mark Slee | e2bd58d | 2006-10-31 05:09:24 +0000 | [diff] [blame] | 8 | from SCons.Builder import Builder |
| 9 | |
mvaradachari | 476b796 | 2007-09-17 20:40:16 +0000 | [diff] [blame] | 10 | def scons_env(env, add=''): |
dweatherford | 65b7075 | 2007-10-31 02:18:14 +0000 | [diff] [blame] | 11 | opath = path.dirname(path.abspath('$TARGET')) |
| 12 | lstr = 'thrift --cpp -o ' + opath + ' ' + add + ' $SOURCE' |
mvaradachari | 476b796 | 2007-09-17 20:40:16 +0000 | [diff] [blame] | 13 | cppbuild = Builder(action = lstr) |
Mark Slee | e2bd58d | 2006-10-31 05:09:24 +0000 | [diff] [blame] | 14 | env.Append(BUILDERS = {'ThriftCpp' : cppbuild}) |
| 15 | |
| 16 | def 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') |