Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mamake: add nice PS4 to shell actions, demystifying log output
The shell action trace in the log file has always been hard to follow. Shell action commands are traced without any context. For people unfamiliar with the build system (currently everyone but a handful of people), it is unclear where these come from. mamake now sets a PS4 tracing prompt for each shell action that shows the Mamfile that the shell action originates from as well as the line number range of the corresponding make...done block. It would be nice if we could trace the exact line number of each 'exec' statement, but that is not possible with the basic design of this system; 'exec' statements are combined into a script buffer and that is executed as a whole upon reaching 'done'. Since 'exec' statements can begin at any point in the block and need not even be contiguous to belong to the same script, exact line number information is lost. However, showing the make...done block range also has advantages; it makes it more intuitive to understand the build system. Here is a sample fragment: + (libast/Mamfile:239-242) /bin/cp -f FEATURE/sys ast_sys.h + (libast/Mamfile:158-250) iffe -v -X ast -X std -c 'cc -D_BL[...] iffe: test results in FEATURE/stdio are up to date + (libast/Mamfile:157-254) /bin/cp -f FEATURE/stdio ast_stdio.h Note how the line number ranges show three different shell scripts belonging to three nested blocks. src/cmd/INIT/mamake.c: - Add a 'line' member to the Rule_t struct. - rule(): When defining a rule r (e.g. upon 'make'), store the current line number in r->line. - run(): When running a shell action, emit a PS4 assignment set a nice PS4 showing the last component of the parent directory and the current file name (generally Mamfile), r->line (the 'make' line), and the current line (the 'done' line).
- Loading branch information