summaryrefslogtreecommitdiff
path: root/perl
diff options
context:
space:
mode:
authorDan Jacques <dnj@google.com>2018-04-10 15:05:43 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-04-11 09:09:56 (GMT)
commit07d90eadb50ee687a7313186b654975b0944a74e (patch)
treed6bee14117a8c61c5c18220d2ffb5f1d40d871b6 /perl
parentf6a0ad4be71a337e2e8787788a4b467204a4c4bb (diff)
downloadgit-07d90eadb50ee687a7313186b654975b0944a74e.zip
git-07d90eadb50ee687a7313186b654975b0944a74e.tar.gz
git-07d90eadb50ee687a7313186b654975b0944a74e.tar.bz2
Makefile: add Perl runtime prefix support
Broaden the RUNTIME_PREFIX flag to configure Git's Perl scripts to locate the Git installation's Perl support libraries by resolving against the script's path, rather than hard-coding that path at build-time. Hard-coding at build time worked on previous RUNTIME_PREFIX configurations (i.e., Windows) because the Perl scripts were run within a virtual filesystem whose paths were consistent regardless of the location of the actual installation. This will no longer be the case for non-Windows RUNTIME_PREFIX users. When enabled, RUNTIME_PREFIX now requires Perl's system paths to be expressed relative to a common installation directory in the Makefile, and uses that relationship to locate support files based on the known starting point of the script being executed, much like RUNTIME_PREFIX does for the Git binary. This change enables Git's Perl scripts to work when their Git installation is relocated or moved to another system, even when they are not in a virtual filesystem environment. Signed-off-by: Dan Jacques <dnj@google.com> Thanks-to: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Thanks-to: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'perl')
-rw-r--r--perl/Git/I18N.pm2
-rw-r--r--perl/header_templates/runtime_prefix.template.pl42
2 files changed, 43 insertions, 1 deletions
diff --git a/perl/Git/I18N.pm b/perl/Git/I18N.pm
index dba96ff..bfb4fb6 100644
--- a/perl/Git/I18N.pm
+++ b/perl/Git/I18N.pm
@@ -18,7 +18,7 @@ our @EXPORT_OK = @EXPORT;
sub __bootstrap_locale_messages {
our $TEXTDOMAIN = 'git';
- our $TEXTDOMAINDIR = $ENV{GIT_TEXTDOMAINDIR} || '@@LOCALEDIR@@';
+ our $TEXTDOMAINDIR ||= $ENV{GIT_TEXTDOMAINDIR} || '@@LOCALEDIR@@';
require POSIX;
POSIX->import(qw(setlocale));
diff --git a/perl/header_templates/runtime_prefix.template.pl b/perl/header_templates/runtime_prefix.template.pl
new file mode 100644
index 0000000..9d28b3d
--- /dev/null
+++ b/perl/header_templates/runtime_prefix.template.pl
@@ -0,0 +1,42 @@
+# BEGIN RUNTIME_PREFIX generated code.
+#
+# This finds our Git::* libraries relative to the script's runtime path.
+sub __git_system_path {
+ my ($relpath) = @_;
+ my $gitexecdir_relative = '@@GITEXECDIR_REL@@';
+
+ # GIT_EXEC_PATH is supplied by `git` or the test suite.
+ my $exec_path;
+ if (exists $ENV{GIT_EXEC_PATH}) {
+ $exec_path = $ENV{GIT_EXEC_PATH};
+ } else {
+ # This can happen if this script is being directly invoked instead of run
+ # by "git".
+ require FindBin;
+ $exec_path = $FindBin::Bin;
+ }
+
+ # Trim off the relative gitexecdir path to get the system path.
+ (my $prefix = $exec_path) =~ s/\Q$gitexecdir_relative\E$//;
+
+ require File::Spec;
+ return File::Spec->catdir($prefix, $relpath);
+}
+
+BEGIN {
+ use lib split /@@PATHSEP@@/,
+ (
+ $ENV{GITPERLLIB} ||
+ do {
+ my $perllibdir = __git_system_path('@@PERLLIBDIR_REL@@');
+ (-e $perllibdir) || die("Invalid system path ($relpath): $path");
+ $perllibdir;
+ }
+ );
+
+ # Export the system locale directory to the I18N module. The locale directory
+ # is only installed if NO_GETTEXT is set.
+ $Git::I18N::TEXTDOMAINDIR = __git_system_path('@@LOCALEDIR_REL@@');
+}
+
+# END RUNTIME_PREFIX generated code.