-
Notifications
You must be signed in to change notification settings - Fork 7
/
build.sh
executable file
·135 lines (106 loc) · 2.52 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/bin/bash
set -e
VERSION=1.0
TARGETS="trainer.native tagger.native"
FLAGS=" -libs str -I util -I hunpos -I hunpos/lib"
OCAMLBUILD=ocamlbuild
clean ()
{
$OCAMLBUILD $FLAGS -clean;
}
# generates a version.ml file which is compiled into
# the source
makeVersionMl()
{
echo "let version = \""$(VERSION)"\"" > version.ml
echo "let date = \""`date`"\"" >> version.ml
}
ocb()
{
if (echo -e "`ocamlbuild -version | sed -e 's/^.*[[:space:]]//g'`\n4.02" | sort -ct. -k1,1n -k2,2n 2>/dev/null >/dev/null)
then
FLAGS="$FLAGS"
PPFLAGF=-ppflag
PPFLAG="sed -e 's/^\(.*[[:space:]]\)\?Bytes\([^[:alpha:]].*\)\?$/\1String\2/g'"
$OCAMLBUILD $FLAGS $PPFLAGF "$PPFLAG" $TARGETS
else
$OCAMLBUILD $FLAGS $TARGETS
fi
}
usage()
{
echo "usage: ./build [ build | clean | release linux | release win | release macosx ]"
}
copyReleaseFiles ()
{
echo "NO README FILE"
}
releaseNx ()
{
cd _build
DIR=hunpos-$VERSION-$1
rm -rf $DIR; mkdir $DIR
if [ $1 == "win" ]; then
EXT=".exe"
if [ ! -e /bin/cygwin1.dll ]; then
echo "cygwin1.dll dynamic library not found."
echo "it will be not packaged with the release."
else
echo "packaging the cygwin1.dll dynamic library."
cp /bin/cygwin1.dll $DIR
fi
fi
cp hunpos/trainer.native $DIR/hunpos-train$EXT
cp hunpos/tagger.native $DIR/hunpos-tag$EXT
copyReleaseFiles $DIR
echo "compressing the release..."
if [ $1 == "win" ]; then
ARCHIVE=$DIR.zip
rm -f $ARCHIVE
zip -r $ARCHIVE $DIR
else
ARCHIVE=$DIR.tgz
rm -f $ARCHIVE
tar cvfz $ARCHIVE $DIR
fi
echo
echo "the release is ready at _build/$ARCHIVE"
echo
echo "uploading the release to its proper place at the mokk ftp server..."
echo "(obviously, this final step will fail if you are not the maintainer."
echo "in this case, just press Ctrl-C and enjoy the release.)"
echo
echo -n "please enter your kruso.mokk.bme.hu username: "
read USERNAME
scp $ARCHIVE [email protected]:/public/Tool/Hunpos/Pre/
ssh [email protected] chmod -w /public/Tool/Hunpos/Pre/$ARCHIVE
}
release()
{
if [ $# -eq 0 ]; then
echo "please specify a platform";
usage
else
case $1 in
linux) ;;
macosx) ;;
win) ;;
*) echo "unknown platform $1" ; exit ;;
esac;
ocb;
releaseNx $1;
fi
}
rule() {
case $1 in
clean) clean;;
build) ocb ;;
release) shift; release $*;;
*) echo "unknown action $1";;
esac;
}
if [ $# -eq 0 ]; then
usage ;
else
rule $*;
fi