Menu

File Exist function

Help
Anonymous
2009-11-04
2013-03-15
  • Anonymous

    Anonymous - 2009-11-04

    I would like to implement a file verifier that works like this:

    Whenever a complete build is done then it should be possible to run a target e.g. called test which ensures that all specified files exist. The reason is that some times a build error is silent and we don't see that something went wrong except for a file missing in the output directory.

    Is there a built in function that will let you get 0/1 depending if a file exists or not?

    Also should I make this as a phony task or is there a way I could make it dependent so it won't be kicked off every time?

    Thanks.

    Henrik

     
  • Daniel Pfeiffer

    Daniel Pfeiffer - 2009-11-17

    Hi Henrik!

    our functions are smart, in that they know of files that can be built, not only those that currently exist.  You could do something with $(perl -f …), but I wonder why you need this.  If your rules are correct, mpp itself tests this for you, before continuing with rules that depend on the one that just ran.

    In

    > xyz: 
    >      &echo this should be phony

    you get a warning, that xyz did not appear.  This should actually be an error, but cannot, because legacy makefiles have such sloppy behaviour.  But on your mpp command line, or in your makefile you can force this by saying

    > makepp\_require\_phony=1

    hope this helps 
    Daniel

     
  • Anonymous

    Anonymous - 2009-11-22

    The real reason for this is that we have some builds using old tools not available on all development machines. At some point of time I uncommented one of the targets because I didn't have the proper tools installed. Afterwards I discovered that I accidently commited it and didn't notice this until it hit the customers.

    So what I'm trying is to make a filter for stupidities where files gets commented out or others are missing for one reason or another.

    I know that makepp does a good job by itself but even the best tool cannot save you from human mistakes. This is why I want to implement this double check.

    How would I use this perl -f in the makefiles?

    Thanks.
    Henrik

     
  • Daniel Pfeiffer

    Daniel Pfeiffer - 2009-11-23

    You have (at least) two possibilites, either as a function:

        &echo $(perl -f '/tmp/makefile' ? 'yes' : 'no')

    or as conditional statements:

        ifperl -f '/tmp/makefile'
            &echo yes
        else
            &echo no
        endif

     

Log in to post a comment.