Commit Graph

16588 Commits

Author SHA1 Message Date
rillig
1516c90ccf make(1): document how make behaved for null bytes in the makefile 2020-12-06 20:07:25 +00:00
rillig
ee90815510 make(1): add test for makefile containing null bytes 2020-12-06 19:18:26 +00:00
rillig
4e133ccc5e make(1): test parsing a makefile that ends in a backslash 2020-12-06 19:00:48 +00:00
rillig
856f84743d make(1): fix undefined behavior in ParseEOF
Adding a number to a null pointer should have been caught by any
Undefined Behavior Sanitizer, but apparently neither GCC nor Clang do
this.
2020-12-06 18:37:04 +00:00
rillig
2069cc7bbf make(1): remove comment decoration 2020-12-06 18:13:17 +00:00
rillig
16ad1eafba make(1): move CleanEnv to UnexportVars
It clearly didn't belong in the GetVarnamesToUnexport part of the code.
2020-12-06 17:41:52 +00:00
rillig
b5432954a4 make(1): extract UnexportVars from Var_UnExport 2020-12-06 17:35:51 +00:00
rillig
73f3a22b54 make(1): fix comment in test for directive unexport-env 2020-12-06 17:29:27 +00:00
rillig
2b33648640 make(1): clean up GetVarnamesToUnexport 2020-12-06 17:27:10 +00:00
rillig
afef166f61 make(1): extract GetVarnamesToUnexport from Var_UnExport 2020-12-06 17:22:44 +00:00
rillig
d97dc758c9 make(1): replace pointer comparisons with enum
Keeping track of what it means if varname.str == str is not as
expressive as declaring what exactly to unexport.
2020-12-06 16:24:30 +00:00
rillig
d179c16de4 make(1): add test for directive unexport-env 2020-12-06 16:06:11 +00:00
rillig
874b4121ce make(1): use FStr in Var_UnExport 2020-12-06 15:40:46 +00:00
rillig
ccced12be8 make(1): add FStr to var.c to make memory handling simpler
The pattern of having a variable and a corresponding freeIt variable
appears over and over again in make, so cast it into a struct.
2020-12-06 14:50:09 +00:00
rillig
cb394f3681 make(1): move type definitions in var.c to the top 2020-12-06 14:20:20 +00:00
rillig
5fe7744e54 make(1): extract FreeEnvVar from Var_Parse 2020-12-06 13:51:06 +00:00
rillig
856b05feb8 make(1): move .include lines as far down as possible 2020-12-06 13:29:34 +00:00
rillig
b95bc08bdf make(1): move COPTS above <bsd.prog.mk> 2020-12-06 12:54:32 +00:00
rillig
d0ce656731 make(1): indent buf.h with tabs instead of spaces 2020-12-06 11:00:56 +00:00
rillig
9df90c54cf make(1): inline macros for debug logging
No changes to the resulting binary, except for the line numbers in
assertions.
2020-12-06 10:49:02 +00:00
rillig
ab8e02500d make(1): clean up macros for debug logging
Using a do-while loop prevents compiler warnings about possible dangling
else.  It also removes the unnecessary negation.
2020-12-06 10:33:42 +00:00
sjg
2699f59671 Don't let gcov mess up results 2020-12-05 22:51:34 +00:00
rillig
eda91dc8cf make(1): indent parse.c with tabs instead of spaces 2020-12-05 19:46:04 +00:00
rillig
37d00948af make(1): reduce indentation in ParseDependencySourceKeyword 2020-12-05 19:06:51 +00:00
rillig
4210bc2dad make(1): extract ParseDependencySourceWait 2020-12-05 19:03:45 +00:00
rillig
ee9186d684 make(1): define constants for enum zero-values 2020-12-05 18:38:02 +00:00
rillig
a64151bf73 make(1): remove redundant assignments 2020-12-05 18:15:40 +00:00
rillig
14d2618057 make(1): add test for unknown modifier in :C modifier replacement 2020-12-05 18:13:44 +00:00
rillig
56cb5728d6 make(1): remove unused parameter from meta_needed 2020-12-05 17:46:41 +00:00
rillig
0ca5c11203 make(1): remove unused parameter from JobOutput 2020-12-05 17:44:22 +00:00
rillig
e5d879283b make(1): refuse to use vsnprintf that is prone to buffer overflows
Several parts of make intentionally depend on the guarantee that
snprintf and vsnprintf do not overflow their buffer.  If an
implementation cannot provide this guarantee, refuse to use it.
2020-12-05 17:25:41 +00:00
rillig
c09eaa11ae make(1): remove unused variable from ArchFindMember 2020-12-05 17:17:37 +00:00
rillig
1dc8f59fce make(1): extract ExpandChildrenRegular from ExpandChildren 2020-12-05 17:12:02 +00:00
rillig
a4609fef81 make(1): indent suff.c with tabs instead of spaces
ExpandChildren is way too deeply nested.
2020-12-05 16:59:47 +00:00
rillig
b5df368a51 make(1): don't concatenate identifiers in Targ_PrintType
Concatenating identifiers makes it difficult to spot them when searching
the code.  This gets rid of the special case for OP_MEMBER and MEMBER.

