diff options
author | Simon J. Gerraty <sjg@FreeBSD.org> | 2020-11-07 21:46:27 +0000 |
---|---|---|
committer | Simon J. Gerraty <sjg@FreeBSD.org> | 2020-11-07 21:46:27 +0000 |
commit | 956e45f6fb3e18b8e89b1341708db60c30bb9f27 (patch) | |
tree | b73e225c44ed4cf063ba39f347d06efaeccb3149 /contrib/bmake/unit-tests/comment.mk | |
parent | f908d8247ef4d535007f608593a29d62b5df3873 (diff) | |
parent | 302da1a3d35c15cb29d76e0a939f8bcb13f7ad80 (diff) |
Update to bmake-20201101
Lots of new unit-tests increase code coverage.
Lots of refactoring, cleanup and simlpification to reduce
code size.
Fixes for Bug 223564 and 245807
Updates to dirdeps.mk and meta2deps.py
Notes
Notes:
svn path=/head/; revision=367465
Diffstat (limited to 'contrib/bmake/unit-tests/comment.mk')
-rw-r--r-- | contrib/bmake/unit-tests/comment.mk | 85 |
1 files changed, 64 insertions, 21 deletions
diff --git a/contrib/bmake/unit-tests/comment.mk b/contrib/bmake/unit-tests/comment.mk index 7dd7dbbe28b5..1cdcfcdd86ba 100644 --- a/contrib/bmake/unit-tests/comment.mk +++ b/contrib/bmake/unit-tests/comment.mk @@ -1,31 +1,74 @@ -# This is a comment -.if ${MACHINE_ARCH} == something -FOO=bar -.endif - -#\ - Multiline comment +# $NetBSD: comment.mk,v 1.2 2020/09/07 19:17:36 rillig Exp $ +# +# Demonstrate how comments are written in makefiles. -BAR=# defined -FOOBAR= # defined +# This is a comment. -# This is an escaped comment \ -that keeps going until the end of this line +#\ +This is a multiline comment. -# Another escaped comment \ +# Another multiline comment \ that \ goes \ -on +on and on. + + # Comments can be indented, but that is rather unusual. + + # Comments can be indented with a tab. + # These are not shell commands, they are just makefile comments. + +.if 1 # There can be comments after conditions. +.endif # And after the closing directive. + +VAR= # This comment makes the variable value empty. +.if ${VAR} != "" +. error +.endif + +# The comment does not need to start at the beginning of a word (as in the +# shell), it can start anywhere. +VAR=# defined but empty + +# The space before the comment is always trimmed. +VAR= value +.if ${VAR} != "value" +. error +.endif # This is NOT an escaped comment due to the double backslashes \\ -all: hi foo bar - @echo comment testing done +VAR= not part of the comment +.if ${VAR} != "not part of the comment" +. error +.endif -hi: - @echo comment testing start +# To escape a comment sign, precede it with a backslash. +VAR= \# # Both in the assignment. +.if ${VAR} != "\#" # And in the comparison. +. error +.endif + +# Since 2012-03-24 the variable modifier :[#] does not need to be escaped. +# To keep the parsing code simple, any "[#" does not start a comment, even +# outside of a variable expression. +WORDS= ${VAR:[#]} [# +.if ${WORDS} != "1 [#" +. error +.endif -foo: - @echo this is $@ +# An odd number of comment signs makes a line continuation, \\\ +no matter if it is 3 or 5 \\\\\ +or 9 backslashes. \\\\\\\\\ +This is the last line of the comment. +VAR= no comment anymore +.if ${VAR} != "no comment anymore" +. error +.endif -bar: - @echo This is how a comment looks: '# comment' +all: +# In the commands associated with a target, the '#' does not start a makefile +# comment. The '#' is just passed to the shell, like any ordinary character. + echo This is a shell comment: # comment +# If the '#' were to start a makefile comment, the following shell command +# would have unbalanced quotes. + echo This is not a shell comment: '# comment' + @echo A shell comment can#not start in the middle of a word. |