make(1): add GNode_Path to access the path of a GNode

This commit is contained in:
rillig 2020-10-25 21:51:48 +00:00
parent d81e818f6b
commit bc562b20b4
8 changed files with 36 additions and 33 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: dir.c,v 1.188 2020/10/25 19:19:07 rillig Exp $ */
/* $NetBSD: dir.c,v 1.189 2020/10/25 21:51:48 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@ -135,7 +135,7 @@
#include "job.h"
/* "@(#)dir.c 8.2 (Berkeley) 1/2/94" */
MAKE_RCSID("$NetBSD: dir.c,v 1.188 2020/10/25 19:19:07 rillig Exp $");
MAKE_RCSID("$NetBSD: dir.c,v 1.189 2020/10/25 21:51:48 rillig Exp $");
#define DIR_DEBUG0(text) DEBUG0(DIR, text)
#define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1)
@ -1367,9 +1367,8 @@ Dir_MTime(GNode *gn, Boolean recheck)
}
}
if (fullName && gn->path == NULL) {
if (fullName != NULL && gn->path == NULL)
gn->path = fullName;
}
gn->mtime = mst.mst_mtime;
return gn->mtime;

View File

@ -1,4 +1,4 @@
/* $NetBSD: job.c,v 1.286 2020/10/25 21:34:52 rillig Exp $ */
/* $NetBSD: job.c,v 1.287 2020/10/25 21:51:48 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@ -143,7 +143,7 @@
#include "trace.h"
/* "@(#)job.c 8.2 (Berkeley) 3/19/94" */
MAKE_RCSID("$NetBSD: job.c,v 1.286 2020/10/25 21:34:52 rillig Exp $");
MAKE_RCSID("$NetBSD: job.c,v 1.287 2020/10/25 21:51:48 rillig Exp $");
/* A shell defines how the commands are run. All commands for a target are
* written into a single file, which is then given to the shell to execute
@ -443,6 +443,8 @@ job_table_dump(const char *where)
static void
JobDeleteTarget(GNode *gn)
{
const char *file;
if (gn->type & OP_JOIN)
return;
if (gn->type & OP_PHONY)
@ -452,12 +454,10 @@ JobDeleteTarget(GNode *gn)
if (noExecute)
return;
{
char *file = (gn->path == NULL ? gn->name : gn->path);
file = GNode_Path(gn);
if (eunlink(file) != -1)
Error("*** %s removed", file);
}
}
/*
* JobSigLock/JobSigUnlock
@ -1138,7 +1138,7 @@ Job_Touch(GNode *gn, Boolean silent)
} else if (gn->type & OP_LIB) {
Arch_TouchLib(gn);
} else {
char *file = gn->path ? gn->path : gn->name;
const char *file = GNode_Path(gn);
times.actime = times.modtime = now;
if (utime(file, &times) < 0){

View File

@ -1,4 +1,4 @@
/* $NetBSD: make.c,v 1.179 2020/10/25 10:07:23 rillig Exp $ */
/* $NetBSD: make.c,v 1.180 2020/10/25 21:51:48 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -107,7 +107,7 @@
#include "job.h"
/* "@(#)make.c 8.1 (Berkeley) 6/6/93" */
MAKE_RCSID("$NetBSD: make.c,v 1.179 2020/10/25 10:07:23 rillig Exp $");
MAKE_RCSID("$NetBSD: make.c,v 1.180 2020/10/25 21:51:48 rillig Exp $");
/* Sequence # to detect recursion. */
static unsigned int checked = 1;
@ -294,8 +294,7 @@ Make_OODate(GNode *gn)
if (gn->youngestChild != NULL &&
gn->mtime < gn->youngestChild->mtime) {
debug_printf("modified before source %s...",
gn->youngestChild->path ? gn->youngestChild->path
: gn->youngestChild->name);
GNode_Path(gn->youngestChild));
} else if (gn->mtime == 0) {
debug_printf("non-existent and no sources...");
} else {
@ -785,7 +784,7 @@ MakeAddAllSrc(GNode *cgn, GNode *pgn)
if (cgn->type & OP_ARCHV)
child = Var_Value(MEMBER, cgn, &p1);
else
child = cgn->path ? cgn->path : cgn->name;
child = GNode_Path(cgn);
if (cgn->type & OP_JOIN) {
allsrc = Var_Value(ALLSRC, cgn, &p2);
} else {
@ -1178,7 +1177,7 @@ Make_ExpandUse(GNodeList *targs)
}
(void)Dir_MTime(gn, 0);
Var_Set(TARGET, gn->path ? gn->path : gn->name, gn);
Var_Set(TARGET, GNode_Path(gn), gn);
UnmarkChildren(gn);
HandleUseNodes(gn);

View File

@ -1,4 +1,4 @@
/* $NetBSD: make.h,v 1.171 2020/10/24 20:51:49 rillig Exp $ */
/* $NetBSD: make.h,v 1.172 2020/10/25 21:51:49 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -587,12 +587,18 @@ void GNode_FprintDetails(FILE *, const char *, const GNode *, const char *);
Boolean NoExecute(GNode *gn);
/* See if the node was seen on the left-hand side of a dependency operator. */
static Boolean MAKE_ATTR_UNUSED
static MAKE_ATTR_UNUSED Boolean
GNode_IsTarget(const GNode *gn)
{
return (gn->type & OP_OPMASK) != 0;
}
static MAKE_ATTR_UNUSED const char *
GNode_Path(const GNode *gn)
{
return gn->path != NULL ? gn->path : gn->name;
}
#ifdef __GNUC__
#define UNCONST(ptr) ({ \
union __unconst { \

View File

@ -1,4 +1,4 @@
/* $NetBSD: meta.c,v 1.130 2020/10/24 10:32:25 rillig Exp $ */
/* $NetBSD: meta.c,v 1.131 2020/10/25 21:51:49 rillig Exp $ */
/*
* Implement 'meta' mode.
@ -794,7 +794,7 @@ meta_job_error(Job *job, GNode *gn, int flags, int status)
"(ignored)" : "");
}
if (gn) {
Var_Set(".ERROR_TARGET", gn->path ? gn->path : gn->name, VAR_GLOBAL);
Var_Set(".ERROR_TARGET", GNode_Path(gn), VAR_GLOBAL);
}
getcwd(cwd, sizeof(cwd));
Var_Set(".ERROR_CWD", cwd, VAR_GLOBAL);

View File

@ -1,4 +1,4 @@
/* $NetBSD: suff.c,v 1.224 2020/10/25 17:12:51 rillig Exp $ */
/* $NetBSD: suff.c,v 1.225 2020/10/25 21:51:49 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -129,7 +129,7 @@
#include "dir.h"
/* "@(#)suff.c 8.4 (Berkeley) 3/21/94" */
MAKE_RCSID("$NetBSD: suff.c,v 1.224 2020/10/25 17:12:51 rillig Exp $");
MAKE_RCSID("$NetBSD: suff.c,v 1.225 2020/10/25 21:51:49 rillig Exp $");
#define SUFF_DEBUG0(text) DEBUG0(SUFF, text)
#define SUFF_DEBUG1(fmt, arg1) DEBUG1(SUFF, fmt, arg1)
@ -1788,7 +1788,7 @@ SuffFindNormalDeps(GNode *gn, SrcList *slst)
}
}
Var_Set(TARGET, gn->path ? gn->path : gn->name, gn);
Var_Set(TARGET, GNode_Path(gn), gn);
pref = (targ != NULL) ? targ->pref : gn->name;
Var_Set(PREFIX, pref, gn);
@ -1953,7 +1953,7 @@ SuffFindDeps(GNode *gn, SrcList *slst)
/*
* Make sure we have these set, may get revised below.
*/
Var_Set(TARGET, gn->path ? gn->path : gn->name, gn);
Var_Set(TARGET, GNode_Path(gn), gn);
Var_Set(PREFIX, gn->name, gn);
SUFF_DEBUG1("SuffFindDeps (%s)\n", gn->name);

