Skip to content

Commit

Permalink
Support for Xcode.app co-exestince and relocation
Browse files Browse the repository at this point in the history
This patch has been trimmed down significantly from its original version
when rebasing on top of git 2.18 because git 2.18 included support for
runtime prefix support for darwin, making this patch mostly duplicative.

The remaining changes are needed to ensure that git-perl can find the
subversion perl module (which relocates with it) and handle relocation
of python scripts.

Signed-off-by: Jeremy Huddleston Sequoia <[email protected]>
  • Loading branch information
jeremyhu committed Feb 27, 2023
1 parent 128eccd commit 9b30433
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2540,6 +2540,7 @@ GIT-PERL-HEADER: $(PERL_HEADER_TEMPLATE) GIT-PERL-DEFINES Makefile
sed -e 's=@@PATHSEP@@=$(pathsep)=g' \
-e "s=@@INSTLIBDIR@@=$$INSTLIBDIR=g" \
-e 's=@@PERLLIBDIR_REL@@=$(perllibdir_relative_SQ)=g' \
-e 's=@@PERLVERSION@@=$(shell grep DEFAULT /usr/local/versioner/perl/versions | sed 's:^.*= *\([^ ]*\)$$:\1:')=g' \
-e 's=@@GITEXECDIR_REL@@=$(gitexecdir_relative_SQ)=g' \
-e 's=@@LOCALEDIR_REL@@=$(localedir_relative_SQ)=g' \
$< >$@+ && \
Expand Down Expand Up @@ -2571,6 +2572,8 @@ $(SCRIPT_PYTHON_GEN): GIT-CFLAGS GIT-PREFIX GIT-PYTHON-VARS
$(SCRIPT_PYTHON_GEN): % : %.py
$(QUIET_GEN) \
sed -e '1s|#!.*python|#!$(PYTHON_PATH_SQ)|' \
-e 's|\(os\.getenv("GITPYTHONLIB"\)[^)]*)|\1,"@@INSTLIBDIR@@")|' \
-e 's|"@@INSTLIBDIR@@"|os.path.realpath(os.path.dirname(sys.argv[0])) + "/../../share/git-core/python"|g' \
$< >$@+ && \
chmod +x $@+ && \
mv $@+ $@
Expand Down
25 changes: 25 additions & 0 deletions perl/header_templates/runtime_prefix.template.pl
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
# BEGIN XCODE RUNTIME_PREFIX generated code
BEGIN {
use File::Spec;
my $PERLVERSION = "@@PERLVERSION@@";
if ($^V =~ m/v([0-9]+).([0-9]+)/) {
$PERLVERSION = $1.".".$2;
}
my $__prefix = File::Spec->rel2abs( __FILE__ );

if ($__prefix =~ m/\/libexec\/git-core\// ) {
$__prefix =~ s/\/libexec\/git-core\/.*//;
unshift @INC, $__prefix . "/share/git-core/perl";
unshift @INC, $__prefix . "/../Library/Perl/".$PERLVERSION."/darwin-thread-multi-2level";
} elsif ($__prefix =~ m/\/bin\// ) {
$__prefix =~ s/\/bin\/.*//;
unshift @INC, $__prefix . "/share/git-core/perl";
unshift @INC, $__prefix . "/../Library/Perl/".$PERLVERSION."/darwin-thread-multi-2level";
} elsif ( $__prefix =~ m/\/usr\// ) {
$__prefix =~ s/\/usr\/.*/\/usr/;
unshift @INC, $__prefix . "/share/git-core/perl";
unshift @INC, $__prefix . "/../Library/Perl/".$PERLVERSION."/darwin-thread-multi-2level";
}
}
# END XCODE RUNTIME_PREFIX generated code.

# BEGIN RUNTIME_PREFIX generated code.
#
# This finds our Git::* libraries relative to the script's runtime path.
Expand Down
3 changes: 3 additions & 0 deletions t/test-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1513,6 +1513,9 @@ fi

GITPERLLIB="$GIT_BUILD_DIR"/perl/build/lib
export GITPERLLIB
PERL_VERSION=$(grep DEFAULT /usr/local/versioner/perl/versions | sed 's:^.*= *\([^ ]*\)$:\1:')
PERL5LIB="$GIT_BUILD_DIR"/perl:"$(xcode-select -p)"/Library/Perl/$PERL_VERSION
export PERL5LIB
test -d "$GIT_BUILD_DIR"/templates/blt || {
BAIL_OUT "You haven't built things yet, have you?"
}
Expand Down

0 comments on commit 9b30433

Please sign in to comment.