shake-build-system

need "ensure dependency is up to date"


I was watching Neil's discussing shake at ICFP. He mentions in the talk that the need function ensures that the dependency is "up to date". What does this mean exactly? Below is the code used in the talk:

"Foo.o" *> \_ -> do
   need ["Foo.c"]
   ...
   ...
   system' "gcc" ["-c", "Foo.c"]

Does this mean that the Shake framework expects there to be a "rule" on how to build "Foo.c", and will run that rule when figuring out if it needs to re-run the rule for building "Foo.o"? If that is the case, does Shake in essence have a map from File to Rule? What happens when my dependency is a file that simply exists on my system? If Shake is not used to generate it, and I use need ["Somefile.txt"], no rule will exist for how to build "Somefile.txt". Will Shake crash? At the root of it all, we have to start from some files that already exist.

P.S. I am new to build systems and to Shake; any guidance is appreciated.


Solution

  • A dependency is "up to date" if all its dependencies are up to date, and it has been run with those dependencies in their current value. But the important point in this question seems to be that Foo.o in Shake can refer to two things:

    You can see this in the error message Shake produces:

    $ shake shakeOptions $ action $ need ["hello.txt"]
    Error, file does not exist and no rule available:
      hello.txt
    

    The fact that rules are named after the file they produced, and the absence of a rule implies it's a source file is shared with build systems like Make. However, this property is different from build systems like Buck/Bazel where targets and sources have distinct namespaces.