Module Name: src Committed By: rillig Date: Thu Oct 8 18:37:26 UTC 2020
Modified Files: src/usr.bin/make/unit-tests: archive.exp archive.mk Log Message: make(1): make individual targets in test archive.mk visible This test still fails on FreeBSD, printing the "ar cru, ranlib" lines twice, and I don't know why. To get more insights into the inner details, without activating the full -dA logging, split the output into paragraphs, one per target. This change reveals another interesting detail: Dependencies without any commands (in this case create-archive) don't inherit the commands from .USEBEFORE and .USE sources. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/archive.exp cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/archive.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/make/unit-tests/archive.exp diff -u src/usr.bin/make/unit-tests/archive.exp:1.5 src/usr.bin/make/unit-tests/archive.exp:1.6 --- src/usr.bin/make/unit-tests/archive.exp:1.5 Fri Sep 4 17:03:17 2020 +++ src/usr.bin/make/unit-tests/archive.exp Thu Oct 8 18:37:26 2020 @@ -1,14 +1,28 @@ +Making remove-archive rm -f libprog.a + +Making libprog.a out-of-date archive.mk modmisc.mk varmisc.mk ar cru libprog.a archive.mk modmisc.mk varmisc.mk ranlib libprog.a + +Making create-archive out-of-date libprog.a + +Making list-archive out-of-date libprog.a ar t libprog.a archive.mk modmisc.mk varmisc.mk + +Making list-archive-wildcard out-of-date ternary.mk archive-suffix.mk archive.mk list-archive-wildcard: archive-suffix.mk list-archive-wildcard: archive.mk list-archive-wildcard: ternary.mk + +Making depend-on-existing-member out-of-date archive.mk depend-on-existing-member + `depend-on-nonexistent-member' is up to date. +Making remove-archive rm -f libprog.a + exit status 0 Index: src/usr.bin/make/unit-tests/archive.mk diff -u src/usr.bin/make/unit-tests/archive.mk:1.8 src/usr.bin/make/unit-tests/archive.mk:1.9 --- src/usr.bin/make/unit-tests/archive.mk:1.8 Mon Sep 7 05:16:32 2020 +++ src/usr.bin/make/unit-tests/archive.mk Thu Oct 8 18:37:26 2020 @@ -1,4 +1,4 @@ -# $NetBSD: archive.mk,v 1.8 2020/09/07 05:16:32 rillig Exp $ +# $NetBSD: archive.mk,v 1.9 2020/10/08 18:37:26 rillig Exp $ # # Very basic demonstration of handling archives, based on the description # in PSD.doc/tutorial.ms. @@ -17,9 +17,9 @@ all: .if ${.PARSEDIR:tA} != ${.CURDIR:tA} @cd ${MAKEFILE:H} && cp ${FILES} [at]*.mk ${.CURDIR} .endif -# The following targets are run in sub-makes to ensure that they get the -# current state of the filesystem right, since they creating and removing -# files. +# The following targets create and remove files. The filesystem cache in +# dir.c would probably not handle this correctly, therefore each of the +# targets is run in its separate sub-make. ${RUN} ${MAKE_CMD} remove-archive ${RUN} ${MAKE_CMD} create-archive ${RUN} ${MAKE_CMD} list-archive @@ -28,30 +28,35 @@ all: ${RUN} ${MAKE_CMD} depend-on-nonexistent-member ${RUN} ${MAKE_CMD} remove-archive -create-archive: ${ARCHIVE} +create-archive: ${ARCHIVE} pre post # The indirect references with the $$ cover the code in Arch_ParseArchive # that calls Var_Parse. It's an esoteric scenario since at the point where # Arch_ParseArchive is called, the dependency line is already fully expanded. # -${ARCHIVE}: $${:Ulibprog.a}(archive.mk modmisc.mk $${:Uvarmisc.mk}) +${ARCHIVE}: $${:Ulibprog.a}(archive.mk modmisc.mk $${:Uvarmisc.mk}) pre post ar cru ${.TARGET} ${.OODATE} ranlib ${.TARGET} -list-archive: ${ARCHIVE} +list-archive: ${ARCHIVE} pre post ar t ${.ALLSRC} # XXX: I had expected that this dependency would select all *.mk files from # the archive. Instead, the globbing is done in the current directory. # To prevent an overly long file list, the pattern is restricted to [at]*.mk. -list-archive-wildcard: ${ARCHIVE}([at]*.mk) +list-archive-wildcard: ${ARCHIVE}([at]*.mk) pre post ${RUN} printf '%s\n' ${.ALLSRC:O:@member@${.TARGET:Q}': '${member:Q}@} -depend-on-existing-member: ${ARCHIVE}(archive.mk) +depend-on-existing-member: ${ARCHIVE}(archive.mk) pre post ${RUN} echo $@ -depend-on-nonexistent-member: ${ARCHIVE}(nonexistent.mk) +depend-on-nonexistent-member: ${ARCHIVE}(nonexistent.mk) pre post ${RUN} echo $@ -remove-archive: +remove-archive: pre post rm -f ${ARCHIVE} + +pre: .USEBEFORE + @echo Making ${.TARGET} ${.OODATE:C,.+,out-of-date,W} ${.OODATE} +post: .USE + @echo