Commit Graph

179 Commits

Author SHA1 Message Date
rillig 23f8f1e198 make: clean up comments
No binary change.
2022-12-06 00:12:44 +00:00
rillig 04db2675e2 make: set WARNS to 6, from the default 5
No binary change on x86_64.
2022-09-27 17:46:58 +00:00
rillig 97dcd22758 make: add .USEBEFORE to Targ_PrintType
When .USEBEFORE was added in targ.c 1.22 from 2001-07-03, it was not
added to Targ_PrintType, probably because the PRINTBIT macro hid the
identifier OP_USE and only used USE.
2022-04-15 12:19:28 +00:00
rillig 68291d4356 make: merge duplicate variables for the main target
No functional change.
2022-01-07 20:50:35 +00:00
rillig 41d6d049a6 make: clean up comments, variable names, function names
The comment in ApplyDependencySourceOther repeated the code, its second
half didn't match any current code.

The comment above ParseDependencySourcesEmpty repeated the code.

No binary change, except for assertion line numbers.
2022-01-07 20:37:25 +00:00
rillig fa9a5efd89 make: rename and inline Targ_Precious
No functional change.
2022-01-07 19:24:27 +00:00
rillig e939df1127 make: convert GNodeFlags from enum into bit-fields
Now that Enum_ToString is implemented for each type separately, it's
easy to convert them to bit-fields.  This gets rid of the magic numbers
12 for CYCLE and 13 for DONECYCLE that left a suspicious gap in the
numbers.  This gap was not needed since the code didn't make use of the
relative ordering of the enum constants.

The effects of this conversion are fewer capital letters in the code,
smaller scope for the GNode flags, and clearer code especially when
setting a flag back to false.

One strange thing is that GCC 10.3.0 doesn't optimize GNodeFlags_IsNone
to an single bitmasking instruction, at least on x86_64.  Instead it
generates a testb instruction for each of the flags, even loading bit 8
separately from the others.  Clang 12.0.1 knows this optimization
though and generates the obvious sequence of movzwl, testl, jz.

No functional change.
2021-11-28 19:51:06 +00:00
rillig 4c3b96d532 make: reduce number of relocations in Targ_PrintType
On x86_64, this saves 120 bytes of .text.

No functional change.
2021-09-12 08:32:23 +00:00
rillig 2e8b3da821 make: fix lint warnings for strict bool mode
In strict bool mode, lint does not consider 'x & y' as having type bool,
if x and y have integer type, it only allows this for enums.

No functional change.
2021-09-12 08:03:48 +00:00
rillig b9d1479cd1 make: fix Targ_PrintType for pre-C99 compilers 2021-09-12 07:52:21 +00:00
rillig c53937813d make: make Targ_PrintType simpler
No functional change.
2021-09-12 07:50:45 +00:00
rillig 588b377eb0 make: use standard %H in strftime instead of %k
The conversion specifier %k is neither in C99 nor in C90.

These timestamps are only used in the debug output.
2021-04-03 12:01:00 +00:00
rillig 244fd9f4c4 make: use C99 bool type instead of defining its own
No functional change.
2021-04-03 11:08:40 +00:00
rillig bc82f3aea8 make: update constant names in comments
No functional change.
2021-02-22 20:38:55 +00:00
rillig 4dc2cd5c6f make: rename context and ctxt to scope
This continues the previous commit, in which VAR_GLOBAL, VAR_INTERNAL
and VAR_CMDLINE were renamed.

Renaming the variable 'ctxt' was trivial since that word is used nowhere
else.  In the comments though, each occurrence of the word 'context' had
to be checked individually since the word 'context' was not only used
for referring to a variable scope.  It is also used to distinguish
different situations where characters are escaped in a certain way
('parsing context') and in a few other expressions.
2021-02-04 21:42:46 +00:00
rillig 5980c2c341 make: rename some VAR constants to SCOPE
The word "context" does not fit perfectly to the variables that are
associate with a GNode, as the context is usually something from the
outside and the variables are more like properties inherent to the
GNode.

The term "global context" fits even less.  Since the thing where
variables are looked up is commonly named a scope, use that term
instead.

This commit only renames the global variables VAR_GLOBAL, VAR_INTERNAL
and VAR_CMDLINE, plus a few very closely related comments.  These are:

	GNode.vars (because of line breaks)
	GNode_Free (dito)
	varname-make_print_var_on_error.mk
	varname-make_print_var_on_error-jobs.mk

The debug message in Var_Stats is left as-is since there is no unit test
for it yet.

The other renamings (variable names "context", "ctxt", as well as
further comments) will be done in a follow-up commit.
2021-02-04 21:33:13 +00:00
rillig a1bc5ad8cf make: replace Global_AppendExpand with Global_Append
All callers with a variable name that is guaranteed to not contain a
dollar sign have been converted to call Global_Append instead of the
previous Global_AppendExpand.  After that, Global_AppendExpand was
unused, therefore it was effectively just renamed.
2021-02-03 13:53:12 +00:00
rillig 3ec10f8db6 make: use shortcut functions Global_SetExpand and Global_AppendExpand
There are many places where global variables are set or appended to.  To
reduce clutter and code size, encode the VAR_GLOBAL in the function
name.

