How to undo intermediate file deletion

前端 未结 3 1005
小蘑菇
小蘑菇 2020-12-10 00:35

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 i

相关标签:
3条回答
  • 2020-12-10 01:12

    You can also use .SECONDARY, which will preserve the specified files even if the build does not break.

    e.g.

     .SECONDARY:
    
    0 讨论(0)
  • 2020-12-10 01:19

    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
    

    or just

    .PRECIOUS: %.c %.o
    

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

    0 讨论(0)
  • 2020-12-10 01:19

    There is a restriction on the use of targets, which affects the behaviour of .PRECIOUS:

    I have targets A/%.foo: and B/%.foo: , so I have set:

    .PRECIOUS: %.foo
    

    and this did not work; I don't understand why, but expansion does not work this way; I had to explicitely list targets exactly as they are written:

    .PRECIOUS: A/%.foo B/%.foo
    

    But even after reading https://www.gnu.org/software/make/manual/html_node/Special-Targets.html I do not understand the difference between .PRECIOUS: and .SECONDARY: .

    It's accepted to use those special targets without depends, but I think this would be very dirty coding and would expect side effects. Some people just put .PRECIOUS: or .SECONDARY: without dep, and later, they complain they have to run make clean after a broken build ...

    0 讨论(0)
提交回复
热议问题