Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make make: .SYSPATH: to add dirs to sysIncPath
details: https://anonhg.NetBSD.org/src/rev/84aec533394f
branches: trunk
changeset: 373209:84aec533394f
user: sjg <sjg%NetBSD.org@localhost>
date: Tue Jan 24 00:24:02 2023 +0000
description:
make: .SYSPATH: to add dirs to sysIncPath
.SYSPATH: with no sources will clear sysIncPath
otherwise sources are added
Reviewed by: rillig
diffstat:
usr.bin/make/dir.c | 19 ++++++++++++++-
usr.bin/make/dir.h | 3 +-
usr.bin/make/main.c | 9 ++++++-
usr.bin/make/make.1 | 19 +++++++++++++++-
usr.bin/make/parse.c | 28 ++++++++++++++++++-----
usr.bin/make/unit-tests/Makefile | 5 ++-
usr.bin/make/unit-tests/dir.mk | 6 +++-
usr.bin/make/unit-tests/opt-debug-graph1.exp | 2 +-
usr.bin/make/unit-tests/opt-debug-graph2.exp | 2 +-
usr.bin/make/unit-tests/opt-debug-graph3.exp | 2 +-
usr.bin/make/unit-tests/suff-main-several.exp | 2 +-
usr.bin/make/unit-tests/suff-transform-debug.exp | 2 +-
12 files changed, 78 insertions(+), 21 deletions(-)
diffs (truncated from 347 to 300 lines):
diff -r 5c9bdb4e1215 -r 84aec533394f usr.bin/make/dir.c
--- a/usr.bin/make/dir.c Tue Jan 24 00:20:00 2023 +0000
+++ b/usr.bin/make/dir.c Tue Jan 24 00:24:02 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dir.c,v 1.279 2022/05/07 21:19:43 rillig Exp $ */
+/* $NetBSD: dir.c,v 1.280 2023/01/24 00:24:02 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -138,7 +138,7 @@
#include "job.h"
/* "@(#)dir.c 8.2 (Berkeley) 1/2/94" */
-MAKE_RCSID("$NetBSD: dir.c,v 1.279 2022/05/07 21:19:43 rillig Exp $");
+MAKE_RCSID("$NetBSD: dir.c,v 1.280 2023/01/24 00:24:02 sjg Exp $");
/*
* A search path is a list of CachedDir structures. A CachedDir has in it the
@@ -577,6 +577,21 @@
}
}
+
+void
+Dir_SetSYSPATH(void)
+{
+ CachedDirListNode *ln;
+
+ Var_ReadOnly(".SYSPATH", false);
+ Global_Delete(".SYSPATH");
+ for (ln = sysIncPath->dirs.first; ln != NULL; ln = ln->next) {
+ CachedDir *dir = ln->datum;
+ Global_Append(".SYSPATH", dir->name);
+ }
+ Var_ReadOnly(".SYSPATH", true);
+}
+
/*
* See if the given name has any wildcard characters in it and all braces and
* brackets are properly balanced.
diff -r 5c9bdb4e1215 -r 84aec533394f usr.bin/make/dir.h
--- a/usr.bin/make/dir.h Tue Jan 24 00:20:00 2023 +0000
+++ b/usr.bin/make/dir.h Tue Jan 24 00:24:02 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dir.h,v 1.46 2021/12/15 12:08:25 rillig Exp $ */
+/* $NetBSD: dir.h,v 1.47 2023/01/24 00:24:02 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -82,6 +82,7 @@
void Dir_InitDot(void);
void Dir_End(void);
void Dir_SetPATH(void);
+void Dir_SetSYSPATH(void);
bool Dir_HasWildcards(const char *) MAKE_ATTR_USE;
void SearchPath_Expand(SearchPath *, const char *, StringList *);
char *Dir_FindFile(const char *, SearchPath *) MAKE_ATTR_USE;
diff -r 5c9bdb4e1215 -r 84aec533394f usr.bin/make/main.c
--- a/usr.bin/make/main.c Tue Jan 24 00:20:00 2023 +0000
+++ b/usr.bin/make/main.c Tue Jan 24 00:24:02 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.587 2023/01/19 21:33:06 rillig Exp $ */
+/* $NetBSD: main.c,v 1.588 2023/01/24 00:24:02 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -111,7 +111,7 @@
#include "trace.h"
/* "@(#)main.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: main.c,v 1.587 2023/01/19 21:33:06 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.588 2023/01/24 00:24:02 sjg Exp $");
#if defined(MAKE_NATIVE) && !defined(lint)
__COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
"The Regents of the University of California. "
@@ -428,6 +428,7 @@
}
Global_Append(MAKEFLAGS, "-m");
Global_Append(MAKEFLAGS, argvalue);
+ Dir_SetSYSPATH();
}
static bool
@@ -1477,6 +1478,10 @@
main_ReadFiles(void)
{
+ if (Lst_IsEmpty(&sysIncPath->dirs))
+ SearchPath_AddAll(sysIncPath, defSysIncPath);
+
+ Dir_SetSYSPATH();
if (!opts.noBuiltins)
ReadBuiltinRules();
diff -r 5c9bdb4e1215 -r 84aec533394f usr.bin/make/make.1
--- a/usr.bin/make/make.1 Tue Jan 24 00:20:00 2023 +0000
+++ b/usr.bin/make/make.1 Tue Jan 24 00:24:02 2023 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: make.1,v 1.358 2023/01/23 23:01:52 sjg Exp $
+.\" $NetBSD: make.1,v 1.359 2023/01/24 00:24:02 sjg Exp $
.\"
.\" Copyright (c) 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -299,6 +299,8 @@
include statements (see the
.Fl I
option).
+The system include path can be referenced via the read-only variable
+.Va .SYSPATH .
.Pp
If a directory name in the
.Fl m
@@ -1326,6 +1328,13 @@
.It Va .SUFFIXES
The list of known suffixes.
It is read-only.
+.It Va .SYSPATH
+The space-separated list of directories that
+.Nm
+searches for makefiles, referred to as the system include path.
+To update this search list, use the special target
+.Sq Ic .SYSPATH
+rather than modifying the variable which is read-only.
.It Va .TARGETS
The list of targets explicitly specified on the command line, if any.
.It Va VPATH
@@ -2534,6 +2543,14 @@
\&.c.o:
cc \-o ${.TARGET} \-c ${.IMPSRC}
.Ed
+.It Ic .SYSPATH
+The sources are directories which are to be added to the system
+include path which
+.Nm
+searches for makefiles.
+If no sources are specified,
+any previously specified directories are removed from the system
+include path.
.El
.Sh ENVIRONMENT
.Nm
diff -r 5c9bdb4e1215 -r 84aec533394f usr.bin/make/parse.c
--- a/usr.bin/make/parse.c Tue Jan 24 00:20:00 2023 +0000
+++ b/usr.bin/make/parse.c Tue Jan 24 00:24:02 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.691 2023/01/23 23:01:52 sjg Exp $ */
+/* $NetBSD: parse.c,v 1.692 2023/01/24 00:24:02 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -105,7 +105,7 @@
#include "pathnames.h"
/* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: parse.c,v 1.691 2023/01/23 23:01:52 sjg Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.692 2023/01/24 00:24:02 sjg Exp $");
/*
* A file being read.
@@ -168,6 +168,7 @@
SP_SINGLESHELL, /* .SINGLESHELL; not mentioned in the manual page */
SP_STALE, /* .STALE */
SP_SUFFIXES, /* .SUFFIXES */
+ SP_SYSPATH, /* .SYSPATH */
SP_WAIT /* .WAIT */
} ParseSpecial;
@@ -293,6 +294,7 @@
{ ".SINGLESHELL", SP_SINGLESHELL, OP_NONE },
{ ".STALE", SP_STALE, OP_NONE },
{ ".SUFFIXES", SP_SUFFIXES, OP_NONE },
+ { ".SYSPATH", SP_SYSPATH, OP_NONE },
{ ".USE", SP_ATTRIBUTE, OP_USE },
{ ".USEBEFORE", SP_ATTRIBUTE, OP_USEBEFORE },
{ ".WAIT", SP_WAIT, OP_NONE },
@@ -923,6 +925,11 @@
*inout_paths = Lst_New();
Lst_Append(*inout_paths, &dirSearchPath);
break;
+ case SP_SYSPATH:
+ if (*inout_paths == NULL)
+ *inout_paths = Lst_New();
+ Lst_Append(*inout_paths, sysIncPath);
+ break;
case SP_MAIN:
/*
* Allow targets from the command line to override the
@@ -1129,15 +1136,17 @@
}
static void
-ClearPaths(SearchPathList *paths)
+ClearPaths(ParseSpecial special, SearchPathList *paths)
{
if (paths != NULL) {
SearchPathListNode *ln;
for (ln = paths->first; ln != NULL; ln = ln->next)
SearchPath_Clear(ln->datum);
}
-
- Dir_SetPATH();
+ if (special == SP_SYSPATH)
+ Dir_SetSYSPATH();
+ else
+ Dir_SetPATH();
}
static char *
@@ -1258,7 +1267,8 @@
opts.silent = true;
break;
case SP_PATH:
- ClearPaths(paths);
+ case SP_SYSPATH:
+ ClearPaths(special, paths);
break;
#ifdef POSIX
case SP_POSIX:
@@ -1322,6 +1332,9 @@
case SP_READONLY:
Var_ReadOnly(word, true);
break;
+ case SP_SYSPATH:
+ AddToPaths(word, paths);
+ break;
default:
break;
}
@@ -1543,6 +1556,7 @@
case SP_PATH:
case SP_READONLY:
case SP_SUFFIXES:
+ case SP_SYSPATH:
ParseDependencySourcesSpecial(p, special, *inout_paths);
if (*inout_paths != NULL) {
Lst_Free(*inout_paths);
@@ -1550,6 +1564,8 @@
}
if (special == SP_PATH)
Dir_SetPATH();
+ if (special == SP_SYSPATH)
+ Dir_SetSYSPATH();
break;
default:
assert(*inout_paths == NULL);
diff -r 5c9bdb4e1215 -r 84aec533394f usr.bin/make/unit-tests/Makefile
--- a/usr.bin/make/unit-tests/Makefile Tue Jan 24 00:20:00 2023 +0000
+++ b/usr.bin/make/unit-tests/Makefile Tue Jan 24 00:24:02 2023 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.330 2023/01/23 23:01:52 sjg Exp $
+# $NetBSD: Makefile,v 1.331 2023/01/24 00:24:02 sjg Exp $
#
# Unit tests for make(1)
#
@@ -538,7 +538,7 @@
SED_CMDS.varname-dot-shell= -e 's, = /[^ ]*, = (details omitted),g'
SED_CMDS.varname-dot-shell+= -e 's,"/[^" ]*","(details omitted)",g'
SED_CMDS.varname-dot-shell+= -e 's,\[/[^] ]*\],[(details omitted)],g'
-SED_CMDS.varname-empty= ${.OBJDIR .PARSEDIR .PATH .SHELL:L:@v@-e '/\\$v/d'@}
+SED_CMDS.varname-empty= ${.OBJDIR .PARSEDIR .PATH .SHELL .SYSPATH:L:@v@-e '/\\$v/d'@}
# Some tests need an additional round of postprocessing.
POSTPROC.depsrc-wait= sed -e '/^---/d' -e 's,^\(: Making 3[abc]\)[123]$$,\1,'
@@ -568,6 +568,7 @@
STD_SED_CMDS.dg1+= -e 's,^\(MACHINE[_ARCH]* *=\) .*,\1 <details omitted>,'
STD_SED_CMDS.dg1+= -e 's,^\(MAKE *=\) .*,\1 <details omitted>,'
STD_SED_CMDS.dg1+= -e 's,^\(\.SHELL *=\) .*,\1 <details omitted>,'
+STD_SED_CMDS.dg1+= -e '/\.SYSPATH/d'
STD_SED_CMDS.dg2= ${STD_SED_CMDS.dg1}
STD_SED_CMDS.dg2+= -e 's,\(last modified\) ..:..:.. ... ..\, ....,\1 <timestamp>,'
diff -r 5c9bdb4e1215 -r 84aec533394f usr.bin/make/unit-tests/dir.mk
--- a/usr.bin/make/unit-tests/dir.mk Tue Jan 24 00:20:00 2023 +0000
+++ b/usr.bin/make/unit-tests/dir.mk Tue Jan 24 00:24:02 2023 +0000
@@ -1,8 +1,10 @@
-# $NetBSD: dir.mk,v 1.9 2021/01/23 10:48:49 rillig Exp $
+# $NetBSD: dir.mk,v 1.10 2023/01/24 00:24:02 sjg Exp $
#
# Tests for dir.c.
-.MAKEFLAGS: -m / # hide /usr/share/mk from the debug log
+# hide /usr/share/mk from the debug log
+.SYSPATH:
+.SYSPATH: /
# Dependency lines may use braces for expansion.
# See DirExpandCurly for the implementation.
diff -r 5c9bdb4e1215 -r 84aec533394f usr.bin/make/unit-tests/opt-debug-graph1.exp
--- a/usr.bin/make/unit-tests/opt-debug-graph1.exp Tue Jan 24 00:20:00 2023 +0000
+++ b/usr.bin/make/unit-tests/opt-debug-graph1.exp Tue Jan 24 00:24:02 2023 +0000
@@ -48,7 +48,7 @@
# refs hits directory
# 1 0 <curdir>
# 1 0 .
-# 1 0 <defsyspath>
+# 2 0 <defsyspath>
#*** Suffixes:
#*** Transformations:
diff -r 5c9bdb4e1215 -r 84aec533394f usr.bin/make/unit-tests/opt-debug-graph2.exp
Home |
Main Index |
Thread Index |
Old Index