Source-Changes-HG archive

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

[src/trunk]: src config(1), config(5): Introduce "select"



details:   https://anonhg.NetBSD.org/src/rev/aa7dc0a22c03
branches:  trunk
changeset: 333374:aa7dc0a22c03
user:      uebayasi <uebayasi%NetBSD.org@localhost>
date:      Fri Oct 31 07:38:36 2014 +0000

description:
config(1), config(5): Introduce "select"

o Introduce a new selection directive "select" to select an attribute (as a
  module) and its dependencies.
o Support "no select" too.
o Stop abusing "options" to select an attribute.
o Bump config(1) version.

diffstat:

 sys/conf/files                          |   4 +-
 sys/conf/std                            |   8 +-
 tests/usr.bin/config/support/conf/files |   9 +++
 tests/usr.bin/config/t_config.sh        |  82 ++++++++++++++++++++++++++------
 usr.bin/config/config.5                 |  14 ++++-
 usr.bin/config/defs.h                   |   4 +-
 usr.bin/config/gram.y                   |  16 +++++-
 usr.bin/config/main.c                   |  11 +---
 usr.bin/config/scan.l                   |   5 +-
 usr.bin/config/sem.c                    |  44 ++++++++++++++++-
 usr.bin/config/sem.h                    |   5 +-
 11 files changed, 156 insertions(+), 46 deletions(-)

diffs (truncated from 462 to 300 lines):

diff -r 37dc81041a67 -r aa7dc0a22c03 sys/conf/files
--- a/sys/conf/files    Fri Oct 31 04:54:17 2014 +0000
+++ b/sys/conf/files    Fri Oct 31 07:38:36 2014 +0000
@@ -1,7 +1,7 @@
-#      $NetBSD: files,v 1.1120 2014/10/12 04:30:42 uebayasi Exp $
+#      $NetBSD: files,v 1.1121 2014/10/31 07:38:36 uebayasi Exp $
 #      @(#)files.newconf       7.5 (Berkeley) 5/10/93
 
-version        20141010
+version        20141030
 
 #
 # device classes
diff -r 37dc81041a67 -r aa7dc0a22c03 sys/conf/std
--- a/sys/conf/std      Fri Oct 31 04:54:17 2014 +0000
+++ b/sys/conf/std      Fri Oct 31 07:38:36 2014 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: std,v 1.19 2014/10/10 12:46:32 uebayasi Exp $
+# $NetBSD: std,v 1.20 2014/10/31 07:38:36 uebayasi Exp $
 #
 # standard MI 'options'
 #
@@ -9,7 +9,9 @@
 # Always include "kern" attribute (module).  Other attributes don't need to
 # depend on "kern".
 #
-options        KERN
+select kern
+
+select net             # XXX Clean up dependency
 
 # the following options are on-by-default to keep
 # kernel config file compatibility.
@@ -22,8 +24,6 @@
 options        AIO             # POSIX asynchronous I/O
 options        MQUEUE          # POSIX message queues
 
-options        NET             # XXX Clean up dependency
-
 #
 # Security model.
 #
diff -r 37dc81041a67 -r aa7dc0a22c03 tests/usr.bin/config/support/conf/files
--- a/tests/usr.bin/config/support/conf/files   Fri Oct 31 04:54:17 2014 +0000
+++ b/tests/usr.bin/config/support/conf/files   Fri Oct 31 07:38:36 2014 +0000
@@ -24,3 +24,12 @@
 attach loopbaby at loopchild
 
 defpseudo      pseudodev: hook
+
+define a
+file   a.c     a
+
+define b: a
+file   b.c     b
+
+define c: b
+file   c.c     c
diff -r 37dc81041a67 -r aa7dc0a22c03 tests/usr.bin/config/t_config.sh
--- a/tests/usr.bin/config/t_config.sh  Fri Oct 31 04:54:17 2014 +0000
+++ b/tests/usr.bin/config/t_config.sh  Fri Oct 31 07:38:36 2014 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_config.sh,v 1.3 2014/10/31 04:54:17 uebayasi Exp $
+# $NetBSD: t_config.sh,v 1.4 2014/10/31 07:38:36 uebayasi Exp $
 #
 # Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -62,6 +62,22 @@
            config -s "${supportdir}" -b "compile/${name}" "${config}"
 }
 
+test_output()
+{
+       local name="${1}"; shift
+       local res=1
+
+       run_and_check_prep "${name}"
+
+       config -s "${supportdir}" -b compile/"${name}" "${config}" >/dev/null &&
+       cd compile/"${name}" &&
+       check_${name} &&
+       cd $OLDPWD &&
+       res=0
+
+       atf_check test $res -eq 0
+}
+
 # Defines a test case for config(1).
 test_case()
 {
@@ -108,7 +124,50 @@
 test_case no_undefined_opt pass \
     "Checks that config allows a negation for an undefined options"
 
+# Attribute selection
+test_case select pass "Attribute selection"
+select_config_str='
+include "../d_min"
+select c
+'
+check_select()
+{
+       local f=Makefile
+
+       grep -q '^a\.o:' $f &&
+       grep -q '^b\.o:' $f &&
+       grep -q '^c\.o:' $f &&
+       :
+}
+select_body() {
+       test_output select
+}
+
+# Attribute negation
+test_case no_select pass "Attribute negation"
+no_select_config_str='
+include "../d_min"
+select c
+no select a
+'
+check_no_select()
+{
+       local f=Makefile
+
+       : >tmp
+       grep -q '^a\.o:' $f >>tmp
+       grep -q '^b\.o:' $f >>tmp
+       grep -q '^c\.o:' $f >>tmp
+
+       [ ! -s tmp ] &&
+       :
+}
+no_select_body() {
+       test_output no_select
+}
+
 # Check minimal kernel config(1) output
+test_case min pass "Minimal config"
 check_min_files()
 {
        test -e Makefile &&
@@ -122,7 +181,6 @@
        test -h regress &&
        :
 }
-
 check_min_makefile()
 {
        local f=Makefile
@@ -136,26 +194,14 @@
        [ ! -s tmp.template ] &&
        :
 }
-
-test_min()
+check_min()
 {
-       local res=1
-
-       run_and_check_prep min
-
-       config -s "${supportdir}" -b compile/min "${config}" >/dev/null &&
-       cd compile/min &&
        check_min_files &&
        check_min_makefile &&
-       cd $OLDPWD &&
-       res=0
-
-       atf_check test $res -eq 0
+       :
 }
-
-test_case min pass "Minimal config"
 min_body() {
-       test_min
+       test_output min
 }
 
 atf_init_test_cases()
@@ -169,5 +215,7 @@
        atf_add_test_case deffs_redef
        atf_add_test_case undefined_opt
        atf_add_test_case no_undefined_opt
+       atf_add_test_case select
+       atf_add_test_case no_select
        atf_add_test_case min
 }
