Tue Dec 28 16:11:01 2021 UTC ()
make: make debug logging for .ORDER more human-friendly

The interesting part of the .ORDER constraint is what is made before
what, so reveal this information in the debug log.

The debug output from the test looks a bit strange since it forces
'three' to be made before 'one', but that's because the test exercises
the edge case of introducing a circular dependency.


(rillig)
diff -r1.591 -r1.592 src/usr.bin/make/parse.c
diff -r1.4 -r1.5 src/usr.bin/make/unit-tests/deptgt-order.exp

cvs diff -r1.591 -r1.592 src/usr.bin/make/parse.c (expand / switch to unified diff)

--- src/usr.bin/make/parse.c 2021/12/28 15:48:59 1.591
+++ src/usr.bin/make/parse.c 2021/12/28 16:11:00 1.592
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: parse.c,v 1.591 2021/12/28 15:48:59 rillig Exp $ */ 1/* $NetBSD: parse.c,v 1.592 2021/12/28 16:11:00 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.
@@ -99,27 +99,27 @@ @@ -99,27 +99,27 @@
99 99
100#include <sys/types.h> 100#include <sys/types.h>
101#include <sys/stat.h> 101#include <sys/stat.h>
102#include <errno.h> 102#include <errno.h>
103#include <stdarg.h> 103#include <stdarg.h>
104#include <stdint.h> 104#include <stdint.h>
105 105
106#include "make.h" 106#include "make.h"
107#include "dir.h" 107#include "dir.h"
108#include "job.h" 108#include "job.h"
109#include "pathnames.h" 109#include "pathnames.h"
110 110
111/* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */ 111/* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */
112MAKE_RCSID("$NetBSD: parse.c,v 1.591 2021/12/28 15:48:59 rillig Exp $"); 112MAKE_RCSID("$NetBSD: parse.c,v 1.592 2021/12/28 16:11:00 rillig Exp $");
113 113
114/* types and constants */ 114/* types and constants */
115 115
116/* 116/*
117 * Structure for a file being read ("included file") 117 * Structure for a file being read ("included file")
118 */ 118 */
119typedef struct IFile { 119typedef struct IFile {
120 FStr name; /* absolute or relative to the cwd */ 120 FStr name; /* absolute or relative to the cwd */
121 bool fromForLoop; /* simulated .include by the .for loop */ 121 bool fromForLoop; /* simulated .include by the .for loop */
122 int lineno; /* current line number in file */ 122 int lineno; /* current line number in file */
123 int first_lineno; /* line number of start of text */ 123 int first_lineno; /* line number of start of text */
124 unsigned int cond_depth; /* 'if' nesting when file opened */ 124 unsigned int cond_depth; /* 'if' nesting when file opened */
125 bool depending; /* state of doing_depend on EOF */ 125 bool depending; /* state of doing_depend on EOF */
@@ -890,28 +890,27 @@ ParseDependencySourceOrder(const char *s @@ -890,28 +890,27 @@ ParseDependencySourceOrder(const char *s
890 GNode *gn; 890 GNode *gn;
891 /* 891 /*
892 * Create proper predecessor/successor links between the previous 892 * Create proper predecessor/successor links between the previous
893 * source and the current one. 893 * source and the current one.
894 */ 894 */
895 gn = Targ_GetNode(src); 895 gn = Targ_GetNode(src);
896 if (doing_depend) 896 if (doing_depend)
897 RememberLocation(gn); 897 RememberLocation(gn);
898 if (order_pred != NULL) { 898 if (order_pred != NULL) {
899 Lst_Append(&order_pred->order_succ, gn); 899 Lst_Append(&order_pred->order_succ, gn);
900 Lst_Append(&gn->order_pred, order_pred); 900 Lst_Append(&gn->order_pred, order_pred);
901 if (DEBUG(PARSE)) { 901 if (DEBUG(PARSE)) {
902 debug_printf( 902 debug_printf(
903 "# ParseDependencySourceOrder: " 903 "# .ORDER forces '%s' to be made before '%s'\n",
904 "added Order dependency %s - %s\n", 
905 order_pred->name, gn->name); 904 order_pred->name, gn->name);
906 Targ_PrintNode(order_pred, 0); 905 Targ_PrintNode(order_pred, 0);
907 Targ_PrintNode(gn, 0); 906 Targ_PrintNode(gn, 0);
908 } 907 }
909 } 908 }
910 /* 909 /*
911 * The current source now becomes the predecessor for the next one. 910 * The current source now becomes the predecessor for the next one.
912 */ 911 */
913 order_pred = gn; 912 order_pred = gn;
914} 913}
915 914
916static void 915static void
917ParseDependencySourceOther(const char *src, GNodeType targetAttr, 916ParseDependencySourceOther(const char *src, GNodeType targetAttr,

cvs diff -r1.4 -r1.5 src/usr.bin/make/unit-tests/deptgt-order.exp (expand / switch to unified diff)

--- src/usr.bin/make/unit-tests/deptgt-order.exp 2021/12/28 15:49:00 1.4
+++ src/usr.bin/make/unit-tests/deptgt-order.exp 2021/12/28 16:11:00 1.5
@@ -1,11 +1,11 @@ @@ -1,11 +1,11 @@
1Parsing line 15: .ORDER: three one 1Parsing line 15: .ORDER: three one
2ParseDependency(.ORDER: three one) 2ParseDependency(.ORDER: three one)
3# ParseDependencySourceOrder: added Order dependency three - one 3# .ORDER forces 'three' to be made before 'one'
4# three, unmade, type OP_DEPENDS|OP_PHONY|OP_HAS_COMMANDS, flags none 4# three, unmade, type OP_DEPENDS|OP_PHONY|OP_HAS_COMMANDS, flags none
5# one, unmade, type OP_DEPENDS|OP_PHONY, flags none 5# one, unmade, type OP_DEPENDS|OP_PHONY, flags none
6Parsing line 16: .MAKEFLAGS: -d0 6Parsing line 16: .MAKEFLAGS: -d0
7ParseDependency(.MAKEFLAGS: -d0) 7ParseDependency(.MAKEFLAGS: -d0)
8: 'Making two out of one.' 8: 'Making two out of one.'
9: 'Making three out of two.' 9: 'Making three out of two.'
10: 'Making all out of three.' 10: 'Making all out of three.'
11exit status 0 11exit status 0