blob: ac992faf304828fd0f50334d54db54aa8d714a31 [file] [log] [blame]
Mark Slee89e2bb82007-03-01 00:20:36 +00001#!/usr/bin/env python
2#
3# Copyright (c) 2006- Facebook
4# Distributed under the Thrift Software License
5#
6# See accompanying file LICENSE or visit the Thrift site at:
7# http://developers.facebook.com/thrift/
8
dweatherford65b70752007-10-31 02:18:14 +00009from os import path
Mark Sleee2bd58d2006-10-31 05:09:24 +000010from SCons.Builder import Builder
11
mvaradachari476b7962007-09-17 20:40:16 +000012def scons_env(env, add=''):
dweatherford65b70752007-10-31 02:18:14 +000013 opath = path.dirname(path.abspath('$TARGET'))
14 lstr = 'thrift --cpp -o ' + opath + ' ' + add + ' $SOURCE'
mvaradachari476b7962007-09-17 20:40:16 +000015 cppbuild = Builder(action = lstr)
Mark Sleee2bd58d2006-10-31 05:09:24 +000016 env.Append(BUILDERS = {'ThriftCpp' : cppbuild})
17
18def 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')