Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/config Add a "package" keyword, which makes it some...



details:   https://anonhg.NetBSD.org/src/rev/29e26cf05dac
branches:  trunk
changeset: 539481:29e26cf05dac
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Sun Nov 17 23:36:19 2002 +0000

description:
Add a "package" keyword, which makes it somewhat easier to add 3rd
party software packages to the kernel.  The statment:

package "../path/to/some/directory/files.package"

is equivalent to the sequence:

prefix "../path/to/some/directory"
include "files.package"
prefix

diffstat:

 usr.sbin/config/defs.h |   3 ++-
 usr.sbin/config/gram.y |  10 +++++++---
 usr.sbin/config/scan.l |  33 ++++++++++++++++++++++++++++++++-
 3 files changed, 41 insertions(+), 5 deletions(-)

diffs (118 lines):

diff -r 088d121767ca -r 29e26cf05dac usr.sbin/config/defs.h
--- a/usr.sbin/config/defs.h    Sun Nov 17 22:53:46 2002 +0000
+++ b/usr.sbin/config/defs.h    Sun Nov 17 23:36:19 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: defs.h,v 1.8 2002/10/09 20:17:00 thorpej Exp $ */
+/*     $NetBSD: defs.h,v 1.9 2002/11/17 23:36:19 thorpej Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -476,6 +476,7 @@
 /* scan.l */
 int    currentline(void);
 int    firstfile(const char *);
+void   package(const char *);
 int    include(const char *, int, int, int);
 
 /* sem.c, other than for yacc actions */
diff -r 088d121767ca -r 29e26cf05dac usr.sbin/config/gram.y
--- a/usr.sbin/config/gram.y    Sun Nov 17 22:53:46 2002 +0000
+++ b/usr.sbin/config/gram.y    Sun Nov 17 23:36:19 2002 +0000
@@ -1,5 +1,5 @@
 %{
-/*     $NetBSD: gram.y,v 1.38 2002/10/11 01:48:25 thorpej Exp $        */
+/*     $NetBSD: gram.y,v 1.39 2002/11/17 23:36:19 thorpej Exp $        */
 
 /*
  * Copyright (c) 1992, 1993
@@ -104,8 +104,8 @@
 %token AND AT ATTACH BUILD CINCLUDE COMPILE_WITH CONFIG DEFFS DEFINE DEFOPT 
 %token DEFPARAM DEFFLAG DEFPSEUDO DEVICE DEVCLASS DUMPS ENDFILE XFILE XOBJECT
 %token FILE_SYSTEM FLAGS IDENT INCLUDE XMACHINE MAJOR MAKEOPTIONS
-%token MAXUSERS MAXPARTITIONS MINOR ON OPTIONS PREFIX PSEUDO_DEVICE ROOT
-%token SOURCE TYPE WITH NEEDS_COUNT NEEDS_FLAG NO BLOCK CHAR DEVICE_MAJOR
+%token MAXUSERS MAXPARTITIONS MINOR ON OPTIONS PACKAGE PREFIX PSEUDO_DEVICE
+%token ROOT SOURCE TYPE WITH NEEDS_COUNT NEEDS_FLAG NO BLOCK CHAR DEVICE_MAJOR
 %token <val> NUMBER
 %token <str> PATHNAME QSTRING WORD EMPTY
 %token ENDDEFS
@@ -245,6 +245,9 @@
        INCLUDE filename                { (void) include($2, 0, 0, 1); } |
        CINCLUDE filename               { (void) include($2, 0, 1, 1); };
 
+package:
+       PACKAGE filename                { package($2); };
+
 prefix:
        PREFIX filename                 { prefix_push($2); } |
        PREFIX                          { prefix_pop(); };
@@ -267,6 +270,7 @@
        object |
        device_major                    { do_devsw = 1; } |
        include |
+       package |
        prefix |
        DEVCLASS WORD                   { (void)defattr($2, NULL, NULL, 1); } |
        DEFFS fsoptfile_opt deffses     { deffilesystem($2, $3); } |
diff -r 088d121767ca -r 29e26cf05dac usr.sbin/config/scan.l
--- a/usr.sbin/config/scan.l    Sun Nov 17 22:53:46 2002 +0000
+++ b/usr.sbin/config/scan.l    Sun Nov 17 23:36:19 2002 +0000
@@ -1,5 +1,5 @@
 %{
-/*     $NetBSD: scan.l,v 1.35 2002/11/07 21:06:04 jrf Exp $    */
+/*     $NetBSD: scan.l,v 1.36 2002/11/17 23:36:20 thorpej Exp $        */
 
 /*
  * Copyright (c) 1992, 1993
@@ -47,6 +47,7 @@
 
 #include <sys/param.h>
 #include <errno.h>
+#include <libgen.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -119,6 +120,7 @@
 object         return XOBJECT;
 on             return ON;
 options                return OPTIONS;
+package                return PACKAGE;
 prefix         return PREFIX;
 pseudo-device  return PSEUDO_DEVICE;
 root           return ROOT;
@@ -210,6 +212,35 @@
 }
 
 /*
+ * Add a "package" to the configuration.  This is essentially
+ * syntactic sugar around the sequence:
+ *
+ *     prefix ../some/directory
+ *     include "files.package"
+ *     prefix
+ */
+void
+package(const char *fname)
+{
+       char *fname1 = estrdup(fname);
+       char *fname2 = estrdup(fname);
+       char *dir = dirname(fname1);
+       char *file = basename(fname2);
+
+       /*
+        * Push the prefix on to the prefix stack and process the include
+        * file.  When we reach the end of the include file, inserting
+        * the PREFIX token into the input stream will pop the prefix off
+        * of the prefix stack.
+        */
+       prefix_push(dir);
+       (void) include(file, PREFIX, 0, 1);
+
+       free(fname1);
+       free(fname2);
+}
+
+/*
  * Open the named file for inclusion at the current point.  Returns 0 on
  * success (file opened and previous state pushed), nonzero on failure
  * (fopen failed, complaint made).  The `ateof' parameter controls the



Home | Main Index | Thread Index | Old Index