The same pattern is applied in the DEBUG macro, by the way.
2020-12-05 15:57:02 +00:00
rillig
5737b54186 make(1): indent targ.c with tabs instead of spaces
Explain the tricky details of GNode_Free.

Invert a condition in Targ_PrintNode to reduce the overall indentation.
2020-12-05 15:35:34 +00:00
rillig
026824484e make(1): extract ShuffleStrings from ApplyModifier_Order 2020-12-05 15:31:18 +00:00
rillig
808fed06b5 make(1): indent remaining code of var.c with tabs instead of spaces 2020-12-05 14:55:17 +00:00
rillig
9515ff74a5 make(1): indent large parts of var.c with tabs instead of spaces
The few remaining functions need to be cleaned up before being indented
further, to reduce the overall indentation.
2020-12-05 14:28:09 +00:00
rillig
a67bc1e4cd make(1): improve explanation of tests for the SysV modifier 2020-12-05 13:01:33 +00:00
sjg
da0e1356d7 Use .MAKE.OS if we can 2020-12-05 03:42:15 +00:00
rillig
4bdfa77c7f make(1): extract UnexportEnv from Var_UnExport 2020-12-04 22:47:57 +00:00
rillig
ef3e9c527f make(1): extract UnexportVar from Var_UnExport 2020-12-04 22:35:40 +00:00
rillig
35e25f72f1 make(1): rename parse functions
The word "Do" was not necessary.
2020-12-04 20:23:33 +00:00
rillig
19fb9dcba2 make(1): inline Lst_Enqueue 2020-12-04 20:11:48 +00:00
rillig
dfc53e1755 make(1): inline Vector_Done 2020-12-04 20:08:07 +00:00
christos
f3f0e8207f __sentinel__ = __sentinel__(0) 2020-12-04 17:56:04 +00:00
rillig
2cf4367e86 make(1): improve variable names in Arch_ParseArchive
The variable buf used to be a Buffer, now it is a simple string pointer.
2020-12-04 14:51:46 +00:00
rillig
65a2faf0b6 make(1): use consistent variable names for list nodes 2020-12-04 14:39:56 +00:00
rillig
cb63c1e6d4 make(1): use fixed format for debug output of the directory cache
The previous output format had a %-20s conversion specifier.  This
produced different output depending on the length of the pathname, which
was too difficult to normalize.  By moving the directory name to the
end, it is no longer necessary to fill up any space, and the numbers are
always aligned properly.

As a result, 3 of the unit tests no longer need any special
postprocessing of their output.
2020-12-04 14:28:50 +00:00
rillig
1c121ce6e2 make(1): format coverage summary as a table
This is only used interactively, not in the official builds, therefore
the additional dependency on Perl doesn't matter.  The same result could
have been achieved in any other programming language, but probably not
as concisely.
2020-12-03 18:43:02 +00:00
rillig
583d8bd566 make(1): add test and tutorial for indirect modifiers 2020-12-01 22:16:36 +00:00
rillig
5514a0f21b make(1): rename local variable in Dir_SetPATH
The variable name should reflect the close relationship to the .DOTLAST
keyword that can be used in search paths.
2020-12-01 20:47:52 +00:00
rillig
71bfc5d9d5 make(1): add test for the special .MAKEFLAGS variable 2020-12-01 20:37:30 +00:00
rillig
0ab8d018af make(1): add test for parse errors in variable name in Var_SetWithFlags 2020-12-01 20:15:23 +00:00
rillig
44b654a638 make(1): document handling of irrelevant conditions before 2020-07-09 2020-12-01 19:37:23 +00:00
rillig
c81fc28b06 make(1): adjust condition descriptions in test cond-short
Before, the conditions in the output had been expanded, which made them
illegible.  The expanded conditions were unrealistic as well since the
evaluation flags differ between a condition and normal evaluation
(VARE_WANTRES, VARE_UNDEFERR).
2020-12-01 19:33:50 +00:00
rillig
28c9f54dfc make(1): remove Dir_InitDir
The function name had been too ambiguous since it didn't mention the
particular directory that was initialized.  Instead of that function,
Dir_InitCur is called directly from main_Init.

