diff options
author | Rolf Bjarne Kvinge <rolf@xamarin.com> | 2011-11-22 05:25:07 +0400 |
---|---|---|
committer | Rolf Bjarne Kvinge <rolf@xamarin.com> | 2011-11-22 05:49:51 +0400 |
commit | 7ce900e4c139d9bcb0d5c86b1cf86b9ae74d82a5 (patch) | |
tree | c0428b2321b41fa78ef20bd831d238d3f9ebaf39 | |
parent | acb6aa85cb55bdc5affe9e1d7c24259d1348e749 (diff) |
Add build magic so that dependencies are linked using git hashes
-rw-r--r-- | Makefile | 9 | ||||
-rwxr-xr-x | version-checks | 178 |
2 files changed, 187 insertions, 0 deletions
@@ -74,3 +74,12 @@ app-dir: package-monomac: (cd main; make package-monomac) + +reset-versions: reset-all +check-versions: check-all + +reset-%: + @./version-checks --reset $* + +check-%: + @./version-checks --check $* diff --git a/version-checks b/version-checks new file mode 100755 index 0000000000..6bc1200a9c --- /dev/null +++ b/version-checks @@ -0,0 +1,178 @@ +#!/bin/bash -e + +cd `dirname $0` +top_srcdir=`pwd` +script_name=./`basename $0` + +# +# Script to check versions of dependencies +# To check the version for all dependencies, just run the script with no arguments. +# To check the version for a specific dependency, run the script with "check <dependency>" +# To reset a dependency to the needed version, run the script with "reset <dependency>" +# It is also possible to pass "reset all" to reset all dependencies +# + +# md-addins +DEP[0]=md-addins +DEP_NAME[0]=MDADDINS +DEP_PATH[0]=${top_srcdir}/../md-addins +DEP_MODULE[0]=git@github.com:xamarin/md-addins.git +DEP_NEEDED_VERSION[0]=7b15f212e3a3243f15b7547d18f07fc8535ecbb6 +DEP_BRANCH_AND_REMOTE[0]="master origin/master" + +# heap-shot +DEP[1]=heap-shot +DEP_NAME[1]=HEAPSHOT +DEP_PATH[1]=${top_srcdir}/../heap-shot +DEP_MODULE[1]=git@github.com:mono/heap-shot.git +DEP_NEEDED_VERSION[1]=498dba772c1e514e5a0d12d4b90e202acc30d1d2 +DEP_BRANCH_AND_REMOTE[1]="master origin/master" + +# other dependencies +# DEP[2]=... +# ... + +function fetch_variables +{ + IGNORE_VERSION=`eval echo \\\$IGNORE_${DEP_NAME[$1]}_VERSION` + THE_PATH=${DEP_PATH[$1]} + NAME=${DEP[$1]} + NEEDED_VERSION=${DEP_NEEDED_VERSION[$1]} + if test -d "$THE_PATH"; then + cd "$THE_PATH" + VERSION=`git log | head -1 | awk '{print $2}' 2>/dev/null` + BRANCH=`git status | head -1 | awk '{print $4}' 2>/dev/null` + cd "$top_srcdir" + else + VERSION= + BRANCH= + fi + BRANCH_AND_REMOTE=${DEP_BRANCH_AND_REMOTE[$1]} + NEEDED_BRANCH=`echo "$BRANCH_AND_REMOTE" | sed -e 's, .*,,'` + MODULE=${DEP_MODULE[$1]} +} + +function reset_version +{ + fetch_variables $1 + + if test -d "$THE_PATH"; then + cd "$THE_PATH" + if ! git show "$NEEDED_VERSION" >/dev/null 2>&1; then + echo "*** [$NAME] git fetch $NAME" + git fetch + fi + else + echo "*** [$NAME] git clone $MODULE" + cd "`dirname $THE_PATH`" + git clone $MODULE + fi + + cd "$THE_PATH" + echo "*** [$NAME] git checkout $NEEDED_BRANCH" + git checkout $NEEDED_BRANCH || git checkout -b $BRANCH_AND_REMOTE + echo "*** [$NAME] git reset --hard $NEEDED_VERSION" + git reset --hard $NEEDED_VERSION + + cd "$top_srcdir" +} + +function check_version +{ + fetch_variables $1 + + if [[ "x$IGNORE_VERSION" == "x" ]]; then + if test ! -d "$THE_PATH"; then + echo "Your $NAME checkout is missing, please run '$script_name --reset $NAME'" + FAILURE=1 + else + if [[ "x$VERSION" != "x$NEEDED_VERSION" || "x$BRANCH" != "x$NEEDED_BRANCH" ]]; then + echo "Your $NAME version is out of date, please run '$script_name --reset $NAME'" + FAILURE=1 + fi + fi + fi +} + +function reset_all +{ + I=0 + while [[ "x${#DEP[@]}" != "x$I" ]]; do + reset_version $I + let I=$I+1 + done +} + +function check_all +{ + I=0 + while [[ "x${#DEP[@]}" != "x$I" ]]; do + check_version $I + let I=$I+1 + done +} + +function find_dep +{ + I=0 + DEP_IDX= + while [[ "x${#DEP[@]}" != "x$I" ]]; do + if [[ "x${DEP[$I]}" == "x" ]]; then + echo "There is no dependency named $1" + exit 1 + elif [[ "x${DEP[$I]}" == "x$1" ]]; then + DEP_IDX=$I + break; + fi + let I=$I+1 + done + if [[ "x$DEP_IDX" == "x" ]]; then + echo "There is no dependency named $1" + exit 1 + fi +} + +FAILURE=0 + +if [[ "x$1" == "x" ]]; then + check_all +elif [[ "x$1" == "x--check-all" ]]; then + check_all +elif [[ "x$1" == "x--check" && "x$2" == "xall" ]]; then + check_all +elif [[ "x$1" == "x--check" && "x$2" == "x" ]]; then + check_all +elif [[ "x$1" == "x--check" ]]; then + shift + while [[ "x$1" != "x" ]]; do + find_dep $1 + check_version $DEP_IDX + shift + done +elif [[ "x$1" == "x--reset-all" ]]; then + reset_all +elif [[ "x$1" == "x--reset" && "x$2" == "xall" ]]; then + reset_all +elif [[ "x$1" == "x--reset" && "x$2" == "x" ]]; then + reset_all +elif [[ "x$1" == "x--reset" ]]; then + shift + while [[ "x$1" != "x" ]]; do + find_dep $1 + reset_version $DEP_IDX + shift + done +else + echo Unknown arguments: $@ + echo 'Expected --reset|--check <list of dependencies>' + exit 1 +fi + +if [[ "x$FAILURE" == "x1" ]]; then + echo "One or more modules needs update" + exit 1 +else + echo "All dependent modules up to date" +fi + + |