如何撤消中间文件删除 [英] How to undo intermediate file deletion

查看:122
本文介绍了如何撤消中间文件删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个软件堆栈,可在构建过程中创建一些中间文件.出现一些问题,构建中断.我想看看那些中间生成的文件.令我惊讶的是,这些文件在构建过程中被删除.

I have a software stack that creates some intermediate files as a part of build process. There is some problem come up and the build breaks. I want to have a look at those intermediate generated files. To my surprise those files are being deleted as a part of build process.

Removing intermediate files...
rm fact_test_without_proxies.c fact_test_main.c fact_test_without_proxies.o

我查看了Makefile,但没有看到任何明确的规则将其删除.是否可以有任何隐式规则来删除中间文件.如果是,如何禁用那些隐式规则?

I went through the Makefiles I don't see any explicit rules deleting them. Can there be any implicit rules to delete intermediate files. If yes how can I disable those implicit rules ?

仅当使用--debug选项执行make时,我才看到打印件Removing intermediate files....

I see the print Removing intermediate files... only if make is executed with --debug option.

skmt@tux:~/coding/factorial/ut$ make --debug
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for x86_64-pc-linux-gnu
Reading makefiles...
Updating goal targets....
 File `check' does not exist.
   File `test_dept_run' does not exist.
     File `fact_test' does not exist.
       File `fact_using_proxies.o' does not exist.
           File `fact_test_without_proxies' does not exist.
            File `fact_test_without_proxies.o' does not exist.
             File `fact_test_without_proxies.c' does not exist.
              File `fact_test_main.c' does not exist.
             Must remake target `fact_test_main.c'.
nm -p fact_test.o | build_main_from_symbols >fact_test_main.c
             Successfully remade target file `fact_test_main.c'.
            Must remake target `fact_test_without_proxies.c'.
cp fact_test_main.c fact_test_without_proxies.c
            Successfully remade target file `fact_test_without_proxies.c'.
           Must remake target `fact_test_without_proxies.o'.
gcc  -I../src  -c -o fact_test_without_proxies.o fact_test_without_proxies.c
           Successfully remade target file `fact_test_without_proxies.o'.
          Must remake target `fact_test_without_proxies'.
gcc   fact_test_without_proxies.o fact.o fact_test.o   -o fact_test_without_proxies
fact.o: In function `unknown':
fact.c:(.text+0x67): undefined reference to `do_update'
collect2: ld returned 1 exit status
make: *** [fact_test_without_proxies] Error 1
Removing intermediate files...
rm fact_test_without_proxies.c fact_test_main.c fact_test_without_proxies.o

推荐答案

如果您使用的是GNUMake,则可以使用特殊的目标.PRECIOUS:

If you're using GNUMake, you can use the special target .PRECIOUS:

.PRECIOUS: fact_test_without_proxies.c fact_test_main.c fact_test_without_proxies.o

或者只是

.PRECIOUS: %.c %.o

唯一的效果是,如果Make被杀死或中断,这些文件将不会被删除.

Its only effect is that these files will not be deleted if Make is killed or interrupted.

这篇关于如何撤消中间文件删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