Commit Graph

15231 Commits

Author SHA1 Message Date
rillig
009ae8030a make(1): add tags to some of the unnamed structs
The tags prevent the structs from accidentally becoming compatible
types.

While here, remove a few typedefs for structs that are single-purpose,
since there is no point in abstracting from the actual representation of
these types.
2020-09-25 15:54:50 +00:00
rillig
9e29c82f91 make(1): rename local variables in ParseFuncArg 2020-09-25 15:40:06 +00:00
rillig
8d74bb7e38 make(1): inline ArchFindArchive into ArchStatMember
This avoids a few void pointers and unnecessary function calls.
2020-09-25 14:49:51 +00:00
rillig
cd77909724 make(1): make code in ArchSVR4Entry simpler 2020-09-25 14:41:35 +00:00
rillig
1699bf056f make(1): fix type of local variable in ParseModifierPart
Thanks, Clang-Tidy.
2020-09-25 14:10:09 +00:00
rillig
f7a07e60cf make(1): fix type of local variable in ApplyModifiers
Thanks, Clang-Tidy.
2020-09-25 14:07:12 +00:00
rillig
e1c1f6772d make(1): inline Lst_ForEach in MakeUnmark
By the way, the additional argument to Lst_ForEach was not used at all.
2020-09-25 14:00:17 +00:00
rillig
921a8f8fce make(1): replace a few calls to Lst_Open with simple loops
This avoids relying on the internal iterator of the list, which is
supposed to be removed in the near future.
2020-09-25 06:49:13 +00:00
rillig
96e1152df4 make(1): document details on why JobRun runs .END in compat mode 2020-09-25 06:20:44 +00:00
rillig
4b0186d54c make(1): document expansion of undefined variables in Var_Subst
From reading the code alone, it is not obvious what effects this
innocent-looking code has.
2020-09-25 06:06:15 +00:00
rillig
df955ddda3 make(1): add test for partial expansion of undefined variables 2020-09-25 05:56:59 +00:00
rillig
bb82a5bfdc make(1): rename local variables in Var_Subst
The variable name "str" did not make it clear enough that the pointer is
constantly moving, to parse the given string.  The name "p" expresses
this more clearly.
2020-09-25 05:04:51 +00:00
rillig
293320330f make(1): fix build on Debian 9
lst.h:92:5: error: unknown type name 'uint8_t'

It had been broken since the previous commit on 2020-09-24 08:23:29.
2020-09-25 04:18:11 +00:00
rillig
ff01c24104 make(1): make the API of the List partially public
Accessing the fields List.first, List.last, ListNode.prev, ListNode.next
and ListNode.datum in read-only mode should be more efficient than a
whole function call.

All modifications to the lists or their nodes must still happen via
function calls.

This change reduces the code size, makes the code faster to execute and
allows Lst_ForEach to be written inline without the visual overhead of
function calls.
2020-09-24 08:23:29 +00:00
rillig
7e3fe24ae7 make(1): remove redundant function prototypes in suff.c 2020-09-24 08:02:32 +00:00
rillig
1848d6d425 make(1): inline Lst_ForEach in Targ_PrintCmds 2020-09-24 07:59:33 +00:00
rillig
6d249710d5 make(1): migrate printCMD in meta mode to Lst_ForEach 2020-09-24 07:53:32 +00:00
rillig
c51b6afb9a make(1): inline Lst_ForEach for debugging output in search paths 2020-09-24 07:49:58 +00:00
rillig
02ca9f2d7e make(1): migrate MakeTimeStamp and MakeUnmark to Lst_ForEach 2020-09-24 07:37:42 +00:00
rillig
455f274a50 make(1): migrate MakeAddAllSrc to Lst_ForEach 2020-09-24 07:34:35 +00:00
rillig
7a5c7eeb37 make(1): move documentation for MakeAddAllSrc to its correct place 2020-09-24 07:32:03 +00:00
rillig
c3188d97f7 make(1): merge Lst_ForEachFrom into Lst_ForEachUntil 2020-09-24 07:23:26 +00:00
rillig
4ec7405c5c make(1): rename Lst_ForEach to Lst_ForEachUntil
Since the callback function returns a terminating condition, this is not
really a foreach loop.

Many of the calls to Lst_ForEachUntil don't make use of the terminating
condition, and several don't modify the list structurally, which means
they don't need this complicated implementation.

In a follow-up commit, Lst_ForEach will be added back with a much
simpler implementation that iterates over the list naively, without a
terminating condition and without taking the iteration state from
Lst_Open/Lst_Next/Lst_Close into account.  The migration to this simpler
implementation will be done step by step since each callback function
needs to be examined closely.
2020-09-24 07:11:29 +00:00
rillig
8410b85440 make(1): refactor add_wait_dep to not use Lst_ForEachFrom anymore
It was the last remaining use of that function outside of lst.c.

While here, clean up the code of add_wait_dep by removing unreachable
code (the GNode lists never contain NULL, only the GNode.commands lists
do that).
2020-09-24 06:45:59 +00:00
rillig
e9a7cfb4a5 make(1): extend documentation in the varname-empty test 2020-09-24 06:03:44 +00:00
rillig
24f144256a make(1): add tests for spaces in condition functions 2020-09-23 08:11:28 +00:00
rillig
7a66810d3a make(1): remove debug output from counter tests
Now that the tests work as intended, the debug information is no longer
necessary.  It was only intended to track down the cause of the
unexpected behavior.
2020-09-23 07:54:08 +00:00
rillig
b289a7c0b8 make(1): fix unexpected behavior in ::= variable modifier
Previously, the ::= modifier had returned an error value, which caused
the variable expression to be preserved.  This behavior was not useful
in this case; it had only been intended to be used for undefined
variables.

To fix it, distinguish between parse errors, undefined variables and
regular empty strings.
2020-09-23 07:50:58 +00:00
rillig
df5be418ac make(1): merge duplicate code for delayed commands 2020-09-23 07:30:12 +00:00
rillig
b032101167 make(1): inline local variable delim
Now that ParseModifierPart generates the error message itself, there is
no need to keep this variable around since it is read a single time.
2020-09-23 04:27:39 +00:00
rillig
cf2410f348 make(1): add variant of the counter test
I had expected that using the ::+= modifier instead of the ::= modifier
would work, since the assignment modifier for COUNTER no longer contains
a reference to itself.  But instead of ending up at 4, the counter even
goes up to 6.
2020-09-23 03:33:54 +00:00
rillig
84ce7c67b4 make(1): fix assertion failure in -j mode with .END node
There had been two separate global variables for the .END node, and in
parallel mode, only the one in jobs.c was initialized.

The code in JobRun heads over to Compat_Make without calling Compat_Run
first, which left the variable ENDNode uninitialized.
2020-09-23 03:06:38 +00:00
rillig
c28dae9d28 make(1): condense code in Var_Subst 2020-09-22 20:23:57 +00:00
rillig
e366c9989a make(1): prepare Var_Subst for proper error handling
Returning a VarParseResult instead of a string makes it possible to let
the error bubble up, until it reaches the main expression.
2020-09-22 20:19:46 +00:00
rillig
be6fc95d18 make(1): fix unnecessary length limitation for -v option 2020-09-22 19:51:19 +00:00
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