-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.sh
executable file
·126 lines (124 loc) · 3.77 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
#!/bin/bash
#^# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
# @version : 0.60
# @type : library
# @date : 2018
# @license : GPLv3.0 <http://www.gnu.org/licenses/>
# @author : a-Sansara <[dev]at[pluie]dot[org]>
# @copyright : pluie.org <http://www.pluie.org>
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# This file is part of pluie-yaml.
#
# pluie-yaml is free software (free as in speech) : you can redistribute it
# and/or modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of the License,
# or (at your option) any later version.
#
# pluie-yaml is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License
# along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #^#
# --------------------------------------------------------
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
lib="pluie-yaml-0.6"
samples=" src/vala/Pluie/Samples.YamlObject.vala \
src/vala/Pluie/Samples.YamlChild.vala \
src/vala/Pluie/Samples.YamlStruct.vala "
c1="\033[1;38;5;215m"
c2="\033[1;38;5;97m"
cok="\033[1;38;5;37m"
cko="\033[1;38;5;204m"
off="\033[m"
resume=
# --------------------------------------------------------
function build.title()
{
local s="$cko>"
local c3=""
local state=""
if [ ! -z "$2" ]; then
state="${cko}FAILED"
if [ $2 -eq 0 ]; then
state="${cok}SUCCESS"
fi
s="$cko<"
fi
if [ ! -z $3 ]; then
echo -e " |- $state $c1$1 $off"
else
echo -e "\n $s $c1[$c2$1$c1] $state$off"
fi
}
# --------------------------------------------------------
function build.lib()
{
cd "$DIR"
build.title "$lib LIB BUILD"
meson --prefix=/usr ./ build
if [ "$1" -eq 1 ]; then
meson configure -DLOCAL=true build
else
meson configure -DLOCAL=false build
fi
if [ "$UID" != "0" ]; then
sudo ninja -v install -C build
else
ninja -v install -C build
fi
local rs=$?
build.title "$lib LIB BUILD" $rs
return $rs
}
# --------------------------------------------------------
function build.samples()
{
for file in ./samples/*.vala
do
if [[ -f $file ]]; then
if [ -z "$1" ] || [ "$1" == "$file" ]; then
build.sample "$file"
fi
fi
done
echo -e "\n RESUME : "
for t in $resume; do
build.title "${t:1}" ${t:0:1} 1
done
echo -e " binary files are located in ./bin ($DIR)"
}
# --------------------------------------------------------
function build.sample()
{
local f="$(basename $1)"
local fx="${f:0:-5}"
local state="FAILED"
local cmd="valac -v -X -Wno-discarded-qualifiers -X -Wno-deprecated-declarations --pkg gee-0.8 --pkg gio-2.0 --pkg pluie-echo-0.2 --pkg $lib $samples $1 -o ./bin/$fx"
build.title "$f SAMPLE BUILD"
echo
$cmd
local done=$?
resume="$resume$done$f "
build.title "$f SAMPLE BUILD" $done
}
# --------------------------------------------------------
function build.main()
{
local onefile=""
if [ ! -z "$1" ]; then
onefile="./samples/$1.vala"
fi
build.lib "$2"
if [ $? -eq 0 ]; then
build.samples $onefile
fi
}
build.main "$1" "${2:-0}"