The pseudo CachedDir entry ".DOTLAST" is initialized at the very
beginning.  The observable behavior is unchanged since this a
memory-only object with no connection to the file system.
2020-12-01 19:28:32 +00:00
rillig
c6ea76207f make(1): add tests for suppressing "stopped in"
These tests demonstrate the unwanted behavior described in PR bin/55578
and PR bin/55832.
2020-12-01 17:50:04 +00:00
rillig
30d7ed040f make(1): fix tests for :gmtime and :localtime for 32-bit time_t
https://bugs.freebsd.org/251465
2020-11-30 21:10:15 +00:00
rillig
6e61cbbfc0 make(1): clean up variable names in Dir_FindFile
The special path entry is called .DOTLAST, therefore the local variable
should have the same name.

A variable named 'base' must not point to the slash of a pathname.  It
may only point to the character after the slash, everything else is
confusing, even if it's only for a brief moment.
2020-11-30 20:25:37 +00:00
rillig
74587d252a make(1): document difference between 'cur' and 'dot' 2020-11-30 20:17:00 +00:00
rillig
cc33398f35 make(1): add test for directory cache and exists() 2020-11-30 20:12:29 +00:00
rillig
c574887a83 make(1): fix memory leak for lstat cache in -DCLEANUP mode 2020-11-30 18:49:58 +00:00
sjg
644330f605 Add some tests for meta mode 2020-11-30 18:32:49 +00:00
rillig
5bad562d79 make(1): document how short-circuit evaluation behaved on 2020-07-03 2020-11-30 18:20:20 +00:00
rillig
d8435a3ecc make(1): initialize global variables in dir.c
Calling CachedDir_Assign requires that the variable be initialized.  On
most systems, NULL is represented as all-zero bits already.  This change
is only for the few other systems.

Add some comments explaining the implementation of Dir_AddDir since that
is tricky to read from the code alone.
2020-11-29 21:50:50 +00:00
rillig
68212223a6 make(1): reduce memory allocation in meta_oodate 2020-11-29 21:31:55 +00:00
rillig
733418ce24 make(1): reduce memory allocation in meta mode 2020-11-29 21:28:06 +00:00
rillig
7a70c4ea70 make(1): add test variant for reference counting logging 2020-11-29 21:27:08 +00:00
rillig
22d703e606 make(1): clean up memory management for CachedDirs
Previously, the reference count for a newly created CacheDir had been
set to 1 in CacheNewDir.  This was wrong because at that point, the
object had not been referenced by any nonlocal variable.  The reference
count is no longer incremented at this point.

All callers of CacheNewDir either append the newly created CachedDir to
a SearchPath via Lst_Append and CachedDir_Ref, or they assign it to a
global variable via CachedDir_Assign.

Since the reference count is no longer wrongly incremented, it does not
need to be decremented more than necessary in Dir_End.  To keep the code
simple and maintainable, all assignments to global variables are now
handled by CachedDir_Assign.  Adding a CachedDir to a list is still done
manually via Lst_Append, and the corresponding code for decrementing is
in SearchPath_Clean and SearchPath_Free.  These details may be cleaned
up in a follow-up commit.

As a result, when OpenDirs_Done is called in the unit tests, the list of
open directories is empty.  It had been non-empty in a single unit test
before (dep-wildcards.mk), as a result of calling Dir_Expand.

The additional debug logging for the reference counting is not enabled
by default since it contains memory addresses, which makes the output
dependent on the memory allocator.

The function CachedDir_Destroy has been merged into CachedDir_Undef,
which had only been used in Dir_End before.  The new name emphasizes
that it corresponds to CachedDir_Ref.
2020-11-29 18:49:36 +00:00
rillig
d55908461f make(1): fix the reference count of dotLast going negative
The memory management for dotLast is quite simple.  It is initialized
exactly once main_Init > Init_Objdir > Dir_InitDir and freed exactly
once in main_CleanUp > Dir_End.  Previously, dotLast was not freed at all.

