Is there a smarter alternative to “watch make”?

前端 未结 11 623
渐次进展
渐次进展 2021-02-01 15:28

I ran into this useful tip that if you\'re working on files a lot and you want them to build automatically you run:

watch make

And it re-runs make every couple s

11条回答
  •  遇见更好的自我
    2021-02-01 16:09

    Using classic gnu make and inotifywait, without interval-based polling:

    watch:
        while true; do \
            make $(WATCHMAKE); \
            inotifywait -qre close_write .; \
        done
    

    This way make is triggered on every file write in the current directory tree. You can specify the target by running

    make watch WATCHMAKE=foo
    

提交回复
热议问题