Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DESTDIR prefix hack #15

Merged
merged 1 commit into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Revision history for {{$dist->name}}

{{$NEXT}}
- Add DESTDIR prefix hack. See issue <https://github.com/PerlAlien/Alien-Build/issues/407>
for more information.

0.05 2023-10-29 15:08:30-04:00 America/New_York
- Deprecate interpolation of `%{meson}`.
Expand Down
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,24 @@ for the use of other modules.

Returns the command name for running meson.

## \_apply\_destdir\_prefix\_hack

use alienfile;

eval {
require Alien::Meson;
Alien::Meson->_apply_destdir_prefix_hack;
};

share { ... }

Applies a hack to fix how the `DESTDIR` and prefix are joined to follow the
approach that Meson takes. See issue at [https://github.com/PerlAlien/Alien-Build/issues/407](https://github.com/PerlAlien/Alien-Build/issues/407)
for more information.

**WARNING**: This is a hack. It is not expected to work long-term and if a
better solution is possible, it will be deprecated then removed.

# HELPERS

## meson
Expand Down
36 changes: 36 additions & 0 deletions lib/Alien/Meson.pm
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use base qw( Alien::Base );
use 5.008004;

use Path::Tiny;
use Alien::Build::Util qw( _destdir_prefix );

=head1 NAME

Expand Down Expand Up @@ -89,6 +90,41 @@ sub bin_dir {
}
}

=head2 _apply_destdir_prefix_hack

use alienfile;

eval {
require Alien::Meson;
Alien::Meson->_apply_destdir_prefix_hack;
};

share { ... }

Applies a hack to fix how the C<DESTDIR> and prefix are joined to follow the
approach that Meson takes. See issue at L<https://github.com/PerlAlien/Alien-Build/issues/407>
for more information.

B<WARNING>: This is a hack. It is not expected to work long-term and if a
better solution is possible, it will be deprecated then removed.

=cut

sub _apply_destdir_prefix_hack {
my ($class) = @_;
no warnings "redefine";
# Work around for Meson's `destdir_join` which drops the first part of
# the path when joining (this is the drive letter).
# See <https://github.com/mesonbuild/meson/blob/1.2.3/mesonbuild/scripts/__init__.py>.
*Alien::Build::Util::_destdir_prefix = \&_meson_destdir_prefix;
}

sub _meson_destdir_prefix {
my($destdir, $prefix) = @_;
$prefix =~ s{^/?([a-z]):}{}i if $^O eq 'MSWin32';
path($destdir)->child($prefix)->stringify;
}

=head1 HELPERS

=head2 meson
Expand Down
Loading