View File

@ -1,4 +1,4 @@
/* $NetBSD: targ.c,v 1.123 2020/10/25 19:19:07 rillig Exp $ */
/* $NetBSD: targ.c,v 1.124 2020/10/25 21:51:49 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -121,7 +121,7 @@
#include "dir.h"
/* "@(#)targ.c 8.2 (Berkeley) 3/19/94" */
MAKE_RCSID("$NetBSD: targ.c,v 1.123 2020/10/25 19:19:07 rillig Exp $");
MAKE_RCSID("$NetBSD: targ.c,v 1.124 2020/10/25 21:51:49 rillig Exp $");
static GNodeList *allTargets; /* the list of all targets found so far */
#ifdef CLEANUP
@ -516,8 +516,7 @@ PrintOnlySources(void)
if (GNode_IsTarget(gn))
continue;
debug_printf("#\t%s [%s]",
gn->name, gn->path ? gn->path : gn->name);
debug_printf("#\t%s [%s]", gn->name, GNode_Path(gn));
Targ_PrintType(gn->type);
debug_printf("\n");
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: var.c,v 1.588 2020/10/25 19:19:07 rillig Exp $ */
/* $NetBSD: var.c,v 1.589 2020/10/25 21:51:49 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -121,7 +121,7 @@
#include "metachar.h"
/* "@(#)var.c 8.3 (Berkeley) 3/19/94" */
MAKE_RCSID("$NetBSD: var.c,v 1.588 2020/10/25 19:19:07 rillig Exp $");
MAKE_RCSID("$NetBSD: var.c,v 1.589 2020/10/25 21:51:49 rillig Exp $");
#define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
#define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@ -2172,7 +2172,7 @@ ApplyModifier_Path(const char **pp, ApplyModifiersState *st)
gn = Targ_FindNode(st->v->name);
if (gn == NULL || gn->type & OP_NOPATH) {
path = NULL;
} else if (gn->path) {
} else if (gn->path != NULL) {
path = bmake_strdup(gn->path);
} else {
SearchPath *searchPath = Suff_FindPath(gn);