| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: targ.c,v 1.99 2020/09/26 16:55:58 rillig Exp $ */ | | 1 | /* $NetBSD: targ.c,v 1.100 2020/09/26 17:02:11 rillig Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1988, 1989, 1990, 1993 | | 4 | * Copyright (c) 1988, 1989, 1990, 1993 |
5 | * The Regents of the University of California. All rights reserved. | | 5 | * The Regents of the University of California. All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to Berkeley by | | 7 | * This code is derived from software contributed to Berkeley by |
8 | * Adam de Boor. | | 8 | * Adam de Boor. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -111,27 +111,27 @@ | | | @@ -111,27 +111,27 @@ |
111 | * Debugging: | | 111 | * Debugging: |
112 | * Targ_PrintGraph Print out the entire graphm all variables | | 112 | * Targ_PrintGraph Print out the entire graphm all variables |
113 | * and statistics for the directory cache. Should | | 113 | * and statistics for the directory cache. Should |
114 | * print something for suffixes, too, but... | | 114 | * print something for suffixes, too, but... |
115 | */ | | 115 | */ |
116 | | | 116 | |
117 | #include <stdio.h> | | 117 | #include <stdio.h> |
118 | #include <time.h> | | 118 | #include <time.h> |
119 | | | 119 | |
120 | #include "make.h" | | 120 | #include "make.h" |
121 | #include "dir.h" | | 121 | #include "dir.h" |
122 | | | 122 | |
123 | /* "@(#)targ.c 8.2 (Berkeley) 3/19/94" */ | | 123 | /* "@(#)targ.c 8.2 (Berkeley) 3/19/94" */ |
124 | MAKE_RCSID("$NetBSD: targ.c,v 1.99 2020/09/26 16:55:58 rillig Exp $"); | | 124 | MAKE_RCSID("$NetBSD: targ.c,v 1.100 2020/09/26 17:02:11 rillig Exp $"); |
125 | | | 125 | |
126 | static GNodeList *allTargets; /* the list of all targets found so far */ | | 126 | static GNodeList *allTargets; /* the list of all targets found so far */ |
127 | #ifdef CLEANUP | | 127 | #ifdef CLEANUP |
128 | static GNodeList *allGNs; /* List of all the GNodes */ | | 128 | static GNodeList *allGNs; /* List of all the GNodes */ |
129 | #endif | | 129 | #endif |
130 | static Hash_Table targets; /* a hash table of same */ | | 130 | static Hash_Table targets; /* a hash table of same */ |
131 | | | 131 | |
132 | #ifdef CLEANUP | | 132 | #ifdef CLEANUP |
133 | static void TargFreeGN(void *); | | 133 | static void TargFreeGN(void *); |
134 | #endif | | 134 | #endif |
135 | | | 135 | |
136 | void | | 136 | void |
137 | Targ_Init(void) | | 137 | Targ_Init(void) |
| @@ -501,54 +501,57 @@ PrintNode(void *gnp, void *passp) | | | @@ -501,54 +501,57 @@ PrintNode(void *gnp, void *passp) |
501 | /* Print the contents of a node. */ | | 501 | /* Print the contents of a node. */ |
502 | void | | 502 | void |
503 | Targ_PrintNode(GNode *gn, int pass) | | 503 | Targ_PrintNode(GNode *gn, int pass) |
504 | { | | 504 | { |
505 | PrintNode(gn, &pass); | | 505 | PrintNode(gn, &pass); |
506 | } | | 506 | } |
507 | | | 507 | |
508 | void | | 508 | void |
509 | Targ_PrintNodes(GNodeList *gnodes, int pass) | | 509 | Targ_PrintNodes(GNodeList *gnodes, int pass) |
510 | { | | 510 | { |
511 | Lst_ForEach(gnodes, PrintNode, &pass); | | 511 | Lst_ForEach(gnodes, PrintNode, &pass); |
512 | } | | 512 | } |
513 | | | 513 | |
514 | /* Print only those targets that are just a source. | | 514 | /* Print only those targets that are just a source. */ |
515 | * The name of each file is printed, preceded by #\t. */ | | | |
516 | static void | | 515 | static void |
517 | TargPrintOnlySrc(void *gnp, void *dummy MAKE_ATTR_UNUSED) | | 516 | PrintOnlySources(void) |
518 | { | | 517 | { |
519 | GNode *gn = (GNode *)gnp; | | 518 | GNodeListNode *ln; |
520 | if (!OP_NOP(gn->type)) | | | |
521 | return; | | | |
522 | | | 519 | |
523 | fprintf(debug_file, "#\t%s [%s]", | | 520 | for (ln = allTargets->first; ln != NULL; ln = ln->next) { |
524 | gn->name, gn->path ? gn->path : gn->name); | | 521 | GNode *gn = ln->datum; |
525 | Targ_PrintType(gn->type); | | 522 | if (!OP_NOP(gn->type)) |
526 | fprintf(debug_file, "\n"); | | 523 | continue; |
| | | 524 | |
| | | 525 | fprintf(debug_file, "#\t%s [%s]", |
| | | 526 | gn->name, gn->path ? gn->path : gn->name); |
| | | 527 | Targ_PrintType(gn->type); |
| | | 528 | fprintf(debug_file, "\n"); |
| | | 529 | } |
527 | } | | 530 | } |
528 | | | 531 | |
529 | /* Input: | | 532 | /* Input: |
530 | * pass 1 => before processing | | 533 | * pass 1 => before processing |
531 | * 2 => after processing | | 534 | * 2 => after processing |
532 | * 3 => after processing, an error occurred | | 535 | * 3 => after processing, an error occurred |
533 | */ | | 536 | */ |
534 | void | | 537 | void |
535 | Targ_PrintGraph(int pass) | | 538 | Targ_PrintGraph(int pass) |
536 | { | | 539 | { |
537 | fprintf(debug_file, "#*** Input graph:\n"); | | 540 | fprintf(debug_file, "#*** Input graph:\n"); |
538 | Lst_ForEach(allTargets, PrintNode, &pass); | | 541 | Targ_PrintNodes(allTargets, pass); |
539 | fprintf(debug_file, "\n\n"); | | 542 | fprintf(debug_file, "\n\n"); |
540 | fprintf(debug_file, "#\n# Files that are only sources:\n"); | | 543 | fprintf(debug_file, "#\n# Files that are only sources:\n"); |
541 | Lst_ForEach(allTargets, TargPrintOnlySrc, NULL); | | 544 | PrintOnlySources(); |
542 | fprintf(debug_file, "#*** Global Variables:\n"); | | 545 | fprintf(debug_file, "#*** Global Variables:\n"); |
543 | Var_Dump(VAR_GLOBAL); | | 546 | Var_Dump(VAR_GLOBAL); |
544 | fprintf(debug_file, "#*** Command-line Variables:\n"); | | 547 | fprintf(debug_file, "#*** Command-line Variables:\n"); |
545 | Var_Dump(VAR_CMD); | | 548 | Var_Dump(VAR_CMD); |
546 | fprintf(debug_file, "\n"); | | 549 | fprintf(debug_file, "\n"); |
547 | Dir_PrintDirectories(); | | 550 | Dir_PrintDirectories(); |
548 | fprintf(debug_file, "\n"); | | 551 | fprintf(debug_file, "\n"); |
549 | Suff_PrintAll(); | | 552 | Suff_PrintAll(); |
550 | } | | 553 | } |
551 | | | 554 | |
552 | /* Propagate some type information to cohort nodes (those from the :: | | 555 | /* Propagate some type information to cohort nodes (those from the :: |
553 | * dependency operator). | | 556 | * dependency operator). |
554 | * | | 557 | * |