From 561741517f05d8c1bfc92b4025c1cba46a236eb7 Mon Sep 17 00:00:00 2001 From: Dmitry Makovey Date: Thu, 28 Aug 2025 17:24:19 -0700 Subject: [PATCH 1/3] Add builder mode to Makefile Added builder mode to allow building under more enclosed environments where external git is absent, reducing number of external dependencies required for build Add tests both modes: development and build Accommodate v2.50 builds along with master builds --- .gitlab-ci.yml | 1 + Makefile | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8b9a7e78041..8b089e9e30e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -269,6 +269,7 @@ test: - GO_VERSION: !reference [.versions, go_supported] TEST_TARGET: test USE_MESON: YesPlease + BUILD_MODE: [ development, build ] - TEST_TARGET: [ test-with-praefect, diff --git a/Makefile b/Makefile index 070e88b486f..528153a644e 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,12 @@ # directory. -include config.mak +# BUILD_MODE defines whether we're building for redistribution ( "build" ) or +# for development environment "development". Presently "build" mode eliminates +# dependency on host to have "git" installed and utilizes "git" compiled +# within this project +BUILD_MODE =development + # Unexport environment variables which have an effect on Git itself. # We need to keep GIT_PREFIX because it's used to determine where our # self-built Git should be installed into. It's probably not going to @@ -42,7 +48,11 @@ INSTALL_DEST_DIR := ${DESTDIR}${bindir} GIT_PREFIX ?= ${PREFIX} # Tools -GIT := $(shell command -v git) +ifeq ($(BUILD_MODE),build) + GIT := ${BUILD_DIR}/bin/gitaly-git-v2.50 +else + GIT := $(shell command -v git) +endif GOIMPORTS := ${TOOLS_DIR}/goimports GOFUMPT := ${TOOLS_DIR}/gofumpt GOLANGCI_LINT := ${TOOLS_DIR}/golangci-lint @@ -698,6 +708,10 @@ ${DEPENDENCY_DIR}: | ${BUILD_DIR} # These targets build a full Git distribution with the Makefile... ${DEPENDENCY_DIR}/git-distribution/git: ${DEPENDENCY_DIR}/git-distribution/Makefile +ifeq ($(BUILD_MODE),build) + ${Q}env -u PROFILE -u MAKEFLAGS -u GIT_VERSION ${MAKE} -C "${@D}" configure + ${Q}env -u PROFILE -u MAKEFLAGS -u GIT_VERSION bash -c "cd ${@D}; ./configure CFLAGS="${CFLAGS}" CXXFLAGS="${CXXFLAGS}" CPPFLAGS="${CPPFLAGS}" LDFLAGS="${LDFLAGS}" --prefix=${GIT_PREFIX}" +endif ${Q}env -u PROFILE -u MAKEFLAGS -u GIT_VERSION ${MAKE} -C "$( Date: Tue, 21 Oct 2025 15:18:54 -0700 Subject: [PATCH 2/3] Apply 1 suggestion(s) to 1 file(s) Co-authored-by: Patrick Steinhardt --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 528153a644e..4c631d90f99 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ # for development environment "development". Presently "build" mode eliminates # dependency on host to have "git" installed and utilizes "git" compiled # within this project -BUILD_MODE =development +BUILD_MODE ?= development # Unexport environment variables which have an effect on Git itself. # We need to keep GIT_PREFIX because it's used to determine where our -- GitLab From f3fa74e310af50fd5f3a2809d40ed816cafbf414 Mon Sep 17 00:00:00 2001 From: Dmitry Makovey Date: Tue, 21 Oct 2025 15:20:51 -0700 Subject: [PATCH 3/3] Apply suggestion from @pks-gitlab --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 4c631d90f99..1720c24e201 100644 --- a/Makefile +++ b/Makefile @@ -777,8 +777,8 @@ ${DEPENDENCY_DIR}/git-filter-repo.version: dependency-version | ${DEPENDENCY_DIR # otherwise try to rebuild all targets depending on it whenever we build # something else. We thus depend on the Makefile instead. -${DEPENDENCY_DIR}/git-master/Makefile: GIT_VERSION_REF=$(GIT_VERSION_MASTER) -${DEPENDENCY_DIR}/git-2.50/Makefile: GIT_VERSION_REF=$(GIT_VERSION_2_50) +${DEPENDENCY_DIR}/git-master/Makefile: GIT_VERSION_REF=${GIT_VERSION_MASTER} +${DEPENDENCY_DIR}/git-2.50/Makefile: GIT_VERSION_REF=${GIT_VERSION_2_50} ${DEPENDENCY_DIR}/git-%/Makefile: ${DEPENDENCY_DIR}/git-%.version @ # In builder mode we don't want to depend on git to build git -- GitLab