Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: mamake: some more necessary TLC, fixing minor issues
This commit fixes three minor bugs in mamake: 1. The 'bind' command did not correctly propagate errors in its dependencies (e.g. a failure to link) to the current rule, causing a problem with the -k (keep going) option. 2. When an error occurred in a recursive mamake invovation, the nonzero exit status was not propagated back to the parent invocation and the failed build could exit with a zero status if the -k option was given. 3. When building in parallel and a rule's action had an error, the error message may have the wrong line number. (re: ced499a) It also does some refactoring and various tweaks, and fixes more potential dependency bugs. Main changes below (more minor or self-evident tweaks omitted). src/cmd/INIT/mamake.c: - Change newof() macro expansions to standard calloc/malloc/realloc calls, which are a lot easier to read. Delete newof(). - Use time_t for time variables. This will keep mamake working past 2038 on machines where 'unsigned long' is only 32 bits. - Fix bug 3 as follows. The reap() function now delays the unsetting of a rule's PID until after potentially calling error_making(). The rule pointer is passed to report() via error_making() and report() checks if the rule's PID is set, in wich case the rule's endline is shown instead of the current input line. - Add check_shellaction() which checks the results of a shell action and throws errors if needed. This replaces duplicate logic in run() and reap(), which both now just call that function. - Report "target not generated" instead of "missing prerequisite" when a shell action exits with status 0 (success) but its target file is not found. This is done by having check_shellaction() pass a special code -1 to error_making(). - Add clearout_bg() which clears out the current rule's list of background jobs, waiting for them to finish (letting reap() throw errors) and propagating their timestamps for depencencies and and RULE_error flags for -k. This is now used both by the 'done' command and before invoking a virtual rule's shell action (which is never run in parallel). - make(): case KEY('b','i','n','d'): - Correctly make sure that the indicated library (if built in the same Mamfile) has finished linking, and propagate its timestamp and error flag. This fixes bug 1. - Include header dependencies in the context of the current rule, not in the unnamed dummy rule. This should fix potential depedency bugs on the first use of 'bind' for a library. - make(): case KEY('m','a','k','e'): - Eliminate loop that, before making the current rule, reaps any background jobs that have finished and cuts them out of the list. This worked fine, but is redundant. It is sufficient to call clearout_bg() at 'done' (see above). - main(): When doing recurse() and bailing out, return with the highest remembered exit status. This fixes bug 2. src/cmd/INIT/mamprobe.sh: - Change remaining nmake-style variable expansions $(...) to new %mamake {...} expansions, not ${...}. (re: f5d5318) bin/package: - Filter '#reason:' lines from mamake -e out of the results; this is just noise for this purpose (whereas the trace headers are useful to know which target a compiler error message belongs to).
- Loading branch information