diff -r 37dc81041a67 -r aa7dc0a22c03 usr.bin/config/config.5
--- a/usr.bin/config/config.5   Fri Oct 31 04:54:17 2014 +0000
+++ b/usr.bin/config/config.5   Fri Oct 31 07:38:36 2014 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: config.5,v 1.24 2014/05/29 08:13:17 wiz Exp $
+.\" $NetBSD: config.5,v 1.25 2014/10/31 07:38:36 uebayasi Exp $
 .\"
 .\"  Copyright (c) 2006, 2007 The NetBSD Foundation.
 .\"  All rights reserved.
@@ -24,7 +24,7 @@
 .\"  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\"  POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd May 29, 2014
+.Dd October 30, 2014
 .Dt CONFIG 5
 .Os
 .Sh NAME
@@ -620,8 +620,10 @@
 If option
 .Ar name
 has not been previously selected, the statement produces an error.
-.It Oo Ic no Oc Ic file-system Ar name Op , Ar name Op , Ar ...
-Adds or removes support for all the listed file-systems.
+.It Ic file-system Ar name Op , Ar name Op , Ar ...
+Adds support for all the listed file-systems.
+.It Ic no file-system Ar name Op , Ar name Op , Ar ...
+Removes support for all the listed file-systems.
 .It Ic config Ar name Ic root on Ar device Oo Ic type Ar fs Oc Op Ic dumps on \
     Ar device
 Adds
@@ -696,6 +698,10 @@
 .It Ic no makeoptions Ar name Op , Ar name Op , Ar ...
 Removes one or more definitions from the generated
 .Pa Makefile .
+.It Ic select Ar name
+Adds the specified attribute and its dependencies.
+.It Ic no select Ar name
+Removes the specified attribute and all the attributes which depend on it.
 .El
 .Sh FILES
 The files are relative to the kernel source top directory (e.g.,
diff -r 37dc81041a67 -r aa7dc0a22c03 usr.bin/config/defs.h
--- a/usr.bin/config/defs.h     Fri Oct 31 04:54:17 2014 +0000
+++ b/usr.bin/config/defs.h     Fri Oct 31 07:38:36 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: defs.h,v 1.59 2014/10/29 17:14:50 christos Exp $       */
+/*     $NetBSD: defs.h,v 1.60 2014/10/31 07:38:36 uebayasi Exp $       */
 
 /*
  * Copyright (c) 1992, 1993
@@ -107,7 +107,7 @@
  * The next two lines define the current version of the config(1) binary,
  * and the minimum version of the configuration files it supports.
  */
-#define CONFIG_VERSION         20141010
+#define CONFIG_VERSION         20141030
 #define CONFIG_MINVERSION      0
 
 /*
diff -r 37dc81041a67 -r aa7dc0a22c03 usr.bin/config/gram.y
--- a/usr.bin/config/gram.y     Fri Oct 31 04:54:17 2014 +0000
+++ b/usr.bin/config/gram.y     Fri Oct 31 07:38:36 2014 +0000
@@ -1,5 +1,5 @@
 %{
-/*     $NetBSD: gram.y,v 1.44 2014/10/29 17:14:50 christos Exp $       */
+/*     $NetBSD: gram.y,v 1.45 2014/10/31 07:38:36 uebayasi Exp $       */
 
 /*
  * Copyright (c) 1992, 1993
@@ -42,7 +42,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: gram.y,v 1.44 2014/10/29 17:14:50 christos Exp $");
+__RCSID("$NetBSD: gram.y,v 1.45 2014/10/31 07:38:36 uebayasi Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -181,7 +181,7 @@
 %token XOBJECT OBSOLETE ON OPTIONS
 %token PACKAGE PLUSEQ PREFIX PSEUDO_DEVICE PSEUDO_ROOT
 %token ROOT
-%token SINGLE SOURCE
+%token SELECT SINGLE SOURCE
 %token TYPE
 %token VECTOR VERSION
 %token WITH
@@ -705,6 +705,8 @@
 /* One config item. */
 selection:
          definition
+       | select_attr
+       | select_no_attr
        | select_no_filesystems
        | select_filesystems
        | select_no_makeoptions
@@ -725,6 +727,14 @@
        | select_device_instance
 ;
 
+select_attr:
+       SELECT WORD                     { addattr($2); }
+;
+
+select_no_attr:
+       NO SELECT WORD                  { delattr($3); }
+;
+
 select_no_filesystems:
        NO FILE_SYSTEM no_fs_list
 ;
diff -r 37dc81041a67 -r aa7dc0a22c03 usr.bin/config/main.c



Home | Main Index | Thread Index | Old Index