The first call to CachedDir_Unref decremented the refCount to 0 but
didn't free anything.  Next, CachedDir_Destroy was called, which
decremented the reference count to -1, therefore skipping the actual
freeing.  This was probably an implementation mistake.

Since Dir_End is called at the very end of main_CleanUp, no code
accesses dotLast after it has been freed.
2020-11-29 16:37:10 +00:00
rillig
b52551f521 make(1): move CachedDir_Destroy up to the related functions 2020-11-29 16:04:34 +00:00
rillig
85c7000e55 make(1): extract CachedDir_Free0 from CachedDir_Destroy 2020-11-29 15:58:37 +00:00
rillig
6034552ecf make(1): remove wrong comment in Dir_InitCur
In a makefile with repeated ".CURDIR=." lines, Dir_AddDir is called with
a NULL path, once per line.  Since the path is NULL, the search for
OpenDirs_Find is skipped and the directory is always read from disk.
The freshly read directory has a refCount of 1, and the refCount never
raises above 2.

In Dir_InitCur, the directory of the previous .CURDIR has a refCount of
2, which is decremented twice and then freed.  After this, the new
directory is placed in the global 'cur', after incrementing its refCount
to 2.

It still seems wrong that the refCount of 'cur' is 2 instead of 1, but
it works well.
2020-11-29 15:14:32 +00:00
rillig
470c3b700e make(1): add debug logging for OpenDirs_Done 2020-11-29 14:29:19 +00:00
rillig
3afe048430 make(1): extract CacheNewDir from Dir_AddDir
Change the debug output for directories that are not found.
2020-11-29 12:30:40 +00:00
rillig
9c4948c9b0 make(1): make documentation of CachedDir.refCount more precise 2020-11-29 11:17:41 +00:00
rillig
09e000705a make(1): add debug logging for reference counting of CachedDir 2020-11-29 10:57:16 +00:00
rillig
432bd0ddcb make(1): normalize order of declarations in dir.c 2020-11-29 09:51:39 +00:00
rillig
087d4a0563 make(1): remove comment about returning const
The callers modify the reference count of the CachedDir, therefore it
must be modifiable.
2020-11-29 09:42:54 +00:00
rillig
c0a61e27e9 make(1): rename Dir_Destroy to CachedDir_Destroy
It is no longer exported by the Dir module.
2020-11-29 09:38:04 +00:00
rillig
84085cca68 make(1): use space instead of tab for preprocessor directives 2020-11-29 09:27:40 +00:00
rillig
59d6def469 make(1): unexport CachedDir internals 2020-11-29 08:48:24 +00:00
rillig
6f66206a01 make(1): reduce memory allocation for dirSearchPath 2020-11-29 01:40:26 +00:00
rillig
40a620462f make(1): reduce memory allocations for parsing dependencies 2020-11-29 01:35:33 +00:00
rillig
d9f6df7cec make(1): reduce memory allocations in suffix storage 2020-11-29 01:30:38 +00:00
rillig
c91d221250 make(1): reduce memory allocations in suffix handling 2020-11-29 01:24:18 +00:00
rillig
ddcc472c42 make(1): reduce memory allocation in ExpandWildcards for suffixes 2020-11-29 01:19:11 +00:00
rillig
26c51dd6fc make(1): reduce memory allocation in ExpandChildren for suffixes 2020-11-29 01:16:37 +00:00
rillig
4c46d4bd3d make(1): reduce memory allocation in suffix candidate search 2020-11-29 01:12:45 +00:00
rillig
4e0b769f19 make(1): reduce memory allocation in suffix rule handling 2020-11-29 01:10:08 +00:00
rillig
3e85c0fa41 make(1): reduce memory allocation for target handling 2020-11-29 01:05:08 +00:00
rillig
997298cde5 make(1): reduce memory allocation in suffix handling
The function Lst_MoveAll previously freed the source list.  This
function was only used in a few places, and none of them really needed
the allocation.
2020-11-29 00:54:43 +00:00
rillig
a674dd368a make(1): fix main_CleanUp in -DCLEANUP mode (broken since 1 hour)
Broken since main.c 1.486 from 2020-11-28, about 1 hour ago.
2020-11-29 00:42:01 +00:00
rillig
3e7b0787d3 make(1): reduce memory allocation for targets
This change moves the initialization and finalization of the list of
targets to the same function.  They had been split before.
2020-11-29 00:04:22 +00:00
rillig
9bac525681 make(1): reduce memory allocation for toBeMade 2020-11-28 23:50:58 +00:00
rillig
0593ee75cf make(1): reduce memory allocation in Make_ProcessWait 2020-11-28 23:48:36 +00:00
rillig
49129ea461 make(1): reduce memory allocation in Make_ExpandUse 2020-11-28 23:45:25 +00:00
rillig
a10305460f make(1): reduce memory allocation in ReadBuiltinRules 2020-11-28 23:43:14 +00:00
rillig
e102bca64e make(1): reduce memory allocation for CmdOpts.create 2020-11-28 23:39:58 +00:00
rillig
e87223c304 make(1): reduce memory allocation in CmdOpts.variables 2020-11-28 23:35:44 +00:00
rillig
4929944685 make(1): reduce memory allocation in CmdOpts.makefiles 2020-11-28 23:32:22 +00:00
rillig
e27340e9d4 make(1): reduce memory allocation in OpenDirs 2020-11-28 23:22:14 +00:00
rillig
12bd7715ad make(1): reduce memory allocation in Arch_ParseArchive 2020-11-28 23:13:28 +00:00
rillig
85028cce00 make(1): replace void pointer in Dir_Destroy with proper pointer 2020-11-28 22:59:53 +00:00
rillig
9bc32ab45b make(1): replace Dir_Destroy with SearchPath_Free
The function Dir_Destroy is an implementation detail of the cached
directories, and it should not be exported to the other modules.  The
search paths, on the other hand, are the high-level API that may be used
by the other modules, as the concept of search paths is documented in
the manual page.
2020-11-28 22:56:01 +00:00
rillig
2c1f8b4c34 make(1): rename some Dir functions to SearchPath
These functions have the search path as their main subject.
2020-11-28 22:13:56 +00:00
rillig
aa3ed0e416 make(1): reduce pointer indirection for archives 2020-11-28 19:26:10 +00:00
rillig
673efe08f3 make(1): reduce pointer indirection for GNode.implicitParents 2020-11-28 19:22:32 +00:00
rillig
eac02ebf12 make(1): reduce pointer indirection for GNode.cohorts 2020-11-28 19:20:03 +00:00
rillig
04763a4014 make(1): reduce pointer indirection for GNode.order_pred and order_succ 2020-11-28 19:16:53 +00:00
rillig
5a24a58276 make(1): reduce memory allocation for GNode.parents and GNode.children 2020-11-28 19:12:28 +00:00
rillig
e93d02d95f make(1): remove pointer indirection from GNode.commands
Just to save a few memory allocations.  No noticeable effect on the
performance though.
2020-11-28 18:55:52 +00:00
rillig
461723e058 make(1): improve type of local variable in Var_Export1 2020-11-28 16:36:19 +00:00
rillig
255c48976e make(1): fix type of local variable in ParseMessage 2020-11-28 16:34:13 +00:00
rillig
b136e34b03 make(1): remove unused label 2020-11-28 16:31:34 +00:00
rillig
f3042f3822 make(1): move test for recursive variable to cond-func-empty
Previously, the documentation of that test was much too short to explain
all the effects that happened in the bug situation from 2020-06-28 until
2020-07-02.
2020-11-28 14:08:37 +00:00
rillig
7fdaeb8c5f make(1): rename parameter in meta_needed and meta_create
It conflicts with the global variable in dir.c when make is built in
all-in-one mode.
2020-11-28 10:28:53 +00:00
rillig
6e1aae1731 make(1): fix local variable name in meta_create 2020-11-28 10:25:45 +00:00
rillig
4babdd3a46 make(1): rename local variable in ModifyWord_Root
The name 'dot' conflicted with the global variable from dir.c when make
was compiled in all-in-one mode.
2020-11-28 10:09:28 +00:00
rillig
179d396094 make(1): rename local variable in ModifyWord_Suffix
It conflicted with 'dot' from dir.c.
2020-11-28 10:07:26 +00:00
rillig
1296fcd859 make(1): rename local variable in ParseFindKeyword
It conflicts with the global 'cur'.
2020-11-28 10:05:49 +00:00
rillig
610833722f make(1): rename local variable in Cmd_Exec
It conflicts with the global fds in job.c.
2020-11-28 10:00:25 +00:00
rillig
927b4b6d02 make(1): allow multiple RCS IDs in all-in-one mode 2020-11-28 09:45:01 +00:00
rillig
153e6e1aab make(1): add multiple-inclusion guard for trace.h
Needed for all-in-one mode since this header is included 3 times.
2020-11-28 08:41:53 +00:00
rillig
8b03784eeb make(1): rename conflicting global variables called 'error'
When compiling make in all-in-one mode, these variable names conflict.
They could have been merged into a single variable, but that would have
required to make it a global variable for the other modules as well.
The parse module has a similar variable called 'fatals'.  All these can
possibly be merged into a single variable, but not now.
2020-11-28 08:40:05 +00:00
rillig
3330831119 make(1): rename global variables in job.c
When compiling make in all-in-one mode, the variable name nfds conflicts
with the local variable name nfds in meta_compat_parent.

