summaryrefslogtreecommitdiff
path: root/scripts/Dpkg/Build/Types.pm
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2016-04-03 19:45:14 +0200
committerGuillem Jover <guillem@debian.org>2016-05-02 04:03:19 +0200
commitbc2068676fe68ff4080ddee254622ee689ad28ac (patch)
tree6b1b61c7d128cbacc06bd6859d5a6cbb5f7f4f75 /scripts/Dpkg/Build/Types.pm
parente731c1fcca81470e08f81ded165243bc5f05f8d0 (diff)
downloaddpkg-bc2068676fe68ff4080ddee254622ee689ad28ac.tar.gz
scripts: Add support for new --build option to define build type
This simplifies the way to select what to build, and makes it both easier to remember, and easier to deal with in the code. The current set of split single options are really a mess.
Diffstat (limited to 'scripts/Dpkg/Build/Types.pm')
-rw-r--r--scripts/Dpkg/Build/Types.pm54
1 files changed, 53 insertions, 1 deletions
diff --git a/scripts/Dpkg/Build/Types.pm b/scripts/Dpkg/Build/Types.pm
index 7f6f1bc65..9a921fa0b 100644
--- a/scripts/Dpkg/Build/Types.pm
+++ b/scripts/Dpkg/Build/Types.pm
@@ -19,7 +19,7 @@ package Dpkg::Build::Types;
use strict;
use warnings;
-our $VERSION = '0.01';
+our $VERSION = '0.02';
our @EXPORT = qw(
BUILD_DEFAULT
BUILD_SOURCE
@@ -32,6 +32,8 @@ our @EXPORT = qw(
build_has_none
build_is
set_build_type
+ set_build_type_from_options
+ get_build_options_from_type
);
use Exporter qw(import);
@@ -98,6 +100,15 @@ use constant BUILD_FULL => BUILD_BINARY | BUILD_SOURCE;
my $current_type = BUILD_FULL | BUILD_DEFAULT;
my $current_option = undef;
+my @build_types = qw(source any all);
+my %build_types = (
+ full => BUILD_FULL,
+ source => BUILD_SOURCE,
+ any => BUILD_ARCH_DEP,
+ all => BUILD_ARCH_INDEP,
+ binary => BUILD_BINARY,
+);
+
=back
=head1 FUNCTIONS
@@ -182,6 +193,47 @@ sub set_build_type
$current_option = $build_option;
}
+=item set_build_type_from_options($build_type, $build_option, %opts)
+
+Set the current build type from a list of build type components.
+
+The function will check and abort on incompatible build type assignments,
+this behavior can be disabled by using the boolean option "nocheck".
+
+=cut
+
+sub set_build_type_from_options
+{
+ my ($build_parts, $build_option, %opts) = @_;
+
+ my $build_type = 0;
+ foreach my $type (split /,/, $build_parts) {
+ usageerr(g_('unknown build type %s'), $type)
+ unless exists $build_types{$type};
+ $build_type |= $build_types{$type};
+ }
+
+ set_build_type($build_type, $build_option, %opts);
+}
+
+=item get_build_options_from_type()
+
+Get the current build type as a set of comma-separated string options.
+
+=cut
+
+sub get_build_options_from_type
+{
+ return 'full' if build_has_all(BUILD_FULL);
+
+ my @parts;
+ foreach my $type (@build_types) {
+ push @parts, $type if build_has_all($build_types{$type});
+ }
+
+ return join ',', @parts;
+}
+
=back
=head1 CHANGES