Merge pull request #25 from guyush1/allow-build-with-and-without-python
build: Allow building gdb with and without python
This commit is contained in:
commit
f7e97cac7f
3
.github/workflows/pr-pipeline.yaml
vendored
3
.github/workflows/pr-pipeline.yaml
vendored
@ -9,6 +9,7 @@ jobs:
|
|||||||
build:
|
build:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
|
build_type: ["build", "build-with-python"]
|
||||||
architecture: ["x86_64", "arm", "aarch64", "powerpc", "mips", "mipsel"]
|
architecture: ["x86_64", "arm", "aarch64", "powerpc", "mips", "mipsel"]
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@ -21,4 +22,4 @@ jobs:
|
|||||||
run: sudo apt-get install -y wget
|
run: sudo apt-get install -y wget
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: make build-${{ matrix.architecture }} -j$((`nproc`+1))
|
run: make ${{ matrix.build_type }}-${{ matrix.architecture }} -j$((`nproc`+1))
|
||||||
|
39
Makefile
39
Makefile
@ -1,17 +1,24 @@
|
|||||||
ARCHS := x86_64 arm aarch64 powerpc mips mipsel
|
ARCHS := x86_64 arm aarch64 powerpc mips mipsel
|
||||||
|
|
||||||
TARGETS := $(addprefix build-, $(ARCHS))
|
TARGETS := $(addprefix build-, $(ARCHS))
|
||||||
|
PYTHON_TARGETS := $(addprefix build-with-python-, $(ARCHS))
|
||||||
|
ALL_TARGETS := $(TARGETS) $(PYTHON_TARGETS)
|
||||||
|
|
||||||
PACK_TARGETS := $(addprefix pack-, $(ARCHS))
|
PACK_TARGETS := $(addprefix pack-, $(ARCHS))
|
||||||
|
PYTHON_PACK_TARGETS := $(addprefix pack-with-python-, $(ARCHS))
|
||||||
|
ALL_PACK_TARGETS := $(PACK_TARGETS) $(PYTHON_PACK_TARGETS)
|
||||||
|
|
||||||
SUBMODULE_PACKAGES := $(wildcard src/submodule_packages/*)
|
SUBMODULE_PACKAGES := $(wildcard src/submodule_packages/*)
|
||||||
BUILD_PACKAGES_DIR := "build/packages"
|
BUILD_PACKAGES_DIR := "build/packages"
|
||||||
|
|
||||||
.PHONY: clean help download_packages build build-docker-image $(TARGETS) $(PACK_TARGETS)
|
.PHONY: clean help download_packages build build-docker-image $(ALL_TARGETS) $(ALL_PACK_TARGETS)
|
||||||
|
|
||||||
help:
|
help:
|
||||||
@echo "Usage:"
|
@echo "Usage:"
|
||||||
@echo " make build"
|
@echo " make build"
|
||||||
@echo ""
|
@echo ""
|
||||||
|
|
||||||
@for target in $(TARGETS); do \
|
@for target in $(ALL_TARGETS); do \
|
||||||
echo " $$target"; \
|
echo " $$target"; \
|
||||||
done
|
done
|
||||||
|
|
||||||
@ -20,7 +27,7 @@ help:
|
|||||||
|
|
||||||
build/build-docker-image.stamp: Dockerfile
|
build/build-docker-image.stamp: Dockerfile
|
||||||
mkdir -p build
|
mkdir -p build
|
||||||
docker build -t gdb-static .
|
docker buildx build --tag gdb-static .
|
||||||
touch build/build-docker-image.stamp
|
touch build/build-docker-image.stamp
|
||||||
|
|
||||||
build-docker-image: build/build-docker-image.stamp
|
build-docker-image: build/build-docker-image.stamp
|
||||||
@ -40,19 +47,31 @@ symlink-git-packages: build/symlink-git-packages.stamp
|
|||||||
|
|
||||||
download-packages: build/download-packages.stamp
|
download-packages: build/download-packages.stamp
|
||||||
|
|
||||||
build: $(TARGETS)
|
build: $(ALL_TARGETS)
|
||||||
|
|
||||||
$(TARGETS): build-%: symlink-git-packages download-packages build-docker-image
|
$(TARGETS): build-%:
|
||||||
|
@$(MAKE) _build-$*
|
||||||
|
|
||||||
|
$(PYTHON_TARGETS): build-with-python-%:
|
||||||
|
@WITH_PYTHON="--with-python" $(MAKE) _build-$*
|
||||||
|
|
||||||
|
_build-%: symlink-git-packages download-packages build-docker-image
|
||||||
mkdir -p build
|
mkdir -p build
|
||||||
docker run --user $(shell id -u):$(shell id -g) \
|
docker run --user $(shell id -u):$(shell id -g) \
|
||||||
--rm --volume .:/app/gdb gdb-static env TERM=xterm-256color \
|
--rm --volume .:/app/gdb gdb-static env TERM=xterm-256color \
|
||||||
/app/gdb/src/compilation/build.sh $* /app/gdb/build/ /app/gdb/src
|
/app/gdb/src/compilation/build.sh $* /app/gdb/build/ /app/gdb/src $(WITH_PYTHON)
|
||||||
|
|
||||||
pack: $(PACK_TARGETS)
|
pack: $(ALL_PACK_TARGETS)
|
||||||
|
|
||||||
$(PACK_TARGETS): pack-%: build-%
|
$(PACK_TARGETS): pack-%:
|
||||||
if [ ! -f "build/artifacts/gdb-static-$*.tar.gz" ]; then \
|
@$(MAKE) _pack-$*
|
||||||
tar -czf "build/artifacts/gdb-static-$*.tar.gz" -C "build/artifacts/$*" .; \
|
|
||||||
|
$(PYTHON_PACK_TARGETS): pack-with-python-%:
|
||||||
|
@TAR_EXT="with-python-" ARTIFACT_EXT="_with_python" $(MAKE) _pack-$*
|
||||||
|
|
||||||
|
_pack-%: build-%
|
||||||
|
if [ ! -f "build/artifacts/gdb-static-$(TAR_EXT)$*.tar.gz" ]; then \
|
||||||
|
tar -czf "build/artifacts/gdb-static-$(TAR_EXT)$*.tar.gz" -C "build/artifacts/$*$(ARTIFACT_EXT)" .; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
clean-git-packages:
|
clean-git-packages:
|
||||||
|
@ -335,6 +335,7 @@ function build_gdb() {
|
|||||||
# $3: libiconv prefix
|
# $3: libiconv prefix
|
||||||
# $4: libgmp prefix
|
# $4: libgmp prefix
|
||||||
# $5: libmpfr prefix
|
# $5: libmpfr prefix
|
||||||
|
# $6: whether to build with python or not
|
||||||
#
|
#
|
||||||
# Echoes:
|
# Echoes:
|
||||||
# The gdb build directory
|
# The gdb build directory
|
||||||
@ -348,7 +349,15 @@ function build_gdb() {
|
|||||||
local libiconv_prefix="$3"
|
local libiconv_prefix="$3"
|
||||||
local libgmp_prefix="$4"
|
local libgmp_prefix="$4"
|
||||||
local libmpfr_prefix="$5"
|
local libmpfr_prefix="$5"
|
||||||
local gdb_build_dir="$(realpath "$gdb_dir/build-$target_arch")"
|
local with_python="$6"
|
||||||
|
|
||||||
|
if [[ "$with_python" == "yes" ]]; then
|
||||||
|
local python_flag="--with-python=/app/gdb/build/packages/cpython-static/build-$target_arch/bin/python3-config"
|
||||||
|
local gdb_build_dir="$(realpath "$gdb_dir/build-${target_arch}_with_python")"
|
||||||
|
else
|
||||||
|
local python_flag="--without-python"
|
||||||
|
local gdb_build_dir="$(realpath "$gdb_dir/build-${target_arch}")"
|
||||||
|
fi
|
||||||
|
|
||||||
echo "$gdb_build_dir"
|
echo "$gdb_build_dir"
|
||||||
mkdir -p "$gdb_build_dir"
|
mkdir -p "$gdb_build_dir"
|
||||||
@ -363,7 +372,7 @@ function build_gdb() {
|
|||||||
>&2 fancy_title "Building gdb for $target_arch"
|
>&2 fancy_title "Building gdb for $target_arch"
|
||||||
|
|
||||||
../configure -C --enable-static --with-static-standard-libraries --disable-inprocess-agent \
|
../configure -C --enable-static --with-static-standard-libraries --disable-inprocess-agent \
|
||||||
--enable-tui --with-python=/app/gdb/build/packages/cpython-static/build-$target_arch/bin/python3-config \
|
--enable-tui "$python_flag" \
|
||||||
"--with-libiconv-prefix=$libiconv_prefix" --with-libiconv-type=static \
|
"--with-libiconv-prefix=$libiconv_prefix" --with-libiconv-type=static \
|
||||||
"--with-gmp=$libgmp_prefix" \
|
"--with-gmp=$libgmp_prefix" \
|
||||||
"--with-mpfr=$libmpfr_prefix" \
|
"--with-mpfr=$libmpfr_prefix" \
|
||||||
@ -390,6 +399,7 @@ function install_gdb() {
|
|||||||
# $1: gdb build directory
|
# $1: gdb build directory
|
||||||
# $2: artifacts directory
|
# $2: artifacts directory
|
||||||
# $3: target architecture
|
# $3: target architecture
|
||||||
|
# $4: whether gdb was built with or without python
|
||||||
#
|
#
|
||||||
# Returns:
|
# Returns:
|
||||||
# 0: success
|
# 0: success
|
||||||
@ -398,15 +408,22 @@ function install_gdb() {
|
|||||||
local gdb_build_dir="$1"
|
local gdb_build_dir="$1"
|
||||||
local artifacts_dir="$2"
|
local artifacts_dir="$2"
|
||||||
local target_arch="$3"
|
local target_arch="$3"
|
||||||
|
local with_python="$4"
|
||||||
|
|
||||||
if [[ -d "$artifacts_dir/$target_arch" && -n "$(ls -A "$artifacts_dir/$target_arch")" ]]; then
|
if [[ "$with_python" == "yes" ]]; then
|
||||||
|
local artifacts_location="$artifacts_dir/${target_arch}_with_python"
|
||||||
|
else
|
||||||
|
local artifacts_location="$artifacts_dir/${target_arch}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -d "$artifacts_location" && -n "$(ls -A "$artifacts_location")" ]]; then
|
||||||
>&2 echo "Skipping install: gdb already installed for $target_arch"
|
>&2 echo "Skipping install: gdb already installed for $target_arch"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
temp_artifacts_dir="$(mktemp -d)"
|
temp_artifacts_dir="$(mktemp -d)"
|
||||||
|
|
||||||
mkdir -p "$artifacts_dir/$target_arch"
|
mkdir -p "$artifacts_location"
|
||||||
|
|
||||||
make -C "$gdb_build_dir" install "DESTDIR=$temp_artifacts_dir" 1>&2
|
make -C "$gdb_build_dir" install "DESTDIR=$temp_artifacts_dir" 1>&2
|
||||||
if [[ $? -ne 0 ]]; then
|
if [[ $? -ne 0 ]]; then
|
||||||
@ -415,7 +432,7 @@ function install_gdb() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
while read file; do
|
while read file; do
|
||||||
cp "$file" "$artifacts_dir/$target_arch/"
|
cp "$file" "$artifacts_location/"
|
||||||
done < <(find "$temp_artifacts_dir/usr/local/bin" -type f -executable)
|
done < <(find "$temp_artifacts_dir/usr/local/bin" -type f -executable)
|
||||||
|
|
||||||
rm -rf "$temp_artifacts_dir"
|
rm -rf "$temp_artifacts_dir"
|
||||||
@ -429,8 +446,9 @@ function build_and_install_gdb() {
|
|||||||
# $2: libiconv prefix
|
# $2: libiconv prefix
|
||||||
# $3: libgmp prefix
|
# $3: libgmp prefix
|
||||||
# $4: libmpfr prefix
|
# $4: libmpfr prefix
|
||||||
# $5: install directory
|
# $5: whether to build with python or not
|
||||||
# $6: target architecture
|
# $6: install directory
|
||||||
|
# $7: target architecture
|
||||||
#
|
#
|
||||||
# Returns:
|
# Returns:
|
||||||
# 0: success
|
# 0: success
|
||||||
@ -440,15 +458,16 @@ function build_and_install_gdb() {
|
|||||||
local libiconv_prefix="$2"
|
local libiconv_prefix="$2"
|
||||||
local libgmp_prefix="$3"
|
local libgmp_prefix="$3"
|
||||||
local libmpfr_prefix="$4"
|
local libmpfr_prefix="$4"
|
||||||
local artifacts_dir="$5"
|
local with_python="$5"
|
||||||
local target_arch="$6"
|
local artifacts_dir="$6"
|
||||||
|
local target_arch="$7"
|
||||||
|
|
||||||
gdb_build_dir="$(build_gdb "$gdb_dir" "$target_arch" "$libiconv_prefix" "$libgmp_prefix" "$libmpfr_prefix")"
|
gdb_build_dir="$(build_gdb "$gdb_dir" "$target_arch" "$libiconv_prefix" "$libgmp_prefix" "$libmpfr_prefix" "$with_python")"
|
||||||
if [[ $? -ne 0 ]]; then
|
if [[ $? -ne 0 ]]; then
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
install_gdb "$gdb_build_dir" "$artifacts_dir" "$target_arch"
|
install_gdb "$gdb_build_dir" "$artifacts_dir" "$target_arch" "$with_python"
|
||||||
if [[ $? -ne 0 ]]; then
|
if [[ $? -ne 0 ]]; then
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
@ -461,10 +480,12 @@ function build_gdb_with_dependencies() {
|
|||||||
# $1: target architecture
|
# $1: target architecture
|
||||||
# $2: build directory
|
# $2: build directory
|
||||||
# $3: src directory
|
# $3: src directory
|
||||||
|
# $4: whether to build gdb with python or not
|
||||||
|
|
||||||
local target_arch="$1"
|
local target_arch="$1"
|
||||||
local build_dir="$2"
|
local build_dir="$2"
|
||||||
local source_dir="$3"
|
local source_dir="$3"
|
||||||
|
local with_python="$4"
|
||||||
local packages_dir="$build_dir/packages"
|
local packages_dir="$build_dir/packages"
|
||||||
local artifacts_dir="$build_dir/artifacts"
|
local artifacts_dir="$build_dir/artifacts"
|
||||||
|
|
||||||
@ -496,15 +517,18 @@ function build_gdb_with_dependencies() {
|
|||||||
fi
|
fi
|
||||||
set_ncurses_link_variables "$ncursesw_build_dir"
|
set_ncurses_link_variables "$ncursesw_build_dir"
|
||||||
|
|
||||||
python_build_dir="$(build_python "$packages_dir/cpython-static" "$target_arch")"
|
if [[ "$with_python" == "yes" ]]; then
|
||||||
|
build_python "$packages_dir/cpython-static" "$target_arch"
|
||||||
if [[ $? -ne 0 ]]; then
|
if [[ $? -ne 0 ]]; then
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
build_and_install_gdb "$packages_dir/binutils-gdb" \
|
build_and_install_gdb "$packages_dir/binutils-gdb" \
|
||||||
"$iconv_build_dir/lib/.libs/" \
|
"$iconv_build_dir/lib/.libs/" \
|
||||||
"$gmp_build_dir/.libs/" \
|
"$gmp_build_dir/.libs/" \
|
||||||
"$mpfr_build_dir/src/.libs/" \
|
"$mpfr_build_dir/src/.libs/" \
|
||||||
|
"$with_python" \
|
||||||
"$artifacts_dir" \
|
"$artifacts_dir" \
|
||||||
"$target_arch"
|
"$target_arch"
|
||||||
if [[ $? -ne 0 ]]; then
|
if [[ $? -ne 0 ]]; then
|
||||||
@ -513,12 +537,17 @@ function build_gdb_with_dependencies() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function main() {
|
function main() {
|
||||||
if [[ $# -ne 3 ]]; then
|
if [[ $# -lt 3 ]]; then
|
||||||
>&2 echo "Usage: $0 <target_arch> <build_dir> <src_dir>"
|
>&2 echo "Usage: $0 <target_arch> <build_dir> <src_dir> [--with-python]"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
build_gdb_with_dependencies "$1" "$2" "$3"
|
local with_python="no"
|
||||||
|
if [[ "$4" == "--with-python" ]]; then
|
||||||
|
with_python="yes"
|
||||||
|
fi
|
||||||
|
|
||||||
|
build_gdb_with_dependencies "$1" "$2" "$3" "$with_python"
|
||||||
if [[ $? -ne 0 ]]; then
|
if [[ $? -ne 0 ]]; then
|
||||||
>&2 echo "Error: failed to build gdb with dependencies"
|
>&2 echo "Error: failed to build gdb with dependencies"
|
||||||
exit 1
|
exit 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user