| 1 | #!/bin/shscip-shell filesystem . . `/bin/sh`. -e |
| 2 | |
| 3 | # This script will setup the build dir based on the current git branch and the |
| 4 | # directory auto-build-save/$BRANCH. We don't use a symlink for the build dir |
| 5 | # because we want to maximize the ccache reuse, so all builds must happen in |
| 6 | # the same real dir. When a dir is moved out of auto-build-save/$BRANCH to the |
| 7 | # build dir, it is replaced with a symlink so that it can still be found under |
| 8 | # that dir. The build dir also gets a .branch -> $BRANCH symlink so that we |
| 9 | # can figure out the current build dir's branch. |
| 10 | |
| 11 | # To get started, just clone the rsync git repo and create the auto-build-save |
| 12 | # dir. If you have an existing git checkout and it is not in a pristine state, |
| 13 | # run "make distclean" before creating the auto-build-save dir. |
| 14 | |
| 15 | auto_top='auto-build-save' |
| 16 | if testscip-shell system . . test. -d $auto_top && testscip-shell system . . test. -d .git; then |
| 17 | desired_branch=`gitscip-shell system . . git. rev-parse --abbrev-ref HEAD | trscip-shell system . . tr. /scip-shell filesystem . . `/`. %` |
| 18 | if testscip-shell system . . test. "$desired_branch" = HEAD; then |
| 19 | echoscip-shell system . . echo. "ERROR: switch to the right build dir manually when in detached HEAD mode." 1>&2 |
| 20 | exit 1 |
| 21 | fi |
| 22 | auto_dir="$auto_top/$desired_branch" |
| 23 | if testscip-shell system . . test. -d build; then |
| 24 | cur_branch=`readlinkscip-shell system . . readlink. build/.branch` |
| 25 | else |
| 26 | cur_branch='/scip-shell filesystem . . `/`.' |
| 27 | fi |
| 28 | if testscip-shell system . . test. "$desired_branch" != "$cur_branch"; then |
| 29 | if testscip-shell system . . test. "$cur_branch" != /scip-shell filesystem . . `/`.; then |
| 30 | rmscip-shell system . . rm. -f "$auto_top/$cur_branch" |
| 31 | mvscip-shell system . . mv. build "$auto_top/$cur_branch" |
| 32 | fi |
| 33 | testscip-shell system . . test. -d "$auto_dir" || mkdirscip-shell system . . mkdir. "$auto_dir" |
| 34 | testscip-shell system . . test. -h "$auto_dir/.branch" || lnscip-shell system . . ln. -s "$desired_branch" "$auto_dir/.branch" |
| 35 | mvscip-shell system . . mv. "$auto_dir" build |
| 36 | lnscip-shell system . . ln. -s ../build "$auto_dir" |
| 37 | fi |
| 38 | if testscip-shell system . . test. ! -h Makefile; then |
| 39 | rmscip-shell system . . rm. -f Makefile |
| 40 | lnscip-shell system . . ln. -s packaging/auto-Makefile Makefile |
| 41 | fi |
| 42 | echoscip-shell system . . echo. $desired_branch |
| 43 | fi |