summaryrefslogtreecommitdiff
path: root/usr.bin/make/make.c
AgeCommit message (Collapse)Author
2023-02-14make: clean up calls to Var_Substrillig
None of the calls to Var_Subst used the return value, and the return value was always VPR_OK. No functional change.
2022-12-05make: inline local macro in GNodeFlags_ToStringrillig
No binary change.
2022-09-27make: set WARNS to 6, from the default 5rillig
No binary change on x86_64.
2022-08-17make: fix exit status for '-q' (since 1994)rillig
2022-05-07make: allow to randomize build order of targetsrillig
In complex dependency structures, when a build fails, a probable cause is a missing dependency declaration between some files. In compat mode, the build order is deterministic, in jobs mode, it is somewhat deterministic. To explore more edge cases, add the line ".MAKE.MODE += randomize-targets" somewhere in the makefile. Fixes PR bin/45226 by riastradh. Reviewed by christos.
2022-05-07make: inline MakeBuildParentrillig
The word "parent" didn't match exactly, since this part is about the predecessor/successor relationship due to the .ORDER attribute. No functional change.
2022-05-07make: inline make_abort, improve error detailsrillig
This function was only called a single time, making the source code line number redundant. Instead, print the name of the state instead of its ordinal value.
2022-01-09make: use consistent variable names for varargsrillig
No binary change.
2022-01-08make: remove redundant bracesrillig
No binary change, except for assertion line numbers.
2021-12-27make: remove unnecessary words from command line optionsrillig
Several years ago, the command line options were individual global variables. The global variable could therefore not be named 'silent' since that would have conflicted with local variables of the same name. After moving the global variable to the namespace 'struct CmdOpts', there is no conflict anymore. There doesn't seem to be any risk of naming collisions for the names 'touch' and 'query'. No functional change.
2021-12-15make: format comments according to /usr/share/misc/stylerillig
Assisted by indent(1), with manual corrections due to its many remaining bugs. No functional change.
2021-11-28make: fix a few lint warnings about type mismatch in enum comparisonsrillig
These warnings were triggered with the lint flag '-e', which enables additional checks on enums. This check would have detected the type mismatch from the previous commit. The check has a few strange warnings though, complaining about initialization of 'unsigned long' with 'unsigned long', so don't enable it for the official builds. No functional change.
2021-11-28make: move duplicate function Buf_AddFlag to buf.crillig
It is used only for debug output, therefore performance doesn't matter. 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-11-28make: replace bloated bit-set-to-string code with simple coderillig
It was a nice idea to implement a bit-set using an enum type and have a generic ToString function for them. In the end, the implementation involved really heavy preprocessor magic and was probably difficult to understand. Replace all the code with a few bits of straight-forward preprocessor magic that can be readily understood by just looking 5 lines around, instead of digging through 130 lines of lengthy macro definitions. Curiously, this reduces the binary size even though the 3 ToString functions now have a few lines of duplicate code and there are more explicit function calls. The ToString functions are only seldom used, so the additional memory allocation is acceptable. No functional change.
2021-04-04make: rename a few functions to be more descriptiverillig
No functional change.
2021-04-03make: use C99 bool type instead of defining its ownrillig
No functional change.
2021-02-05make: in the Var_ functions, move the scope to the frontrillig
This change provides for a more natural reading order in the code. Placing the scope first makes it immediately clear in which context the remaining parameters are interpreted. 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-02make: remove unused INTERNAL flagrillig
It had been used for cached_realpaths, until this variable had its type changed from GNode to HashTable in main.c 1.469 from 2020-11-14.
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-02-01make: remove unused return type of MakeBuildParentrillig
2021-02-01make: reduce indentation in MakeAddAllSrcrillig
No functional change.
2021-01-30make(1): reduce boilerplate for printing bit sets in debug moderillig
No functional change.
2021-01-16make(1): fix a few inconsistencies for lint's strict bool moderillig
2021-01-10make(1): consistently use boolean expressions in conditionsrillig
Most of the make code already followed the style of explicitly writing (ptr != NULL) instead of the shorter (ptr) in conditions. The remaining 50 instances have been found by an experimental, unpublished check in lint(1) that treats bool expressions as incompatible to any other scalar type, just as in Java, C#, Pascal and several other languages. The only unsafe operation on Boolean that is left over is (flags & FLAG), for an enum implementing a bit set. If Boolean is an ordinary integer type (the default), some high bits may get lost. But if Boolean is the same as _Bool (by compiling with -DUSE_C99_BOOLEAN), C99 6.3.1.2 defines that a conversion from any scalar to the type _Bool acts as a comparison to 0, which cannot lose any bits.
2020-12-30make(1): format multi-line commentsrillig
2020-12-19make(1): rename parameter line to linenorillig
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-15make(1): indent make.c with tabs instead of spacesrillig
2020-12-15make(1): extract MakeChildren from MakeStartJobsrillig
2020-12-06make(1): remove comment decorationrillig
2020-11-28make(1): reduce memory allocation for toBeMaderillig
2020-11-28make(1): reduce memory allocation in Make_ProcessWaitrillig
2020-11-28make(1): reduce memory allocation in Make_ExpandUserillig
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-27make(1): inline Lst_ForEachUntil in meta moderillig
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-24make(1): indent some functions in make.c with tabs instead of spacesrillig
2020-11-24make(1): remove void pointers from MakeBuildParentrillig
2020-11-24make(1): inline Lst_ForEachUntil in Make_Updaterillig
2020-11-24make(1): remove void pointers from MakeBuildChildrillig
2020-11-24make(1): inline Lst_ForEachUntil in MakeStartJobsrillig
2020-11-24make(1): inline Lst_ForEachUntil in MakeBuildChildrillig
This prepares for removing the void pointers from the function signature.
2020-11-24make(1): add high-level API for GNode.maderillig
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-21make(1): fix indentation in Make_HandleUserillig