Last active
August 29, 2015 14:13
-
-
Save codebrainz/69b8df344481b51112c5 to your computer and use it in GitHub Desktop.
Run build system when sources change
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Inspired by: https://exyr.org/2011/inotify-run/ | |
| # base source dir, found from script's dir, in my case it's `..` to the base srcdir | |
| SRCDIR=$(cd "$(dirname $(dirname "$0"))"; pwd -P) | |
| # command to run initially and on file changes, in my case in `build` dir | |
| COMMAND="make -C $SRCDIR/build" | |
| # message to print before running command | |
| FORMAT="Running \`$COMMAND' ..." | |
| # run once right away | |
| echo "$FORMAT" | |
| $COMMAND | |
| # keep running when some files change | |
| while inotifywait -qre close_write --format "$FORMAT" "$SRCDIR/sodac" | |
| do | |
| $COMMAND | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment