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 is_{system|share}_install methods #420

Merged
merged 1 commit into from
Oct 25, 2024
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
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,22 @@ This will return the install type. (See the like named install property
above for details). This method will call `probe` if it has not already
been called.

## is\_system\_install

```perl
my $boolean = $build->is_system_install;
```

Returns true if the alien is a system install type.

## is\_share\_install

```perl
my $boolean = $build->is_share_install;
```

Returns true if the alien is a share install type.

## download\_rule

```perl
Expand Down
41 changes: 39 additions & 2 deletions lib/Alien/Base.pm
Original file line number Diff line number Diff line change
Expand Up @@ -455,8 +455,15 @@ sub version_cmp {
my $bool = Alien::MyLibrary->install_type($install_type);

Returns the install type that was used when C<Alien::MyLibrary> was
installed. If a type is provided (the second form in the synopsis)
returns true if the actual install type matches. Types include:
installed.

If a type is provided (the second form in the synopsis)
returns true if the actual install type matches.
For this use case it is recommended to use C<is_system_install>
or C<is_share_install> instead as these are less prone to
typographical errors.

Types include:

=over 4

Expand All @@ -480,6 +487,36 @@ sub install_type {
return @_ ? $type eq $_[0] : $type;
}


=head2 is_system_install

my $type = $build->is_system_install;

Returns true if the alien is a system install type.

=cut

sub is_system_install
{
my($self) = @_;
$self->install_type('system');
}

=head2 is_share_install

my $type = $build->is_share_install;

Returns true if the alien is a share install type.

=cut

sub is_share_install
{
my($self) = @_;
$self->install_type('share');
}


sub _pkgconfig_keyword {
my $self = shift;
my $keyword = shift;
Expand Down
31 changes: 31 additions & 0 deletions lib/Alien/Build.pm
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,8 @@ sub root
$root;
}

=cut

=head2 install_type

my $type = $build->install_type;
Expand All @@ -964,6 +966,35 @@ sub install_type
$self->{runtime_prop}->{install_type} ||= $self->probe;
}

=head2 is_system_install

my $boolean = $build->is_system_install;

Returns true if the alien is a system install type.

=cut

sub is_system_install
{
my($self) = @_;
$self->install_type eq 'system';
}

=head2 is_share_install

my $boolean = $build->is_share_install;

Returns true if the alien is a share install type.

=cut

sub is_share_install
{
my($self) = @_;
$self->install_type eq 'share';
}


=head2 download_rule

my $rule = $build->download_rule;
Expand Down
4 changes: 4 additions & 0 deletions t/alien_base.t
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ subtest 'Alien::Build system' => sub {
is( Alien::libfoo1->install_type, 'system' );
is( Alien::libfoo1->install_type('system'), T() );
is( Alien::libfoo1->install_type('share'), F() );
is( Alien::libfoo1->is_system_install, T() );
is( Alien::libfoo1->is_share_install, F() );
};

is( Alien::libfoo1->config('name'), 'foo', 'config.name' );
Expand Down Expand Up @@ -253,6 +255,8 @@ subtest 'Alien::Build share' => sub {
is( Alien::libfoo2->install_type, 'share' );
is( Alien::libfoo2->install_type('system'), F() );
is( Alien::libfoo2->install_type('share'), T() );
is( Alien::libfoo2->is_system_install, F() );
is( Alien::libfoo2->is_share_install, T() );
};

is( Alien::libfoo2->config('name'), 'foo', 'config.name' );
Expand Down
Loading