X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;ds=sidebyside;f=misc%2Fcheck-proj.sh;h=4b19c97ae3e11f3fb4fd8d3b885289a69d702f73;hb=13ef558fff71eaa8c829e07a57bad53eb016a074;hp=a97030ae4a2119ab09c2049755c6c717cb7a5239;hpb=8ddd1263783972fe3822b6912425f76a6e79f75c;p=xonotic%2Fgmqcc.git diff --git a/misc/check-proj.sh b/misc/check-proj.sh index a97030a..4b19c97 100755 --- a/misc/check-proj.sh +++ b/misc/check-proj.sh @@ -1,16 +1,18 @@ #!/bin/sh host="gmqcc.qc.to" -location=${host}"/files" -list=${location}"/files" -hashes=${location}"/hashes" +location="$host/files" +list="$location/files" +hashes="$location/hashes" +options="$location/options" #download required things download_list=$(wget -qO- ${list}) download_hashes=$(wget -qO- ${hashes}) +download_options=$(wget -qO- ${options}) download() { - pushd ~/.gmqcc/testsuite >> /dev/null + pushd ~/.gmqcc/testsuite > /dev/null echo "$download_list" | while read -r line do echo "downloading $line ..." @@ -18,10 +20,12 @@ download() { done echo "$download_hashes" > ~/.gmqcc/testsuite/hashes - popd >> /dev/null + echo "$download_options" > ~/.gmqcc/testsuite/options + + popd > /dev/null } -if [ -z "$download_list" -o -z "$download_hashes" ]; then +if [ -z "$download_list" -o -z "$download_hashes" -o -z "$download_options" ]; then echo "failed to download required information to check projects." if [ "$(ping -q -c1 "${host}")" ]; then @@ -36,10 +40,16 @@ if [ -z "$download_list" -o -z "$download_hashes" ]; then fi # we have existing contents around -if [ -f ~/.gmqcc/testsuite/hashes ]; then +if [ -f ~/.gmqcc/testsuite/hashes -a -f ~/.gmqcc/testsuite/options ]; then echo "$download_hashes" > /tmp/gmqcc_download_hashes - diff -u ~/.gmqcc/testsuite/hashes /tmp/gmqcc_download_hashes >> /dev/null - if [ $? -ne 0 ]; then + echo "$download_options" > /tmp/gmqcc_download_options + + diff -u ~/.gmqcc/testsuite/hashes /tmp/gmqcc_download_hashes > /dev/null + check_hash=$? + diff -u ~/.gmqcc/testsuite/options /tmp/gmqcc_download_options > /dev/null + check_opts=$? + + if [ $check_hash -ne 0 -o $check_opts -ne 0 ]; then echo "consistency errors in hashes (possible update), obtaining fresh contents" rm -rf ~/.gmqcc/testsuite/projects rm ~/.gmqcc/testsuite/*.zip @@ -58,31 +68,69 @@ fi if [ ! -d ~/.gmqcc/testsuite/projects ]; then mkdir -p ~/.gmqcc/testsuite/projects - pushd ~/.gmqcc/testsuite/projects >> /dev/null - echo "$(ls ../ | cat | grep -v '^hashes$' | grep -v '^projects$')" | while read -r line + pushd ~/.gmqcc/testsuite/projects > /dev/null + echo "$(ls ../ | cat | grep -v '^hashes$' | grep -v '^projects$' | grep -v '^options$')" | while read -r line do echo "extracting project $line" mkdir "$(echo "$line" | sed 's/\(.*\)\..*/\1/')" unzip -qq "../$line" -d $(echo "$line" | sed 's/\(.*\)\..*/\1/') done - popd >> /dev/null + popd > /dev/null else echo "previous state exists, using it" fi # compile projects in those directories -pushd ~/.gmqcc/testsuite/projects >> /dev/null +gmqcc_bin="gmqcc" +env -i type gmqcc 1>/dev/null 2>&1 || { + if [ -f ../gmqcc ]; then + echo "previous build of gmqcc exists, using it" + gmqcc_bin="$(pwd)/../gmqcc" + elif [ -f ./gmqcc ]; then + echo "previous build of gmqcc exists, using it" + gmqcc_bin="$(pwd)/gmqcc" + else + echo "gmqcc not installed and previous build doesn't exist" + echo "please run make, or make install" + exit 1 + fi +} + +pushd ~/.gmqcc/testsuite/projects > /dev/null find . -maxdepth 1 -mindepth 1 -type d -printf "%f\n" | while read -r line do - echo -n "compiling $line..." - pushd "$line" >> /dev/null - gmqcc -std=qcc >> /dev/null - if [ $? -ne 0 ]; then + error=0 + echo -n "compiling $line... " + pushd "$line" > /dev/null + + # does the project have multiple subprojects? + if [ -f dirs ]; then + cat dirs | while read -r dir + do + # change to subproject + pushd "$dir" > /dev/null + "$gmqcc_bin" $(cat ../../../options | grep "$line:" | awk '{print $2}') > /dev/null 2>&1 + if [ $? -ne 0 ]; then + error=1 + fi + popd > /dev/null + done + # nope only one project + else + "$gmqcc_bin" $(cat ../../options | grep "$line:" | awk '{print $2}') > /dev/null 2>&1 + if [ $? -ne 0 ]; then + error=1 + fi + fi + + # status + if [ $error -ne 0 ]; then echo "error" else echo "success" fi - popd >> /dev/null + popd > /dev/null done -popd >> /dev/null + +popd > /dev/null