2020-07-15 20:13:51 +00:00
|
|
|
#!/bin/bash
|
2021-04-19 11:34:06 +00:00
|
|
|
if [ -z "$GITHUB_WORKSPACE" ];then
|
|
|
|
echo "GITHUB_WORKSPACE environemnt variable not set!"
|
|
|
|
exit 1
|
|
|
|
fi
|
2020-07-15 20:13:51 +00:00
|
|
|
if [ "$#" -ne 1 ];then
|
|
|
|
echo "Usage: ${0} [x86|x86_64|armhf|aarch64]"
|
|
|
|
echo "Example: ${0} x86_64"
|
|
|
|
exit 1
|
|
|
|
fi
|
2021-04-19 11:34:06 +00:00
|
|
|
set -e
|
|
|
|
set -o pipefail
|
|
|
|
set -x
|
2020-07-15 20:13:51 +00:00
|
|
|
source $GITHUB_WORKSPACE/build/lib.sh
|
|
|
|
init_lib $1
|
|
|
|
|
|
|
|
build_gdb() {
|
|
|
|
fetch "$GIT_BINUTILS_GDB" "${BUILD_DIRECTORY}/binutils-gdb" git
|
|
|
|
cd "${BUILD_DIRECTORY}/binutils-gdb/" || { echo "Cannot cd to ${BUILD_DIRECTORY}/binutils-gdb/"; exit 1; }
|
2020-07-30 07:15:09 +00:00
|
|
|
git clean -fdx
|
2022-10-05 10:21:05 +00:00
|
|
|
git checkout gdb-12.1-release
|
2020-07-30 07:15:09 +00:00
|
|
|
CMD="CFLAGS=\"${GCC_OPTS}\" "
|
|
|
|
CMD+="CXXFLAGS=\"${GXX_OPTS}\" "
|
2020-11-04 11:41:52 +00:00
|
|
|
CMD+="LDFLAGS=\"-static\" "
|
|
|
|
if [ "$CURRENT_ARCH" != "x86_64" ];then
|
2020-07-30 07:15:09 +00:00
|
|
|
CMD+="CC_FOR_BUILD=\"/x86_64-linux-musl-cross/bin/x86_64-linux-musl-gcc\" "
|
|
|
|
CMD+="CPP_FOR_BUILD=\"/x86_64-linux-musl-cross/bin/x86_64-linux-musl-g++\" "
|
|
|
|
fi
|
2020-11-04 11:41:52 +00:00
|
|
|
CMD+="${BUILD_DIRECTORY}/binutils-gdb/configure --build=x86_64-linux-musl --host=$(get_host_triple) "
|
2021-04-19 11:34:06 +00:00
|
|
|
CMD+="--disable-shared --enable-static --enable-gdbserver --disable-nls --disable-inprocess-agent"
|
2020-07-30 07:15:09 +00:00
|
|
|
|
2020-11-04 11:41:52 +00:00
|
|
|
mkdir -p "${BUILD_DIRECTORY}/gdb_build"
|
|
|
|
cd "${BUILD_DIRECTORY}/gdb_build/"
|
|
|
|
eval "$CMD"
|
2020-07-15 20:13:51 +00:00
|
|
|
make -j4
|
|
|
|
|
2020-11-04 11:41:52 +00:00
|
|
|
strip "${BUILD_DIRECTORY}/gdb_build/gdb/gdb" "${BUILD_DIRECTORY}/gdb_build/gdbserver/gdbserver"
|
2020-07-15 20:13:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
main() {
|
|
|
|
build_gdb
|
2020-11-04 11:41:52 +00:00
|
|
|
if [ ! -f "${BUILD_DIRECTORY}/gdb_build/gdb/gdb" ] || \
|
|
|
|
[ ! -f "${BUILD_DIRECTORY}/gdb_build/gdbserver/gdbserver" ];then
|
2020-07-15 20:13:51 +00:00
|
|
|
echo "[-] Building GDB ${CURRENT_ARCH} failed!"
|
|
|
|
exit 1
|
|
|
|
fi
|
2020-11-04 11:41:52 +00:00
|
|
|
GDB_VERSION=$(get_version "${BUILD_DIRECTORY}/gdb_build/gdb/gdb --version |head -n1 |awk '{print \$4}'")
|
|
|
|
GDBSERVER_VERSION=$(get_version "${BUILD_DIRECTORY}/gdb_build/gdbserver/gdbserver --version |head -n1 |awk '{print \$4}'")
|
2021-04-19 14:03:23 +00:00
|
|
|
version_number=$(echo "$GDB_VERSION" | cut -d"-" -f2)
|
2020-11-04 11:41:52 +00:00
|
|
|
cp "${BUILD_DIRECTORY}/gdb_build/gdb/gdb" "${OUTPUT_DIRECTORY}/gdb${GDB_VERSION}"
|
|
|
|
cp "${BUILD_DIRECTORY}/gdb_build/gdbserver/gdbserver" "${OUTPUT_DIRECTORY}/gdbserver${GDBSERVER_VERSION}"
|
2020-07-15 20:13:51 +00:00
|
|
|
echo "[+] Finished building GDB ${CURRENT_ARCH}"
|
|
|
|
|
2023-05-22 06:44:33 +00:00
|
|
|
echo "PACKAGED_NAME=gdb${GDB_VERSION}" >> $GITHUB_OUTPUT
|
|
|
|
echo "PACKAGED_NAME_PATH=/output/*" >> $GITHUB_OUTPUT
|
|
|
|
echo "PACKAGED_VERSION=${version_number}" >> $GITHUB_OUTPUT
|
2020-07-15 20:13:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
main
|