Module Name: src Committed By: uebayasi Date: Tue Sep 1 13:42:48 UTC 2015
Modified Files: src/usr.bin/config: config.5 defs.h files.c gram.y scan.l util.c Log Message: Introduce a new syntax, "buildprefix", to specify prefix of files under kernel build subdirectory. This is not used now that everything is built at the top of kernel build directory. It will become mandatory for source/object files put out of kernel source tree to specify corresponding build subdirectory. Only ``no dots'' relative path is accepted as "buildprefix". To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/usr.bin/config/config.5 cvs rdiff -u -r1.80 -r1.81 src/usr.bin/config/defs.h cvs rdiff -u -r1.24 -r1.25 src/usr.bin/config/files.c cvs rdiff -u -r1.51 -r1.52 src/usr.bin/config/gram.y cvs rdiff -u -r1.23 -r1.24 src/usr.bin/config/scan.l cvs rdiff -u -r1.19 -r1.20 src/usr.bin/config/util.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/config/config.5 diff -u src/usr.bin/config/config.5:1.33 src/usr.bin/config/config.5:1.34 --- src/usr.bin/config/config.5:1.33 Tue Sep 1 01:50:14 2015 +++ src/usr.bin/config/config.5 Tue Sep 1 13:42:48 2015 @@ -1,4 +1,4 @@ -.\" $NetBSD: config.5,v 1.33 2015/09/01 01:50:14 pgoyette Exp $ +.\" $NetBSD: config.5,v 1.34 2015/09/01 13:42:48 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 August 31, 2015 +.Dd September 1, 2015 .Dt CONFIG 5 .Os .Sh NAME @@ -254,6 +254,7 @@ The argument obeys the same rules as for If .Ar path is given, it pushes a new prefix for +.Ic file , .Ic include and .Ic cinclude . @@ -265,6 +266,21 @@ The .Ar path argument is either absolute or relative to the current defined prefix, which defaults to the top of the kernel source tree. +.It Ic buildprefix Op Ar path +If +.Ar path +is given, it pushes a new build prefix for +.Ic file . +.Ic buildprefix +statements act like a stack, and an empty +.Ar path +argument has the latest prefix popped out. +The +.Ar path +argument is relative to the current defined buildprefix, which +defaults to the top of the kernel build directory. +When prefix is either absolute or relative out of the kernel source tree (../), +buildprefix must be defined. .It Ic ifdef Ar attribute .It Ic ifndef Ar attribute .It Ic elifdef Ar attribute Index: src/usr.bin/config/defs.h diff -u src/usr.bin/config/defs.h:1.80 src/usr.bin/config/defs.h:1.81 --- src/usr.bin/config/defs.h:1.80 Tue Sep 1 12:46:20 2015 +++ src/usr.bin/config/defs.h Tue Sep 1 13:42:48 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: defs.h,v 1.80 2015/09/01 12:46:20 uebayasi Exp $ */ +/* $NetBSD: defs.h,v 1.81 2015/09/01 13:42:48 uebayasi Exp $ */ /* * Copyright (c) 1992, 1993 @@ -346,6 +346,7 @@ struct files { const char *fi_dir; /* path to file */ const char *fi_path; /* full file path */ const char *fi_prefix; /* any file prefix */ + const char *fi_buildprefix; /* prefix in builddir */ int fi_suffix; /* single char suffix */ size_t fi_len; /* path string length */ struct condexpr *fi_optx; /* options expression */ @@ -391,6 +392,10 @@ struct condexpr { * File/object prefixes. These are arranged in a stack, and affect * the behavior of the source path. */ + +struct prefix; +SLIST_HEAD(prefixlist, prefix); + struct prefix { SLIST_ENTRY(prefix) pf_next; /* next prefix in stack */ const char *pf_prefix; /* the actual prefix */ @@ -482,8 +487,10 @@ struct filelist allcfiles; /* list of a struct filelist allsfiles; /* list of all .S files */ struct filelist allofiles; /* list of all .o files */ -SLIST_HEAD(, prefix) prefixes, /* prefix stack */ +struct prefixlist prefixes, /* prefix stack */ allprefixes; /* all prefixes used (after popped) */ +struct prefixlist buildprefixes, /* build prefix stack */ + allbuildprefixes;/* all build prefixes used (after popped) */ SLIST_HEAD(, prefix) curdirs; /* curdir stack */ extern struct attr allattr; @@ -614,6 +621,8 @@ int onlist(struct nvlist *, void *); /* util.c */ void prefix_push(const char *); void prefix_pop(void); +void buildprefix_push(const char *); +void buildprefix_pop(void); char *sourcepath(const char *); extern int dflag; #define CFGDBG(n, ...) \ Index: src/usr.bin/config/files.c diff -u src/usr.bin/config/files.c:1.24 src/usr.bin/config/files.c:1.25 --- src/usr.bin/config/files.c:1.24 Tue Sep 1 12:46:20 2015 +++ src/usr.bin/config/files.c Tue Sep 1 13:42:48 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: files.c,v 1.24 2015/09/01 12:46:20 uebayasi Exp $ */ +/* $NetBSD: files.c,v 1.25 2015/09/01 13:42:48 uebayasi Exp $ */ /* * Copyright (c) 1992, 1993 @@ -45,7 +45,7 @@ #endif #include <sys/cdefs.h> -__RCSID("$NetBSD: files.c,v 1.24 2015/09/01 12:46:20 uebayasi Exp $"); +__RCSID("$NetBSD: files.c,v 1.25 2015/09/01 13:42:48 uebayasi Exp $"); #include <sys/param.h> #include <errno.h> @@ -173,6 +173,8 @@ addfile(const char *path, struct condexp fi->fi_dir = intern(dir); fi->fi_prefix = SLIST_EMPTY(&prefixes) ? NULL : SLIST_FIRST(&prefixes)->pf_prefix; + fi->fi_buildprefix = SLIST_EMPTY(&buildprefixes) ? NULL : + SLIST_FIRST(&buildprefixes)->pf_prefix; fi->fi_len = strlen(path); fi->fi_suffix = path[fi->fi_len - 1]; fi->fi_optx = optx; Index: src/usr.bin/config/gram.y diff -u src/usr.bin/config/gram.y:1.51 src/usr.bin/config/gram.y:1.52 --- src/usr.bin/config/gram.y:1.51 Tue Sep 1 11:22:59 2015 +++ src/usr.bin/config/gram.y Tue Sep 1 13:42:48 2015 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: gram.y,v 1.51 2015/09/01 11:22:59 uebayasi Exp $ */ +/* $NetBSD: gram.y,v 1.52 2015/09/01 13:42:48 uebayasi Exp $ */ /* * Copyright (c) 1992, 1993 @@ -42,7 +42,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: gram.y,v 1.51 2015/09/01 11:22:59 uebayasi Exp $"); +__RCSID("$NetBSD: gram.y,v 1.52 2015/09/01 13:42:48 uebayasi Exp $"); #include <sys/types.h> #include <sys/param.h> @@ -179,7 +179,7 @@ static struct loclist *namelocvals(const %token XMACHINE MAJOR MAKEOPTIONS MAXUSERS MAXPARTITIONS MINOR %token NEEDS_COUNT NEEDS_FLAG NO %token XOBJECT OBSOLETE ON OPTIONS -%token PACKAGE PLUSEQ PREFIX PSEUDO_DEVICE PSEUDO_ROOT +%token PACKAGE PLUSEQ PREFIX BUILDPREFIX PSEUDO_DEVICE PSEUDO_ROOT %token ROOT %token SELECT SINGLE SOURCE %token TYPE @@ -317,6 +317,7 @@ definition: | define_object | define_device_major | define_prefix + | define_buildprefix | define_devclass | define_filesystems | define_attribute @@ -361,6 +362,12 @@ define_prefix: | PREFIX { prefix_pop(); } ; +define_buildprefix: + BUILDPREFIX filename { buildprefix_push($2); } + | BUILDPREFIX WORD { buildprefix_push($2); } + | BUILDPREFIX { buildprefix_pop(); } +; + define_devclass: DEVCLASS WORD { (void)defdevclass($2, NULL, NULL, 1); } ; Index: src/usr.bin/config/scan.l diff -u src/usr.bin/config/scan.l:1.23 src/usr.bin/config/scan.l:1.24 --- src/usr.bin/config/scan.l:1.23 Tue Jun 16 21:12:19 2015 +++ src/usr.bin/config/scan.l Tue Sep 1 13:42:48 2015 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: scan.l,v 1.23 2015/06/16 21:12:19 christos Exp $ */ +/* $NetBSD: scan.l,v 1.24 2015/09/01 13:42:48 uebayasi Exp $ */ /* * Copyright (c) 1992, 1993 @@ -42,7 +42,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: scan.l,v 1.23 2015/06/16 21:12:19 christos Exp $"); +__RCSID("$NetBSD: scan.l,v 1.24 2015/09/01 13:42:48 uebayasi Exp $"); #include <sys/param.h> #include <errno.h> @@ -164,6 +164,7 @@ obsolete return OBSOLETE; on return ON; options return OPTIONS; prefix return PREFIX; +buildprefix return BUILDPREFIX; pseudo-device return PSEUDO_DEVICE; pseudo-root return PSEUDO_ROOT; root return ROOT; Index: src/usr.bin/config/util.c diff -u src/usr.bin/config/util.c:1.19 src/usr.bin/config/util.c:1.20 --- src/usr.bin/config/util.c:1.19 Wed Oct 29 17:14:50 2014 +++ src/usr.bin/config/util.c Tue Sep 1 13:42:48 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: util.c,v 1.19 2014/10/29 17:14:50 christos Exp $ */ +/* $NetBSD: util.c,v 1.20 2015/09/01 13:42:48 uebayasi Exp $ */ /* * Copyright (c) 1992, 1993 @@ -45,7 +45,7 @@ #endif #include <sys/cdefs.h> -__RCSID("$NetBSD: util.c,v 1.19 2014/10/29 17:14:50 christos Exp $"); +__RCSID("$NetBSD: util.c,v 1.20 2015/09/01 13:42:48 uebayasi Exp $"); #include <sys/types.h> #include <assert.h> @@ -73,46 +73,76 @@ static void cfgvxmsg(const char *, int, * Prefix stack */ -/* - * Push a prefix onto the prefix stack. - */ -void -prefix_push(const char *path) +static void +prefixlist_push(struct prefixlist *pl, const char *path) { + struct prefix *prevpf = SLIST_FIRST(pl); struct prefix *pf; char *cp; pf = ecalloc(1, sizeof(struct prefix)); - if (! SLIST_EMPTY(&prefixes) && *path != '/') { - cp = emalloc(strlen(SLIST_FIRST(&prefixes)->pf_prefix) + 1 + + if (prevpf != NULL) { + cp = emalloc(strlen(prevpf->pf_prefix) + 1 + strlen(path) + 1); - (void) sprintf(cp, "%s/%s", - SLIST_FIRST(&prefixes)->pf_prefix, path); + (void) sprintf(cp, "%s/%s", prevpf->pf_prefix, path); pf->pf_prefix = intern(cp); free(cp); } else pf->pf_prefix = intern(path); - SLIST_INSERT_HEAD(&prefixes, pf, pf_next); + SLIST_INSERT_HEAD(pl, pf, pf_next); } -/* - * Pop a prefix off the prefix stack. - */ -void -prefix_pop(void) +static void +prefixlist_pop(struct prefixlist *allpl, struct prefixlist *pl) { struct prefix *pf; - if ((pf = SLIST_FIRST(&prefixes)) == NULL) { + if ((pf = SLIST_FIRST(pl)) == NULL) { cfgerror("no prefixes on the stack to pop"); return; } - SLIST_REMOVE_HEAD(&prefixes, pf_next); + SLIST_REMOVE_HEAD(pl, pf_next); /* Remember this prefix for emitting -I... directives later. */ - SLIST_INSERT_HEAD(&allprefixes, pf, pf_next); + SLIST_INSERT_HEAD(allpl, pf, pf_next); +} + +/* + * Push a prefix onto the prefix stack. + */ +void +prefix_push(const char *path) +{ + prefixlist_push(&prefixes, path); +} + +/* + * Pop a prefix off the prefix stack. + */ +void +prefix_pop(void) +{ + prefixlist_pop(&allprefixes, &prefixes); +} + +/* + * Push a buildprefix onto the buildprefix stack. + */ +void +buildprefix_push(const char *path) +{ + prefixlist_push(&buildprefixes, path); +} + +/* + * Pop a buildprefix off the buildprefix stack. + */ +void +buildprefix_pop(void) +{ + prefixlist_pop(&allbuildprefixes, &buildprefixes); } /*