]> git.ipfire.org Git - thirdparty/git.git/blob - perl/header_templates/runtime_prefix.template.pl
completion: nounset mode fixes
[thirdparty/git.git] / perl / header_templates / runtime_prefix.template.pl
1 # BEGIN RUNTIME_PREFIX generated code.
2 #
3 # This finds our Git::* libraries relative to the script's runtime path.
4 sub __git_system_path {
5 my ($relpath) = @_;
6 my $gitexecdir_relative = '@@GITEXECDIR_REL@@';
7
8 # GIT_EXEC_PATH is supplied by `git` or the test suite.
9 my $exec_path;
10 if (exists $ENV{GIT_EXEC_PATH}) {
11 $exec_path = $ENV{GIT_EXEC_PATH};
12 } else {
13 # This can happen if this script is being directly invoked instead of run
14 # by "git".
15 require FindBin;
16 $exec_path = $FindBin::Bin;
17 }
18
19 # Trim off the relative gitexecdir path to get the system path.
20 (my $prefix = $exec_path) =~ s/\Q$gitexecdir_relative\E$//;
21
22 require File::Spec;
23 return File::Spec->catdir($prefix, $relpath);
24 }
25
26 BEGIN {
27 use lib split /@@PATHSEP@@/,
28 (
29 $ENV{GITPERLLIB} ||
30 do {
31 my $perllibdir = __git_system_path('@@PERLLIBDIR_REL@@');
32 (-e $perllibdir) || die("Invalid system path ($relpath): $path");
33 $perllibdir;
34 }
35 );
36
37 # Export the system locale directory to the I18N module. The locale directory
38 # is only installed if NO_GETTEXT is set.
39 $Git::I18N::TEXTDOMAINDIR = __git_system_path('@@LOCALEDIR_REL@@');
40 }
41
42 # END RUNTIME_PREFIX generated code.