pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc Add support for sets of options where at least one opt...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/bb18e53ba1a4
branches:  trunk
changeset: 497371:bb18e53ba1a4
user:      dillo <dillo%pkgsrc.org@localhost>
date:      Tue Jul 26 09:00:42 2005 +0000

description:
Add support for sets of options where at least one option from each
set must be selected, requested and reviewed by wiz:

PKG_OPTIONS_NONEMPTY_SETS
       This is a list of names of sets of options.  At
       least one option from each set must be selected.
       The options in each set are listed in
       PKG_OPTIONS_SET.<setname>.  Options from the sets
       will be automatically added to PKG_SUPPORTED_OPTIONS.

diffstat:

 mk/bsd.options.mk                  |  63 +++++++++++++++++++++++++++++++------
 regress/pkg-options/Makefile       |   5 +-
 regress/pkg-options/files/sets.mk  |  20 ++++++++++++
 regress/pkg-options/files/sets.out |   1 +
 4 files changed, 77 insertions(+), 12 deletions(-)

diffs (187 lines):

diff -r 9f425b71c4cd -r bb18e53ba1a4 mk/bsd.options.mk
--- a/mk/bsd.options.mk Tue Jul 26 07:55:33 2005 +0000
+++ b/mk/bsd.options.mk Tue Jul 26 09:00:42 2005 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.options.mk,v 1.44 2005/07/19 10:30:22 dillo Exp $
+# $NetBSD: bsd.options.mk,v 1.45 2005/07/26 09:00:42 dillo Exp $
 #
 # This Makefile fragment provides boilerplate code for standard naming
 # conventions for handling per-package build options.
@@ -16,7 +16,7 @@
 #              options specifically for this package.
 #
 #      PKG_OPTIONS_OPTIONAL_GROUPS
-#              This is a list names of groups of mutually exclusive
+#              This is a list of names of groups of mutually exclusive
 #              options.  The options in each group are listed in
 #              PKG_OPTIONS_GROUP.<groupname>.  The most specific
 #              setting of any option from the group takes precedence
@@ -29,6 +29,13 @@
 #              the packages will fail if no option from the group
 #              is selected.
 #
+#      PKG_OPTIONS_NONEMPTY_SETS
+#             This is a list of names of sets of options.  At
+#             least one option from each set must be selected.
+#             The options in each set are listed in
+#             PKG_OPTIONS_SET.<setname>.  Options from the sets
+#             will be automatically added to PKG_SUPPORTED_OPTIONS.
+#
 #      PKG_SUGGESTED_OPTIONS (defaults to empty)
 #              This is a list of build options which are enabled by default.
 #
@@ -52,10 +59,10 @@
 #              A list of warnings about deprecated variables or
 #              options used, and what to use instead.
 #
-#       If none of PKG_SUPPORTED_OPTIONS, PKG_OPTIONS_OPTIONAL_GROUPS,
-#      and PKG_OPTIONS_REQUIRED_GROUPS are defined, PKG_OPTIONS is
-#      set to the empty list and the package is otherwise treated as
-#      not using the options framework.
+#      If none of PKG_SUPPORTED_OPTIONS, PKG_OPTIONS_OPTIONAL_GROUPS,
+#      PKG_OPTIONS_REQUIRED_GROUPS, and PKG_OPTIONS_NONEMPTY_SETS are
+#      defined, PKG_OPTIONS is set to the empty list and the package
+#      is otherwise treated as not using the options framework.
 #              
 #
 # Optionally, the user may define the following variables in /etc/mk.conf:
@@ -145,7 +152,7 @@
 # Check for variable definitions required before including this file.
 .if !defined(PKG_OPTIONS_VAR)
 PKG_FAIL_REASON+=      "bsd.options.mk: PKG_OPTIONS_VAR is not defined."
-.elif !defined(PKG_SUPPORTED_OPTIONS) && !defined(PKG_OPTIONS_OPTIONAL_GROUPS) && !defined(PKG_OPTIONS_REQUIRED_GROUPS)
+.elif !defined(PKG_SUPPORTED_OPTIONS) && !defined(PKG_OPTIONS_OPTIONAL_GROUPS) && !defined(PKG_OPTIONS_REQUIRED_GROUPS) && !defined(PKG_OPTIONS_NONEMPTY_SETS)
 # no supported options: set PKG_OPTIONS to empty and skip rest of file
 PKG_OPTIONS=   #empty
 .else # process the rest of the file
@@ -155,6 +162,9 @@
 #
 .for _grp_ in ${PKG_OPTIONS_OPTIONAL_GROUPS} ${PKG_OPTIONS_REQUIRED_GROUPS}
 _PKG_OPTIONS_GROUP_STACK.${_grp_}:=#empty
+.if !defined(PKT_OPTION_GROUP.${_grp_}) || empty(PKT_OPTION_GROUP.${_grp_})
+PKG_FAIL_REASON:="bsd.options.mk: PKG_OPTIONS_GROUP."${_grp_:Q}" must be non-empty."
+.endif
 .  for _opt_ in ${PKG_OPTIONS_GROUP.${_grp_}}
 PKG_SUPPORTED_OPTIONS+= ${_opt_}
 _PKG_OPTIONS_GROUP_MAP.${_opt_}=${_grp_}
@@ -162,12 +172,26 @@
 .endfor
 
 #
