From 1e3d3b3aed86a451de73a73f419a579531a362ad Mon Sep 17 00:00:00 2001 From: Vasily Date: Fri, 28 Dec 2018 15:15:40 +0100 Subject: [PATCH] Add additional error handling to verification scripts --- build_scripts/linux/verify_formatting | 6 ++++- build_scripts/win/verify_formatting.cmd | 33 ++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/build_scripts/linux/verify_formatting b/build_scripts/linux/verify_formatting index 998ae74..8ddd177 100644 --- a/build_scripts/linux/verify_formatting +++ b/build_scripts/linux/verify_formatting @@ -8,7 +8,11 @@ if [ $? -eq 0 ]; then project_path=$build_path/../.. python $project_path/build_scripts/run-clang-format.py $project_path/src -r --color always; - echo "FORMATTED CORRECTLY." + if [ $? -eq 0 ]; then + echo "FORMATTED CORRECTLY." + else + echo "NOT FORMATTED CORRECTLY." + fi else echo "Could not find clang-format." fi diff --git a/build_scripts/win/verify_formatting.cmd b/build_scripts/win/verify_formatting.cmd index ad0c91a..997643d 100644 --- a/build_scripts/win/verify_formatting.cmd +++ b/build_scripts/win/verify_formatting.cmd @@ -5,5 +5,36 @@ REM As per above link, %~dp0 expands the zeroth arg to a drive letter and path o REM Project dir is up two dirs from the file. SET project_dir=%~dp0\..\..\ +ECHO %current_activity%: Testing if clang-format can be located: + +IF NOT DEFINED CLANG_FORMAT_LOC ( + ECHO %current_activity%: CLANG_FORMAT_LOC not defined. Using default value. + SET CLANG_FORMAT_LOC="C:\Program Files\LLVM\bin\clang-format.exe" +) +ECHO %current_activity%: CLANG_FORMAT_LOC set to '%CLANG_FORMAT_LOC%'. + +REM EXIST won't find items in the PATH. WHERE will. +SET CLANG_FORMAT_VALID=0 +IF EXIST %CLANG_FORMAT_LOC% SET CLANG_FORMAT_VALID=1 +IF %CLANG_FORMAT_VALID% EQU 0 ( + WHERE /Q %CLANG_FORMAT_LOC% + IF NOT ERRORLEVEL 1 SET CLANG_FORMAT_VALID=1 +) + +IF %CLANG_FORMAT_VALID% EQU 1 ( + ECHO %current_activity%: CLANG_FORMAT_LOC exists. +) ELSE ( + ECHO %current_activity%: CLANG_FORMAT_LOC directory does not exist. Exiting. + EXIT /B %exit_code_failure_build_locations% +) + +ECHO %current_activity%: Clang-format located. + +%CLANG_FORMAT_LOC% --version + python %project_dir%/build_scripts/run-clang-format.py %project_dir%/src -r --color never --clang-format-executable %CLANG_FORMAT_LOC% -IF NOT ERRORLEVEL 1 THEN ECHO FORMATTED CORRECTLY. \ No newline at end of file +IF NOT ERRORLEVEL 1 ( + ECHO FORMATTED CORRECTLY. +) ELSE ( + ECHO NOT FORMATTED CORRECTLY. +) \ No newline at end of file