The variable name jobfds was misleading.  It has nothing to do with file
descriptors, it's just an array of jobs.
2020-11-28 08:31:41 +00:00
rillig
a229cb70c4 make(1): clean up after a successful .META test 2020-11-27 08:39:07 +00:00
rillig
053b08eb2b make(1): add very basic test about meta mode
This test is just meant to cover the existing code, it still needs to be
cleaned up to serve as a tutorial and to highlight the really
interesting points.
2020-11-27 08:36:10 +00:00
rillig
357a62a61b make(1): inline meta_file_t for printCMD
This struct had only been necessary as long as printCMD was a callback
to Lst_ForEach or Lst_ForEachUntil.
2020-11-27 08:18:14 +00:00
rillig
a41e5257d9 make(1): inline Lst_ForEachUntil in meta mode
This means no more unnecessary void pointers in function signatures and
no more abstraction level at checking a single element of a list.  In
most cases it is more appropriate to define a function that operates on
the list as a whole, thereby hiding implementation details like the
ListNode from the caller.
2020-11-27 08:07:26 +00:00
sjg
a4b8ab5ff9 Add .MAKE.UID and .MAKE.GID 2020-11-25 00:50:44 +00:00
sjg
67ae709ee1 access(2) does not work for root, so skip objdir-writable 2020-11-25 00:32:18 +00:00
rillig
ed4779b2cf make(1): indent some functions in make.c with tabs instead of spaces 2020-11-24 23:13:09 +00:00
rillig
2a724961c8 make(1): remove void pointers from MakeBuildParent 2020-11-24 22:58:54 +00:00
rillig
f080921b64 make(1): inline Lst_ForEachUntil in Make_Update 2020-11-24 22:55:24 +00:00
rillig
15739dec26 make(1): remove void pointers from MakeBuildChild 2020-11-24 22:50:38 +00:00
rillig
8fc798ee16 make(1): inline Lst_ForEachUntil in MakeStartJobs 2020-11-24 22:45:24 +00:00
rillig
97cae118d5 make(1): inline Lst_ForEachUntil in MakeBuildChild
This prepares for removing the void pointers from the function
signature.
2020-11-24 22:32:18 +00:00
rillig
55495ce99c make(1): rename local variable in ApplyModifier_Assign 2020-11-24 21:42:28 +00:00
rillig
eb19129ed7 make(1): indent make.h with tabs instead of spaces 2020-11-24 20:17:17 +00:00
rillig
39cbb53300 make(1): fix indentation for short expressions in main.c 2020-11-24 19:52:06 +00:00
rillig
97e7e491d3 make(1): indent list functions with tabs instead of spaces 2020-11-24 19:46:29 +00:00
rillig
bef295a92a make(1): add high-level API for GNode.made
Having an enum whose constants must be ordered in a certain way may be
unexpected to casual readers.  Hide this implementation detail in
separate functions.
2020-11-24 19:33:13 +00:00
rillig
4026a54ade make(1): fix error handling for .BEGIN dependency in -k mode 2020-11-24 19:04:42 +00:00
rillig
2e03ddb408 make(1): add test for bug in error handling of .BEGIN in -k mode 2020-11-24 19:02:59 +00:00
rillig
8282efccc5 make(1): fix error handling for dependency of .END in -k mode
Fix one bug, find 4 new ones.  All these bugs have been around since
2005-05-08, when dependencies on the .BEGIN, .END and .INTERRUPT nodes
were implemented.  Before that, checking gn->made == ERROR was
appropriate, but adding the dependencies made ABORTED a new possible
error value from Compat_Make.
2020-11-24 18:17:45 +00:00
rillig
b4eade63ff make(1): add test for error in dependency of .END node in -k mode 2020-11-24 17:59:42 +00:00
rillig
62066330bb make(1): document the enum GNodeMade
Given only the state names and their individual documentation, it is
hard to see the full picture.  To make this easier, provide typical
examples of the ways that a GNode takes through these states.
2020-11-24 17:42:31 +00:00
rillig
9126fea341 make(1): move documentation about the result of Compat_Make 2020-11-24 16:28:44 +00:00
rillig
cd73b6b125 make(1): fix missing "Stop." after failed .END node in -k mode 2020-11-24 15:59:18 +00:00
rillig
c0b7bdab99 make(1): add test for missing "Stop" after error in .END 2020-11-24 15:36:51 +00:00
rillig
a50b3dc0b0 make(1): remove redundant null check from meta_needed
The result of bmake_realloc can never be NULL.
2020-11-23 23:44:03 +00:00
rillig
4adbce360a make(1): use comparisons in boolean expressions
The generated code stays exactly the same.
2020-11-23 23:41:11 +00:00
rillig
1e36bc5f85 make(1): indent remaining functions in dir.c with tabs 2020-11-23 23:00:36 +00:00
rillig
a80264b1f3 make(1): extract ResolveMovedDepends from ResolveFullName 2020-11-23 22:57:56 +00:00
rillig
86d8330811 make(1): extract ResolveFullName from Dir_UpdateMTime 2020-11-23 22:31:04 +00:00
rillig
df83500846 make(1): in Dir_Expand, don't re-use local variables
While here, add a few remarks from a previous attempt at flattening
the function.
2020-11-23 22:14:54 +00:00
rillig
e4852493c9 make(1): update the deactivated code in Dir_FindFile
While here, reduce the scope of the variable ln.
2020-11-23 22:05:58 +00:00
rillig
819d0d717c make(1): indent Dir_Expand with tabs instead of spaces 2020-11-23 21:48:42 +00:00
rillig
6b10d49042 make(1): flatten Dir_Expand
While here, leave comments in all places where unexpected edge cases
might have hidden.
2020-11-23 21:45:30 +00:00
rillig
69f9166fe8 make(1): use properly typed comparisons in boolean contexts 2020-11-23 20:52:59 +00:00
rillig
7179b788e7 make(1): align end-of-line comments with tabs 2020-11-23 20:41:20 +00:00
rillig
a148714f6c make(1): indent dir.c using tabs instead of spaces
Except for Dir_Expand and Dir_UpdateMTime, which are nested too deeply
to use tabs right now.  They first have to be split into separate
functions.
2020-11-23 20:21:34 +00:00
rillig
36ec30d3db make(1): indent cond.c with tabs instead of spaces 2020-11-23 20:05:31 +00:00
rillig
2af51e50f1 make(1): indent compat.c with tabs instead of spaces 2020-11-23 19:35:10 +00:00
rillig
508755e695 make(1): split Compat_Make into smaller functions 2020-11-23 19:27:20 +00:00
rillig
4fef087a55 make(1): extract DebugFailedTarget from Compat_RunCommand 2020-11-23 19:14:24 +00:00
rillig
b9e13463c5 make(1): indent buf.c with tabs instead of spaces 2020-11-23 19:07:12 +00:00
rillig
aad897c157 make(1): indent arch.c with tabs instead of spaces 2020-11-23 19:02:54 +00:00
rillig
58c7b461dc make(1): migrate CachedDir.files from HashTable to HashSet 2020-11-23 18:24:05 +00:00
rillig
1830d415fa make(1): add HashSet type
This makes the code for handling suffixes simpler since it doesn't need
the clumsy API of HashTable_CreateEntry anymore.
2020-11-23 18:07:10 +00:00
rillig
4a7b365ec7 make(1): use tabs for indentation in hash.h and hash.c 2020-11-23 17:59:21 +00:00
rillig
18dd66ad3f make(1): make output of test opt-debug-graph1 consistent
The output from the directory cache made the regular NetBSD build fail
because the pathname to the working directory differs, thus affecting
the spacing.

