Commit 683811f8 authored by Michael Pyne's avatar Michael Pyne
Browse files

modularize: Move ksb::PhaseList to separate file.

This PhaseList was one of the first modules added as part of the
refactoring effort, but I don't think it has ended up very useful (or at
least not as I had designed).

This move also required fixing ksb::BuildContext which had not 'use'd
ksb::PhaseList before, it had worked by accident.
parent 2ee3d30e
......@@ -90,60 +90,6 @@ my $run_mode = 'build'; # Determines if updating, building, installing, etc.
# }}}
# package ksb::PhaseList {{{
{
# Handles the "phases" for kdesrc-build, e.g. a simple list of phases,
# and methods to add, clear, or filter out phases.
package ksb::PhaseList;
use ksb::Util;
# Constructor. Passed in values are the initial phases in this set.
sub new
{
my ($class, @args) = @_;
return bless [@args], $class;
}
# Filters out the given phase from the current list of phases.
sub filterOutPhase
{
my ($self, $phase) = @_;
@{$self} = grep { $_ ne $phase } @{$self};
}
# Adds the requested phase to the list of phases to build.
sub addPhase
{
my ($self, $phase) = @_;
push @{$self}, $phase unless list_has([@{$self}], $phase);
}
# Returns true if the given phase name is present in this list.
sub has
{
my ($self, $phase) = @_;
return grep { $_ eq $phase } (@{$self});
}
# Get/sets number of phases depending on whether any are passed in.
sub phases
{
my ($self, @args) = @_;
@$self = @args if scalar @args;
return @$self;
}
sub clear
{
my $self = shift;
splice @$self;
}
1;
}
# }}}
# package ksb::BuildContext {{{
{
# This contains the information needed about the build context, e.g.
......@@ -163,6 +109,7 @@ my $run_mode = 'build'; # Determines if updating, building, installing, etc.
use ksb::Debug;
use ksb::Util;
use ksb::PhaseList;
my @DefaultPhases = qw/update build install/;
my @rcfiles = ("./kdesrc-buildrc", "$ENV{HOME}/.kdesrc-buildrc");
......
package ksb::PhaseList;
# Handles the "phases" for kdesrc-build, e.g. a simple list of phases,
# and methods to add, clear, or filter out phases.
use strict;
use warnings;
use v5.10;
use ksb::Util;
# Constructor. Passed in values are the initial phases in this set.
sub new
{
my ($class, @args) = @_;
return bless [@args], $class;
}
# Filters out the given phase from the current list of phases.
sub filterOutPhase
{
my ($self, $phase) = @_;
@{$self} = grep { $_ ne $phase } @{$self};
}
# Adds the requested phase to the list of phases to build.
sub addPhase
{
my ($self, $phase) = @_;
push @{$self}, $phase unless list_has([@{$self}], $phase);
}
# Returns true if the given phase name is present in this list.
sub has
{
my ($self, $phase) = @_;
return grep { $_ eq $phase } (@{$self});
}
# Get/sets number of phases depending on whether any are passed in.
sub phases
{
my ($self, @args) = @_;
@$self = @args if scalar @args;
return @$self;
}
sub clear
{
my $self = shift;
splice @$self;
}
1;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment