Commit Graph

15196 Commits

Author SHA1 Message Date
rillig
981a071ef1 make(1): add test for unintended double expansion of deferred commands 2020-09-22 19:41:09 +00:00
rillig
cea1f12002 make(1): remove obsolete fix for PR bin/29985 2020-09-22 19:08:47 +00:00
rillig
71c3558cf2 make(1): add test for .for loop from PR bin/29985 2020-09-22 18:54:50 +00:00
rillig
5215803cd6 make(1): prepare error handling in nested variable expressions
Having ParseModifierPart return VarParseResult allows to report the
errors from nested variable expressions.
2020-09-22 18:07:58 +00:00
rillig
188824f8ab make(1): handle errors about missing delimiter in a single place 2020-09-22 17:51:06 +00:00
rillig
d91446df81 make(1): move ParseModifierPart further down in the code
This way, it can access the ApplyModifierState, which will be used in a
follow-up commit to reduce the code duplication around the error
handling for missing delimiters.
2020-09-22 17:42:57 +00:00
rillig
6c593e8a6f make(1): remove remaining references to VAR_JUNK and VAR_KEEP 2020-09-22 06:23:33 +00:00
rillig
40e77a92f9 make(1): move VAR_JUNK and VAR_KEEP away from VarFlags
These two flags have nothing to do with a variable.  They are only used
while evaluating a variable expression.

While here, rename the flags and make their documentation more precise.
2020-09-22 06:13:38 +00:00
rillig
0dcd908ccd make(1): rename VarParseErrors to VarParseResult
The name VPE_OK was confusing since it was not an error at all.
2020-09-22 06:06:18 +00:00
rillig
0c35a86423 make(1): extract common code from the ApplyModifier functions 2020-09-22 05:55:49 +00:00
rillig
d7cf3a1628 make(1): fix type of global variable 'create' 2020-09-22 05:12:08 +00:00
rillig
a2ec3df107 make(1): use fine-grained type names for lists and their nodes
This is only intended to help the human reader.  There is no additional
type safety yet.
2020-09-22 04:05:41 +00:00
rillig
222b541caf make(1): rename type Path to CachedDir
The word "path" is commonly used either as an abbreviation for pathname
(a string consisting of several directory or file names) or as an
abbreviation for search path (a list of directory names used for
searching files), but not for a single directory.
2020-09-22 02:26:22 +00:00
rillig
d5631b520f make(1): add specific typedefs for lists
These typedefs are only intended to help human readers, they do not
provide any type-safety.  They also make the pointers explicit, which
had been hidden before by the typedef for Lst and LstNode.  Typing a few
'*' is less work than finding out which of the many types are pointers
and which aren't.

In meta.c, the variable "ln" served two completely different purposes,
which have been split again.  Register allocation is the job of the
compiler, not of the human source code reader.
2020-09-21 17:44:25 +00:00
rillig
69ef6fbe0d make(1): clean up VarParseErrors, for proper error handling
Having a pure bitset was wrong.

Instead, there are several alternatives (parse error, eval error, undef
error), and each of them can either have an error message printed (good)
or not (bad).  In addition, there are VPE_OK for successful expression
evaluation and VPE_UNKNOWN (only used during migration to the correct
error handling scheme).
2020-09-21 05:28:26 +00:00
rillig
cc07d45207 make(1): run tests with absolute filenames as well
The tests varname-dot-parsedir and varname-dot-parsefile had been broken
before if they were run with the "-f $PWD/$test.mk" option.  This way of
running the tests is used by FreeBSD.
2020-09-21 04:20:35 +00:00
rillig
a5c78e4ba6 make(1): fix tests for .PARSEDIR/.PARSEFILE
The output of these tests previously depended upon whether the test
makefile was specified as relative or as absolute path.  In NetBSD, it
is specified as relative path, in FreeBSD as absolute path.

Adjust the expected output to hide this difference; in the .rawout files
it is still visible.
2020-09-21 03:45:29 +00:00
rillig
7c8060daaa make(1): clean up Arch_ParseArchive
This code is so seldom used that it's not necessary to squeeze out every
little bit of performance.  It's more important for the code to be clear
and simple.
2020-09-21 03:12:25 +00:00
christos
5201132afb add optimize attribute 2020-09-18 14:19:08 +00:00
rillig
4533eb952d make(1): move flags for lint test into the test itself 2020-09-15 16:22:04 +00:00
rillig
112abe58bf make(1): fix coverity annotation for CondParser_String
It had been broken since 2020-09-08, when CondLexer (now CondParser) was
added.
2020-09-14 23:09:34 +00:00
rillig
5645426c7a make(1): fix wrong error for undefined variables in lint mode 2020-09-14 21:55:53 +00:00
rillig
ac0094dd94 make(1): add test for wrong error in lint mode for undefined variable 2020-09-14 21:52:49 +00:00
rillig
10c494f5ff make(1): in lint mode, allow undefined variables in dependency lines
This is needed to get past the first few seconds in a src/build.sh run.

The nest obstacle is src/tools/Makefile.gnuhost:30, where the variable
MODULE is undefined even though that file says in line 3 that MODULE is
expected to be set.  It has been saying this since 2001, but since make
didn't have the corresponding check enabled, this didn't break the
build.
2020-09-14 21:23:58 +00:00
rillig
ad00bcf04d make(1): inline character constants in var.c
This removes a level of indirection, and the macro names were quite
similar in appearance as well.  The macros may have been used by people
whose editors don't recognize C string and character literals when
navigating to the corresponding brace or parenthesis.  These editors had
already been confused before this commit since there are also string
literals with unbalanced parentheses, and there are far fewer
compensating comments such as /*{*/ or /*)*/ in the code.  In fact, the
only such comment that is left over was in for.c.

