From 24542579463d3f3a66535c4861c72eedb0cefda3 Mon Sep 17 00:00:00 2001 From: Roddy Rappaport Date: Thu, 5 Dec 2024 23:51:36 +0200 Subject: [PATCH] Add submodules to build/packages Using symlinks the submodules are added to appear just like any downloaded unpacked tar. Also added a Makefile clean rule to clean the submodules, which includes Reseting the submodules to the origin branch state, including ignored files. --- Makefile | 23 ++++++++++++++++------ src/{ => compilation}/build.sh | 0 src/{ => compilation}/download_packages.sh | 0 src/{ => compilation}/utils.sh | 0 src/submodule_packages/cpython-static | 2 +- 5 files changed, 18 insertions(+), 7 deletions(-) rename src/{ => compilation}/build.sh (100%) rename src/{ => compilation}/download_packages.sh (100%) rename src/{ => compilation}/utils.sh (100%) diff --git a/Makefile b/Makefile index cc2ec48..1a8d376 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,8 @@ ARCHS := x86_64 arm aarch64 powerpc mips mipsel TARGETS := $(addprefix build-, $(ARCHS)) PACK_TARGETS := $(addprefix pack-, $(ARCHS)) +SUBMODULE_PACKAGES := $(wildcard src/submodule_packages/*) +BUILD_PACKAGES_DIR := "build/packages" .PHONY: clean help download_packages build build-docker-image $(TARGETS) $(PACK_TARGETS) @@ -23,22 +25,28 @@ build/build-docker-image.stamp: Dockerfile build-docker-image: build/build-docker-image.stamp -build/download-packages.stamp: build/build-docker-image.stamp src/download_packages.sh - mkdir -p build/packages +build/download-packages.stamp: build/build-docker-image.stamp src/compilation/download_packages.sh + mkdir -p $(BUILD_PACKAGES_DIR) docker run --user $(shell id -u):$(shell id -g) \ --rm --volume .:/app/gdb gdb-static env TERM=xterm-256color \ - /app/gdb/src/download_packages.sh /app/gdb/build/packages + /app/gdb/src/compilation/download_packages.sh /app/gdb/$(BUILD_PACKAGES_DIR)/ touch build/download-packages.stamp +build/symlink-git-packages.stamp: $(SUBMODULE_PACKAGES) + mkdir -p $(BUILD_PACKAGES_DIR) + ln -sf $(addprefix /app/gdb/, $(SUBMODULE_PACKAGES)) $(BUILD_PACKAGES_DIR)/ + +symlink-git-packages: build/symlink-git-packages.stamp + download-packages: build/download-packages.stamp build: $(TARGETS) -$(TARGETS): build-%: download-packages build-docker-image +$(TARGETS): build-%: symlink-git-packages download-packages build-docker-image mkdir -p build docker run --user $(shell id -u):$(shell id -g) \ --rm --volume .:/app/gdb gdb-static env TERM=xterm-256color \ - /app/gdb/src/build.sh $* /app/gdb/build/ /app/gdb/src + /app/gdb/src/compilation/build.sh $* /app/gdb/build/ /app/gdb/src pack: $(PACK_TARGETS) @@ -47,7 +55,10 @@ $(PACK_TARGETS): pack-%: build-% tar -czf "build/artifacts/gdb-static-$*.tar.gz" -C "build/artifacts/$*" .; \ fi -clean: +clean-git-packages: + git submodule foreach '[[ ! "$$sm_path" == src/submodule_packages/* ]] || git clean -xffd' + +clean: clean-git-packages rm -rf build # Kill and remove all containers of image gdb-static docker ps -a | grep -P "^[a-f0-9]+\s+gdb-static\s+" | awk '{print $$1}' | xargs docker rm -f 2>/dev/null || true diff --git a/src/build.sh b/src/compilation/build.sh similarity index 100% rename from src/build.sh rename to src/compilation/build.sh diff --git a/src/download_packages.sh b/src/compilation/download_packages.sh similarity index 100% rename from src/download_packages.sh rename to src/compilation/download_packages.sh diff --git a/src/utils.sh b/src/compilation/utils.sh similarity index 100% rename from src/utils.sh rename to src/compilation/utils.sh diff --git a/src/submodule_packages/cpython-static b/src/submodule_packages/cpython-static index e201d7d..d734d02 160000 --- a/src/submodule_packages/cpython-static +++ b/src/submodule_packages/cpython-static @@ -1 +1 @@ -Subproject commit e201d7df36871dad439bd5162123f080397abb38 +Subproject commit d734d02f4ce9ca77aa6708bf5bd16429e147e9ef