From de7ccf2a4313398fb29133ad78c5547805233666 Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Mon, 3 Jan 2022 11:18:12 -0500 Subject: Add helpful error checks for common user errors. --- build.sh | 6 ++++++ install.sh | 26 +++++++++++++++----------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/build.sh b/build.sh index 63a5d32..98f6249 100755 --- a/build.sh +++ b/build.sh @@ -3,6 +3,12 @@ set -e CCOPT= CXXOPT= +# error if devkitarm is not installed and binutils-arm-none-eabi is not installed +if ! ([ -v DEVKITARM ] && [ -d "$DEVKITARM/bin" ]) && ! (command -v arm-none-eabi-as &> /dev/null && command -v arm-none-eabi-ar &> /dev/null) ; then + echo "Could not find a binutils installation! Re-read the instructions and make sure you've installed either devkitARM or binutils-arm-none-eabi, depending on your system." + exit 1 +fi + if [ ! -z "$CC" ]; then CCOPT=CC=$CC; fi if [ ! -z "$CXX" ]; then CXXOPT=CXX=$CXX; fi make -C gcc clean diff --git a/install.sh b/install.sh index 608d82d..6396d3d 100755 --- a/install.sh +++ b/install.sh @@ -1,17 +1,21 @@ #!/bin/sh set -e if [ "$1" != "" ]; then - mkdir -p $1/tools/agbcc - mkdir -p $1/tools/agbcc/bin - mkdir -p $1/tools/agbcc/include - mkdir -p $1/tools/agbcc/lib - cp agbcc $1/tools/agbcc/bin/ - cp old_agbcc $1/tools/agbcc/bin/ - cp agbcc_arm $1/tools/agbcc/bin/ - cp -R libc/include $1/tools/agbcc/ #drop include, because we don't want include/include - cp ginclude/* $1/tools/agbcc/include/ - cp libgcc.a $1/tools/agbcc/lib/ - cp libc.a $1/tools/agbcc/lib/ + if [ -d "$1" ]; then + mkdir -p $1/tools/agbcc + mkdir -p $1/tools/agbcc/bin + mkdir -p $1/tools/agbcc/include + mkdir -p $1/tools/agbcc/lib + cp agbcc $1/tools/agbcc/bin/ + cp old_agbcc $1/tools/agbcc/bin/ + cp agbcc_arm $1/tools/agbcc/bin/ + cp -R libc/include $1/tools/agbcc/ #drop include, because we don't want include/include + cp ginclude/* $1/tools/agbcc/include/ + cp libgcc.a $1/tools/agbcc/lib/ + cp libc.a $1/tools/agbcc/lib/ + else + echo "Target directory does not exist. Did you mean to do \"./install.sh ../$1\"?" + fi else echo "Usage: install.sh PATH" fi -- cgit v1.2.3 From 1fcda818cb15f3f07dc5796f4a0ea6dccd10f95d Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Mon, 3 Jan 2022 11:22:32 -0500 Subject: Fix indentation. --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 6396d3d..818deae 100755 --- a/install.sh +++ b/install.sh @@ -17,5 +17,5 @@ if [ "$1" != "" ]; then echo "Target directory does not exist. Did you mean to do \"./install.sh ../$1\"?" fi else - echo "Usage: install.sh PATH" + echo "Usage: install.sh PATH" fi -- cgit v1.2.3 From 9f762735d7e65956861cab25bcf4f802a7c1c441 Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Mon, 3 Jan 2022 11:29:11 -0500 Subject: Better install.sh error messages. --- install.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 818deae..a258c46 100755 --- a/install.sh +++ b/install.sh @@ -14,7 +14,11 @@ if [ "$1" != "" ]; then cp libgcc.a $1/tools/agbcc/lib/ cp libc.a $1/tools/agbcc/lib/ else - echo "Target directory does not exist. Did you mean to do \"./install.sh ../$1\"?" + if [ -d "../$1" ]; then + echo "Target directory does not exist. Did you mean to do \"./install.sh ../$1\"?" + else + echo "Target directory does not exist. If you aren't familiar with relative paths, make sure that agbcc and $1 are in the same directory, and run \"./install.sh ../$1\" again." + fi fi else echo "Usage: install.sh PATH" -- cgit v1.2.3 From c19734bb7acd33e27fb28fb1ebb84b5270aac8c5 Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Fri, 7 Jan 2022 11:09:13 -0500 Subject: Improvements to error messages. --- install.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index a258c46..54aa66e 100755 --- a/install.sh +++ b/install.sh @@ -17,7 +17,15 @@ if [ "$1" != "" ]; then if [ -d "../$1" ]; then echo "Target directory does not exist. Did you mean to do \"./install.sh ../$1\"?" else - echo "Target directory does not exist. If you aren't familiar with relative paths, make sure that agbcc and $1 are in the same directory, and run \"./install.sh ../$1\" again." + if case $1 in ".."*) true;; *) false;; esac; then + echo "Target directory does not exist. If you aren't familiar with relative paths, make sure that agbcc and the repository are in the same directory, and run \"./install.sh $1\" again." + else + if echo "$1" | grep -qE '^[^/]*.$'; then + echo "Target directory does not exist. You probably meant to do \"./install.sh ../$1\", but agbcc and $1 do not exist in the same directory. Check your spelling, make sure that the repository has been cloned, ensure that agbcc and the repository are in the same directory, and run \"./install.sh ../$1\" again." + else + echo "Target directory does not exist. Check your spelling, re-read the instructions, and try again." + fi + fi fi fi else -- cgit v1.2.3