From patchwork Fri Dec 20 19:44:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13917339 Received: from fhigh-b4-smtp.messagingengine.com (fhigh-b4-smtp.messagingengine.com [202.12.124.155]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 513192210C0 for ; Fri, 20 Dec 2024 19:44:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.155 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734723890; cv=none; b=DkObTks5VR3wT/y4tHrW0aThqqcz/QPhOJRrNUlTlR3+qoK1pOuN1gx7h12v1IvZ9d5MWi0CV5Ex/uMKmxvTDQ69rQhlvGiG3dv/NzY2cAHP7Fz0qirAP1/yxhTLKVJZyC9BAJXvK6z4yGVeR9DMhBG+X/26rHNNhSVcmcNpvZM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734723890; c=relaxed/simple; bh=zlz8TQoeinzR6zxpnWEVUk38ytVA47Nwr1b9uG2pkrw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Dc6t9BlV3gWPYqBtDY8G8yRWHeCDRM1ZhQCfXKOXX+lI9g7RKbNrf2USqg3Xav7/AS2cQL9uA51976r7lKoykQb/Qjj9tR9+YSBoav4+CmRWxYTo9NfCrRdPAsf/IB2LIsJiS5GJ3T68ASXFXdr4TZJ1n5qHtt6GLrinfy8msTQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b=K6Hkk8MP; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=yHF4zX0C; arc=none smtp.client-ip=202.12.124.155 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="K6Hkk8MP"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="yHF4zX0C" Received: from phl-compute-07.internal (phl-compute-07.phl.internal [10.202.2.47]) by mailfhigh.stl.internal (Postfix) with ESMTP id 4ACAD25401F0; Fri, 20 Dec 2024 14:44:47 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-07.internal (MEProxy); Fri, 20 Dec 2024 14:44:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc:cc :content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1734723887; x=1734810287; bh=eoP7AntFmEPS9NxDjnc4l6eW2QrwKFZBEtIQFwDAGsg=; b= K6Hkk8MPsnSP5v96YdTKbwQXSRxBd5v6OckGvLDkVIR/dDrCdJrExqHkT8nNpb+E QilMtp+qOaUiM8Fsw1lpf/ZZmWve5rGxQnMcG5sV6C+WNSI70rtCpXOaVUc3x0Yg NZ/YQ3jTBOCOjBj1kCLEYv9UTSNsU8S7+QxAdVTuA05CyzcrQHrrr/qzXdNCvi/I l7uZCGcHlVzDAtYefcWQU6TUshgykzEkJ9tW0WNbnnNSvVMPH262kyV61mCRmnG2 +vuY558o89HzJ/9COOKleJ9EXyacOkCe7unpaDrqs2WjB5OOBdNOPwjdGStujayl O9sExYZ6ZyIndzUHWucMCQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1734723887; x= 1734810287; bh=eoP7AntFmEPS9NxDjnc4l6eW2QrwKFZBEtIQFwDAGsg=; b=y HF4zX0CA/QaSCwOm+vkeAdX988KzePH7FSqOD3Kvt8pSBH6fMwQr+8vll2E4vSjV G+wAsWpd/amFUDiOE+zG/2IZMMU3tnMA2OjSj0mxkLz3lrHGc+VX3FJ5eQxSFZNR Ag3vJABnxoY+y/Kjf4oE6rSM2l09iEW+5eD/PT5x4amzDO4IcugprvBhjJ5nogJh GddYqilZqfBTC7niLpFuh4+C86CZMhRs6ljiLvv3eJ8FXlV2+f8jOkqz/w+ePI2+ E6mjzBh637szKlMrQPwEryi5fsAK/DDvNCNhaxmeLo1iGyliXM6zz4rhLxVOE2qQ ZPI1adT+GDb9mihvjlb+w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddruddtvddguddvhecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecunecujfgurhephfffuf ggtgfgkfhfjgfvvefosehtjeertdertdejnecuhfhrohhmpefrrghtrhhitghkucfuthgv ihhnhhgrrhguthcuoehpshesphhkshdrihhmqeenucggtffrrghtthgvrhhnpeffueeiud ejvdekheeuvdekfeffiedvueelteekudehjeetkeegvddugfdtgfeileenucevlhhushht vghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehpshesphhkshdrihhmpd hnsggprhgtphhtthhopeegpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehgihht shhtvghrsehpohgsohigrdgtohhmpdhrtghpthhtohepshhpvggtthhrrghlsehgohhogh hlvgdrtghomhdprhgtphhtthhopehpvghffhesphgvfhhfrdhnvghtpdhrtghpthhtohep ghhithesvhhgvghrrdhkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 20 Dec 2024 14:44:45 -0500 (EST) Received: by vm-mail (OpenSMTPD) with ESMTPSA id 813d257b (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Fri, 20 Dec 2024 19:42:50 +0000 (UTC) From: Patrick Steinhardt Date: Fri, 20 Dec 2024 20:44:21 +0100 Subject: [PATCH v3 1/6] Makefile: stop including "GIT-VERSION-FILE" in docs Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241220-b4-pks-git-version-via-environment-v3-1-1fd79b52a5fb@pks.im> References: <20241220-b4-pks-git-version-via-environment-v3-0-1fd79b52a5fb@pks.im> In-Reply-To: <20241220-b4-pks-git-version-via-environment-v3-0-1fd79b52a5fb@pks.im> To: git@vger.kernel.org Cc: Junio C Hamano , Kyle Lippincott , Jeff King X-Mailer: b4 0.14.2 We include "GIT-VERSION-FILE" in our docs Makefile, but don't actually use the "GIT_VERSION" variable that it provides. This is a leftover from the conversion to make "GIT-VERSION-GEN" generate version information in-place by substituting placeholders in 4838deab65 (Makefile: refactor GIT-VERSION-GEN to be reusable, 2024-12-06) and subsequent commits, where all usages of the variable were removed. Stop including the file. Signed-off-by: Patrick Steinhardt --- Documentation/Makefile | 7 ------- 1 file changed, 7 deletions(-) diff --git a/Documentation/Makefile b/Documentation/Makefile index 3392e1ce7ebc540784912476847380d9c1775ac8..44c9e9369a11a6a5091079b7221a085b2f08e6cd 100644 --- a/Documentation/Makefile +++ b/Documentation/Makefile @@ -276,13 +276,6 @@ install-pdf: pdf install-html: html '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(DESTDIR)$(htmldir) -../GIT-VERSION-FILE: FORCE - $(QUIET_SUBDIR0)../ $(QUIET_SUBDIR1) GIT-VERSION-FILE - -ifneq ($(filter-out lint-docs clean,$(MAKECMDGOALS)),) --include ../GIT-VERSION-FILE -endif - mergetools_txt = mergetools-diff.txt mergetools-merge.txt # From patchwork Fri Dec 20 19:44:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13917340 Received: from fhigh-b4-smtp.messagingengine.com (fhigh-b4-smtp.messagingengine.com [202.12.124.155]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7F4072210F9 for ; Fri, 20 Dec 2024 19:44:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.155 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734723890; cv=none; b=VBpmmGacbbkF3PKZxl+ngeVtKWRQ64vSNpKUPJPKD5NdCb2Cr7Y4c9UwOW7bQO4XLTqO2BNDz5wzwQaPgpTvbvUU4ezyuGyHKQSIiFGCVMcBGsBrztSWUB488ijfIuTzVR9cLYk3ZF12GoflerP8UfxRQlgnlruGv3Rd+WWQDGg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734723890; c=relaxed/simple; bh=Qt4K0VUeeyaOODSM6n4ifONuJR1IX4ti7oAChoRXGk4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Vxqr7apqyC8u5mMImyM3HsoodShgH4EO9EAhzRvsVAUp9VpWIu3EvYuswUAiaxmC7ueP9iYKZwtxURHZal54ZP/6CxBgnk4Wkfijc/kU9dOTorIda70hZgtFTMKvZmy7m85L2xnFVz/Bu6iWY9cp9MYRMZGfM9oQOE2/K40TmCo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b=yfnMxm35; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=L0AEQg/M; arc=none smtp.client-ip=202.12.124.155 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="yfnMxm35"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="L0AEQg/M" Received: from phl-compute-12.internal (phl-compute-12.phl.internal [10.202.2.52]) by mailfhigh.stl.internal (Postfix) with ESMTP id 8E62025401F1; Fri, 20 Dec 2024 14:44:47 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-12.internal (MEProxy); Fri, 20 Dec 2024 14:44:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc:cc :content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1734723887; x=1734810287; bh=Uc66z8wWX4Y+6Ht83qyKskS1gIvPZQi4go7hBf6Ahzk=; b= yfnMxm35XMP01fHGlVTe5MPgsP5OApXJg/3lJQ8l/APE3dgj/W5ZBWvYkwI9fEIS zNX4GNPA/WZXhZ1KZwDXvKD8tKIM88mVHj+nuGEZ/ZFs+kF2Yz++7WJhMNcTkBJj wLt2tMgn7SXhHMHaXbGrlLQf0o2jvV+5mat3F4srwejFuQyAbE/KMrh2ntxF8Dvp t7ZZHJFVF/UyjglUrsPRPA8ebwZpEphuKH8AnDS13Z+RHq6Rf8qfMiaR8vGKCtve +AMnHIJ9bPsqOxgwibQfCsh4jG/nD7zoAK9M7qyHxtbW+GOE6Jj/JUk+PkFLb38R Sv2yJO3TF+Bsxk1A37UaCA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1734723887; x= 1734810287; bh=Uc66z8wWX4Y+6Ht83qyKskS1gIvPZQi4go7hBf6Ahzk=; b=L 0AEQg/MN57Dl30eF9Z5J2nWC4YI81BxwwW5i9cDnD3Mxjrsu52fONqy/jhY1dmLK oJPYHrgrg45o7TXNfOtCOXt2Cj478HiZZuawT2JcgCrK7HIU1WPjLSHjSeedphgQ tzJCUcI6LB6SyoFpS/xwBeLBPR61p1A+OnocdedOLbZHYvQYdYK8ZpGc7NlCga71 QD56rElb/oTVpjtPuNStPPukr/IK3MWpE0xerWquLU/9R+CiEjC+NLDkj4VuUr9d redExqgO2vrQ7k9abvtOE+ng66Udn8jyZrx42ljQ5sY2vq0VIhcJCoRlANdHF/r9 UmcROdmAivVXCpuS0Swag== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddruddtvddguddvhecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecunecujfgurhephfffuf ggtgfgkfhfjgfvvefosehtjeertdertdejnecuhfhrohhmpefrrghtrhhitghkucfuthgv ihhnhhgrrhguthcuoehpshesphhkshdrihhmqeenucggtffrrghtthgvrhhnpeejhffgte etvedtgfevkeekleeftefgleetjeekkedvvdfgudefhfeklefghfffteenucffohhmrghi nheprhgsrdhinhdptghonhhfrdhinhdprhgtrdhinhenucevlhhushhtvghrufhiiigvpe dtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehpshesphhkshdrihhmpdhnsggprhgtphht thhopeegpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehgihhtshhtvghrsehpoh gsohigrdgtohhmpdhrtghpthhtohepghhithesvhhgvghrrdhkvghrnhgvlhdrohhrghdp rhgtphhtthhopehsphgvtghtrhgrlhesghhoohhglhgvrdgtohhmpdhrtghpthhtohepph gvfhhfsehpvghffhdrnhgvth X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 20 Dec 2024 14:44:46 -0500 (EST) Received: by vm-mail (OpenSMTPD) with ESMTPSA id 64daf08d (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Fri, 20 Dec 2024 19:42:51 +0000 (UTC) From: Patrick Steinhardt Date: Fri, 20 Dec 2024 20:44:22 +0100 Subject: [PATCH v3 2/6] Makefile: drop unneeded indirection for GIT-VERSION-GEN outputs Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241220-b4-pks-git-version-via-environment-v3-2-1fd79b52a5fb@pks.im> References: <20241220-b4-pks-git-version-via-environment-v3-0-1fd79b52a5fb@pks.im> In-Reply-To: <20241220-b4-pks-git-version-via-environment-v3-0-1fd79b52a5fb@pks.im> To: git@vger.kernel.org Cc: Junio C Hamano , Kyle Lippincott , Jeff King X-Mailer: b4 0.14.2 Some of the callsites of GIT-VERSION-GEN generate the target file with a "+" suffix first and then move the file into place when the new contents are different compared to the old contents. This allows us to avoid a needless rebuild by not updating timestamps of the target file when its contents will remain unchanged anyway. In fact though, this exact logic is already handled in GIT-VERSION-GEN, so doing this manually is pointless. This is a leftover from an earlier version of 4838deab65 (Makefile: refactor GIT-VERSION-GEN to be reusable, 2024-12-06), where the script didn't handle that logic for us. Drop the needless indirection. Signed-off-by: Patrick Steinhardt --- Documentation/Makefile | 6 ++---- Makefile | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/Documentation/Makefile b/Documentation/Makefile index 44c9e9369a11a6a5091079b7221a085b2f08e6cd..1a398d0dc359671d461fceb7a1636268a51411da 100644 --- a/Documentation/Makefile +++ b/Documentation/Makefile @@ -211,12 +211,10 @@ XMLTO_EXTRA += --skip-validation XMLTO_EXTRA += -x manpage.xsl asciidoctor-extensions.rb: asciidoctor-extensions.rb.in FORCE - $(QUIET_GEN)GIT_USER_AGENT="$(GIT_USER_AGENT)" $(SHELL_PATH) ../GIT-VERSION-GEN "$(shell pwd)/.." $< $@+ - @if cmp $@+ $@ >/dev/null 2>&1; then $(RM) $@+; else mv $@+ $@; fi + $(QUIET_GEN)GIT_USER_AGENT="$(GIT_USER_AGENT)" $(SHELL_PATH) ../GIT-VERSION-GEN "$(shell pwd)/.." $< $@ else asciidoc.conf: asciidoc.conf.in FORCE - $(QUIET_GEN)GIT_USER_AGENT="$(GIT_USER_AGENT)" $(SHELL_PATH) ../GIT-VERSION-GEN "$(shell pwd)/.." $< $@+ - @if cmp $@+ $@ >/dev/null 2>&1; then $(RM) $@+; else mv $@+ $@; fi + $(QUIET_GEN)GIT_USER_AGENT="$(GIT_USER_AGENT)" $(SHELL_PATH) ../GIT-VERSION-GEN "$(shell pwd)/.." $< $@ endif ASCIIDOC_DEPS += docinfo.html diff --git a/Makefile b/Makefile index 79739a13d2132204f56b1ef4ca879bd51c5164b4..695a9d9765daf864605002d572129bae7a8c4e40 100644 --- a/Makefile +++ b/Makefile @@ -2512,8 +2512,7 @@ pager.sp pager.s pager.o: EXTRA_CPPFLAGS = \ -DPAGER_ENV='$(PAGER_ENV_CQ_SQ)' version-def.h: version-def.h.in GIT-VERSION-GEN GIT-VERSION-FILE GIT-USER-AGENT - $(QUIET_GEN)GIT_USER_AGENT="$(GIT_USER_AGENT)" $(SHELL_PATH) ./GIT-VERSION-GEN "$(shell pwd)" $< $@+ - @if cmp $@+ $@ >/dev/null 2>&1; then $(RM) $@+; else mv $@+ $@; fi + $(QUIET_GEN)GIT_USER_AGENT="$(GIT_USER_AGENT)" $(SHELL_PATH) ./GIT-VERSION-GEN "$(shell pwd)" $< $@ version.sp version.s version.o: version-def.h @@ -2554,8 +2553,7 @@ $(SCRIPT_SH_GEN) $(SCRIPT_LIB) : % : %.sh generate-script.sh GIT-BUILD-OPTIONS G mv $@+ $@ git.rc: git.rc.in GIT-VERSION-GEN GIT-VERSION-FILE - $(QUIET_GEN)$(SHELL_PATH) ./GIT-VERSION-GEN "$(shell pwd)" $< $@+ - @if cmp $@+ $@ >/dev/null 2>&1; then $(RM) $@+; else mv $@+ $@; fi + $(QUIET_GEN)$(SHELL_PATH) ./GIT-VERSION-GEN "$(shell pwd)" $< $@ git.res: git.rc GIT-PREFIX $(QUIET_RC)$(RC) -i $< -o $@ From patchwork Fri Dec 20 19:44:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13917341 Received: from fhigh-b4-smtp.messagingengine.com (fhigh-b4-smtp.messagingengine.com [202.12.124.155]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AC730221451 for ; Fri, 20 Dec 2024 19:44:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.155 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734723891; cv=none; b=cswdI04ihakzFJI8luADK0m6wPjnypHWa15tpZ1Z7VOd2VHUnJ0F8CC/2c1vPxxxAiGcwHkFpnpGM/rj7vGIZxm5jYJR0rqbmEmmQkRbB2CKOcNsy0MSYQal+4vFqldGESrpnSu45uzTHpb8vu06jjWKMWLa3o6d5K/mCNl9qUM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734723891; c=relaxed/simple; bh=khWASZt9OzT9zOo/+Gkb1YNdn2fhbRkdguSUILvGqFw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ivtO3r/G/dxjdqcBSowlflV8xyXEfotpfeLe1ZUOWtEOB6noDcK+jTMZwHsnrqwCE6iMbcgsRIx/VZdbcwCx1OsY7jhJXAL8cKafqYV7SMoSiAQp5RBfT6MWJlbLilvHnDGwtQVOR1bCzt+MBloYwk2aigxOvyNz52+1E/i7ebM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b=U2hbd4nG; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=tydPGWrG; arc=none smtp.client-ip=202.12.124.155 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="U2hbd4nG"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="tydPGWrG" Received: from phl-compute-07.internal (phl-compute-07.phl.internal [10.202.2.47]) by mailfhigh.stl.internal (Postfix) with ESMTP id CBF9525401F4; Fri, 20 Dec 2024 14:44:48 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-07.internal (MEProxy); Fri, 20 Dec 2024 14:44:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc:cc :content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1734723888; x=1734810288; bh=cOFY9nXY85SJb9rdYs0wBD+2W+TlhaVUbONDAE/zzyI=; b= U2hbd4nGzTNzRzyH18iwDNGKpxRB0/mmQtsRGznEWMgb1ifNa6ZBBbFwWJNsby0M VQj/ydosrbo5ADswxD2ojTU6wyam2r0rbPczk3ZCfWwBpuXPmnOenCauk59r7vMq mQ0Z4xufzCIIAEvjCp26eOkJSjgR01MPDYeJ+n5AqClY+RWrRZlbLawYuczCczJX QIuYDxCfcHKxZrsFAt2qpXqCvz+qSMxXrvbYateM/tMh7he3oGgp3pQNjtfkqKNx h4T3FuGalc0NSH3oDAyGbgOrg5iV5pxEOwMJUDEdTD6dkd2ExHGUWShY5eVR45OS nG8ddlhhSFXFr6//YN0U0g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1734723888; x= 1734810288; bh=cOFY9nXY85SJb9rdYs0wBD+2W+TlhaVUbONDAE/zzyI=; b=t ydPGWrGbJxWCGuVZ3qOydCcz4QFb6fIOKGwFLl+fJXG6u7X8d0JI13WjGKJCLa5E 5j0C10NQK7fJCIFWHMlOiTR0ZapK7ONA13sM7IS5zBBodGx639KX3mbojxYEZwgf /HwCQ/HRB19wr8IQrAWDk41JxtASS9wDlhWeBNBNjG2CpYUJHnbwfXMQf2rNbLU6 WoTI0XFXsHkxwtwV8Jesij08rCrMNGDGikxSrTtZySYiOcZ49FYHJPFSp5dzl0C/ Dcg7bsB5JE2VQ0wFlkgMnsLveB5Upz8rDV1qQrz52dD/VlOmyvlO/Hdmx55A9muK DlMS7rjN+t7Ro0utfmURQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddruddtvddguddvhecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecunecujfgurhephfffuf ggtgfgkfhfjgfvvefosehtjeertdertdejnecuhfhrohhmpefrrghtrhhitghkucfuthgv ihhnhhgrrhguthcuoehpshesphhkshdrihhmqeenucggtffrrghtthgvrhhnpeejhffgte etvedtgfevkeekleeftefgleetjeekkedvvdfgudefhfeklefghfffteenucffohhmrghi nheprhgsrdhinhdptghonhhfrdhinhdprhgtrdhinhenucevlhhushhtvghrufhiiigvpe dtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehpshesphhkshdrihhmpdhnsggprhgtphht thhopeegpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehsphgvtghtrhgrlhesgh hoohhglhgvrdgtohhmpdhrtghpthhtohepghhithesvhhgvghrrdhkvghrnhgvlhdrohhr ghdprhgtphhtthhopehgihhtshhtvghrsehpohgsohigrdgtohhmpdhrtghpthhtohepph gvfhhfsehpvghffhdrnhgvth X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 20 Dec 2024 14:44:47 -0500 (EST) Received: by vm-mail (OpenSMTPD) with ESMTPSA id 07a855e8 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Fri, 20 Dec 2024 19:42:52 +0000 (UTC) From: Patrick Steinhardt Date: Fri, 20 Dec 2024 20:44:23 +0100 Subject: [PATCH v3 3/6] Makefile: introduce template for GIT-VERSION-GEN Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241220-b4-pks-git-version-via-environment-v3-3-1fd79b52a5fb@pks.im> References: <20241220-b4-pks-git-version-via-environment-v3-0-1fd79b52a5fb@pks.im> In-Reply-To: <20241220-b4-pks-git-version-via-environment-v3-0-1fd79b52a5fb@pks.im> To: git@vger.kernel.org Cc: Junio C Hamano , Kyle Lippincott , Jeff King X-Mailer: b4 0.14.2 Introduce a new template to call GIT-VERSION-GEN. This will allow us to iterate on how exactly the script is called in subsequent commits without having to adapt all call sites every time. Signed-off-by: Patrick Steinhardt --- Documentation/Makefile | 4 ++-- Makefile | 6 +++--- shared.mak | 8 ++++++++ 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Documentation/Makefile b/Documentation/Makefile index 1a398d0dc359671d461fceb7a1636268a51411da..ff30ab6c4295525757f6a150ec4ff0c72487f440 100644 --- a/Documentation/Makefile +++ b/Documentation/Makefile @@ -211,10 +211,10 @@ XMLTO_EXTRA += --skip-validation XMLTO_EXTRA += -x manpage.xsl asciidoctor-extensions.rb: asciidoctor-extensions.rb.in FORCE - $(QUIET_GEN)GIT_USER_AGENT="$(GIT_USER_AGENT)" $(SHELL_PATH) ../GIT-VERSION-GEN "$(shell pwd)/.." $< $@ + $(QUIET_GEN)$(call version_gen,"$(shell pwd)/..",$<,$@) else asciidoc.conf: asciidoc.conf.in FORCE - $(QUIET_GEN)GIT_USER_AGENT="$(GIT_USER_AGENT)" $(SHELL_PATH) ../GIT-VERSION-GEN "$(shell pwd)/.." $< $@ + $(QUIET_GEN)$(call version_gen,"$(shell pwd)/..",$<,$@) endif ASCIIDOC_DEPS += docinfo.html diff --git a/Makefile b/Makefile index 695a9d9765daf864605002d572129bae7a8c4e40..9cfe3d0aa968eff10379d22edff6cc6f4518c2ff 100644 --- a/Makefile +++ b/Makefile @@ -593,7 +593,7 @@ include shared.mak GIT-VERSION-FILE: FORCE @OLD=$$(cat $@ 2>/dev/null || :) && \ - $(SHELL_PATH) ./GIT-VERSION-GEN "$(shell pwd)" GIT-VERSION-FILE.in $@ && \ + $(call version_gen,"$(shell pwd)",GIT-VERSION-FILE.in,$@) && \ NEW=$$(cat $@ 2>/dev/null || :) && \ if test "$$OLD" != "$$NEW"; then echo "$$NEW" >&2; fi -include GIT-VERSION-FILE @@ -2512,7 +2512,7 @@ pager.sp pager.s pager.o: EXTRA_CPPFLAGS = \ -DPAGER_ENV='$(PAGER_ENV_CQ_SQ)' version-def.h: version-def.h.in GIT-VERSION-GEN GIT-VERSION-FILE GIT-USER-AGENT - $(QUIET_GEN)GIT_USER_AGENT="$(GIT_USER_AGENT)" $(SHELL_PATH) ./GIT-VERSION-GEN "$(shell pwd)" $< $@ + $(QUIET_GEN)$(call version_gen,"$(shell pwd)",$<,$@) version.sp version.s version.o: version-def.h @@ -2553,7 +2553,7 @@ $(SCRIPT_SH_GEN) $(SCRIPT_LIB) : % : %.sh generate-script.sh GIT-BUILD-OPTIONS G mv $@+ $@ git.rc: git.rc.in GIT-VERSION-GEN GIT-VERSION-FILE - $(QUIET_GEN)$(SHELL_PATH) ./GIT-VERSION-GEN "$(shell pwd)" $< $@ + $(QUIET_GEN)$(call version_gen,"$(shell pwd)",$<,$@) git.res: git.rc GIT-PREFIX $(QUIET_RC)$(RC) -i $< -o $@ diff --git a/shared.mak b/shared.mak index 29bebd30d8acbce9f50661cef48ecdbae1e41f5a..b23c5505c9692b032cd0b18d3e4ede288614d937 100644 --- a/shared.mak +++ b/shared.mak @@ -116,3 +116,11 @@ endef define libpath_template -L$(1) $(if $(filter-out -L,$(CC_LD_DYNPATH)),$(CC_LD_DYNPATH)$(1)) endef + +# Populate build information into a file via GIT-VERSION-GEN. Requires the +# absolute path to the root source directory as well as input and output files +# as arguments, in that order. +define version_gen +GIT_USER_AGENT="$(GIT_USER_AGENT)" \ +$(SHELL_PATH) "$(1)/GIT-VERSION-GEN" "$(1)" "$(2)" "$(3)" +endef From patchwork Fri Dec 20 19:44:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13917342 Received: from fout-b4-smtp.messagingengine.com (fout-b4-smtp.messagingengine.com [202.12.124.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3F421221475 for ; Fri, 20 Dec 2024 19:44:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.147 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734723892; cv=none; b=QSJW+N0W2j2VBE//1yeM005lbt5xIxMFyXYOT+MqA3mB8dNERUMrsNpYkQnj5IGv6aFrNtHqLIEQmv9+Kz7Q24T0cwaLgGTzbHsooMF1hYRJsf/ABy8A4SwIpSKW5mPYMNYTYKQ4bH7ffJnZxumdz7PqtKXOj3gAzc1rBx0iA8w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734723892; c=relaxed/simple; bh=1t/FfGdnA25Nzdf5cyBL0KtjEpJYvDv/F17cw4HsJR4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=CtZ5OYiD2KAdNNL671pUS4iDuKTbNCCE4CXlqvp7pcUEknKFVWBEB0eqbDxeWZ+IHyvwVfdbKajTIerPbdpc4YxYfhJ6noK9E9VI41anNttMSgT5fkJh8R7BU0K63Ft0mopQNZKEb4u3A6UrwXK+erYKmBWuYui5pQ1U1bpJ2Fg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b=wxU6fGlW; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=4DBlr34h; arc=none smtp.client-ip=202.12.124.147 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="wxU6fGlW"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="4DBlr34h" Received: from phl-compute-03.internal (phl-compute-03.phl.internal [10.202.2.43]) by mailfout.stl.internal (Postfix) with ESMTP id 24E1E11400C7; Fri, 20 Dec 2024 14:44:49 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-03.internal (MEProxy); Fri, 20 Dec 2024 14:44:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc:cc :content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1734723888; x=1734810288; bh=q8Y/Q2JsIIpyn74b9xgtzjcuPsOPWCy4jOw3Th31q9c=; b= wxU6fGlWS85GFrtimPbDdDKuDygWSy0E5KiV2ZPH39cLPMlm8NwCcX38x89sHB75 PHTLe2fWttjzQYdMMteN2vB2Z4RbKw9PCou5NCEm6pIM0OxIs4fi1r+IX4hTGMKG hXxiGEZuMygQKIkV66mUFwnkvfX2fTpCTM6L6PAhlFAK3+6r0JvcJXQbFdz3M+c/ gnqd7qc1qT54D8CmwZwrqZ3XSDjHWLN4qFfxA2oJyfA2TiM/u57sGPj2o1ogw+0q vAY1pKplTENtRw+wCvvVW8bk+xG/CLqQfOwvo0lnDmsuc/REPFmHaJmaDvTkcTWr I5Aah1S+jueCX4DZzzb3sw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1734723888; x= 1734810288; bh=q8Y/Q2JsIIpyn74b9xgtzjcuPsOPWCy4jOw3Th31q9c=; b=4 DBlr34hoEEzoHTpc7tb3noeA1DlABHgtDt3GBG5rddKGpmpi8RpMfJFmDn+Ewgj6 vw7acOFZmMHATOZXCrqSSB+Hmrl3MoFhnEPgMvXfsNcSjekhn6OtPN+ebydjv21s 8qausLXw5HVHLg5KrPaeTjhDLP+ClcMIHQopEHjh3k5mbRSxtJX17+CEhqzUfqhF MC2ifcNfNYAUcPO4XYAnvK0VIo5XM1XezK4vJGzzpApQWgwKDlOIWeKNSQLp0mU4 O6EZYa0G9NmslfpxSh9w7jd2B28Or2yXmxGMt5G8nQZmjqv+/+TJp4TlFTjPkUax hHGDGkEXE1BOzSg8PyodQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddruddtvddguddvhecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecunecujfgurhephfffuf ggtgfgkfhfjgfvvefosehtjeertdertdejnecuhfhrohhmpefrrghtrhhitghkucfuthgv ihhnhhgrrhguthcuoehpshesphhkshdrihhmqeenucggtffrrghtthgvrhhnpeefgfdtge ejieetledvleeifeeuieetfeffvefhffffvdettdefkeffteekkeeiheenucffohhmrghi nhepghhnuhdrohhrghdpmhgrkhdruggvvhenucevlhhushhtvghrufhiiigvpedtnecurf grrhgrmhepmhgrihhlfhhrohhmpehpshesphhkshdrihhmpdhnsggprhgtphhtthhopeeg pdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehgihhtshhtvghrsehpohgsohigrd gtohhmpdhrtghpthhtohepghhithesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphht thhopehsphgvtghtrhgrlhesghhoohhglhgvrdgtohhmpdhrtghpthhtohepphgvfhhfse hpvghffhdrnhgvth X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 20 Dec 2024 14:44:47 -0500 (EST) Received: by vm-mail (OpenSMTPD) with ESMTPSA id 874a2bb6 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Fri, 20 Dec 2024 19:42:53 +0000 (UTC) From: Patrick Steinhardt Date: Fri, 20 Dec 2024 20:44:24 +0100 Subject: [PATCH v3 4/6] GIT-VERSION-GEN: fix overriding GIT_VERSION Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241220-b4-pks-git-version-via-environment-v3-4-1fd79b52a5fb@pks.im> References: <20241220-b4-pks-git-version-via-environment-v3-0-1fd79b52a5fb@pks.im> In-Reply-To: <20241220-b4-pks-git-version-via-environment-v3-0-1fd79b52a5fb@pks.im> To: git@vger.kernel.org Cc: Junio C Hamano , Kyle Lippincott , Jeff King X-Mailer: b4 0.14.2 GIT-VERSION-GEN tries to derive the version that Git is being built from via multiple different sources in the following order: 1. A file called "version" in the source tree's root directory, if it exists. 2. The current commit in case Git is built from a Git repository. 3. Otherwise, we use a fallback version stored in a variable which is bumped whenever a new Git version is getting tagged. It used to be possible to override the version by overriding the `GIT_VERSION` Makefile variable (e.g. `make GIT_VERSION=foo`). This worked somewhat by chance, only: `GIT-VERSION-GEN` would write the actual Git version into `GIT-VERSION-FILE`, not the overridden value, but when including the file into our Makefile we would not override the `GIT_VERSION` variable because it has already been set by the user. And because our Makefile used the variable to propagate the version to our build tools instead of using `GIT-VERSION-FILE` the resulting build artifacts used the overridden version. But that subtle mechanism broke with 4838deab65 (Makefile: refactor GIT-VERSION-GEN to be reusable, 2024-12-06) and subsequent commits because the version information is not propagated via the Makefile variable anymore, but instead via the files that `GIT-VERSION-GEN` started to write. And as the script never knew about the `GIT_VERSION` environment variable in the first place it uses one of the values listed above instead of the overridden value. Fix this issue by making `GIT-VERSION-GEN` handle the case where `GIT_VERSION` has been set via the environment. Note that this requires us to introduce a new GIT_VERSION_OVERRIDE variable that stores a potential user-provided value, either via the environment or via "config.mak". Ideally we wouldn't need it and could just continue to use GIT_VERSION for this. But unfortunately, Makefiles will first include all sub-Makefiles before figuring out whether it needs to re-make any of them [1]. Consequently, if there already is a GIT-VERSION-FILE, we would have slurped in its value of GIT_VERSION before we call GIT-VERSION-GEN, and because GIT-VERSION-GEN now uses that value as an override it would mean that the first generated value for GIT_VERSION will remain unchanged. Furthermore we have to move the include for "GIT-VERSION-FILE" after the includes for "config.mak" and related so that GIT_VERSION_OVERRIDE can be set to the value provided by "config.mak". [1]: https://www.gnu.org/software/make/manual/html_node/Remaking-Makefiles.html Signed-off-by: Patrick Steinhardt --- Documentation/Makefile | 4 ++++ GIT-VERSION-GEN | 48 ++++++++++++++++++++++++++---------------------- Makefile | 19 ++++++++++++------- shared.mak | 1 + 4 files changed, 43 insertions(+), 29 deletions(-) diff --git a/Documentation/Makefile b/Documentation/Makefile index ff30ab6c4295525757f6a150ec4ff0c72487f440..a89823e1d1ee5042367bdcca6ed426196d49ce89 100644 --- a/Documentation/Makefile +++ b/Documentation/Makefile @@ -181,6 +181,10 @@ endif -include ../config.mak.autogen -include ../config.mak +# Set GIT_VERSION_OVERRIDE such that version_gen knows to substitute +# GIT_VERSION in case it was set by the user. +GIT_VERSION_OVERRIDE := $(GIT_VERSION) + ifndef NO_MAN_BOLD_LITERAL XMLTO_EXTRA += -m manpage-bold-literal.xsl endif diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN index de0e63bdfbac263884e2ea328cc2ef11ace7a238..9b785da226eff2d7952d3306f45fd2933fdafaca 100755 --- a/GIT-VERSION-GEN +++ b/GIT-VERSION-GEN @@ -27,31 +27,35 @@ fi GIT_CEILING_DIRECTORIES="$SOURCE_DIR/.." export GIT_CEILING_DIRECTORIES -# First see if there is a version file (included in release tarballs), -# then try git-describe, then default. -if test -f "$SOURCE_DIR"/version +if test -z "$GIT_VERSION" then - VN=$(cat "$SOURCE_DIR"/version) || VN="$DEF_VER" -elif { - test -d "$SOURCE_DIR/.git" || - test -d "${GIT_DIR:-.git}" || - test -f "$SOURCE_DIR"/.git; - } && - VN=$(git -C "$SOURCE_DIR" describe --match "v[0-9]*" HEAD 2>/dev/null) && - case "$VN" in - *$LF*) (exit 1) ;; - v[0-9]*) - git -C "$SOURCE_DIR" update-index -q --refresh - test -z "$(git -C "$SOURCE_DIR" diff-index --name-only HEAD --)" || - VN="$VN-dirty" ;; - esac -then - VN=$(echo "$VN" | sed -e 's/-/./g'); -else - VN="$DEF_VER" + # First see if there is a version file (included in release tarballs), + # then try git-describe, then default. + if test -f "$SOURCE_DIR"/version + then + VN=$(cat "$SOURCE_DIR"/version) || VN="$DEF_VER" + elif { + test -d "$SOURCE_DIR/.git" || + test -d "${GIT_DIR:-.git}" || + test -f "$SOURCE_DIR"/.git; + } && + VN=$(git -C "$SOURCE_DIR" describe --match "v[0-9]*" HEAD 2>/dev/null) && + case "$VN" in + *$LF*) (exit 1) ;; + v[0-9]*) + git -C "$SOURCE_DIR" update-index -q --refresh + test -z "$(git -C "$SOURCE_DIR" diff-index --name-only HEAD --)" || + VN="$VN-dirty" ;; + esac + then + VN=$(echo "$VN" | sed -e 's/-/./g'); + else + VN="$DEF_VER" + fi + + GIT_VERSION=$(expr "$VN" : v*'\(.*\)') fi -GIT_VERSION=$(expr "$VN" : v*'\(.*\)') GIT_BUILT_FROM_COMMIT=$(git -C "$SOURCE_DIR" rev-parse -q --verify HEAD 2>/dev/null) GIT_DATE=$(git -C "$SOURCE_DIR" show --quiet --format='%as' 2>/dev/null) if test -z "$GIT_USER_AGENT" diff --git a/Makefile b/Makefile index 9cfe3d0aa968eff10379d22edff6cc6f4518c2ff..3cdd2278fdaa40feb6139992aa275ad26aaae4a6 100644 --- a/Makefile +++ b/Makefile @@ -591,13 +591,6 @@ include shared.mak # # Disable -pedantic compilation. -GIT-VERSION-FILE: FORCE - @OLD=$$(cat $@ 2>/dev/null || :) && \ - $(call version_gen,"$(shell pwd)",GIT-VERSION-FILE.in,$@) && \ - NEW=$$(cat $@ 2>/dev/null || :) && \ - if test "$$OLD" != "$$NEW"; then echo "$$NEW" >&2; fi --include GIT-VERSION-FILE - # Set our default configuration. # # Among the variables below, these: @@ -1465,6 +1458,18 @@ ifdef DEVELOPER include config.mak.dev endif +GIT-VERSION-FILE: FORCE + @OLD=$$(cat $@ 2>/dev/null || :) && \ + $(call version_gen,"$(shell pwd)",GIT-VERSION-FILE.in,$@) && \ + NEW=$$(cat $@ 2>/dev/null || :) && \ + if test "$$OLD" != "$$NEW"; then echo "$$NEW" >&2; fi + +# We need to set GIT_VERSION_OVERRIDE before including the version file as +# otherwise any user-provided value for GIT_VERSION would have been overridden +# already. +GIT_VERSION_OVERRIDE := $(GIT_VERSION) +-include GIT-VERSION-FILE + # what 'all' will build and 'install' will install in gitexecdir, # excluding programs for built-in commands ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS) diff --git a/shared.mak b/shared.mak index b23c5505c9692b032cd0b18d3e4ede288614d937..a66f46969e301b35d88650f2c6abc6c0ba1b0f3d 100644 --- a/shared.mak +++ b/shared.mak @@ -122,5 +122,6 @@ endef # as arguments, in that order. define version_gen GIT_USER_AGENT="$(GIT_USER_AGENT)" \ +GIT_VERSION="$(GIT_VERSION_OVERRIDE)" \ $(SHELL_PATH) "$(1)/GIT-VERSION-GEN" "$(1)" "$(2)" "$(3)" endef From patchwork Fri Dec 20 19:44:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13917344 Received: from fout-b4-smtp.messagingengine.com (fout-b4-smtp.messagingengine.com [202.12.124.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7450C22332F for ; Fri, 20 Dec 2024 19:44:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.147 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734723893; cv=none; b=Lu67RB7TEKQqUfrTVXxSwTrzbg/LLgoAdHZ9stpC56T3OfjugPdtwb/wxSAzjprTHdlIaOz5cy/RwZOqMWTMxP6twoOA+19s1aFfxJOV0j/rIbdy1XEdTV2YPtCRsCFjraLwuHjS2FbtDHv3HxDcnDpbxnFCVTOFwsWu2gwFifg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734723893; c=relaxed/simple; bh=xlwYu45PLvGxAt3Q6xUnrIxlyygvkVMwkzeqATr84ag=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=DMHRdHwYguWpq/2xK2Q98R0Gb398tVJGBSncExVQryCMemOZmDFgpJew56pNOvznZg+3kbK1n5MBlW4j1ZSvFze2hO/Fn643zh5HekJv/lpAZsW/4uFJPKuxh+oPk4ap5TipMbOpaoaqPM1gbTYTTQh9yqsktWeRx+N5LAUfP54= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b=w6ca04mU; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=4r2O0BCS; arc=none smtp.client-ip=202.12.124.147 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="w6ca04mU"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="4r2O0BCS" Received: from phl-compute-09.internal (phl-compute-09.phl.internal [10.202.2.49]) by mailfout.stl.internal (Postfix) with ESMTP id 78F7C11400FA; Fri, 20 Dec 2024 14:44:50 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-09.internal (MEProxy); Fri, 20 Dec 2024 14:44:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc:cc :content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1734723890; x=1734810290; bh=xcYawtI5xgcx+Ciov+meI6WtNRDmG9hTD+BB2tgmuL0=; b= w6ca04mUxOcFKAkASjgOVbNlLEx6iRGUVGAQdBuilIPed8a5QJEIi9Wd54b97AJs Zs4NQ0f7yD9WnxN8n2i9w5Ye+w0cGsSK/wmFU0OaTjnzjvDDw7kpxUTigtvpcWWk VIQLpBFdmOTuDeJa6/LSI82ieuWrBsI2PwviZaU+kK36FzdXrJ69xsIU7CmeO9uI 5TUaOlIpf2HiyqKJmWxjUEyRuqbis44rHfSaSo2ZV4/tnJBg89bObWG6sxj9i2N9 Dg/pJ+YQz59oToCZSRxSd/UvlUqKAfax/FJ/j+fh4RsrQRqaXsvJbSxQ6o6dmaGn 86SAwsYRB7B1X2046vhQew== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1734723890; x= 1734810290; bh=xcYawtI5xgcx+Ciov+meI6WtNRDmG9hTD+BB2tgmuL0=; b=4 r2O0BCSRW93DqJxeF1teRzWEILsFtHmG1L/V1XXT/RhY/Sh2ze/0AmURmppmI144 HS1b01SqpV74UZOlcjjp/okEiR2dZqqvnbK3vzbKigcNSsSQUIjXb8ed4H4wQ4My 0Z5JI7WQO7bKAe+u4pLE2+ywnwiow34TbFg6uY35/1NzExSgHtmK6THT3ynS8WMp ew+FmQ2V60L3niSN8lKsjCep9jnbB9a7mlJFHhvMGfB38BciLAap0WkLoYRJGOEj O9q+fNhP66AwYm68CAv6ZbEkjq5y6lh0nmxmyIm9SFW0lwqOTwIJAAViv0totyat 6ssd+h+CWGscKNu1RRPTg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddruddtvddguddviecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecunecujfgurhephfffuf ggtgfgkfhfjgfvvefosehtjeertdertdejnecuhfhrohhmpefrrghtrhhitghkucfuthgv ihhnhhgrrhguthcuoehpshesphhkshdrihhmqeenucggtffrrghtthgvrhhnpeffueeiud ejvdekheeuvdekfeffiedvueelteekudehjeetkeegvddugfdtgfeileenucevlhhushht vghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehpshesphhkshdrihhmpd hnsggprhgtphhtthhopeegpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehsphgv tghtrhgrlhesghhoohhglhgvrdgtohhmpdhrtghpthhtohepghhithhsthgvrhesphhosg hogidrtghomhdprhgtphhtthhopehpvghffhesphgvfhhfrdhnvghtpdhrtghpthhtohep ghhithesvhhgvghrrdhkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 20 Dec 2024 14:44:49 -0500 (EST) Received: by vm-mail (OpenSMTPD) with ESMTPSA id 89d06767 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Fri, 20 Dec 2024 19:42:53 +0000 (UTC) From: Patrick Steinhardt Date: Fri, 20 Dec 2024 20:44:25 +0100 Subject: [PATCH v3 5/6] GIT-VERSION-GEN: fix overriding GIT_BUILT_FROM_COMMIT and GIT_DATE Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241220-b4-pks-git-version-via-environment-v3-5-1fd79b52a5fb@pks.im> References: <20241220-b4-pks-git-version-via-environment-v3-0-1fd79b52a5fb@pks.im> In-Reply-To: <20241220-b4-pks-git-version-via-environment-v3-0-1fd79b52a5fb@pks.im> To: git@vger.kernel.org Cc: Junio C Hamano , Kyle Lippincott , Jeff King X-Mailer: b4 0.14.2 Same as with the preceding commit, neither GIT_BUILT_FROM_COMMIT nor GIT_DATE can be overridden via the environment. Especially the latter is of importance given that we set it in our own "Documentation/doc-diff" script. Make the values of both variables overridable. Luckily we don't pull in these values via any included Makefiles, so the fix is trivial compared to the fix for GIT_VERSON. Signed-off-by: Patrick Steinhardt --- GIT-VERSION-GEN | 12 ++++++++++-- shared.mak | 2 ++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN index 9b785da226eff2d7952d3306f45fd2933fdafaca..497b4e48d20f9d1d20f2db2a3aae2a92316b7ca9 100755 --- a/GIT-VERSION-GEN +++ b/GIT-VERSION-GEN @@ -56,8 +56,16 @@ then GIT_VERSION=$(expr "$VN" : v*'\(.*\)') fi -GIT_BUILT_FROM_COMMIT=$(git -C "$SOURCE_DIR" rev-parse -q --verify HEAD 2>/dev/null) -GIT_DATE=$(git -C "$SOURCE_DIR" show --quiet --format='%as' 2>/dev/null) +if test -z "$GIT_BUILT_FROM_COMMIT" +then + GIT_BUILT_FROM_COMMIT=$(git -C "$SOURCE_DIR" rev-parse -q --verify HEAD 2>/dev/null) +fi + +if test -z "$GIT_DATE" +then + GIT_DATE=$(git -C "$SOURCE_DIR" show --quiet --format='%as' 2>/dev/null) +fi + if test -z "$GIT_USER_AGENT" then GIT_USER_AGENT="git/$GIT_VERSION" diff --git a/shared.mak b/shared.mak index a66f46969e301b35d88650f2c6abc6c0ba1b0f3d..1a99848a95174c5e386c59321655937e7b7d8a28 100644 --- a/shared.mak +++ b/shared.mak @@ -121,6 +121,8 @@ endef # absolute path to the root source directory as well as input and output files # as arguments, in that order. define version_gen +GIT_BUILT_FROM_COMMIT="$(GIT_BUILT_FROM_COMMIT)" \ +GIT_DATE="$(GIT_DATE)" \ GIT_USER_AGENT="$(GIT_USER_AGENT)" \ GIT_VERSION="$(GIT_VERSION_OVERRIDE)" \ $(SHELL_PATH) "$(1)/GIT-VERSION-GEN" "$(1)" "$(2)" "$(3)" From patchwork Fri Dec 20 19:44:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13917343 Received: from fhigh-b4-smtp.messagingengine.com (fhigh-b4-smtp.messagingengine.com [202.12.124.155]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7E8D02236E8 for ; Fri, 20 Dec 2024 19:44:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.155 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734723893; cv=none; b=Uc+8gJemhoiKJoAp2Xjt07Rshcf564z3m3KOLuRAgKgqaLCLjxODTXBC+e7s7fWPUv9fO/2bf/ztxBuo3ziRi8EMg5GlE4isZJACVYRrFNAz7zSQCrnI0eTkV//Dy39ioq8Q0XChhJAWwCtcuaCh3dehAeEkdj6Ay9/205fG32k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734723893; c=relaxed/simple; bh=SWtKVYqEH2dlesWv740OBSC1m8E0dSpAGnv/p18GXq8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mvAfRrLDTUoFBi/fhGT6SR+cXf55D/0MARc4Vs5yFpCqcmZ4usst6zTKXBeTl9dWlInkZDVHwa5xsRyFl72535d8yhBkqWRtSHKQGncWA32AB2in6NMV+RulJNljpC99fYWAApGt2yxsRxjlWLNryX/T2iXMOUE1NUqPXwmIPJg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b=aq0TAz/O; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=KSeSACnh; arc=none smtp.client-ip=202.12.124.155 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="aq0TAz/O"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="KSeSACnh" Received: from phl-compute-11.internal (phl-compute-11.phl.internal [10.202.2.51]) by mailfhigh.stl.internal (Postfix) with ESMTP id A08E9254014E; Fri, 20 Dec 2024 14:44:50 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-11.internal (MEProxy); Fri, 20 Dec 2024 14:44:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc:cc :content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1734723890; x=1734810290; bh=Ahhl40NFQT1iU3EMsw4mAJe4U7EYMH0GfxAueUAzjj4=; b= aq0TAz/OByFH+XTgwyQOLjcbQ9yBHwySXOrrnzgJfepQ9FPOLQ0llxFdNeaggrQG DAG3kqpgXnYKt9K8NIelFV6QJteAW9C1aXNaRaFdvhUiyUKfvabWEPUQzVjAt4lO ziKsmxM6t5/7dlih5WfcMY/6ZL/aY1dMIk3jKsiwcpZA6q0RfY0qomg4oHhfL9xF OZ3gdaZvyDkzCxLSDM1OCetTcYy5RQphqXYK2mqdtODpwgcX6Ifw78f18yQX6dTk yR49jEcqYhrI7WmAFiTmp6+ChxDogxHoV+xOELKQDwKsdCDhfHdlzNX8bLKg9wd0 zrlQVNS+vD3abHQ281Nghg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1734723890; x= 1734810290; bh=Ahhl40NFQT1iU3EMsw4mAJe4U7EYMH0GfxAueUAzjj4=; b=K SeSACnhF3cjo5nqekrP4VUbNI2qW8DOJjbXflBm7aq2twT5YZna4MKbhY3e9Wx8H +HIi6LcwRNRbU+ld79rvbOFMwJ4oIXPD94n+DFf3IlWcZ71WNw82y4+vrOWgjilN wMJwnSvjcx/LCttQN6oTxxwEXB/T1o0OfjoWDCBbYDP5FLxxLSTPw1qQPKFKyrrc 3r9OKLww1WaoenvrtwzH5Gl6lCCZSUKxaV6WLCG2mp6omIbq4fq2kf97urL9KJ4d xwvf/68M26N+OTjFpckjbY5Ob60tZTu8IULEbEDovpAmb2R5LFMZHQ8AGPQnAN65 Du6JorEdgacPWw0DlwWiw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddruddtvddguddvhecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecunecujfgurhephfffuf ggtgfgkfhfjgfvvefosehtjeertdertdejnecuhfhrohhmpefrrghtrhhitghkucfuthgv ihhnhhgrrhguthcuoehpshesphhkshdrihhmqeenucggtffrrghtthgvrhhnpeefieevtd euhfduhfefudejteeifedvleeklefftdegkeeugeejjefgkeeufffhueenucffohhmrghi nheptghonhhfrdhinhdprhgtrdhinhenucevlhhushhtvghrufhiiigvpedtnecurfgrrh grmhepmhgrihhlfhhrohhmpehpshesphhkshdrihhmpdhnsggprhgtphhtthhopeegpdhm ohguvgepshhmthhpohhuthdprhgtphhtthhopehgihhtsehvghgvrhdrkhgvrhhnvghlrd horhhgpdhrtghpthhtohepghhithhsthgvrhesphhosghogidrtghomhdprhgtphhtthho pehpvghffhesphgvfhhfrdhnvghtpdhrtghpthhtohepshhpvggtthhrrghlsehgohhogh hlvgdrtghomh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 20 Dec 2024 14:44:49 -0500 (EST) Received: by vm-mail (OpenSMTPD) with ESMTPSA id ab576976 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Fri, 20 Dec 2024 19:42:54 +0000 (UTC) From: Patrick Steinhardt Date: Fri, 20 Dec 2024 20:44:26 +0100 Subject: [PATCH v3 6/6] meson: add options to override build information Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241220-b4-pks-git-version-via-environment-v3-6-1fd79b52a5fb@pks.im> References: <20241220-b4-pks-git-version-via-environment-v3-0-1fd79b52a5fb@pks.im> In-Reply-To: <20241220-b4-pks-git-version-via-environment-v3-0-1fd79b52a5fb@pks.im> To: git@vger.kernel.org Cc: Junio C Hamano , Kyle Lippincott , Jeff King X-Mailer: b4 0.14.2 We inject various different kinds of build information into build artifacts, like the version string or the commit from which Git was built. Add options to let users explicitly override this information with Meson. Signed-off-by: Patrick Steinhardt --- Documentation/meson.build | 1 + meson.build | 13 +++++++++++++ meson_options.txt | 10 ++++++++++ 3 files changed, 24 insertions(+) diff --git a/Documentation/meson.build b/Documentation/meson.build index f2426ccaa30c29bd60b850eb0a9a4ab77c66a629..fca3eab1f1360a5fdeda89c1766ab8cdb3267b89 100644 --- a/Documentation/meson.build +++ b/Documentation/meson.build @@ -219,6 +219,7 @@ asciidoc_conf = custom_target( input: meson.current_source_dir() / 'asciidoc.conf.in', output: 'asciidoc.conf', depends: [git_version_file], + env: version_gen_environment, ) asciidoc_common_options = [ diff --git a/meson.build b/meson.build index 0dccebcdf16b07650d943e53643f0e09e2975cc9..be32d60e841a3055ed2bdf6fd449a48b66d94cd0 100644 --- a/meson.build +++ b/meson.build @@ -201,6 +201,16 @@ if get_option('sane_tool_path') != '' script_environment.prepend('PATH', get_option('sane_tool_path')) endif +# The environment used by GIT-VERSION-GEN. Note that we explicitly override +# environment variables that might be set by the user. This is by design so +# that we always use whatever Meson has configured instead of what is present +# in the environment. +version_gen_environment = script_environment +version_gen_environment.set('GIT_BUILT_FROM_COMMIT', get_option('built_from_commit')) +version_gen_environment.set('GIT_DATE', get_option('build_date')) +version_gen_environment.set('GIT_USER_AGENT', get_option('user_agent')) +version_gen_environment.set('GIT_VERSION', get_option('version')) + compiler = meson.get_compiler('c') libgit_sources = [ @@ -1485,6 +1495,7 @@ git_version_file = custom_target( ], input: meson.current_source_dir() / 'GIT-VERSION-FILE.in', output: 'GIT-VERSION-FILE', + env: version_gen_environment, build_always_stale: true, ) @@ -1501,6 +1512,7 @@ version_def_h = custom_target( # Depend on GIT-VERSION-FILE so that we don't always try to rebuild this # target for the same commit. depends: [git_version_file], + env: version_gen_environment, ) # Build a separate library for "version.c" so that we do not have to rebuild @@ -1544,6 +1556,7 @@ if host_machine.system() == 'windows' input: meson.current_source_dir() / 'git.rc.in', output: 'git.rc', depends: [git_version_file], + env: version_gen_environment, ) common_main_sources += import('windows').compile_resources(git_rc, diff --git a/meson_options.txt b/meson_options.txt index 32a72139bae870745d9131cc9086a4594826be91..8ead1349550807420bdb95e55298ea4f3f2ea9d0 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -16,6 +16,16 @@ option('runtime_prefix', type: 'boolean', value: false, option('sane_tool_path', type: 'string', value: '', description: 'A colon-separated list of paths to prepend to PATH if your tools in /usr/bin are broken.') +# Build information compiled into Git and other parts like documentation. +option('build_date', type: 'string', value: '', + description: 'Build date reported by our documentation.') +option('built_from_commit', type: 'string', value: '', + description: 'Commit that Git was built from reported by git-version(1).') +option('user_agent', type: 'string', value: '', + description: 'User agent reported to remote servers.') +option('version', type: 'string', value: '', + description: 'Version string reported by git-version(1) and other tools.') + # Features supported by Git. option('curl', type: 'feature', value: 'enabled', description: 'Build helpers used to access remotes with the HTTP transport.')