This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=23322f43e80ce0c67a361b3b00c680e170fee58f

commit 23322f43e80ce0c67a361b3b00c680e170fee58f
Author: Guillem Jover <guil...@debian.org>
AuthorDate: Mon Jul 23 12:02:38 2018 +0200

    Dpkg::Build::Types: Add new set_build_type_from_targets() function
---
 debian/changelog            |  1 +
 scripts/Dpkg/Build/Types.pm | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index 700f69715..059de6ed5 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -109,6 +109,7 @@ dpkg (1.19.1) UNRELEASED; urgency=medium
       last 4KiB of the file instead of using «tail -n40», which should be
       both faster and more portable, as the default tail(1) is not POSIX
       compliant on all systems (c.f. Solaris).
+    - Dpkg::Build::Types: Add new set_build_type_from_targets() function.
   * Documentation:
     - Update gettext minimal version in README.
     - Add a missing dot on the dpkg-buildflags(1) «lfs» feature paragraph.
diff --git a/scripts/Dpkg/Build/Types.pm b/scripts/Dpkg/Build/Types.pm
index b6c2366f3..9fd0344df 100644
--- a/scripts/Dpkg/Build/Types.pm
+++ b/scripts/Dpkg/Build/Types.pm
@@ -33,6 +33,7 @@ our @EXPORT = qw(
     build_is
     set_build_type
     set_build_type_from_options
+    set_build_type_from_targets
     get_build_options_from_type
 );
 
@@ -108,6 +109,15 @@ my %build_types = (
     any => BUILD_ARCH_DEP,
     all => BUILD_ARCH_INDEP,
 );
+my %build_targets = (
+    'clean' => BUILD_SOURCE,
+    'build' => BUILD_BINARY,
+    'build-arch' => BUILD_ARCH_DEP,
+    'build-indep' => BUILD_ARCH_INDEP,
+    'binary' => BUILD_BINARY,
+    'binary-arch' => BUILD_ARCH_DEP,
+    'binary-indep' => BUILD_ARCH_INDEP,
+);
 
 =back
 
@@ -217,6 +227,28 @@ sub set_build_type_from_options
     set_build_type($build_type, $build_option, %opts);
 }
 
+=item set_build_type_from_targets($build_targets, $build_option, %opts)
+
+Set the current build type from a list of comma-separated build target
+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_targets
+{
+    my ($build_targets, $build_option, %opts) = @_;
+
+    my $build_type = 0;
+    foreach my $target (split /,/, $build_targets) {
+        $build_type |= $build_targets{$target} // BUILD_BINARY;
+    }
+
+    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.

-- 
Dpkg.Org's dpkg

Reply via email to