This time, document why the directory cache needs to be excluded from
the output.
2020-11-23 16:01:59 +00:00
rillig
69e871d024 make(1): test that .PHONY targets are not resolved using suffix rules 2020-11-23 15:00:32 +00:00
rillig
fcbb2eb2b1 make(1): fix endless loop when resolving circular suffix rules 2020-11-23 14:47:12 +00:00
rillig
eea9eb47a1 make(1): add debug logging for suffix tests 2020-11-23 14:13:39 +00:00
rillig
87b846ef9e make(1): make control flow simpler in FindThem 2020-11-23 14:04:28 +00:00
rillig
2a440a6f23 make(1): fix DEBUG_SRC logging in FindThem
The node is also removed from the list if it is neither found in the
nodes nor in the file system.  The logging did not reflect this.
2020-11-23 13:52:27 +00:00
rillig
fde9046190 make(1): add test for debug output from transformation rules 2020-11-22 23:45:20 +00:00
rillig
492003234b make(1): add high-level API for CandidateSearcher
This avoids passing invisible void pointers around in Lst_Append.  It
also provides a convenient place to document what it means to "add a
candidate to the searcher".
2020-11-22 22:58:43 +00:00
rillig
1f8c1f89fc make(1): add CandidateSearcher to resolve transformation rules
Having a simple list of candidates is not enough.  It is currently
possible to construct endless loops with huge memory usage, as
demonstrated in suff-transform-endless.mk.

