blob: 7afd694f2b83e764d1ed9e9bfdb0c1bee00c47cc [file] [log] [blame]
Adrien Béraud04d822c2015-04-02 17:44:36 -04001#!/bin/bash -
2#
3# Copyright (C) 2004-2014 Savoir-Faire Linux Inc.
4#
5# Author: Emeric Vigier <emeric.vigier@savoirfairelinux.com>
6#
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 3 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program; if not, write to the Free Software
19# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20#
21# Additional permission under GNU GPL version 3 section 7:
22#
23# If you modify this program, or any covered work, by linking or
24# combining it with the OpenSSL project's OpenSSL library (or a
25# modified version of that library), containing parts covered by the
26# terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
27# grants you additional permission to convey the resulting work.
28# Corresponding Source for a non-source form of such a combination
29# shall include the source code for the parts of OpenSSL used as well
30# as that of the covered work.
31#
32
33# input: jni/jni_interface.i
34# output: ringservice_loader.c
35# ring_wrapper.cpp
36# ringservice.java
37# ringserviceJNI.java
38# ManagerImpl.java
39
Adrien Béraudb00ed3f2015-06-07 15:36:06 -040040SRCDIR=app/src/main/jni
Adrien Béraud04d822c2015-04-02 17:44:36 -040041PACKAGE=cx.ring.service
Adrien Béraudb00ed3f2015-06-07 15:36:06 -040042PACKAGEDIR=app/src/main/java/cx/ring/service
Adrien Béraud04d822c2015-04-02 17:44:36 -040043ROOT=`pwd`
44
45echo "in $ROOT"
46
47echo "Checking that swig is 2.0.6 or later"
48SWIGVER=`swig -version | \
49 grep -i "SWIG version" | \
50 awk '{print $3}'`
51SWIGVER1=`echo $SWIGVER | \
52 awk '{split($0, array, ".")} END{print array[1]}'`
53SWIGVER2=`echo $SWIGVER | \
54 awk '{split($0, array, ".")} END{print array[2]}'`
55SWIGVER3=`echo $SWIGVER | \
56 awk '{split($0, array, ".")} END{print array[3]}'`
57
58echo swig-$SWIGVER1.$SWIGVER2.$SWIGVER3
59
60if [[ $SWIGVER1 -ge 2 ]]; then
61 echo "swig version is greater than 2.x"
62 if [[ $SWIGVER1 -gt 2 ]]; then
63 echo "swig version is greater than 3.x"
64 else
65 if [[ $SWIGVER2 -ge 1 ]]; then
66 echo "swig version is greater than 2.1"
67 else
68 echo "swig version is less than 2.1"
69 if [[ $SWIGVER3 -ge 6 ]]; then
70 echo "swig version is greater than 2.0.6"
71 else
72 echo "swig version is less than 2.0.6"
73 echo "exiting..."
74 exit 4
75 fi
76 fi
77 fi
78else
79 echo "swig version is less than 2.x"
80 echo "exiting..."
81 exit 3
82fi
83
84echo "Generating ring_wrapper.cpp..."
85
86swig -v -c++ -java \
87-package $PACKAGE \
88-outdir $PACKAGEDIR \
89-o $SRCDIR/ring_wrapper.cpp $SRCDIR/jni_interface.i
90
91echo "Generating ringservice_loader.c..."
92python $SRCDIR/JavaJNI2CJNI_Load.py \
93-i $ROOT/$PACKAGEDIR/RingserviceJNI.java \
94-o $SRCDIR/ringservice_loader.c \
95-t $SRCDIR/ringservice.c.template \
96-m Ringservice \
97-p $PACKAGE
98
Adrien Béraud87d878d2015-06-03 15:09:19 -040099echo "Appending ring_wrapper.cpp..."
Adrien Béraud04d822c2015-04-02 17:44:36 -0400100cat $SRCDIR/ringservice_loader.c >> $SRCDIR/ring_wrapper.cpp
101
102echo -n "in "
103echo "Done"
104exit 0