-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake.sh
More file actions
executable file
·135 lines (114 loc) · 4 KB
/
make.sh
File metadata and controls
executable file
·135 lines (114 loc) · 4 KB
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
#!/usr/bin/env bash
function priv_lazbuild
(
if ! command -v lazbuild >/dev/null 2>&1; then
source /etc/os-release
case "${ID:?}" in
debian|ubuntu)
sudo apt-get update
sudo apt-get install -y \
wget \
ca-certificates \
libgtk2.0-dev
declare -r FPC_VERSION="3.2.2-210709"
declare -r LAZ_VERSION="4.4"
declare -r LAZ_BASE_URL="https://sourceforge.net/projects/lazarus/files/Lazarus%20Linux%20amd64%20DEB/Lazarus%20${LAZ_VERSION}"
declare -r QT6_URL="https://github.com/davidbannon/libqt6pas/releases/download/v6.2.10/"
declare -A PKG=(
[fpc]="fpc-laz_${FPC_VERSION}_amd64.deb"
[src]="fpc-src_${FPC_VERSION}_amd64.deb"
[laz]="lazarus-project_${LAZ_VERSION}.0-0_amd64.deb"
)
declare -A QT6=(
[dev]="libqt6pas6-dev_6.2.10-1_amd64.deb"
[non]="libqt6pas6_6.2.10-1_amd64.deb"
)
TMPDIR="build"
pushd "${TMPDIR}" >/dev/null
for p in "${QT6[@]}"; do
wget -nc -L "${QT6_URL}/${p}" -O ${p} || true
sudo apt install -y ./${p}
done
for p in "${PKG[@]}"; do
wget -nc -L "${LAZ_BASE_URL}/${p}/download" -O ${p} || true
sudo apt install -y ./${p}
done
popd >/dev/null
;;
*)
printf 'Unsupported OS: %s\n' "${ID}" >&2
exit 1
;;
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]}"
wait
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
declare -i errors=0
while read -r; do
TMP_OUT="$(mktemp)"
if lazbuild --build-all --verbose --recursive \
--no-write-project \
--build-mode='release' \
--widgetset='qt6' \
"${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' -E '(Error|Fatal):' "${TMP_OUT}"
((errors+=1))
fi 1>&2
rm -f "${TMP_OUT}"
done < <(find "${VAR[src]}" -type f -name '*.lpi' | sort)
exit "${errors}"
)
function priv_main
(
set -euo pipefail
if ((${#})); then
case ${1} in
build) priv_lazbuild ;;
*) priv_clippit ;;
esac
else
priv_clippit
fi
)
if [ -d "src/backup" ]; then
mv src/backup /tmp/backup
fi
priv_main "${@}"
if [ -d "/tmp/backup" ]; then
mv /tmp/backup src/backup
fi