To fix this, a straight-forward idea is to remember which candidates
have already been searched and to not search them again.

This also fixes a small inconsistency in the code.  Most parameters had
been named slst (the s came from a time when Candidate was named Src),
except for Suff_FindDeps, where the variable was named srcs.  The
confusing thing about this was that the name srcs is used throughout the
file for a different purpose.  Only in FindThem there were two
parameters of the same type, which made this even more confusing.
2020-11-22 22:27:19 +00:00
rillig
0a0d44f067 make(1): fix confusing command output in test suff-transform-endless 2020-11-22 21:37:09 +00:00
rillig
3c2d904d39 make(1): add more debugging for searching transformation rules 2020-11-22 21:34:34 +00:00
rillig
6bfc267595 make(1): add another unit test for suffix handling 2020-11-22 20:36:17 +00:00
rillig
a8fc26104f make(1): add debug logging for setting and resetting the main target
The suffix code still doesn't behave as expected.  Make sure that at
least setting the main target works as expected.  It does, and the added
debug logging provides further hints for debugging the suffix handling
code.
2020-11-22 20:29:53 +00:00
rillig
852778f69d make(1): add remark to add a "reasonable way" to format time_t 0 2020-11-22 20:01:46 +00:00
rillig
43adeab6ec make(1): document the selection of the main target 2020-11-22 19:37:27 +00:00
rillig
7be3276869 make(1): use canonical character comparison in ParseDoDependencyTargets 2020-11-22 19:14:24 +00:00
rillig
91d0efe670 make(1): make configuration of export tests simpler
The configuration section of unit-tests/Makefile is already complicated
enough to read, due to the excessive use of regular expressions.
Therefore, to keep the structuring elements at a minimum, inline the
.for loop.
2020-11-22 18:44:10 +00:00
rillig
6378fdfa01 make(1): add more output to test for -dg1
Previously, the variables section had been omitted.  This was because
the variables had been output in hashcode order until 2020-10-18, and
because some of the variable values are specific to the test environment
or the individual run (MACHINE_ARCH, MAKE.PPID).
2020-11-22 18:25:43 +00:00
rillig
b9640f2714 make(1): rename local variable in UpdateTargets 2020-11-22 18:13:52 +00:00
rillig
0f3758f11f make(1): extract FindDepsLib from FindDepsRegularKnown 2020-11-22 17:20:15 +00:00
rillig
d5db985cf3 make(1): rename Candidate.pref to prefix
The new name nicely matches the .PREFIX variable.
2020-11-22 12:05:20 +00:00
rillig
deb06c505d make(1): improve documentation of Candidate fields 2020-11-22 12:00:27 +00:00
rillig
4fd735d2c6 make(1): extract ExpandMember from FindDepsArchive 2020-11-22 11:50:31 +00:00
rillig
b47eee4fc9 make(1): extract ExpandAllChildren from FindDepsArchive 2020-11-22 11:46:49 +00:00
rillig
c548aa12de make(1): extract string handling from Suffix_GetSuffix
Finding a suffix of a string is not the job of the Suffix type.
2020-11-22 11:30:02 +00:00
rillig
219b99288c make(1): rename StrIsPrefix to StrTrimPrefix
Only functions returning Boolean should have the word Is in their name.
2020-11-22 11:26:50 +00:00