diff --git a/Changes b/Changes index d840758..0472fb4 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,8 @@ Revision history for {{$dist->name}} {{$NEXT}} + - Add DESTDIR prefix hack. See issue + for more information. 0.05 2023-10-29 15:08:30-04:00 America/New_York - Deprecate interpolation of `%{meson}`. diff --git a/README.md b/README.md index b4f95c2..a089ea8 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/lib/Alien/Meson.pm b/lib/Alien/Meson.pm index ef1afed..dd7d59a 100644 --- a/lib/Alien/Meson.pm +++ b/lib/Alien/Meson.pm @@ -6,6 +6,7 @@ use base qw( Alien::Base ); use 5.008004; use Path::Tiny; +use Alien::Build::Util qw( _destdir_prefix ); =head1 NAME @@ -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 and prefix are joined to follow the +approach that Meson takes. See issue at L +for more information. + +B: 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 . + *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