The word Expand in the function names says that the variable name is
expanded.  In most of the cases, this is not necessary, but there are no
corresponding functions Global_Set or Global_Append yet.

Encoding the information whether the name is expanded or not in the
function name will make inconsistencies obvious in future manual code
reviews. Letting the compiler check this by using different types for
unexpanded and expanded variable names is probably not worth the effort.
There are still a few bugs to be fixed, such as in SetVar, which expands
the variable name twice in a row.
2021-02-03 08:00:36 +00:00
rillig 0840915c87 make: remove overengineered Enum_ValueToString
For printing the status of a GNode, there was already made_name (now
renamed to GNodeMade_Name), which prints user-friendly text instead of
the bare enum constant names.

To do this change confidently, I first had to demonstrate that the
output really affects something other than just the word "UNMADE". There
had not been a test for that case before, and the test immediately
discovered a bug in the -dg2 and -dg3 options.  This bug is one of the
oldest in make, dating back to at least 1993.
2021-02-02 17:56:31 +00:00
rillig 810790fcb7 make(1): make a few more bool expressions more precise
The previous version of lint(1) from a few hours ago didn't catch all
occurrences.  And even the current one doesn't catch everything.
Function arguments and return types still need some work.  The "return
quietly" from shouldDieQuietly still implicitly converts from int to
_Bool.

No functional change.
2021-01-10 23:59:53 +00:00
rillig 6e84975ccd make(1): spell nonexistent consistently 2020-12-18 15:47:34 +00:00
rillig d80c99b6f3 make(1): use symbolic time for 0 in Make_Recheck
This makes the test depsrc-optional independent from the current time
zone.
2020-12-18 14:46:44 +00:00
rillig 6e3f82b272 make(1): constify Targ_FmtTime 2020-12-18 14:36:46 +00:00
rillig 6357e11169 make(1): format function definitions consistently 2020-12-15 21:19:47 +00:00
rillig f650bd93fa make(1): inline Targ_Ignore and Targ_Silent
Each of these functions was only used 2 times, and each of these calls
used a different part of the whole expression.
2020-12-12 00:05:05 +00:00
rillig 2125e11bfd make(1): clean up debug logging 2020-12-07 23:59:59 +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 ee9186d684 make(1): define constants for enum zero-values 2020-12-05 18:38:02 +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 65a2faf0b6 make(1): use consistent variable names for list nodes 2020-12-04 14:39:56 +00:00
rillig 3e85c0fa41 make(1): reduce memory allocation for target handling 2020-11-29 01:05:08 +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 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 4adbce360a make(1): use comparisons in boolean expressions
The generated code stays exactly the same.
2020-11-23 23:41:11 +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 9cf07831bd make(1): rename GNode.context to vars
Especially in the variables module, the expression 'ctxt->context' looked
redundant.  Having a GNode as a context sounds ok, but a context of a
context just doesn't make sense.
2020-11-21 18:41:57 +00:00
rillig 416a199000 make(1): add more debug logging for suffix handling
One notable thing is that there is no debug output when adding a
transformation rule like ".c.o",  which means that these rules don't end
up in the global allTargets variable.

This may or may not be intentional.  It seems not intentional since this
is one of the causes for the suff-rebuild test to behave unexpectedly.
2020-11-21 11:59:22 +00:00
rillig 91b9265a19 make(1): improve comment style in GNode_Free
It was unclear what the ellipsis referred to.  It was meant to refer to
the function call Lst_Free, but that was not necessarily obvious to a
casual reader.
2020-11-21 10:56:17 +00:00
rillig ed1ae9b4ee make(1): fix comment for allTargets
Source nodes are also included in this list.  What's not includes is
nodes that are _only_ source nodes.
2020-11-21 10:50:39 +00:00
rillig 50a84755c6 make(1): clean up code style in targ.c 2020-11-16 22:28:44 +00:00
rillig 66dadf45cc make(1): initialize and free GNode fields in declaration order
Initialization and destruction of the fields is independent from the
other fields.  Therefore use declaration order, which allows to quickly
see whether a field was forgotten.

While here, add comments that in cleanup mode, not all memory is freed.
The variables of a node and the suffix survive right now.
2020-11-16 22:27:03 +00:00
rillig 5f6b9ee03e make(1): rename variables in targ.c
The previous names didn't make it obvious that 'allTargets' and 'targets'
belong together.  Naming both 'allTargets' provides a stronger hint.
2020-11-16 21:59:08 +00:00
rillig 2084acadbb make(1): clean up and extend comments in targ.c 2020-11-16 21:53:10 +00:00
rillig 73f094ffae make(1): make some GNode functions const 2020-11-16 21:48:18 +00:00
rillig e99bba9c48 make(1): in CLEANUP mode, preallocate list of all GNodes
This makes the code simpler and more uniform.
2020-11-16 21:44:29 +00:00