summaryrefslogtreecommitdiff
path: root/usr.bin/make/targ.c
AgeCommit message (Collapse)Author
2022-12-06make: clean up commentsrillig
No binary change.
2022-09-27make: set WARNS to 6, from the default 5rillig
No binary change on x86_64.
2022-04-15make: add .USEBEFORE to Targ_PrintTyperillig
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-01-07make: merge duplicate variables for the main targetrillig
No functional change.
2022-01-07make: clean up comments, variable names, function namesrillig
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-07make: rename and inline Targ_Preciousrillig
No functional change.
2021-11-28make: convert GNodeFlags from enum into bit-fieldsrillig
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-09-12make: reduce number of relocations in Targ_PrintTyperillig
On x86_64, this saves 120 bytes of .text. No functional change.
2021-09-12make: fix lint warnings for strict bool moderillig
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-12make: fix Targ_PrintType for pre-C99 compilersrillig
2021-09-12make: make Targ_PrintType simplerrillig
No functional change.
2021-04-03make: use standard %H in strftime instead of %krillig
The conversion specifier %k is neither in C99 nor in C90. These timestamps are only used in the debug output.
2021-04-03make: use C99 bool type instead of defining its ownrillig
No functional change.
2021-02-22make: update constant names in commentsrillig
No functional change.
2021-02-04make: rename context and ctxt to scoperillig
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-04make: rename some VAR constants to SCOPErillig
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-03make: replace Global_AppendExpand with Global_Appendrillig
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-03make: use shortcut functions Global_SetExpand and Global_AppendExpandrillig
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-02make: remove overengineered Enum_ValueToStringrillig
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-01-10make(1): make a few more bool expressions more preciserillig
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.
2020-12-18make(1): spell nonexistent consistentlyrillig
2020-12-18make(1): use symbolic time for 0 in Make_Recheckrillig
This makes the test depsrc-optional independent from the current time zone.
2020-12-18make(1): constify Targ_FmtTimerillig
2020-12-15make(1): format function definitions consistentlyrillig
2020-12-12make(1): inline Targ_Ignore and Targ_Silentrillig
Each of these functions was only used 2 times, and each of these calls used a different part of the whole expression.
2020-12-07make(1): clean up debug loggingrillig
2020-12-06make(1): inline macros for debug loggingrillig
No changes to the resulting binary, except for the line numbers in assertions.
2020-12-05make(1): define constants for enum zero-valuesrillig
2020-12-05make(1): don't concatenate identifiers in Targ_PrintTyperillig
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-05make(1): indent targ.c with tabs instead of spacesrillig
Explain the tricky details of GNode_Free. Invert a condition in Targ_PrintNode to reduce the overall indentation.
2020-12-04make(1): use consistent variable names for list nodesrillig
2020-11-29make(1): reduce memory allocation for target handlingrillig
2020-11-29make(1): reduce memory allocation for targetsrillig
This change moves the initialization and finalization of the list of targets to the same function. They had been split before.
2020-11-28make(1): reduce pointer indirection for GNode.implicitParentsrillig
2020-11-28make(1): reduce pointer indirection for GNode.cohortsrillig
2020-11-28make(1): reduce pointer indirection for GNode.order_pred and order_succrillig
2020-11-28make(1): reduce memory allocation for GNode.parents and GNode.childrenrillig
2020-11-28make(1): remove pointer indirection from GNode.commandsrillig
Just to save a few memory allocations. No noticeable effect on the performance though.
2020-11-23make(1): use comparisons in boolean expressionsrillig
The generated code stays exactly the same.
2020-11-22make(1): add remark to add a "reasonable way" to format time_t 0rillig
2020-11-21make(1): rename GNode.context to varsrillig
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-21make(1): add more debug logging for suffix handlingrillig
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-21make(1): improve comment style in GNode_Freerillig
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-21make(1): fix comment for allTargetsrillig
Source nodes are also included in this list. What's not includes is nodes that are _only_ source nodes.
2020-11-16make(1): clean up code style in targ.crillig
2020-11-16make(1): initialize and free GNode fields in declaration orderrillig
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-16make(1): rename variables in targ.crillig
The previous names didn't make it obvious that 'allTargets' and 'targets' belong together. Naming both 'allTargets' provides a stronger hint.
2020-11-16make(1): clean up and extend comments in targ.crillig
2020-11-16make(1): make some GNode functions constrillig
2020-11-16make(1): in CLEANUP mode, preallocate list of all GNodesrillig
This makes the code simpler and more uniform.