targ.c
来自「早期freebsd实现」· C语言 代码 · 共 586 行 · 第 1/2 页
C
586 行
} else { return (FALSE); }}/*- *----------------------------------------------------------------------- * Targ_Precious -- * See if the given target is precious * * Results: * TRUE if it is precious. FALSE otherwise * * Side Effects: * None *----------------------------------------------------------------------- */BooleanTarg_Precious (gn) GNode *gn; /* the node to check */{ if (allPrecious || (gn->type & (OP_PRECIOUS|OP_DOUBLEDEP))) { return (TRUE); } else { return (FALSE); }}/******************* DEBUG INFO PRINTING ****************/static GNode *mainTarg; /* the main target, as set by Targ_SetMain *//*- *----------------------------------------------------------------------- * Targ_SetMain -- * Set our idea of the main target we'll be creating. Used for * debugging output. * * Results: * None. * * Side Effects: * "mainTarg" is set to the main target's node. *----------------------------------------------------------------------- */voidTarg_SetMain (gn) GNode *gn; /* The main target we'll create */{ mainTarg = gn;}static int/*ARGSUSED*/TargPrintName (gn, ppath) GNode *gn; int ppath;{ printf ("%s ", gn->name);#ifdef notdef if (ppath) { if (gn->path) { printf ("[%s] ", gn->path); } if (gn == mainTarg) { printf ("(MAIN NAME) "); } }#endif /* notdef */ return (0);}intTarg_PrintCmd (cmd) char *cmd;{ printf ("\t%s\n", cmd); return (0);}/*- *----------------------------------------------------------------------- * Targ_FmtTime -- * Format a modification time in some reasonable way and return it. * * Results: * The time reformatted. * * Side Effects: * The time is placed in a static area, so it is overwritten * with each call. * *----------------------------------------------------------------------- */char *Targ_FmtTime (time) time_t time;{ struct tm *parts; static char buf[40]; static char *months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; parts = localtime(&time); sprintf (buf, "%d:%02d:%02d %s %d, 19%d", parts->tm_hour, parts->tm_min, parts->tm_sec, months[parts->tm_mon], parts->tm_mday, parts->tm_year); return(buf);} /*- *----------------------------------------------------------------------- * Targ_PrintType -- * Print out a type field giving only those attributes the user can * set. * * Results: * * Side Effects: * *----------------------------------------------------------------------- */voidTarg_PrintType (type) register int type;{ register int tbit; #ifdef __STDC__#define PRINTBIT(attr) case CONCAT(OP_,attr): printf("." #attr " "); break#define PRINTDBIT(attr) case CONCAT(OP_,attr): if (DEBUG(TARG)) printf("." #attr " "); break#else#define PRINTBIT(attr) case CONCAT(OP_,attr): printf(".attr "); break#define PRINTDBIT(attr) case CONCAT(OP_,attr): if (DEBUG(TARG)) printf(".attr "); break#endif /* __STDC__ */ type &= ~OP_OPMASK; while (type) { tbit = 1 << (ffs(type) - 1); type &= ~tbit; switch(tbit) { PRINTBIT(OPTIONAL); PRINTBIT(USE); PRINTBIT(EXEC); PRINTBIT(IGNORE); PRINTBIT(PRECIOUS); PRINTBIT(SILENT); PRINTBIT(MAKE); PRINTBIT(JOIN); PRINTBIT(INVISIBLE); PRINTBIT(NOTMAIN); PRINTDBIT(LIB); /*XXX: MEMBER is defined, so CONCAT(OP_,MEMBER) gives OP_"%" */ case OP_MEMBER: if (DEBUG(TARG)) printf(".MEMBER "); break; PRINTDBIT(ARCHV); } }}/*- *----------------------------------------------------------------------- * TargPrintNode -- * print the contents of a node *----------------------------------------------------------------------- */static intTargPrintNode (gn, pass) GNode *gn; int pass;{ if (!OP_NOP(gn->type)) { printf("#\n"); if (gn == mainTarg) { printf("# *** MAIN TARGET ***\n"); } if (pass == 2) { if (gn->unmade) { printf("# %d unmade children\n", gn->unmade); } else { printf("# No unmade children\n"); } if (! (gn->type & (OP_JOIN|OP_USE|OP_EXEC))) { if (gn->mtime != 0) { printf("# last modified %s: %s\n", Targ_FmtTime(gn->mtime), (gn->made == UNMADE ? "unmade" : (gn->made == MADE ? "made" : (gn->made == UPTODATE ? "up-to-date" : "error when made")))); } else if (gn->made != UNMADE) { printf("# non-existent (maybe): %s\n", (gn->made == MADE ? "made" : (gn->made == UPTODATE ? "up-to-date" : (gn->made == ERROR ? "error when made" : "aborted")))); } else { printf("# unmade\n"); } } if (!Lst_IsEmpty (gn->iParents)) { printf("# implicit parents: "); Lst_ForEach (gn->iParents, TargPrintName, (ClientData)0); fputc ('\n', stdout); } } if (!Lst_IsEmpty (gn->parents)) { printf("# parents: "); Lst_ForEach (gn->parents, TargPrintName, (ClientData)0); fputc ('\n', stdout); } printf("%-16s", gn->name); switch (gn->type & OP_OPMASK) { case OP_DEPENDS: printf(": "); break; case OP_FORCE: printf("! "); break; case OP_DOUBLEDEP: printf(":: "); break; } Targ_PrintType (gn->type); Lst_ForEach (gn->children, TargPrintName, (ClientData)0); fputc ('\n', stdout); Lst_ForEach (gn->commands, Targ_PrintCmd, (ClientData)0); printf("\n\n"); if (gn->type & OP_DOUBLEDEP) { Lst_ForEach (gn->cohorts, TargPrintNode, (ClientData)pass); } } return (0);}/*- *----------------------------------------------------------------------- * TargPrintOnlySrc -- * Print only those targets that are just a source. * * Results: * 0. * * Side Effects: * The name of each file is printed preceeded by #\t * *----------------------------------------------------------------------- */static intTargPrintOnlySrc(gn) GNode *gn;{ if (OP_NOP(gn->type)) { printf("#\t%s [%s]\n", gn->name, gn->path ? gn->path : gn->name); } return (0);}/*- *----------------------------------------------------------------------- * Targ_PrintGraph -- * print the entire graph. heh heh * * Results: * none * * Side Effects: * lots o' output *----------------------------------------------------------------------- */voidTarg_PrintGraph (pass) int pass; /* Which pass this is. 1 => no processing * 2 => processing done */{ printf("#*** Input graph:\n"); Lst_ForEach (allTargets, TargPrintNode, (ClientData)pass); printf("\n\n"); printf("#\n# Files that are only sources:\n"); Lst_ForEach (allTargets, TargPrintOnlySrc); printf("#*** Global Variables:\n"); Var_Dump (VAR_GLOBAL); printf("#*** Command-line Variables:\n"); Var_Dump (VAR_CMD); printf("\n"); Dir_PrintDirectories(); printf("\n"); Suff_PrintAll();}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?