+# add options from sets to PKG_SUPPORTED_OPTIONS
+#
+_PKG_OPTIONS_ALL_SETS:=#empty
+.for _set_ in ${PKG_OPTIONS_NONEMPTY_SETS}
+.  if !defined(PKT_OPTIONS_SET.${_set_}) || empty(PKT_OPTIONS_SET.${_set_})
+PKG_FAIL_REASON:="bsd.options.mk: PKG_OPTIONS_SET."${_set_:Q}" must be non-empty."
+.  endif
+.  for _opt_ in ${PKG_OPTIONS_SET.${_set_}}
+PKG_SUPPORTED_OPTIONS+=        ${_opt_}
+_PKG_OPTIONS_ALL_SETS+=        ${_opt_}
+.  endfor
+.endfor
+
+#
 # include deprecated variable to options mapping
 #
 .include "${.CURDIR}/../../mk/defaults/obsolete.mk"
 
 #
-# place options imlied by legacy variables in PKG_LEGACY_OPTIONS
+# place options implied by legacy variables in PKG_LEGACY_OPTIONS
 #
 .for _m_ in ${PKG_OPTIONS_LEGACY_VARS}
 _var_:=        ${_m_:C/:.*//}
@@ -278,6 +302,19 @@
 .endfor
 .undef _opt_
 
+.for _set_ in ${PKG_OPTIONS_NONEMPTY_SETS}
+_ISEMPTY:=true
+.  for _opt_ in ${PKG_OPTIONS_SET.${_set_}
+.    if !empty(PKG_OPTIONS:M${_opt_})
+_ISEMPTY:=false
+.    endif
+.  endfor
+.  if ${_ISEMPTY} == "true"
+PKG_FAIL_REASON:="At least one of the following options must be selected: "${PKG_OPTIONS_SET.${_set_}:O:u:Q}
+.  endif
+.endfor
+.undef _ISEMPTY
+
 .if !empty(_OPTIONS_UNSUPPORTED)
 PKG_FAIL_REASON:=      "The following selected options are not supported: "${_OPTIONS_UNSUPPORTED:O:u:Q}"."
 .endif
@@ -304,9 +341,9 @@
 
 .PHONY: show-options
 show-options:
-       @${ECHO} The following options are supported by this package:
+       @${ECHO} Any of the following general options may be selected:
 .for _opt_ in ${PKG_SUPPORTED_OPTIONS:O}
-.  if !defined(_PKG_OPTIONS_GROUP_MAP.${_opt_})
+.  if !defined(_PKG_OPTIONS_GROUP_MAP.${_opt_}) && empty(_PKG_OPTIONS_ALL_SETS:M${_opt_})
        @${ECHO} "      "${_opt_:Q}"    "`${SED} -n "s/^"${_opt_:Q}"    //p" ../../mk/defaults/options.description`
 .  endif
 .endfor
@@ -322,6 +359,12 @@
        @${ECHO} "      "${_opt_:Q}"    "`${SED} -n "s/^"${_opt_:Q}"    //p" ../../mk/defaults/options.description`
 .  endfor
 .endfor
+.for _set_ in ${PKG_OPTIONS_NONEMPTY_SETS}
+       @${ECHO} "At least one of the following "${_set_:Q}" options must be selected:"
+.  for _opt_ in ${PKG_OPTIONS_SET.${_set_}:O}
+       @${ECHO} "      "${_opt_:Q}"    "`${SED} -n "s/^"${_opt_:Q}"    //p" ../../mk/defaults/options.description`
+.  endfor
+.endfor
        @${ECHO}
        @${ECHO} "These options are enabled by default: "${PKG_SUGGESTED_OPTIONS:O:Q}
        @${ECHO} "These options are currently enabled: "${PKG_OPTIONS:O:Q}
diff -r 9f425b71c4cd -r bb18e53ba1a4 regress/pkg-options/Makefile
--- a/regress/pkg-options/Makefile      Tue Jul 26 07:55:33 2005 +0000
+++ b/regress/pkg-options/Makefile      Tue Jul 26 09:00:42 2005 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.5 2005/06/02 20:38:51 dillo Exp $
+# $NetBSD: Makefile,v 1.6 2005/07/26 09:00:42 dillo Exp $
 #
 
 DISTNAME=      regress-pkg-options-1.0
@@ -8,7 +8,8 @@
 MAINTAINER=    rillig%NetBSD.org@localhost
 COMMENT=       Test bsd.options.mk framework
 
-REGRESS_TESTS= all group-required groups legacy-opt order simple unsupported
+REGRESS_TESTS= all group-required groups legacy-opt order sets
+REGRESS_TESTS+=        simple unsupported
 
 do-test:
 .for t in ${REGRESS_TESTS}
diff -r 9f425b71c4cd -r bb18e53ba1a4 regress/pkg-options/files/sets.mk
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/regress/pkg-options/files/sets.mk Tue Jul 26 09:00:42 2005 +0000
@@ -0,0 +1,20 @@
+# $NetBSD: sets.mk,v 1.1 2005/07/26 09:00:42 dillo Exp $
+#
+# This file tests non-empty option sets (PKG_OPTIONS_NONEMPTY_SETS).
+#
+
+MAKECONF=                      /dev/null
+
+PKG_OPTIONS_VAR=               PKG_OPTIONS.foo
+PKG_SUPPORTED_OPTIONS=         single
+PKG_OPTIONS_NONEMPTY_SETS=     abc def
+PKG_OPTIONS_SET.abc=           a b c
+PKG_OPTIONS_SET.def=           d e f
+
+PKG_OPTIONS.foo=       a
+
+.include "../../mk/bsd.options.mk"
+
+.PHONY: test
+test:
+       echo ${PKG_FAIL_REASON:Q}
diff -r 9f425b71c4cd -r bb18e53ba1a4 regress/pkg-options/files/sets.out
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/regress/pkg-options/files/sets.out        Tue Jul 26 09:00:42 2005 +0000
@@ -0,0 +1,1 @@
+"At least one of the following options must be selected: "d\ e\ f



Home | Main Index | Thread Index | Old Index