X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fgmqcc.git;a=blobdiff_plain;f=misc%2Fcheck-proj.sh;h=b70e75f2dfdbe9c3a45f9ef0b22187ee6fd256be;hp=80d3ee2e7e27571f3a5009fbc4cc3a8e65f0f448;hb=6bd6379c87fe82b8e0169fdd2065830f0c4688b3;hpb=f44c127fbd99965030e271794513246c299c6f9c diff --git a/misc/check-proj.sh b/misc/check-proj.sh index 80d3ee2..b70e75f 100755 --- a/misc/check-proj.sh +++ b/misc/check-proj.sh @@ -1,16 +1,19 @@ #!/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 + local old="$PWD" + cd ~/.gmqcc/testsuite echo "$download_list" | while read -r line do echo "downloading $line ..." @@ -18,10 +21,12 @@ download() { done echo "$download_hashes" > ~/.gmqcc/testsuite/hashes - popd >> /dev/null + echo "$download_options" > ~/.gmqcc/testsuite/options + + cd "$old" } -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 +41,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,14 +69,15 @@ 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 + old="$PWD" + cd ~/.gmqcc/testsuite/projects + 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 + cd "$old" else echo "previous state exists, using it" fi @@ -74,27 +86,55 @@ fi gmqcc_bin="gmqcc" env -i type gmqcc 1>/dev/null 2>&1 || { if [ -f ../gmqcc ]; then - echo "found previous build of gmqcc, using it" + 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 "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 +end_dir="$PWD" +cd ~/.gmqcc/testsuite/projects +start="$PWD" +find . -maxdepth 1 -mindepth 1 -type d | while read -r line do + line="${line#./}" echo -n "compiling $line... " - pushd "$line" >> /dev/null - "$gmqcc_bin" -std=qcc > /dev/null 2>&1 - if [ $? -ne 0 ]; then - echo "error" + cd "${start}/${line}" + + # does the project have multiple subprojects? + if [ -f dirs ]; then + echo "" + cat dirs | while read -r dir + do + # change to subproject + echo -n " compiling $dir... " + old="$PWD" + cd "$dir" + cmd="$(cat ../../../options | grep "$line:" | awk '{print substr($0, index($0, $2))}')" + "$gmqcc_bin" $cmd > /dev/null 2>&1 + if [ $? -ne 0 ]; then + echo "error" + else + echo "success" + fi + cd "$old" + done + # nope only one project else - echo "success" + cmd="$(cat ../../options | grep "$line:" | awk '{print substr($0, index($0, $2))}')" + "$gmqcc_bin" $cmd > /dev/null 2>&1 + if [ $? -ne 0 ]; then + echo "error" + else + echo "success" + fi fi - - popd >> /dev/null done -popd >> /dev/null + +cd "$end_dir"