make: use shortcut functions Global_SetExpand and Global_AppendExpand
There are many places where global variables are set or appended to. To reduce clutter and code size, encode the VAR_GLOBAL in the function name. The word Expand in the function names says that the variable name is expanded. In most of the cases, this is not necessary, but there are no corresponding functions Global_Set or Global_Append yet. Encoding the information whether the name is expanded or not in the function name will make inconsistencies obvious in future manual code reviews. Letting the compiler check this by using different types for unexpanded and expanded variable names is probably not worth the effort. There are still a few bugs to be fixed, such as in SetVar, which expands the variable name twice in a row.
This commit is contained in:
parent
6066202251
commit
3ec10f8db6
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: dir.c,v 1.265 2021/01/30 20:53:29 rillig Exp $ */
|
||||
/* $NetBSD: dir.c,v 1.266 2021/02/03 08:00:36 rillig 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.265 2021/01/30 20:53:29 rillig Exp $");
|
||||
MAKE_RCSID("$NetBSD: dir.c,v 1.266 2021/02/03 08:00:36 rillig Exp $");
|
||||
|
||||
/*
|
||||
* A search path is a list of CachedDir structures. A CachedDir has in it the
|
||||
@ -555,15 +555,15 @@ Dir_SetPATH(void)
|
||||
CachedDir *dir = ln->datum;
|
||||
if (dir == dotLast) {
|
||||
seenDotLast = TRUE;
|
||||
Var_Append(".PATH", dotLast->name, VAR_GLOBAL);
|
||||
Global_AppendExpand(".PATH", dotLast->name);
|
||||
}
|
||||
}
|
||||
|
||||
if (!seenDotLast) {
|
||||
if (dot != NULL)
|
||||
Var_Append(".PATH", dot->name, VAR_GLOBAL);
|
||||
Global_AppendExpand(".PATH", dot->name);
|
||||
if (cur != NULL)
|
||||
Var_Append(".PATH", cur->name, VAR_GLOBAL);
|
||||
Global_AppendExpand(".PATH", cur->name);
|
||||
}
|
||||
|
||||
for (ln = dirSearchPath.dirs.first; ln != NULL; ln = ln->next) {
|
||||
@ -572,14 +572,14 @@ Dir_SetPATH(void)
|
||||
continue;
|
||||
if (dir == dot && seenDotLast)
|
||||
continue;
|
||||
Var_Append(".PATH", dir->name, VAR_GLOBAL);
|
||||
Global_AppendExpand(".PATH", dir->name);
|
||||
}
|
||||
|
||||
if (seenDotLast) {
|
||||
if (dot != NULL)
|
||||
Var_Append(".PATH", dot->name, VAR_GLOBAL);
|
||||
Global_AppendExpand(".PATH", dot->name);
|
||||
if (cur != NULL)
|
||||
Var_Append(".PATH", cur->name, VAR_GLOBAL);
|
||||
Global_AppendExpand(".PATH", cur->name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: job.c,v 1.412 2021/02/01 21:09:25 rillig Exp $ */
|
||||
/* $NetBSD: job.c,v 1.413 2021/02/03 08:00:36 rillig Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
|
||||
@ -142,7 +142,7 @@
|
||||
#include "trace.h"
|
||||
|
||||
/* "@(#)job.c 8.2 (Berkeley) 3/19/94" */
|
||||
MAKE_RCSID("$NetBSD: job.c,v 1.412 2021/02/01 21:09:25 rillig Exp $");
|
||||
MAKE_RCSID("$NetBSD: job.c,v 1.413 2021/02/03 08:00:36 rillig Exp $");
|
||||
|
||||
/*
|
||||
* A shell defines how the commands are run. All commands for a target are
|
||||
@ -2177,7 +2177,7 @@ Job_SetPrefix(void)
|
||||
if (targPrefix != NULL) {
|
||||
free(targPrefix);
|
||||
} else if (!Var_Exists(MAKE_JOB_PREFIX, VAR_GLOBAL)) {
|
||||
Var_Set(MAKE_JOB_PREFIX, "---", VAR_GLOBAL);
|
||||
Global_SetExpand(MAKE_JOB_PREFIX, "---");
|
||||
}
|
||||
|
||||
(void)Var_Subst("${" MAKE_JOB_PREFIX "}",
|
||||
@ -2791,8 +2791,8 @@ Job_ServerStart(int max_tokens, int jp_0, int jp_1)
|
||||
snprintf(jobarg, sizeof jobarg, "%d,%d",
|
||||
tokenWaitJob.inPipe, tokenWaitJob.outPipe);
|
||||
|
||||
Var_Append(MAKEFLAGS, "-J", VAR_GLOBAL);
|
||||
Var_Append(MAKEFLAGS, jobarg, VAR_GLOBAL);
|
||||
Global_AppendExpand(MAKEFLAGS, "-J");
|
||||
Global_AppendExpand(MAKEFLAGS, jobarg);
|
||||
|
||||
/*
|
||||
* Preload the job pipe with one token per job, save the one
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: main.c,v 1.526 2021/02/01 21:04:10 rillig Exp $ */
|
||||
/* $NetBSD: main.c,v 1.527 2021/02/03 08:00:36 rillig 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.526 2021/02/01 21:04:10 rillig Exp $");
|
||||
MAKE_RCSID("$NetBSD: main.c,v 1.527 2021/02/03 08:00:36 rillig Exp $");
|
||||
#if defined(MAKE_NATIVE) && !defined(lint)
|
||||
__COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
|
||||
"The Regents of the University of California. "
|
||||
@ -409,8 +409,8 @@ MainParseArgJobsInternal(const char *argvalue)
|
||||
jp_1 = -1;
|
||||
opts.compatMake = TRUE;
|
||||
} else {
|
||||
Var_Append(MAKEFLAGS, "-J", VAR_GLOBAL);
|
||||
Var_Append(MAKEFLAGS, argvalue, VAR_GLOBAL);
|
||||
Global_AppendExpand(MAKEFLAGS, "-J");
|
||||
Global_AppendExpand(MAKEFLAGS, argvalue);
|
||||
}
|
||||
}
|
||||
|
||||
@ -427,9 +427,9 @@ MainParseArgJobs(const char *argvalue)
|
||||
progname);
|
||||
exit(2); /* Not 1 so -q can distinguish error */
|
||||
}
|
||||
Var_Append(MAKEFLAGS, "-j", VAR_GLOBAL);
|
||||
Var_Append(MAKEFLAGS, argvalue, VAR_GLOBAL);
|
||||
Var_Set(".MAKE.JOBS", argvalue, VAR_GLOBAL);
|
||||
Global_AppendExpand(MAKEFLAGS, "-j");
|
||||
Global_AppendExpand(MAKEFLAGS, argvalue);
|
||||
Global_SetExpand(".MAKE.JOBS", argvalue);
|
||||
maxJobTokens = opts.maxJobs;
|
||||
}
|
||||
|
||||
@ -446,8 +446,8 @@ MainParseArgSysInc(const char *argvalue)
|
||||
} else {
|
||||
(void)SearchPath_Add(sysIncPath, argvalue);
|
||||
}
|
||||
Var_Append(MAKEFLAGS, "-m", VAR_GLOBAL);
|
||||
Var_Append(MAKEFLAGS, argvalue, VAR_GLOBAL);
|
||||
Global_AppendExpand(MAKEFLAGS, "-m");
|
||||
Global_AppendExpand(MAKEFLAGS, argvalue);
|
||||
}
|
||||
|
||||
static Boolean
|
||||
@ -458,22 +458,22 @@ MainParseArg(char c, const char *argvalue)
|
||||
break;
|
||||
case 'B':
|
||||
opts.compatMake = TRUE;
|
||||
Var_Append(MAKEFLAGS, "-B", VAR_GLOBAL);
|
||||
Var_Set(MAKE_MODE, "compat", VAR_GLOBAL);
|
||||
Global_AppendExpand(MAKEFLAGS, "-B");
|
||||
Global_SetExpand(MAKE_MODE, "compat");
|
||||
break;
|
||||
case 'C':
|
||||
MainParseArgChdir(argvalue);
|
||||
break;
|
||||
case 'D':
|
||||
if (argvalue[0] == '\0') return FALSE;
|
||||
Var_Set(argvalue, "1", VAR_GLOBAL);
|
||||
Var_Append(MAKEFLAGS, "-D", VAR_GLOBAL);
|
||||
Var_Append(MAKEFLAGS, argvalue, VAR_GLOBAL);
|
||||
Global_SetExpand(argvalue, "1");
|
||||
Global_AppendExpand(MAKEFLAGS, "-D");
|
||||
Global_AppendExpand(MAKEFLAGS, argvalue);
|
||||
break;
|
||||
case 'I':
|
||||
Parse_AddIncludeDir(argvalue);
|
||||
Var_Append(MAKEFLAGS, "-I", VAR_GLOBAL);
|
||||
Var_Append(MAKEFLAGS, argvalue, VAR_GLOBAL);
|
||||
Global_AppendExpand(MAKEFLAGS, "-I");
|
||||
Global_AppendExpand(MAKEFLAGS, argvalue);
|
||||
break;
|
||||
case 'J':
|
||||
MainParseArgJobsInternal(argvalue);
|
||||
@ -481,24 +481,24 @@ MainParseArg(char c, const char *argvalue)
|
||||
case 'N':
|
||||
opts.noExecute = TRUE;
|
||||
opts.noRecursiveExecute = TRUE;
|
||||
Var_Append(MAKEFLAGS, "-N", VAR_GLOBAL);
|
||||
Global_AppendExpand(MAKEFLAGS, "-N");
|
||||
break;
|
||||
case 'S':
|
||||
opts.keepgoing = FALSE;
|
||||
Var_Append(MAKEFLAGS, "-S", VAR_GLOBAL);
|
||||
Global_AppendExpand(MAKEFLAGS, "-S");
|
||||
break;
|
||||
case 'T':
|
||||
tracefile = bmake_strdup(argvalue);
|
||||
Var_Append(MAKEFLAGS, "-T", VAR_GLOBAL);
|
||||
Var_Append(MAKEFLAGS, argvalue, VAR_GLOBAL);
|
||||
Global_AppendExpand(MAKEFLAGS, "-T");
|
||||
Global_AppendExpand(MAKEFLAGS, argvalue);
|
||||
break;
|
||||
case 'V':
|
||||
case 'v':
|
||||
opts.printVars = c == 'v' ? PVM_EXPANDED : PVM_UNEXPANDED;
|
||||
Lst_Append(&opts.variables, bmake_strdup(argvalue));
|
||||
/* XXX: Why always -V? */
|
||||
Var_Append(MAKEFLAGS, "-V", VAR_GLOBAL);
|
||||
Var_Append(MAKEFLAGS, argvalue, VAR_GLOBAL);
|
||||
Global_AppendExpand(MAKEFLAGS, "-V");
|
||||
Global_AppendExpand(MAKEFLAGS, argvalue);
|
||||
break;
|
||||
case 'W':
|
||||
opts.parseWarnFatal = TRUE;
|
||||
@ -506,35 +506,35 @@ MainParseArg(char c, const char *argvalue)
|
||||
break;
|
||||
case 'X':
|
||||
opts.varNoExportEnv = TRUE;
|
||||
Var_Append(MAKEFLAGS, "-X", VAR_GLOBAL);
|
||||
Global_AppendExpand(MAKEFLAGS, "-X");
|
||||
break;
|
||||
case 'd':
|
||||
/* If '-d-opts' don't pass to children */
|
||||
if (argvalue[0] == '-')
|
||||
argvalue++;
|
||||
else {
|
||||
Var_Append(MAKEFLAGS, "-d", VAR_GLOBAL);
|
||||
Var_Append(MAKEFLAGS, argvalue, VAR_GLOBAL);
|
||||
Global_AppendExpand(MAKEFLAGS, "-d");
|
||||
Global_AppendExpand(MAKEFLAGS, argvalue);
|
||||
}
|
||||
MainParseArgDebug(argvalue);
|
||||
break;
|
||||
case 'e':
|
||||
opts.checkEnvFirst = TRUE;
|
||||
Var_Append(MAKEFLAGS, "-e", VAR_GLOBAL);
|
||||
Global_AppendExpand(MAKEFLAGS, "-e");
|
||||
break;
|
||||
case 'f':
|
||||
Lst_Append(&opts.makefiles, bmake_strdup(argvalue));
|
||||
break;
|
||||
case 'i':
|
||||
opts.ignoreErrors = TRUE;
|
||||
Var_Append(MAKEFLAGS, "-i", VAR_GLOBAL);
|
||||
Global_AppendExpand(MAKEFLAGS, "-i");
|
||||
break;
|
||||
case 'j':
|
||||
MainParseArgJobs(argvalue);
|
||||
break;
|
||||
case 'k':
|
||||
opts.keepgoing = TRUE;
|
||||
Var_Append(MAKEFLAGS, "-k", VAR_GLOBAL);
|
||||
Global_AppendExpand(MAKEFLAGS, "-k");
|
||||
break;
|
||||
case 'm':
|
||||
MainParseArgSysInc(argvalue);
|
||||
@ -542,28 +542,28 @@ MainParseArg(char c, const char *argvalue)
|
||||
break;
|
||||
case 'n':
|
||||
opts.noExecute = TRUE;
|
||||
Var_Append(MAKEFLAGS, "-n", VAR_GLOBAL);
|
||||
Global_AppendExpand(MAKEFLAGS, "-n");
|
||||
break;
|
||||
case 'q':
|
||||
opts.queryFlag = TRUE;
|
||||
/* Kind of nonsensical, wot? */
|
||||
Var_Append(MAKEFLAGS, "-q", VAR_GLOBAL);
|
||||
Global_AppendExpand(MAKEFLAGS, "-q");
|
||||
break;
|
||||
case 'r':
|
||||
opts.noBuiltins = TRUE;
|
||||
Var_Append(MAKEFLAGS, "-r", VAR_GLOBAL);
|
||||
Global_AppendExpand(MAKEFLAGS, "-r");
|
||||
break;
|
||||
case 's':
|
||||
opts.beSilent = TRUE;
|
||||
Var_Append(MAKEFLAGS, "-s", VAR_GLOBAL);
|
||||
Global_AppendExpand(MAKEFLAGS, "-s");
|
||||
break;
|
||||
case 't':
|
||||
opts.touchFlag = TRUE;
|
||||
Var_Append(MAKEFLAGS, "-t", VAR_GLOBAL);
|
||||
Global_AppendExpand(MAKEFLAGS, "-t");
|
||||
break;
|
||||
case 'w':
|
||||
opts.enterFlag = TRUE;
|
||||
Var_Append(MAKEFLAGS, "-w", VAR_GLOBAL);
|
||||
Global_AppendExpand(MAKEFLAGS, "-w");
|
||||
break;
|
||||
default:
|
||||
case '?':
|
||||
@ -737,7 +737,7 @@ Main_SetObjdir(Boolean writable, const char *fmt, ...)
|
||||
progname, path, strerror(errno));
|
||||
} else {
|
||||
snprintf(objdir, sizeof objdir, "%s", path);
|
||||
Var_Set(".OBJDIR", objdir, VAR_GLOBAL);
|
||||
Global_SetExpand(".OBJDIR", objdir);
|
||||
setenv("PWD", objdir, 1);
|
||||
Dir_InitDot();
|
||||
purge_relative_cached_realpaths();
|
||||
@ -957,13 +957,13 @@ InitVarTargets(void)
|
||||
StringListNode *ln;
|
||||
|
||||
if (Lst_IsEmpty(&opts.create)) {
|
||||
Var_Set(".TARGETS", "", VAR_GLOBAL);
|
||||
Global_SetExpand(".TARGETS", "");
|
||||
return;
|
||||
}
|
||||
|
||||
for (ln = opts.create.first; ln != NULL; ln = ln->next) {
|
||||
const char *name = ln->datum;
|
||||
Var_Append(".TARGETS", name, VAR_GLOBAL);
|
||||
Global_AppendExpand(".TARGETS", name);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1159,8 +1159,8 @@ InitVarMake(const char *argv0)
|
||||
make = abspath;
|
||||
}
|
||||
|
||||
Var_Set("MAKE", make, VAR_GLOBAL);
|
||||
Var_Set(".MAKE", make, VAR_GLOBAL);
|
||||
Global_SetExpand("MAKE", make);
|
||||
Global_SetExpand(".MAKE", make);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1253,8 +1253,8 @@ InitMaxJobs(void)
|
||||
}
|
||||
|
||||
if (n != opts.maxJobs) {
|
||||
Var_Append(MAKEFLAGS, "-j", VAR_GLOBAL);
|
||||
Var_Append(MAKEFLAGS, value, VAR_GLOBAL);
|
||||
Global_AppendExpand(MAKEFLAGS, "-j");
|
||||
Global_AppendExpand(MAKEFLAGS, value);
|
||||
}
|
||||
|
||||
opts.maxJobs = n;
|
||||
@ -1383,21 +1383,21 @@ main_Init(int argc, char **argv)
|
||||
*/
|
||||
Targ_Init();
|
||||
Var_Init();
|
||||
Var_Set(".MAKE.OS", utsname.sysname, VAR_GLOBAL);
|
||||
Var_Set("MACHINE", machine, VAR_GLOBAL);
|
||||
Var_Set("MACHINE_ARCH", machine_arch, VAR_GLOBAL);
|
||||
Global_SetExpand(".MAKE.OS", utsname.sysname);
|
||||
Global_SetExpand("MACHINE", machine);
|
||||
Global_SetExpand("MACHINE_ARCH", machine_arch);
|
||||
#ifdef MAKE_VERSION
|
||||
Var_Set("MAKE_VERSION", MAKE_VERSION, VAR_GLOBAL);
|
||||
Global_SetExpand("MAKE_VERSION", MAKE_VERSION);
|
||||
#endif
|
||||
Var_Set(".newline", "\n", VAR_GLOBAL); /* handy for :@ loops */
|
||||
Global_SetExpand(".newline", "\n"); /* handy for :@ loops */
|
||||
/*
|
||||
* This is the traditional preference for makefiles.
|
||||
*/
|
||||
#ifndef MAKEFILE_PREFERENCE_LIST
|
||||
# define MAKEFILE_PREFERENCE_LIST "makefile Makefile"
|
||||
#endif
|
||||
Var_Set(MAKE_MAKEFILE_PREFERENCE, MAKEFILE_PREFERENCE_LIST, VAR_GLOBAL);
|
||||
Var_Set(MAKE_DEPENDFILE, ".depend", VAR_GLOBAL);
|
||||
Global_SetExpand(MAKE_MAKEFILE_PREFERENCE, MAKEFILE_PREFERENCE_LIST);
|
||||
Global_SetExpand(MAKE_DEPENDFILE, ".depend");
|
||||
|
||||
CmdOpts_Init();
|
||||
allPrecious = FALSE; /* Remove targets when interrupted */
|
||||
@ -1421,10 +1421,10 @@ main_Init(int argc, char **argv)
|
||||
*/
|
||||
Parse_Init();
|
||||
InitVarMake(argv[0]);
|
||||
Var_Set(MAKEFLAGS, "", VAR_GLOBAL);
|
||||
Var_Set(MAKEOVERRIDES, "", VAR_GLOBAL);
|
||||
Var_Set("MFLAGS", "", VAR_GLOBAL);
|
||||
Var_Set(".ALLTARGETS", "", VAR_GLOBAL);
|
||||
Global_SetExpand(MAKEFLAGS, "");
|
||||
Global_SetExpand(MAKEOVERRIDES, "");
|
||||
Global_SetExpand("MFLAGS", "");
|
||||
Global_SetExpand(".ALLTARGETS", "");
|
||||
/* some makefiles need to know this */
|
||||
Var_Set(MAKE_LEVEL ".ENV", MAKE_LEVEL_ENV, VAR_CMDLINE);
|
||||
|
||||
@ -1436,15 +1436,15 @@ main_Init(int argc, char **argv)
|
||||
if (makelevel < 0)
|
||||
makelevel = 0;
|
||||
snprintf(tmp, sizeof tmp, "%d", makelevel);
|
||||
Var_Set(MAKE_LEVEL, tmp, VAR_GLOBAL);
|
||||
Global_SetExpand(MAKE_LEVEL, tmp);
|
||||
snprintf(tmp, sizeof tmp, "%u", myPid);
|
||||
Var_Set(".MAKE.PID", tmp, VAR_GLOBAL);
|
||||
Global_SetExpand(".MAKE.PID", tmp);
|
||||
snprintf(tmp, sizeof tmp, "%u", getppid());
|
||||
Var_Set(".MAKE.PPID", tmp, VAR_GLOBAL);
|
||||
Global_SetExpand(".MAKE.PPID", tmp);
|
||||
snprintf(tmp, sizeof tmp, "%u", getuid());
|
||||
Var_Set(".MAKE.UID", tmp, VAR_GLOBAL);
|
||||
Global_SetExpand(".MAKE.UID", tmp);
|
||||
snprintf(tmp, sizeof tmp, "%u", getgid());
|
||||
Var_Set(".MAKE.GID", tmp, VAR_GLOBAL);
|
||||
Global_SetExpand(".MAKE.GID", tmp);
|
||||
}
|
||||
if (makelevel > 0) {
|
||||
char pn[1024];
|
||||
@ -1499,7 +1499,7 @@ main_Init(int argc, char **argv)
|
||||
#ifndef NO_PWD_OVERRIDE
|
||||
HandlePWD(&sa);
|
||||
#endif
|
||||
Var_Set(".CURDIR", curdir, VAR_GLOBAL);
|
||||
Global_SetExpand(".CURDIR", curdir);
|
||||
|
||||
InitObjdir(machine, machine_arch);
|
||||
|
||||
@ -1561,7 +1561,7 @@ main_PrepareMaking(void)
|
||||
|
||||
{
|
||||
FStr makeflags = Var_Value(MAKEFLAGS, VAR_GLOBAL);
|
||||
Var_Append("MFLAGS", makeflags.str, VAR_GLOBAL);
|
||||
Global_AppendExpand("MFLAGS", makeflags.str);
|
||||
FStr_Done(&makeflags);
|
||||
}
|
||||
|
||||
@ -2104,7 +2104,7 @@ SetErrorVars(GNode *gn)
|
||||
/*
|
||||
* We can print this even if there is no .ERROR target.
|
||||
*/
|
||||
Var_Set(".ERROR_TARGET", gn->name, VAR_GLOBAL);
|
||||
Global_SetExpand(".ERROR_TARGET", gn->name);
|
||||
Var_Delete(".ERROR_CMD", VAR_GLOBAL);
|
||||
|
||||
for (ln = gn->commands.first; ln != NULL; ln = ln->next) {
|
||||
@ -2112,7 +2112,7 @@ SetErrorVars(GNode *gn)
|
||||
|
||||
if (cmd == NULL)
|
||||
break;
|
||||
Var_Append(".ERROR_CMD", cmd, VAR_GLOBAL);
|
||||
Global_AppendExpand(".ERROR_CMD", cmd);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: meta.c,v 1.170 2021/02/01 21:32:54 rillig Exp $ */
|
||||
/* $NetBSD: meta.c,v 1.171 2021/02/03 08:00:36 rillig Exp $ */
|
||||
|
||||
/*
|
||||
* Implement 'meta' mode.
|
||||
@ -534,8 +534,8 @@ meta_create(BuildMon *pbm, GNode *gn)
|
||||
fprintf(fp, "-- command output --\n");
|
||||
fflush(fp);
|
||||
|
||||
Var_Append(".MAKE.META.FILES", fname, VAR_GLOBAL);
|
||||
Var_Append(".MAKE.META.CREATED", fname, VAR_GLOBAL);
|
||||
Global_AppendExpand(".MAKE.META.FILES", fname);
|
||||
Global_AppendExpand(".MAKE.META.CREATED", fname);
|
||||
|
||||
gn->type |= OP_META; /* in case anyone wants to know */
|
||||
if (metaSilent) {
|
||||
@ -569,7 +569,7 @@ meta_init(void)
|
||||
{
|
||||
#ifdef USE_FILEMON
|
||||
/* this allows makefiles to test if we have filemon support */
|
||||
Var_Set(".MAKE.PATH_FILEMON", filemon_path(), VAR_GLOBAL);
|
||||
Global_SetExpand(".MAKE.PATH_FILEMON", filemon_path());
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -616,7 +616,8 @@ meta_mode_init(const char *make_mode)
|
||||
* This works be cause :H will generate '.' if there is no /
|
||||
* and :tA will resolve that to cwd.
|
||||
*/
|
||||
Var_Set(MAKE_META_PREFIX, "Building ${.TARGET:H:tA}/${.TARGET:T}", VAR_GLOBAL);
|
||||
Global_SetExpand(MAKE_META_PREFIX,
|
||||
"Building ${.TARGET:H:tA}/${.TARGET:T}");
|
||||
}
|
||||
if (once)
|
||||
return;
|
||||
@ -632,8 +633,8 @@ meta_mode_init(const char *make_mode)
|
||||
/*
|
||||
* We ignore any paths that start with ${.MAKE.META.IGNORE_PATHS}
|
||||
*/
|
||||
Var_Append(MAKE_META_IGNORE_PATHS,
|
||||
"/dev /etc /proc /tmp /var/run /var/tmp ${TMPDIR}", VAR_GLOBAL);
|
||||
Global_AppendExpand(MAKE_META_IGNORE_PATHS,
|
||||
"/dev /etc /proc /tmp /var/run /var/tmp ${TMPDIR}");
|
||||
(void)Var_Subst("${" MAKE_META_IGNORE_PATHS ":O:u:tA}",
|
||||
VAR_GLOBAL, VARE_WANTRES, &metaIgnorePathsStr);
|
||||
/* TODO: handle errors */
|
||||
@ -782,13 +783,12 @@ meta_job_error(Job *job, GNode *gn, Boolean ignerr, int status)
|
||||
fprintf(pbm->mfp, "\n*** Error code %d%s\n",
|
||||
status, ignerr ? "(ignored)" : "");
|
||||
}
|
||||
if (gn != NULL) {
|
||||
Var_Set(".ERROR_TARGET", GNode_Path(gn), VAR_GLOBAL);
|
||||
}
|
||||
if (gn != NULL)
|
||||
Global_SetExpand(".ERROR_TARGET", GNode_Path(gn));
|
||||
getcwd(cwd, sizeof cwd);
|
||||
Var_Set(".ERROR_CWD", cwd, VAR_GLOBAL);
|
||||
Global_SetExpand(".ERROR_CWD", cwd);
|
||||
if (pbm->meta_fname[0] != '\0') {
|
||||
Var_Set(".ERROR_META_FILE", pbm->meta_fname, VAR_GLOBAL);
|
||||
Global_SetExpand(".ERROR_META_FILE", pbm->meta_fname);
|
||||
}
|
||||
meta_job_finish(job);
|
||||
}
|
||||
@ -1142,7 +1142,7 @@ meta_oodate(GNode *gn, Boolean oodate)
|
||||
}
|
||||
|
||||
/* we want to track all the .meta we read */
|
||||
Var_Append(".MAKE.META.FILES", fname, VAR_GLOBAL);
|
||||
Global_AppendExpand(".MAKE.META.FILES", fname);
|
||||
|
||||
cmdNode = gn->commands.first;
|
||||
while (!oodate && (x = fgetLine(&buf, &bufsz, 0, fp)) > 0) {
|
||||
@ -1217,8 +1217,8 @@ meta_oodate(GNode *gn, Boolean oodate)
|
||||
|
||||
if (lastpid > 0) {
|
||||
/* We need to remember these. */
|
||||
Var_Set(lcwd_vname, lcwd, VAR_GLOBAL);
|
||||
Var_Set(ldir_vname, latestdir, VAR_GLOBAL);
|
||||
Global_SetExpand(lcwd_vname, lcwd);
|
||||
Global_SetExpand(ldir_vname, latestdir);
|
||||
}
|
||||
snprintf(lcwd_vname, sizeof lcwd_vname, LCWD_VNAME_FMT, pid);
|
||||
snprintf(ldir_vname, sizeof ldir_vname, LDIR_VNAME_FMT, pid);
|
||||
@ -1264,9 +1264,9 @@ meta_oodate(GNode *gn, Boolean oodate)
|
||||
child = atoi(p);
|
||||
if (child > 0) {
|
||||
snprintf(cldir, sizeof cldir, LCWD_VNAME_FMT, child);
|
||||
Var_Set(cldir, lcwd, VAR_GLOBAL);
|
||||
Global_SetExpand(cldir, lcwd);
|
||||
snprintf(cldir, sizeof cldir, LDIR_VNAME_FMT, child);
|
||||
Var_Set(cldir, latestdir, VAR_GLOBAL);
|
||||
Global_SetExpand(cldir, latestdir);
|
||||
#ifdef DEBUG_META_MODE
|
||||
if (DEBUG(META))
|
||||
debug_printf(
|
||||
@ -1282,8 +1282,8 @@ meta_oodate(GNode *gn, Boolean oodate)
|
||||
/* Update lcwd and latest directory. */
|
||||
strlcpy(latestdir, p, sizeof latestdir);
|
||||
strlcpy(lcwd, p, sizeof lcwd);
|
||||
Var_Set(lcwd_vname, lcwd, VAR_GLOBAL);
|
||||
Var_Set(ldir_vname, lcwd, VAR_GLOBAL);
|
||||
Global_SetExpand(lcwd_vname, lcwd);
|
||||
Global_SetExpand(ldir_vname, lcwd);
|
||||
#ifdef DEBUG_META_MODE
|
||||
DEBUG4(META, "%s: %d: cwd=%s ldir=%s\n",
|
||||
fname, lineno, cwd, lcwd);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: nonints.h,v 1.190 2021/02/02 17:56:31 rillig Exp $ */
|
||||
/* $NetBSD: nonints.h,v 1.191 2021/02/03 08:00:36 rillig Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
@ -371,9 +371,11 @@ typedef enum VarExportMode {
|
||||
void Var_DeleteVar(const char *, GNode *);
|
||||
void Var_Delete(const char *, GNode *);
|
||||
void Var_Undef(const char *);
|
||||
void Global_SetExpand(const char *, const char *);
|
||||
void Var_Set(const char *, const char *, GNode *);
|
||||
void Var_SetWithFlags(const char *, const char *, GNode *, VarSetFlags);
|
||||
void Var_Append(const char *, const char *, GNode *);
|
||||
void Global_AppendExpand(const char *, const char *);
|
||||
Boolean Var_Exists(const char *, GNode *);
|
||||
FStr Var_Value(const char *, GNode *);
|
||||
const char *Var_ValueDirect(const char *, GNode *);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: parse.c,v 1.538 2021/02/01 22:21:33 rillig Exp $ */
|
||||
/* $NetBSD: parse.c,v 1.539 2021/02/03 08:00:36 rillig Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
@ -109,7 +109,7 @@
|
||||
#include "pathnames.h"
|
||||
|
||||
/* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */
|
||||
MAKE_RCSID("$NetBSD: parse.c,v 1.538 2021/02/01 22:21:33 rillig Exp $");
|
||||
MAKE_RCSID("$NetBSD: parse.c,v 1.539 2021/02/03 08:00:36 rillig Exp $");
|
||||
|
||||
/* types and constants */
|
||||
|
||||
@ -886,7 +886,7 @@ ParseDependencySourceMain(const char *src)
|
||||
* Add the name to the .TARGETS variable as well, so the user can
|
||||
* employ that, if desired.
|
||||
*/
|
||||
Var_Append(".TARGETS", src, VAR_GLOBAL);
|
||||
Global_AppendExpand(".TARGETS", src);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1327,7 +1327,7 @@ ParseDoDependencySourcesEmpty(ParseSpecial specType, SearchPathList *paths)
|
||||
break;
|
||||
#ifdef POSIX
|
||||
case SP_POSIX:
|
||||
Var_Set("%POSIX", "1003.2", VAR_GLOBAL);
|
||||
Global_SetExpand("%POSIX", "1003.2");
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
@ -2281,8 +2281,8 @@ SetFilenameVars(const char *filename, const char *dirvar, const char *filevar)
|
||||
basename = slash + 1;
|
||||
}
|
||||
|
||||
Var_Set(dirvar, dirname, VAR_GLOBAL);
|
||||
Var_Set(filevar, basename, VAR_GLOBAL);
|
||||
Global_SetExpand(dirvar, dirname);
|
||||
Global_SetExpand(filevar, basename);
|
||||
|
||||
DEBUG5(PARSE, "%s: ${%s} = `%s' ${%s} = `%s'\n",
|
||||
__func__, dirvar, dirname, filevar, basename);
|
||||
@ -2375,7 +2375,7 @@ static void
|
||||
ParseTrackInput(const char *name)
|
||||
{
|
||||
if (!VarContainsWord(MAKE_MAKEFILES, name))
|
||||
Var_Append(MAKE_MAKEFILES, name, VAR_GLOBAL);
|
||||
Global_AppendExpand(MAKE_MAKEFILES, name);
|
||||
}
|
||||
|
||||
|
||||
@ -3283,7 +3283,7 @@ Parse_MainName(GNodeList *mainList)
|
||||
if (mainNode->type & OP_DOUBLEDEP)
|
||||
Lst_AppendAll(mainList, &mainNode->cohorts);
|
||||
|
||||
Var_Append(".TARGETS", mainNode->name, VAR_GLOBAL);
|
||||
Global_AppendExpand(".TARGETS", mainNode->name);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: suff.c,v 1.341 2021/01/30 15:48:42 rillig Exp $ */
|
||||
/* $NetBSD: suff.c,v 1.342 2021/02/03 08:00:36 rillig Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
@ -114,7 +114,7 @@
|
||||
#include "dir.h"
|
||||
|
||||
/* "@(#)suff.c 8.4 (Berkeley) 3/21/94" */
|
||||
MAKE_RCSID("$NetBSD: suff.c,v 1.341 2021/01/30 15:48:42 rillig Exp $");
|
||||
MAKE_RCSID("$NetBSD: suff.c,v 1.342 2021/02/03 08:00:36 rillig Exp $");
|
||||
|
||||
typedef List SuffixList;
|
||||
typedef ListNode SuffixListNode;
|
||||
@ -903,11 +903,11 @@ Suff_DoPaths(void)
|
||||
}
|
||||
|
||||
flags = SearchPath_ToFlags(includesPath, "-I");
|
||||
Var_Set(".INCLUDES", flags, VAR_GLOBAL);
|
||||
Global_SetExpand(".INCLUDES", flags);
|
||||
free(flags);
|
||||
|
||||
flags = SearchPath_ToFlags(libsPath, "-L");
|
||||
Var_Set(".LIBS", flags, VAR_GLOBAL);
|
||||
Global_SetExpand(".LIBS", flags);
|
||||
free(flags);
|
||||
|
||||
SearchPath_Free(includesPath);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: targ.c,v 1.161 2021/02/02 17:56:31 rillig Exp $ */
|
||||
/* $NetBSD: targ.c,v 1.162 2021/02/03 08:00:36 rillig Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
@ -113,7 +113,7 @@
|
||||
#include "dir.h"
|
||||
|
||||
/* "@(#)targ.c 8.2 (Berkeley) 3/19/94" */
|
||||
MAKE_RCSID("$NetBSD: targ.c,v 1.161 2021/02/02 17:56:31 rillig Exp $");
|
||||
MAKE_RCSID("$NetBSD: targ.c,v 1.162 2021/02/03 08:00:36 rillig Exp $");
|
||||
|
||||
/*
|
||||
* All target nodes that appeared on the left-hand side of one of the
|
||||
@ -305,7 +305,7 @@ GNode *
|
||||
Targ_NewInternalNode(const char *name)
|
||||
{
|
||||
GNode *gn = GNode_New(name);
|
||||
Var_Append(".ALLTARGETS", name, VAR_GLOBAL);
|
||||
Global_AppendExpand(".ALLTARGETS", name);
|
||||
Lst_Append(&allTargets, gn);
|
||||
DEBUG1(TARG, "Adding \"%s\" to all targets.\n", gn->name);
|
||||
if (doing_depend)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: util.c,v 1.75 2021/02/03 06:58:22 rillig Exp $ */
|
||||
/* $NetBSD: util.c,v 1.76 2021/02/03 08:00:36 rillig Exp $ */
|
||||
|
||||
/*
|
||||
* Missing stuff from OS's
|
||||
@ -15,7 +15,7 @@
|
||||
|
||||
#include "make.h"
|
||||
|
||||
MAKE_RCSID("$NetBSD: util.c,v 1.75 2021/02/03 06:58:22 rillig Exp $");
|
||||
MAKE_RCSID("$NetBSD: util.c,v 1.76 2021/02/03 08:00:36 rillig Exp $");
|
||||
|
||||
#if !defined(MAKE_NATIVE) && !defined(HAVE_STRERROR)
|
||||
extern int errno, sys_nerr;
|
||||
@ -45,7 +45,7 @@ findenv(const char *name, int *offset)
|
||||
len = strlen(name);
|
||||
for (i = 0; (q = environ[i]); i++) {
|
||||
p = strchr(q, '=');
|
||||
if (p == NULL || (size_t)(p - q) != len)
|
||||
if (p == NULL || p - q != len)
|
||||
continue;
|
||||
if (strncmp(name, q, len) == 0) {
|
||||
*offset = i;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: var.c,v 1.790 2021/02/02 21:26:51 rillig Exp $ */
|
||||
/* $NetBSD: var.c,v 1.791 2021/02/03 08:00:36 rillig Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
@ -131,7 +131,7 @@
|
||||
#include "metachar.h"
|
||||
|
||||
/* "@(#)var.c 8.3 (Berkeley) 3/19/94" */
|
||||
MAKE_RCSID("$NetBSD: var.c,v 1.790 2021/02/02 21:26:51 rillig Exp $");
|
||||
MAKE_RCSID("$NetBSD: var.c,v 1.791 2021/02/03 08:00:36 rillig Exp $");
|
||||
|
||||
typedef enum VarFlags {
|
||||
VAR_NONE = 0,
|
||||
@ -748,7 +748,7 @@ ExportVars(const char *varnames, Boolean isExport, VarExportMode mode)
|
||||
var_exportedVars = VAR_EXPORTED_SOME;
|
||||
|
||||
if (isExport && mode == VEM_PLAIN)
|
||||
Var_Append(MAKE_EXPORTED, varname, VAR_GLOBAL);
|
||||
Global_AppendExpand(MAKE_EXPORTED, varname);
|
||||
}
|
||||
Words_Free(words);
|
||||
}
|
||||
@ -868,7 +868,7 @@ UnexportVar(const char *varname, UnexportWhat what)
|
||||
char *cp;
|
||||
(void)Var_Subst(expr, VAR_GLOBAL, VARE_WANTRES, &cp);
|
||||
/* TODO: handle errors */
|
||||
Var_Set(MAKE_EXPORTED, cp, VAR_GLOBAL);
|
||||
Global_SetExpand(MAKE_EXPORTED, cp);
|
||||
free(cp);
|
||||
free(expr);
|
||||
}
|
||||
@ -978,7 +978,7 @@ SetVar(const char *name, const char *val, GNode *ctxt, VarSetFlags flags)
|
||||
if (!opts.varNoExportEnv)
|
||||
setenv(name, val, 1);
|
||||
|
||||
Var_Append(MAKEOVERRIDES, name, VAR_GLOBAL);
|
||||
Global_AppendExpand(MAKEOVERRIDES, name);
|
||||
}
|
||||
if (name[0] == '.' && strcmp(name, MAKE_SAVE_DOLLARS) == 0)
|
||||
save_dollars = ParseBoolean(val, save_dollars);
|
||||
@ -1031,6 +1031,12 @@ Var_Set(const char *name, const char *val, GNode *ctxt)
|
||||
Var_SetWithFlags(name, val, ctxt, VAR_SET_NONE);
|
||||
}
|
||||
|
||||
void
|
||||
Global_SetExpand(const char *name, const char *value)
|
||||
{
|
||||
Var_Set(name, value, VAR_GLOBAL);
|
||||
}
|
||||
|
||||
/*
|
||||
* The variable of the given name has the given value appended to it in the
|
||||
* given context.
|
||||
@ -1106,6 +1112,12 @@ Var_Append(const char *name, const char *val, GNode *ctxt)
|
||||
free(name_freeIt);
|
||||
}
|
||||
|
||||
void
|
||||
Global_AppendExpand(const char *name, const char *value)
|
||||
{
|
||||
Var_Append(name, value, VAR_GLOBAL);
|
||||
}
|
||||
|
||||
/*
|
||||
* See if the given variable exists, in the given context or in other
|
||||
* fallback contexts.
|
||||
|
Loading…
Reference in New Issue
Block a user