Skip to content

Instantly share code, notes, and snippets.

@ndmitchell
Created April 17, 2015 09:20
Show Gist options
  • Save ndmitchell/aaef551b662fb715a258 to your computer and use it in GitHub Desktop.
Save ndmitchell/aaef551b662fb715a258 to your computer and use it in GitHub Desktop.
Ninja phony behaviour
# ninja bar.txt # builds foo.txt and bar.txt
# touch foo.txt
# ninja bar.txt # builds nothing
rule create
command = cmd /c "echo $out > $out"
rule copy
command = cmd /c "copy $from $out"
build foo: phony foo.txt
build bar.txt: copy foo
from = foo.txt
build foo.txt: create
# ninja bar.txt # builds foo.txt and bar.txt
# touch foo.txt
# ninja bar.txt # builds bar.txt
rule create
command = cmd /c "echo $out > $out"
rule copy
command = cmd /c "copy $from $out"
rule phony2
command = cmd /c "echo nothing to do"
build foo: phony2 foo.txt
build bar.txt: copy foo
from = foo.txt
build foo.txt: create
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment