blob: bd542a1413d000cf1c94b61c9391f63fada3e378 [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001Logging Everything of make process
2
3The console's scrollback buffer will often prove to be too small to keep the full output of the package build process.
4
5There are moments you want to enable logging of the build process so that you can comfortably search(grep) through the logfiles
6when there appears to be a problem with building process
7
8The command looks like this:
9
10 make -j2 V=99 2>&1 | tee build.log
11
120 is stdin. 1 is stdout. 2 is stderr
13
14There's one way to remember this construct (maybe it is not entirely accurate):
15 -------------
16 First of all, 2>1 looks like a very good way to redirect stderr to stdout. but remember,
17it has a very harmful disadvantage: it may actually be interpreted as "redirect stderr to a file named 1".
18 -------------
19 & indicates that what follows is a file descriptor and not a filename. So the construct becomes: 2>&1.
20 -------------
21 >& is shell syntax for "fold a file descriptor into another", you can also interprete it as
22"it is the syntax to redirect a stream to another file descriptor"
23
24The part " | tee build.log" causes a file build.log to be created (if it does not yet exist) and a copy of the text that
25your script displays on the console is going to be written to it.
26Any previous content of that logfile will be overwritten.
27
28The part "2>&1" means that you will also catch the ERROR output of failed commands. You would normally not notice,
29but programs can write their output to "standard output" as well as "error output".
30These are two separate "channels" if you like, and since the tee command will only catch "standard output" and
31duplicate it into the target file, you will have to explicitly add "error output" as well.
32Remember, the error output will often be the stuff you're most interested in!
33
34
35By using this command, you are still able to watch the proceedings of the package build process on your console,
36and afterwards you can open the log file in an editor at your leisure.
37
38look for the info:
39
40 •Compilation errors ( grep -iE "(error|failed)" )
41 •Header/include/library files missing ( grep -iE "(not found|unavailable)" )
42
43ref: http://tldp.org/LDP/abs/html/io-redirection.html
44