Skip to content

Commit 4cde133

Browse files
committed
build: make build script more verbose
1 parent e70ba04 commit 4cde133

File tree

4 files changed

+103
-0
lines changed

4 files changed

+103
-0
lines changed

src/build.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#!/bin/bash
22

3+
# Include utils library
4+
script_dir=$(dirname "$0")
5+
. "$script_dir/utils.sh"
6+
37
function set_compliation_variables() {
48
# Set compilation variables such as which compiler to use.
59
#
@@ -18,6 +22,8 @@ function set_compliation_variables() {
1822
return 1
1923
fi
2024

25+
>&2 fancy_title "Setting compilation variables for $target_arch"
26+
2127
if [[ "$target_arch" == "arm" ]]; then
2228
CROSS=arm-linux-gnueabi-
2329
export HOST=arm-linux-gnueabi
@@ -67,6 +73,8 @@ function build_iconv() {
6773

6874
pushd "$iconv_build_dir" > /dev/null
6975

76+
>&2 fancy_title "Building libiconv for $target_arch"
77+
7078
../configure --enable-static "CC=$CC" "CXX=$CXX" "--host=$HOST" \
7179
"CFLAGS=$CFLAGS" "CXXFLAGS=$CXXFLAGS" 1>&2
7280
if [[ $? -ne 0 ]]; then
@@ -82,6 +90,8 @@ function build_iconv() {
8290
mkdir -p ./lib/.libs/lib/
8391
cp ./lib/.libs/libiconv.a ./lib/.libs/lib/
8492

93+
>&2 fancy_title "Finished building libiconv for $target_arch"
94+
8595
popd > /dev/null
8696
}
8797

@@ -113,6 +123,8 @@ function build_libgmp() {
113123

114124
pushd "$gmp_build_dir" > /dev/null
115125

126+
>&2 fancy_title "Building libgmp for $target_arch"
127+
116128
../configure --enable-static "CC=$CC" "CXX=$CXX" "--host=$HOST" \
117129
"CFLAGS=$CFLAGS" "CXXFLAGS=$CXXFLAGS" 1>&2
118130
if [[ $? -ne 0 ]]; then
@@ -129,6 +141,8 @@ function build_libgmp() {
129141
mkdir -p ./.libs/lib/
130142
cp ./.libs/libgmp.a ./.libs/lib/
131143

144+
>&2 fancy_title "Finished building libgmp for $target_arch"
145+
132146
popd > /dev/null
133147
}
134148

@@ -162,6 +176,8 @@ function build_libmpfr() {
162176

163177
pushd "$mpfr_dir/build-$target_arch" > /dev/null
164178

179+
>&2 fancy_title "Building libmpfr for $target_arch"
180+
165181
../configure --enable-static "--with-gmp-build=$libgmp_build_dir" \
166182
"CC=$CC" "CXX=$CXX" "--host=$HOST" \
167183
"CFLAGS=$CFLAGS" "CXXFLAGS=$CXXFLAGS" 1>&2
@@ -179,6 +195,8 @@ function build_libmpfr() {
179195
mkdir -p ./src/.libs/lib
180196
cp ./src/.libs/libmpfr.a ./src/.libs/lib/
181197

198+
>&2 fancy_title "Finished building libmpfr for $target_arch"
199+
182200
popd > /dev/null
183201
}
184202

@@ -216,6 +234,8 @@ function build_gdb() {
216234

217235
pushd "$gdb_build_dir" > /dev/null
218236

237+
>&2 fancy_title "Building gdb for $target_arch"
238+
219239
../configure --enable-static --with-static-standard-libraries --disable-tui --disable-inprocess-agent \
220240
"--with-libiconv-prefix=$libiconv_prefix" --with-libiconv-type=static \
221241
"--with-gmp=$libgmp_prefix" \
@@ -231,6 +251,8 @@ function build_gdb() {
231251
return 1
232252
fi
233253

254+
>&2 fancy_title "Finished building gdb for $target_arch"
255+
234256
popd > /dev/null
235257
}
236258

src/download_packages.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#!/bin/bash
22

3+
# Include utils library
4+
script_dir=$(dirname "$0")
5+
. "$script_dir/utils.sh"
6+
37
# List of package URLs to download
48
PACKAGE_URLS=(
59
"https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.17.tar.gz"
@@ -181,6 +185,8 @@ function download_gdb_packages() {
181185
# Run downloads in parallel
182186
download_pids=()
183187

188+
fancy_title "Starting download of GDB packages"
189+
184190
for url in "${PACKAGE_URLS[@]}"; do
185191
package_dir=$(package_url_to_dir "$url")
186192
download_and_extract_package "$url" "$package_dir" &
@@ -195,6 +201,8 @@ function download_gdb_packages() {
195201
fi
196202
done
197203

204+
fancy_title "Finished downloading GDB packages"
205+
198206
popd
199207
}
200208

src/patch_gdb.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#!/bin/bash
22

3+
# Include utils library
4+
script_dir=$(dirname "$0")
5+
. "$script_dir/utils.sh"
6+
37
function apply_patch() {
48
# Apply a patch to a directory.
59
#
@@ -41,11 +45,13 @@ function main() {
4145
exit 1
4246
fi
4347

48+
fancy_title "Applying GDB patch"
4449
apply_patch "$1" "$2"
4550
if [[ $? -ne 0 ]]; then
4651
>&2 echo "Error: failed to apply GDB patch"
4752
exit 1
4853
fi
54+
fancy_title "Finished applying GDB patch"
4955
}
5056

5157
main "$@"

src/utils.sh

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/bin/bash
2+
3+
GREEN="\033[0;32m"
4+
BOLD="\033[1m"
5+
RESET="\033[0m"
6+
7+
function print_centered() {
8+
# Print a string centered in the terminal.
9+
#
10+
# Parameters:
11+
# $1: string
12+
# $2: line width
13+
#
14+
# Returns:
15+
# 0: success
16+
17+
local string="$1"
18+
local length=${#string}
19+
20+
printf "%*s\n" $((($2 + length) / 2)) "$string"
21+
}
22+
23+
function fancy_title() {
24+
# Print a fancy title.
25+
# The title is centered and surrounded by a line of dashes.
26+
#
27+
# Parameters:
28+
# $1: title
29+
#
30+
# Returns:
31+
# 0: success
32+
33+
local title="$1"
34+
local length=80
35+
local maximum_title_length=60
36+
37+
# Set color to green and bold
38+
tput setaf 2
39+
tput bold
40+
41+
printf "%${length}s\n" | tr ' ' -
42+
43+
# Split the title into words and print them centered
44+
IFS=' ' read -r -a words <<< "$title"
45+
46+
line=""
47+
for word in "${words[@]}"; do
48+
if [[ ${#line} -eq 0 ]]; then
49+
line="$word"
50+
elif [[ $(( ${#line} + ${#word} + 1 )) -gt $maximum_title_length ]]; then
51+
print_centered "$line" "$length"
52+
line="$word"
53+
else
54+
line="$line $word"
55+
fi
56+
done
57+
58+
# Print the last line
59+
if [[ ${#line} -gt 0 ]]; then
60+
print_centered "$line" "$length"
61+
fi
62+
63+
printf "%${length}s\n" | tr ' ' -
64+
65+
# Reset color and style
66+
tput sgr0
67+
}

0 commit comments

Comments
 (0)