This way, there is now a single consistent way of writing these
character literals, which is without macros or comments, since that is
the simplest form.
2020-09-14 20:43:44 +00:00
rillig
e55733cb76 make(1): describe how Parse_Error might print stack traces
In deeply nested include chains and .for loops this may be a useful
feature.  It's a little tricky to generate an intuitive stack trace,
though not impossible.  This explanation also serves as a detailed
documentation about how the .include and .for directives are
implemented.
2020-09-14 19:59:47 +00:00
rillig
0d13485d3e make(1): in debug mode, reset unused stack space to NULL 2020-09-14 19:14:19 +00:00
rillig
21bb227975 make(1): add test for nested .for loops with the same variable name 2020-09-14 18:49:24 +00:00
rillig
3f32a1d72c make(1): in the deptgt test, describe what happens to the targets 2020-09-14 18:27:15 +00:00
rillig
75e5886cf1 make(1): add test for the global variable 'targets' in parse.c 2020-09-14 18:21:26 +00:00
rillig
4c8fef9626 make(1): fix documentation of ParseLinkSrcArgs.specType
That code is never called for .SUFFIXES, but for .END.
2020-09-14 17:47:05 +00:00
rillig
d88b36aad9 make(1): clean up documentation and code of ParseLinkSrc
The previous documentation was focused on the implementation details,
which are already clear from the code.  Add some high-level
documentation to help readers understand how this function fits into the
overall picture.
2020-09-14 17:44:57 +00:00
rillig
f199ad3e4a make(1): add test for combining several special targets 2020-09-14 17:43:36 +00:00
rillig
27738dea48 make(1): eliminate the global variable specType
This variable didn't have an intended lifetype of "whole application",
therefore it is better implemented as a local variable that is passed
around the few functions that really need it.  It's the same pattern as
in the ModifyWord functions in var.c, only this time without a typedef.
2020-09-14 16:59:41 +00:00
rillig
74f34665fb make(1): extract ParseDependencyTargetWord from ParseDoDependency 2020-09-14 16:40:06 +00:00
rillig
dffdd63b59 make(1): split "general GNode *" in ParseDoDepends 2020-09-14 16:33:07 +00:00
rillig
86d18b352d make(1): fix type of parseKeywords.op 2020-09-14 16:27:07 +00:00
rillig
21665c21f2 make(1): extract some code out of ParseDoDependency
With its almost 600 lines, that function is way too long.
2020-09-14 16:23:32 +00:00
rillig
fd153a3a13 make(1): inline LPAREN in parse.c
It's shorter and more readable, and the other characters don't have
named constants as well.
2020-09-14 16:16:52 +00:00
rillig
6741204b24 make(1): flip conditions in ParseDoDependency
In the usual case where the character is a letter or another ordinary
character, each of the terminal conditions has to be evaluated,
therefore from the compiler's view the order doesn't matter.  For
humans, "a unless b" is easier to grasp and more common than "not b but
a", therefore switch to the common pattern.
2020-09-14 16:12:41 +00:00
rillig
958e367541 make(1): split complicated condition in ParseDoDependency 2020-09-14 16:05:09 +00:00
rillig
768cfb5d6c make(1): split confusing condition in ParseDoDependency
A while loop is easier to understand than a do-while loop.

An if statement of the form if-something-then-do-something is easier to
understand than if-complicated-condition-then-continue-doing-something.
2020-09-14 15:11:13 +00:00
rillig
48b1b863bb make(1): clean up documentation of ParseDoDependency
The documentation was too low-level in parts, essentially repeating the
code in prose.  Instead, add more examples and high-level context
information since that is something that the code cannot do.
2020-09-14 14:58:27 +00:00
rillig
24903bc708 make(1): remove obsolete comments from tests 2020-09-14 07:13:29 +00:00
rillig
f8025cdcc2 make(1): don't require nested variables to be defined in conditions
This code only applies to lint mode (-dL) for now.  After a test phase
and a thorough check for possible side effects, it will be activated in
normal mode, too.  Having this code in lint mode is required to run
src/build.sh, which relies a lot on using variables with undefined
nested variables in conditions.

In the default mode, any errors about nested undefined variables are not
printed since in Var_Subst, oldVars is true.  Therefore, it is not urgent
to properly handle these nested variables correctly there.
2020-09-14 07:04:56 +00:00
rillig
10c6f48261 make(1): add test for undefined expressions in conditions in lint mode 2020-09-14 06:44:50 +00:00
rillig
b444745605 make(1): add tests for numbers in conditions 2020-09-14 06:22:59 +00:00
rillig
d1c3f534be make(1): rename local variables in PrintLocation
For PrintLocation, there is no "current" filename or line number,
therefore the "c" in the variable names was confusing.
2020-09-13 21:12:08 +00:00
rillig
b12b32662d make(1): in Var_Parse, replace bmake_strldup with bmake_strsedup 2020-09-13 21:03:14 +00:00
rillig
f9fe73b2ff make(1): add test for dynamic variable with modifiers in Var_Parse 2020-09-13 21:00:34 +00:00