Browse Source

Just show the usage instruction when the script is invoked wrongly.

Yao Wei Tjong 姚伟忠 10 years ago
parent
commit
808c79412f
4 changed files with 3 additions and 5 deletions
  1. 0 1
      cmake_clean.bat
  2. 1 1
      cmake_clean.sh
  3. 1 2
      cmake_generic.bat
  4. 1 1
      cmake_generic.sh

+ 0 - 1
cmake_clean.bat

@@ -32,7 +32,6 @@ cmake -E touch "%BUILD%\CMakeCache.txt"
 
 
 goto :eof
 goto :eof
 :error
 :error
-echo An error has occured, build tree has to be provided as the first argument OR call this script in a build tree itself
 echo Usage: %~nx0 \path\to\build-tree
 echo Usage: %~nx0 \path\to\build-tree
 exit /B 1
 exit /B 1
 :eof
 :eof

+ 1 - 1
cmake_clean.sh

@@ -22,7 +22,7 @@
 #
 #
 
 
 # Clean the CMake cache and CMake generated files in the build tree
 # Clean the CMake cache and CMake generated files in the build tree
-if [ "$1" ] && [ -f "$1"/CMakeCache.txt ]; then BUILD=$1; elif [ -f $(pwd)/CMakeCache.txt ]; then BUILD=$(pwd); else echo -e "An error has occured, build tree has to be provided as the first argument OR call this script in a build tree itself\nUsage: ${0##*/} /path/to/build-tree"; exit 1; fi
+if [ "$1" ] && [ -f "$1"/CMakeCache.txt ]; then BUILD=$1; elif [ -f $(pwd)/CMakeCache.txt ]; then BUILD=$(pwd); else echo Usage: ${0##*/} /path/to/build-tree; exit 1; fi
 rm -rf "$BUILD"/{CMakeCache.txt,CMakeFiles}
 rm -rf "$BUILD"/{CMakeCache.txt,CMakeFiles}
 touch "$BUILD"/CMakeCache.txt
 touch "$BUILD"/CMakeCache.txt
 
 

+ 1 - 2
cmake_generic.bat

@@ -59,7 +59,6 @@ cmake -E make_directory %BUILD% && cmake -E chdir %BUILD% cmake %OPTS% %* %SOURC
 
 
 goto :eof
 goto :eof
 :error
 :error
-echo An error has occured, build tree has to be provided as the first argument OR call this script in a build tree itself
-echo Usage: %~nx0 \path\to\build-tree
+echo Usage: %~nx0 \path\to\build-tree [build-options]
 exit /B 1
 exit /B 1
 :eof
 :eof

+ 1 - 1
cmake_generic.sh

@@ -22,7 +22,7 @@
 #
 #
 
 
 # Determine source tree and build tree
 # Determine source tree and build tree
-if [ "$1" ] && [[ ! "$1" =~ ^- ]]; then BUILD=$1; shift; elif [ -f $(pwd)/CMakeCache.txt ]; then BUILD=$(pwd); else caller=$(ps -o args= $PPID |cut -d' ' -f2); if [[ ! "$caller" =~ cmake_.*\.sh$ ]]; then caller=$0; fi; echo -e "An error has occured, build tree has to be provided as the first argument OR call this script in a build tree itself\nUsage: ${caller##*/} /path/to/build-tree"; exit 1; fi
+if [ "$1" ] && [[ ! "$1" =~ ^- ]]; then BUILD=$1; shift; elif [ -f $(pwd)/CMakeCache.txt ]; then BUILD=$(pwd); else caller=$(ps -o args= $PPID |cut -d' ' -f2); if [[ ! "$caller" =~ cmake_.*\.sh$ ]]; then caller=$0; fi; echo "Usage: ${caller##*/} /path/to/build-tree [build-options]"; exit 1; fi
 SOURCE=$(cd ${0%/*}; pwd)
 SOURCE=$(cd ${0%/*}; pwd)
 if [ "$BUILD" == "." ]; then BUILD=$(pwd); fi
 if [ "$BUILD" == "." ]; then BUILD=$(pwd); fi