blob: 9189d30042680dfa1c1144b3b6df2446e4c743eb [file] [log] [blame]
Bryan Duxbury3fb4f1e2009-03-24 00:36:00 +00001#!/bin/sh
2
David Reissea2cba82009-03-30 21:35:00 +00003#
4# Licensed to the Apache Software Foundation (ASF) under one
5# or more contributor license agreements. See the NOTICE file
6# distributed with this work for additional information
7# regarding copyright ownership. The ASF licenses this file
8# to you under the Apache License, Version 2.0 (the
9# "License"); you may not use this file except in compliance
10# with the License. You may obtain a copy of the License at
11#
12# http://www.apache.org/licenses/LICENSE-2.0
13#
14# Unless required by applicable law or agreed to in writing,
15# software distributed under the License is distributed on an
16# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17# KIND, either express or implied. See the License for the
18# specific language governing permissions and limitations
19# under the License.
20#
21
Anthony F. Molinaro71a58a82010-09-27 19:27:40 +000022# Check some basic
Bryan Duxbury3fb4f1e2009-03-24 00:36:00 +000023if [ -z $BASE ]; then
24 BASE=../..
25fi
26
Anthony F. Molinaro71a58a82010-09-27 19:27:40 +000027if [ -z $OUTDIR ]; then
28 OUTDIR=server-bindings
29fi
30
31if [ -z $THRIFT_BIN ]; then
32 THRIFT_BIN=$(which thrift)
33fi
34
35if [ ! -x "$THRIFT_BIN" ]; then
36 printf "Could not find thrift binary; pass it as environment variable THRIFT_BIN\n"
37 exit 1
38fi
39
40# Figure out what file to generate bindings from
41if [ -z $THRIFT_FILE ]; then
42 THRIFT_FILE=$BASE/test/$1.thrift
43fi
44
45if [ ! -e $THRIFT_FILE ]; then
46 printf "Missing thrift file $THRIFT_FILE \n"
47 exit 2
48fi
49
50# Figure out what file to run has a server
51if [ -z $SERVER_FILE ]; then
52 SERVER_FILE=$BASE/test/hs/$1_TestServer.hs
53fi
54
55if [ ! -e $SERVER_FILE ]; then
56 printf "Missing server code file $SERVER_FILE \n"
57 exit 3
58fi
59
60# Actually run the server bits
61printf "Creating directory $OUTDIR to hold generated bindings... \n"
62[ -d $OUTDIR ] || mkdir $OUTDIR
63
64printf "Generating bindings... \n"
65$THRIFT_BIN -o $OUTDIR --gen hs $THRIFT_FILE
66
67printf "Starting server... \n"
68runhaskell -Wall -Werror -i$BASE/lib/hs/src -i$OUTDIR/gen-hs $SERVER_FILE