From 561741517f05d8c1bfc92b4025c1cba46a236eb7 Mon Sep 17 00:00:00 2001 From: Dmitry Makovey Date: Thu, 28 Aug 2025 17:24:19 -0700 Subject: [PATCH 1/5] 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 8b9a7e7804..8b089e9e30 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 070e88b486..528153a644 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/5] 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 528153a644..4c631d90f9 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/5] Apply suggestion from @pks-gitlab --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 4c631d90f9..1720c24e20 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 From 105f0a0aa423ac7399b61f9f46b19d4d82063046 Mon Sep 17 00:00:00 2001 From: Dmitry Makovey Date: Thu, 23 Oct 2025 14:44:15 -0700 Subject: [PATCH 4/5] Allow Meson use in build mode Add missing settings for Meson to be able to build software when build mode is on --- Makefile | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 1720c24e20..4803c12ea2 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,9 @@ BUILD_MODE ?= development # 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 # matter much though. +ifeq ($(BUILD_MODE),development) unexport $(filter-out GIT_PREFIX,$(shell git rev-parse --local-env-vars)) +endif # Call `make V=1` in order to print commands verbosely. ifeq ($(V),1) @@ -173,7 +175,8 @@ GIT_VERSION_PREV ?= d5518d52b23dc4d7d001b0725c5faab4063a3598 # GIT_VERSION_x_xx defines versions for each instance of bundled Git we ship. When a new # major version is added, be sure to update GIT_PACKED_EXECUTABLES, the *-bundled-git targets, # and add new targets under the "# These targets build specific releases of Git." section. -GIT_VERSION_2_50 ?= v2.50.1.gl1 +# GIT_VERSION_2_50 ?= v2.50.1.gl1 +GIT_VERSION_2_50 ?= 828736d9bd3aee91ed98ec4024eb09ad25aefceb # # OVERRIDE_GIT_VERSION allows you to specify a custom semver value to be reported by the # `git --version` command. This affects bundled and non-bundled Git, and can be used whenever @@ -224,6 +227,11 @@ ifeq ($(origin GIT_BUILD_OPTIONS),undefined) GIT_MESON_BUILD_OPTIONS += -Dpython=disabled GIT_MESON_BUILD_OPTIONS += -Dtests=false GIT_MESON_BUILD_OPTIONS += -Dwrap_mode=nofallback + GIT_MESON_BUILD_OPTIONS += -Dc_args="${CFLAGS}" + GIT_MESON_BUILD_OPTIONS += -Dcpp_args="${CXXFLAGS}" + GIT_MESON_BUILD_OPTIONS += -Dc_link_args="${LDFLAGS}" + GIT_MESON_BUILD_OPTIONS += -Dcpp_link_args="${LDFLAGS}" + # Use non-collision-detecting SHA1 implementation in non-cryptographic scenarios # to improve performance. This is only enabled for Linux platforms. @@ -778,7 +786,8 @@ ${DEPENDENCY_DIR}/git-filter-repo.version: dependency-version | ${DEPENDENCY_DIR # 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-v2.50/Makefile: GIT_VERSION_REF=${GIT_VERSION_2_50} +${DEPENDENCY_DIR}/git-distribution/Makefile: GIT_VERSION_REF=${GIT_VERSION_MASTER} ${DEPENDENCY_DIR}/git-%/Makefile: ${DEPENDENCY_DIR}/git-%.version @ # In builder mode we don't want to depend on git to build git -- GitLab From 01c5e0a0a8db55ce47463acccd439902b8e4ccdc Mon Sep 17 00:00:00 2001 From: Dmitry Makovey Date: Thu, 13 Nov 2025 10:57:47 -0800 Subject: [PATCH 5/5] Remove development mode entirely --- .gitlab-ci.yml | 1 - Makefile | 28 +--------------------------- 2 files changed, 1 insertion(+), 28 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8b089e9e30..8b9a7e7804 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -269,7 +269,6 @@ 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 4803c12ea2..9864d2bbc4 100644 --- a/Makefile +++ b/Makefile @@ -4,19 +4,10 @@ # 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 # matter much though. -ifeq ($(BUILD_MODE),development) -unexport $(filter-out GIT_PREFIX,$(shell git rev-parse --local-env-vars)) -endif # Call `make V=1` in order to print commands verbosely. ifeq ($(V),1) @@ -50,11 +41,7 @@ INSTALL_DEST_DIR := ${DESTDIR}${bindir} GIT_PREFIX ?= ${PREFIX} # Tools -ifeq ($(BUILD_MODE),build) - GIT := ${BUILD_DIR}/bin/gitaly-git-v2.50 -else - GIT := $(shell command -v git) -endif +GIT := ${BUILD_DIR}/bin/gitaly-git-v2.50 GOIMPORTS := ${TOOLS_DIR}/goimports GOFUMPT := ${TOOLS_DIR}/gofumpt GOLANGCI_LINT := ${TOOLS_DIR}/golangci-lint @@ -716,10 +703,8 @@ ${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 "$(