-
Notifications
You must be signed in to change notification settings - Fork 10
/
cudaup.sh
executable file
·174 lines (164 loc) · 3.16 KB
/
cudaup.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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#!/bin/bash
#set -e
OS="linux"
CPU="$HOSTTYPE"
WS=""
DoGet='false'
DoInstallLibs='false'
DoMake='false'
DoClean='false'
lazdir=$(which lazbuild 2> /dev/null) && \
lazdir=$(readlink -f "$lazdir") && \
lazdir=$(dirname "$lazdir")
usage="
Usage: $(basename $0) [option...]
Options:
-g --get download packages
-p --packs install packages to Lazarus
-m --make compile CudaText
-l --lazdir <directiory> set Lazarus directory
-o --os <system> set target OS (win32/win64/linux/freebsd/darwin/solaris)
-c --cpu <arch> set target CPU (i386/x86_64/arm)
-w --ws <widgetset> override WidgetSet (gtk2/gtk3/qt/qt5/cocoa)
--clean delete temp Free Pascal folders (src/*/*/lib/*-*)
-h --help show this message
"
[ $# -eq 0 ] && { echo "$usage"; exit 0; }
OPTIONS=hgpml:o:c:w:
LONGOPTS=clean,help,get,packs,make,lazdir:,os:,cpu:,ws:
! PARSED=$(getopt --options=$OPTIONS --longoptions=$LONGOPTS --name "$0" -- "$@")
if [[ ${PIPESTATUS[0]} -ne 0 ]]; then
echo "$usage"
exit 2
fi
eval set -- "$PARSED"
while true; do
case "$1" in
--clean)
DoClean=true
shift
;;
-g|--get)
DoGet=true
shift
;;
-m|--make)
DoMake=true
shift
;;
-h|--help)
echo "$usage"
exit 0
;;
-l|--lazdir)
lazdir="$2"
shift 2
;;
-c|--cpu)
CPU=$@
shift 2
;;
-o|--os)
OS=$2
shift 2
;;
-w|--ws)
WS=$2
shift 2
;;
-p|--packs)
DoInstallLibs=true
shift
;;
--)
shift
break
;;
esac
done
if [ $DoMake = "true" ]; then
if [ -z "$lazdir" ]; then
echo "Couldn't find Lazarus directory"
echo "Use -l <path> option"
exit 1
fi
if [ ! -x "$lazdir/lazbuild" ]; then
echo "Couldn't find lazbuild"
echo "Use -l <path> option"
exit 1
fi
fi
cd $(dirname "$0")
Repos=$(cat cudaup.repos)
Packets=$(cat cudaup.packets)
if [ $DoClean = 'true' ]
then
if [ -d src ]
then
rm -rf src/*/*/lib/*-*
fi
fi
if [ $DoGet = 'true' ]
then
mkdir -m=rwxrwxrw -pv 'src'
cd src
for i in $Repos
do
temp=${i/'https://github.com/Alexey-T/'/''}
[ ! -d "$temp/.git" ] && git clone "$i"
cd "$temp"
git pull origin master
cd ../
done
cd ../
fi
if [ $DoInstallLibs = 'true' ]
then
for i in $Packets
do
"$lazdir/lazbuild" -q --lazarusdir="$lazdir" "./src/$i"
"$lazdir/lazbuild" -q --lazarusdir="$lazdir" --add-package "./src/$i"
done
"$lazdir/lazbuild" -q --build-ide=
fi
if [ $DoMake = 'true' ]
then
inc=''
if [ $OS != 'linux' ]
then
inc="$inc --os=$OS"
fi
if [ $OS = 'win32' ]
then
CPU='i386'
fi
if [ $OS = 'win64' ]
then
CPU='x86_64'
fi
if [ $CPU != "$HOSTTYPE" ]
then
inc="$inc --cpu=$CPU"
fi
if [ $WS != "" ]
then
inc="$inc --ws=$WS"
fi
if [ $DoInstallLibs = 'false' ]
then
for i in $Packets
do
"$lazdir/lazbuild" $inc -q --lazarusdir="$lazdir" "./src/$i"
done
fi
rm "./src/CudaText/app/cudatext"
"$lazdir/lazbuild" $inc -q --lazarusdir="$lazdir" "./src/CudaText/app/cudatext.lpi"
OUTDIR="./bin/$OS-$CPU-$WS"
mkdir -pv $OUTDIR
if [ $OS = 'win32' ] || [ $OS = 'win64' ]
then
cp ./src/CudaText/app/cudatext.exe $OUTDIR/cudatext.exe
else
cp ./src/CudaText/app/cudatext $OUTDIR/cudatext
fi
fi