Mark Slee | 89e2bb8 | 2007-03-01 00:20:36 +0000 | [diff] [blame] | 1 | # |
David Reiss | ea2cba8 | 2009-03-30 21:35:00 +0000 | [diff] [blame] | 2 | # Licensed to the Apache Software Foundation (ASF) under one |
| 3 | # or more contributor license agreements. See the NOTICE file |
| 4 | # distributed with this work for additional information |
| 5 | # regarding copyright ownership. The ASF licenses this file |
| 6 | # to you under the Apache License, Version 2.0 (the |
| 7 | # "License"); you may not use this file except in compliance |
| 8 | # with the License. You may obtain a copy of the License at |
| 9 | # |
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # |
| 12 | # Unless required by applicable law or agreed to in writing, |
| 13 | # software distributed under the License is distributed on an |
| 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | # KIND, either express or implied. See the License for the |
| 16 | # specific language governing permissions and limitations |
| 17 | # under the License. |
| 18 | # |
Mark Slee | 89e2bb8 | 2007-03-01 00:20:36 +0000 | [diff] [blame] | 19 | |
dweatherford | 65b7075 | 2007-10-31 02:18:14 +0000 | [diff] [blame] | 20 | from os import path |
Mark Slee | e2bd58d | 2006-10-31 05:09:24 +0000 | [diff] [blame] | 21 | from SCons.Builder import Builder |
Nobuaki Sukegawa | 760511f | 2015-11-06 21:24:16 +0900 | [diff] [blame] | 22 | from six.moves import map |
Mark Slee | e2bd58d | 2006-10-31 05:09:24 +0000 | [diff] [blame] | 23 | |
Bryan Duxbury | 6972041 | 2012-01-03 17:32:30 +0000 | [diff] [blame] | 24 | |
mvaradachari | 476b796 | 2007-09-17 20:40:16 +0000 | [diff] [blame] | 25 | def scons_env(env, add=''): |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 26 | opath = path.dirname(path.abspath('$TARGET')) |
| 27 | lstr = 'thrift --gen cpp -o ' + opath + ' ' + add + ' $SOURCE' |
| 28 | cppbuild = Builder(action=lstr) |
| 29 | env.Append(BUILDERS={'ThriftCpp': cppbuild}) |
Bryan Duxbury | 6972041 | 2012-01-03 17:32:30 +0000 | [diff] [blame] | 30 | |
Mark Slee | e2bd58d | 2006-10-31 05:09:24 +0000 | [diff] [blame] | 31 | |
| 32 | def gen_cpp(env, dir, file): |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 33 | scons_env(env) |
| 34 | suffixes = ['_types.h', '_types.cpp'] |
| 35 | targets = map(lambda s: 'gen-cpp/' + file + s, suffixes) |
| 36 | return env.ThriftCpp(targets, dir + file + '.thrift') |