-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmake.sh
86 lines (82 loc) · 2.59 KB
/
make.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
#!/usr/bin/env bash
function priv_clippit
(
cat <<EOF
Usage: bash ${0} [OPTIONS]
Options:
build Build program
EOF
)
function priv_lazbuild
(
if ! (command -v lazbuild); then
source '/etc/os-release'
case ${ID:?} in
debian | ubuntu)
sudo apt-get update
sudo apt-get install -y lazarus &
;;
esac
fi
if [[ -f '.gitmodules' ]]; then
git submodule update --init --recursive --force --remote &
fi
wait
declare -rA VAR=(
[src]='src'
[use]='use'
[pkg]='use/components.txt'
)
if [[ -d "${VAR[use]}" ]]; then
if [[ -f "${VAR[pkg]}" ]]; then
while read -r; do
if [[ -n "${REPLY}" ]] &&
! [[ -d "${VAR[use]}/${REPLY}" ]] &&
! (lazbuild --verbose-pkgsearch "${REPLY}") &&
! (lazbuild --add-package "${REPLY}"); then
declare -A TMP=(
[url]="https://packages.lazarus-ide.org/${REPLY}.zip"
[dir]="${VAR[use]}/${REPLY}"
[out]=$(mktemp)
)
wget --quiet --output-document "${TMP[out]}" "${TMP[url]}"
unzip -o "${TMP[out]}" -d "${TMP[dir]}"
rm --verbose "${TMP[out]}"
fi
done < "${VAR[pkg]}"
fi
find "${VAR[use]}" -type 'f' -name '*.lpk' -printf '\033[32m\tadd package link\t%p\033[0m\n' -exec \
lazbuild --add-package-link {} + 1>&2
fi
if [[ -d "${VAR[src]}" ]]; then
declare -i errors=0
while read -r; do
declare -A TMP=(
[out]=$(mktemp)
)
if (lazbuild --build-all --recursive --no-write-project --build-mode='release' "${REPLY}" > "${TMP[out]}"); then
printf '\x1b[32m\t[%s]\t%s\x1b[0m\n' "${?}" "${REPLY}"
grep --color='always' 'Linking' "${TMP[out]}"
else
printf '\x1b[31m\t[%s]\t%s\x1b[0m\n' "${?}" "${REPLY}"
grep --color='always' --extended-regexp '(Error|Fatal):' "${TMP[out]}"
((errors+=1))
fi 1>&2
rm "${TMP[out]}"
done < <(find "${VAR[src]}" -type 'f' -name '*.lpi' | sort)
exit "${errors}"
fi
)
function priv_main
(
set -euo pipefail
if ((${#})); then
case ${1} in
build) priv_lazbuild ;;
*) priv_clippit ;;
esac
else
priv_clippit
fi
)
priv_main "${@}" >/dev/null