From 4070c9e09fc4295e5b2f8a7cbb5bae1936fdeef8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Wed, 5 May 2021 14:21:38 +0200 Subject: [PATCH 1/5] Makefile: don't re-define PERL_DEFINES MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since 07d90eadb50 (Makefile: add Perl runtime prefix support, 2018-04-10) we have been declaring PERL_DEFINES right after assigning to it, with the effect that the first PERL_DEFINES was ignored. That bug didn't matter in practice since the first line had all the same variables as the second, so we'd correctly re-generate everything. It just made for confusing reading. Let's remove that first assignment, and while we're at it split these across lines to make them more maintainable. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- Makefile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 93664d6714..1d4c02e59d 100644 --- a/Makefile +++ b/Makefile @@ -2270,9 +2270,10 @@ perl_localedir_SQ = $(localedir_SQ) ifndef NO_PERL PERL_HEADER_TEMPLATE = perl/header_templates/fixed_prefix.template.pl -PERL_DEFINES = $(PERL_PATH_SQ):$(PERLLIB_EXTRA_SQ):$(perllibdir_SQ) - -PERL_DEFINES := $(PERL_PATH_SQ) $(PERLLIB_EXTRA_SQ) $(perllibdir_SQ) +PERL_DEFINES := +PERL_DEFINES += $(PERL_PATH_SQ) +PERL_DEFINES += $(PERLLIB_EXTRA_SQ) +PERL_DEFINES += $(perllibdir_SQ) PERL_DEFINES += $(RUNTIME_PREFIX) # Support Perl runtime prefix. In this mode, a different header is installed From 3d49f7220a41147b17c1d826b9c87452b5f68c2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Wed, 5 May 2021 14:21:39 +0200 Subject: [PATCH 2/5] Makefile: regenerate perl/build/* if GIT-PERL-DEFINES changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change the logic to generate perl/build/* to regenerate those files if GIT-PERL-DEFINES changes. This ensures that e.g. changing localedir will result in correctly re-generated files. I don't think that ever worked. The brokenness pre-dates my 20d2a30f8ff (Makefile: replace perl/Makefile.PL with simple make rules, 2017-12-10). Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 1d4c02e59d..a15f39e40f 100644 --- a/Makefile +++ b/Makefile @@ -2676,7 +2676,7 @@ endif NO_PERL_CPAN_FALLBACKS_SQ = $(subst ','\'',$(NO_PERL_CPAN_FALLBACKS)) endif -perl/build/lib/%.pm: perl/%.pm +perl/build/lib/%.pm: perl/%.pm GIT-PERL-DEFINES $(QUIET_GEN)mkdir -p $(dir $@) && \ sed -e 's|@@LOCALEDIR@@|$(perl_localedir_SQ)|g' \ -e 's|@@NO_PERL_CPAN_FALLBACKS@@|$(NO_PERL_CPAN_FALLBACKS_SQ)|g' \ From 368a50d9eea16e8e1181ce12d5c3c1d50216b688 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Wed, 5 May 2021 14:21:40 +0200 Subject: [PATCH 3/5] Makefile: regenerate *.pm on NO_PERL_CPAN_FALLBACKS change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Regenerate the *.pm files in perl/build/* if the NO_PERL_CPAN_FALLBACKS flag added to the *.pm files in 1aca69c0195 (perl Git::LoadCPAN: emit better errors under NO_PERL_CPAN_FALLBACKS, 2018-03-03) is changed. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index a15f39e40f..574b25512e 100644 --- a/Makefile +++ b/Makefile @@ -2275,6 +2275,7 @@ PERL_DEFINES += $(PERL_PATH_SQ) PERL_DEFINES += $(PERLLIB_EXTRA_SQ) PERL_DEFINES += $(perllibdir_SQ) PERL_DEFINES += $(RUNTIME_PREFIX) +PERL_DEFINES += $(NO_PERL_CPAN_FALLBACKS) # Support Perl runtime prefix. In this mode, a different header is installed # into Perl scripts. From 256c2dc42c812e4868532b88155f60f0a269c821 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Wed, 5 May 2021 14:21:41 +0200 Subject: [PATCH 4/5] perl: use mock i18n functions under NO_GETTEXT=Y MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change the logic of the i18n functions I added in 5e9637c6297 (i18n: add infrastructure for translating Git with gettext, 2011-11-18) to use pass-through functions when NO_GETTEXT is defined. This speeds up the compilation time of commands that use this library when NO_GETTEXT=Y is in effect. Loading it and POSIX.pm is around 20ms on my machine, whereas it takes 2ms to just instantiate perl itself. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- Makefile | 3 +++ perl/Git/I18N.pm | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/Makefile b/Makefile index 574b25512e..b8d6b31305 100644 --- a/Makefile +++ b/Makefile @@ -1986,6 +1986,7 @@ ETC_GITCONFIG_SQ = $(subst ','\'',$(ETC_GITCONFIG)) ETC_GITATTRIBUTES_SQ = $(subst ','\'',$(ETC_GITATTRIBUTES)) DESTDIR_SQ = $(subst ','\'',$(DESTDIR)) +NO_GETTEXT_SQ = $(subst ','\'',$(NO_GETTEXT)) bindir_SQ = $(subst ','\'',$(bindir)) bindir_relative_SQ = $(subst ','\'',$(bindir_relative)) mandir_SQ = $(subst ','\'',$(mandir)) @@ -2276,6 +2277,7 @@ PERL_DEFINES += $(PERLLIB_EXTRA_SQ) PERL_DEFINES += $(perllibdir_SQ) PERL_DEFINES += $(RUNTIME_PREFIX) PERL_DEFINES += $(NO_PERL_CPAN_FALLBACKS) +PERL_DEFINES += $(NO_GETTEXT) # Support Perl runtime prefix. In this mode, a different header is installed # into Perl scripts. @@ -2680,6 +2682,7 @@ endif perl/build/lib/%.pm: perl/%.pm GIT-PERL-DEFINES $(QUIET_GEN)mkdir -p $(dir $@) && \ sed -e 's|@@LOCALEDIR@@|$(perl_localedir_SQ)|g' \ + -e 's|@@NO_GETTEXT@@|$(NO_GETTEXT_SQ)|g' \ -e 's|@@NO_PERL_CPAN_FALLBACKS@@|$(NO_PERL_CPAN_FALLBACKS_SQ)|g' \ < $< > $@ diff --git a/perl/Git/I18N.pm b/perl/Git/I18N.pm index 2037f387c8..895e759c57 100644 --- a/perl/Git/I18N.pm +++ b/perl/Git/I18N.pm @@ -16,9 +16,19 @@ BEGIN our @EXPORT = qw(__ __n N__); our @EXPORT_OK = @EXPORT; +# See Git::LoadCPAN's NO_PERL_CPAN_FALLBACKS_STR for a description of +# this "'@@' [...] '@@'" pattern. +use constant NO_GETTEXT_STR => '@@' . 'NO_GETTEXT' . '@@'; +use constant NO_GETTEXT => ( + q[@@NO_GETTEXT@@] ne '' + and + q[@@NO_GETTEXT@@] ne NO_GETTEXT_STR +); + sub __bootstrap_locale_messages { our $TEXTDOMAIN = 'git'; our $TEXTDOMAINDIR ||= $ENV{GIT_TEXTDOMAINDIR} || '@@LOCALEDIR@@'; + die "NO_GETTEXT=" . NO_GETTEXT_STR if NO_GETTEXT; require POSIX; POSIX->import(qw(setlocale)); From 8c55753c68e9c3e56f7a0d96301d2211d9e4ae35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Wed, 12 May 2021 11:49:44 +0200 Subject: [PATCH 5/5] Makefile: make PERL_DEFINES recursively expanded MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since 07d90eadb50 (Makefile: add Perl runtime prefix support, 2018-04-10) PERL_DEFINES has been a simply-expanded variable, let's make it recursively expanded instead. This change doesn't matter for the correctness of the logic. Whether we used simply-expanded or recursively expanded didn't change what we wrote out in GIT-PERL-DEFINES, but being consistent with other rules makes this easier to understand. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b8d6b31305..0705fc2d3f 100644 --- a/Makefile +++ b/Makefile @@ -2271,7 +2271,7 @@ perl_localedir_SQ = $(localedir_SQ) ifndef NO_PERL PERL_HEADER_TEMPLATE = perl/header_templates/fixed_prefix.template.pl -PERL_DEFINES := +PERL_DEFINES = PERL_DEFINES += $(PERL_PATH_SQ) PERL_DEFINES += $(PERLLIB_EXTRA_SQ) PERL_DEFINES += $(perllibdir_SQ)