说实话,对于上面的那个:第 3.3.1.2 节 “从之前错误的那一步恢复继续编译”的功能,已经很强大了
而crosstool-ng,工具做的就是好。
因为,除此之外,又进一步的支持这个,出错时不立刻退出,的功能。
配置如下:
Paths and misc options [*] Debug crosstool-NG [*] Interactive shell on failed commands
Interactive shell on failed commands的help的说明为:
┌─────────────────── Interactive shell on failed commands ────────────────────┐ │ CT_DEBUG_INTERACTIVE: │ │ │ │ If you say 'y' here, then an interactive shell will be spawned for │ │ each failed command. │ │ │ │ This shell will have the same environment that the failed command │ │ was run with, and the working directory will be set to the directory │ │ the failed command was run in. │ │ │ │ After you fix the issue, you can exit the interactive shell with any │ │ of these exit codes: │ │ 1 the issue was fixed, continue the build with the next command │ │ 2 the issue was fixed, re-run the failed command │ │ 3 abort the build │ │ │ │ Note: '2' is only possible for commands run via CT_DoExecLog, though. │ │ │ │ Symbol: DEBUG_INTERACTIVE [=y] │ │ Type : boolean │ │ Prompt: Interactive shell on failed commands │ │ Defined at config/global/ct-behave.in:121 │ │ Depends on: DEBUG_CT [=y] │ │ Location: │ │ -> Paths and misc options │ │ -> Debug crosstool-NG (DEBUG_CT [=y]) │
此处,参数Interactive shell on failed commands的含义是:
直译为:当编译(命令)出错时,提供交互式的shell
其具体实际效果是:
正常情况下,当编译出错,会直接退出crosstool-ng的编译环境,回到当前的命令行。
而设置了此参数后,当编译失败时,不是直接退出编译
而是提供一个交互式的shell
然后你可以(另开一个终端)去修复你的问题
然后修复问题后,再通过
exit N
实现对应的返回N的值,达到对应的效果:
- 1
(不重新执行,之前错误的那个命令)
而接着直接继续编译
- 2
重新执行之前错误的那个命令
然后接着继续执行
常用于:
当某个.c文件编译出错了,然后你另起一个终端,去修改了该.c文件,解决了错误。
然后就可以通过
exit 2
而使得,重新执行命令,重新编译该.c文件,而使得可以正常编译,继续编译。
- 3
直接退出编译
相当于,直接按Ctrl+C,而中断编译
例 3.2. 如何在编译失败后,修复错误,然后继续接着编译
比如,我之前折腾
【记录】crosstool为xscale编译(ct-ng build)过程
时,遇到编译出错后,就回到当前命令行了:
================================================================= [INFO ] Installing static core C compiler [EXTRA] Configuring static core C compiler [EXTRA] Building static core C compiler [EXTRA] Installing static core C compiler [INFO ] Installing static core C compiler: done in 1282.54s (at 67:22) [EXTRA] Saving state to restart at step 'libc_headers'... [INFO ] ================================================================= [INFO ] Installing C library headers [EXTRA] Configuring C library [EXTRA] Installing C library headers [ERROR] make[3]: *** [/home/CLi/develop/crosstool-ng/x-tools/arm-xscale-linux-gnueabi/arm-xscale-linux-gnueabi//sys-root/usr/include/sys/uio.h] Error 1 [ERROR] make[2]: *** [misc/install-headers] Error 2 [ERROR] make[1]: *** [install-headers] Error 2 [ERROR] Build failed in step 'Installing C library headers' [ERROR] Error happened in '/opt/crosstool-ng/lib/ct-ng-1.9.3/scripts/functions' in function 'CT_DoExecLog' (line unknown, sorry) [ERROR] called from '/opt/crosstool-ng/lib/ct-ng-1.9.3/scripts/build/libc/glibc.sh' at line # 175 in function 'do_libc_headers' [ERROR] called from '/opt/crosstool-ng/lib/ct-ng-1.9.3/scripts/crosstool-NG.sh' at line # 597 in function 'main' [ERROR] Look at '/home/CLi/develop/crosstool-ng/x-tools/arm-xscale-linux-gnueabi/build.log' for more info on this error. [ERROR] (elapsed: 76:07.10) [76:12] / /opt/crosstool-ng/bin/ct-ng:143: recipe for target `build' failed make: *** [build] Error 2 CLi@PC-CLI-1 ~/develop/crosstool-ng/crosstool-ng-1.9.3_build $
没有给你机会去修复错误,然后继续编译。
而你能做的,做节省时间的方式,也最多只是,参考:第 3.3.1.2 节 “从之前错误的那一步恢复继续编译”去,在解决了问题之后,去:
ct-ng libc_headers+
从而达到,从出错的步骤,恢复后继续编译的效果,不再重复之前的已经成功编译的那些步骤。
但是,即便是这样,对于编译最开始的部分:
CLi@PC-CLI-1 ~/develop/crosstool-ng/crosstool-ng-1.9.3_build $ ct-ng build [INFO ] Performing some trivial sanity checks [INFO ] Build started 20130724.093552 [INFO ] Building environment variables [EXTRA] Preparing working directories
等步骤,还是需要花点时间的,还是有点重复浪费的感觉。
所以,此处,选中了上面所说的那个"Interactive shell on failed commands"选项后,
当编译出错后,会出现类似于:
【已解决】Ubuntu中crosstool-ng编译出错:scripts/unifdef.c:209:25: error: conflicting types for ‘getline’
中的这样的效果:
[INFO ] ================================================================= [INFO ] Installing kernel headers [EXTRA] Installing kernel headers [ERROR] /home/crifan/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/src/linux-custom/scripts/unifdef.c:209:25: error: conflicting types for 'getline' [ERROR] make[3]: *** [scripts/unifdef] Error 1 [ERROR] make[2]: *** [headers_install] Error 2 [ERROR] make[1]: *** [headers_install] Error 2 [ERROR] [ERROR] >> [ERROR] >> Build failed in step 'Installing kernel headers' [ERROR] >> called in step '(top-level)' [ERROR] >> [ERROR] >> Error happened in: CT_DoExecLog[scripts/functions@257] [ERROR] >> called from: do_kernel_install[scripts/build/kernel/linux.sh@112] [ERROR] >> called from: do_kernel_headers[scripts/build/kernel/linux.sh@91] [ERROR] >> called from: main[scripts/crosstool-NG.sh@632] Current command: 'make' '-C' '/home/crifan/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/src/linux-custom' 'O=/home/crifan/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-xscale-linux-gnueabi/build/build-kernel-headers' 'ARCH=arm' 'INSTALL_HDR_PATH=/home/crifan/develop/crosstool-ng/x-tools/arm-xscale-linux-gnueabi/arm-xscale-linux-gnueabi/sysroot/usr' 'V=0' 'headers_install' exited with error code: 2 Please fix it up and finish by exiting the shell with one of these values: 1 fixed, continue with next build command 2 repeat this build command 3 abort build ct-ng:~/develop/crosstool-ng/crosstool-ng-1.18.0_build>
即,有对应的
Please fix it up and finish by exiting the shell with one of these values
那些信息。
然后,当你去解决了对应的问题后:
此处,只是去修改对应的.build/src/linux-custom/scripts/unifdef.c
,即可。
然后,就可以通过输入:
exit 2
就可以实现:
重新执行此处刚才出错的命令,然后继续重新去编译刚才出错的那个.build/src/linux-custom/scripts/unifdef.c
文件,
从而实现:
当编译出错时,也不立刻退出crosstool-ng的编译,
允许你去修复对应的问题,然后修复完毕后,可以接着继续编译。
因而实现了:
避免重复的,之前的各个步骤,包括最开始的环境检查等等的时间
真正的,彻底的,最大程度上的,节省你的时间和精力。