Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/config Introduce a new syntax, "buildprefix", to spe...
details: https://anonhg.NetBSD.org/src/rev/2a20dbcd1b9b
branches: trunk
changeset: 340357:2a20dbcd1b9b
user: uebayasi <uebayasi%NetBSD.org@localhost>
date: Tue Sep 01 13:42:48 2015 +0000
description:
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".
diffstat:
usr.bin/config/config.5 | 20 ++++++++++-
usr.bin/config/defs.h | 13 ++++++-
usr.bin/config/files.c | 6 ++-
usr.bin/config/gram.y | 13 +++++-
usr.bin/config/scan.l | 5 +-
usr.bin/config/util.c | 82 +++++++++++++++++++++++++++++++++---------------
6 files changed, 102 insertions(+), 37 deletions(-)
diffs (truncated from 318 to 300 lines):
diff -r 9915f853d5a5 -r 2a20dbcd1b9b usr.bin/config/config.5
--- a/usr.bin/config/config.5 Tue Sep 01 12:46:20 2015 +0000
+++ b/usr.bin/config/config.5 Tue Sep 01 13:42:48 2015 +0000
@@ -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 @@
If
.Ar path
is given, it pushes a new prefix for
+.Ic file ,
.Ic include
and
.Ic cinclude .
@@ -265,6 +266,21 @@
.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
diff -r 9915f853d5a5 -r 2a20dbcd1b9b usr.bin/config/defs.h
--- a/usr.bin/config/defs.h Tue Sep 01 12:46:20 2015 +0000
+++ b/usr.bin/config/defs.h Tue Sep 01 13:42:48 2015 +0000
@@ -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 @@
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 @@
* 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 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 @@
/* 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, ...) \
diff -r 9915f853d5a5 -r 2a20dbcd1b9b usr.bin/config/files.c
--- a/usr.bin/config/files.c Tue Sep 01 12:46:20 2015 +0000
+++ b/usr.bin/config/files.c Tue Sep 01 13:42:48 2015 +0000
@@ -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 @@
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;
diff -r 9915f853d5a5 -r 2a20dbcd1b9b usr.bin/config/gram.y
--- a/usr.bin/config/gram.y Tue Sep 01 12:46:20 2015 +0000
+++ b/usr.bin/config/gram.y Tue Sep 01 13:42:48 2015 +0000
@@ -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 @@
%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 @@
| define_object
| define_device_major
| define_prefix
+ | define_buildprefix
| define_devclass
| define_filesystems
| define_attribute
@@ -361,6 +362,12 @@
| 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); }
;
diff -r 9915f853d5a5 -r 2a20dbcd1b9b usr.bin/config/scan.l
--- a/usr.bin/config/scan.l Tue Sep 01 12:46:20 2015 +0000
+++ b/usr.bin/config/scan.l Tue Sep 01 13:42:48 2015 +0000
@@ -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 @@
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;
diff -r 9915f853d5a5 -r 2a20dbcd1b9b usr.bin/config/util.c
--- a/usr.bin/config/util.c Tue Sep 01 12:46:20 2015 +0000
+++ b/usr.bin/config/util.c Tue Sep 01 13:42:48 2015 +0000
@@ -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,28 +73,49 @@
* Prefix stack
*/
+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 (prevpf != NULL) {
+ cp = emalloc(strlen(prevpf->pf_prefix) + 1 +
+ strlen(path) + 1);
+ (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(pl, pf, pf_next);
+}
+
+static void
+prefixlist_pop(struct prefixlist *allpl, struct prefixlist *pl)
+{
+ struct prefix *pf;
+
+ if ((pf = SLIST_FIRST(pl)) == NULL) {
+ cfgerror("no prefixes on the stack to pop");
+ return;
+ }
+
+ SLIST_REMOVE_HEAD(pl, pf_next);
+ /* Remember this prefix for emitting -I... directives later. */
+ SLIST_INSERT_HEAD(allpl, pf, pf_next);
+}
+
/*
* Push a prefix onto the prefix stack.
*/
void
prefix_push(const char *path)
{
- 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 +
- strlen(path) + 1);
- (void) sprintf(cp, "%s/%s",
- SLIST_FIRST(&prefixes)->pf_prefix, path);
- pf->pf_prefix = intern(cp);
- free(cp);
- } else
- pf->pf_prefix = intern(path);
-
- SLIST_INSERT_HEAD(&prefixes, pf, pf_next);
+ prefixlist_push(&prefixes, path);
}
/*
@@ -103,16 +124,25 @@
void
prefix_pop(void)
{
- struct prefix *pf;
+ prefixlist_pop(&allprefixes, &prefixes);
+}
- if ((pf = SLIST_FIRST(&prefixes)) == NULL) {
- cfgerror("no prefixes on the stack to pop");
- return;
- }
+/*
+ * Push a buildprefix onto the buildprefix stack.
+ */
+void
Home |
Main Index |
Thread Index |
Old Index