summaryrefslogtreecommitdiffstats
path: root/BuildTools
diff options
context:
space:
mode:
authorDario Pellegrini <pellegrini.dario@gmail.com>2020-08-08 01:22:41 +0000
committerGitHub <noreply@github.com>2020-08-08 01:22:41 +0000
commite1b174ed10ff215c8f9fae022384a18f4f49d347 (patch)
treebba4f098ef6c72167294fbebffa956b1cfc087da /BuildTools
parentFixed IDXGISwapChain2 issue on Windows 7 (closed https://github.com/DiligentG... (diff)
downloadDiligentCore-e1b174ed10ff215c8f9fae022384a18f4f49d347.tar.gz
DiligentCore-e1b174ed10ff215c8f9fae022384a18f4f49d347.zip
Validate format won't crash if it cannot load the provided binary (#154)
* Validate format won't crash if it cannot load the provided binary * Avoid superfluous output * introduced version checking and delegated validation skipping to cmake * tiny fix
Diffstat (limited to 'BuildTools')
-rwxr-xr-xBuildTools/FormatValidation/validate_format_linux.sh38
1 files changed, 32 insertions, 6 deletions
diff --git a/BuildTools/FormatValidation/validate_format_linux.sh b/BuildTools/FormatValidation/validate_format_linux.sh
index 07d583a4..484672d8 100755
--- a/BuildTools/FormatValidation/validate_format_linux.sh
+++ b/BuildTools/FormatValidation/validate_format_linux.sh
@@ -1,7 +1,33 @@
#!/bin/bash
-python clang-format-validate.py --clang-format-executable ./clang-format_linux_10.0.0 \
--r ../../Common ../../Graphics ../../Platforms ../../Primitives ../../Tests \
---exclude ../../Graphics/HLSL2GLSLConverterLib/include/GLSLDefinitions.h \
---exclude ../../Graphics/HLSL2GLSLConverterLib/include/GLSLDefinitions_inc.h \
---exclude ../../Graphics/GraphicsEngineVulkan/shaders/GenerateMipsCS_inc.h \
---exclude ../../Tests/DiligentCoreAPITest/assets/*
+
+BIN=$(find . -name 'clang-format_linux_*')
+
+## Try to launch the bin
+eval "$BIN --version >/dev/null 2> /dev/null"
+if [ $? -ne 0 ]; then
+ ## BIN failed to run, try to get a system installed clang-format
+ SYS_BIN=$(which clang-format 2> /dev/null)
+ if [ $? -ne 0 ]; then
+ echo "WARNING: skipping format validation as no suitable executable was found"
+ BIN=""
+ else
+ BIN_VERSION=$(echo $BIN | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')
+ SYS_BIN_VERSION=$(eval "$SYS_BIN --version" | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')
+ if [ "$BIN_VERSION" != "$SYS_BIN_VERSION" ]; then
+ echo "WARNING: could not load the provided clang-format for validation."
+ echo " clang-format exists in the system path however its version is $SYS_BIN_VERSION instead of $BIN_VERSION"
+ echo " Should the validation fail, you can try skipping it by setting the cmake option:"
+ echo " DILIGENT_SKIP_FORMAT_VALIDATION"
+ fi
+ BIN="$SYS_BIN"
+ fi
+fi
+
+if [ ! -z "$BIN" ]; then
+ python clang-format-validate.py --clang-format-executable "$BIN" \
+ -r ../../Common ../../Graphics ../../Platforms ../../Primitives ../../Tests \
+ --exclude ../../Graphics/HLSL2GLSLConverterLib/include/GLSLDefinitions.h \
+ --exclude ../../Graphics/HLSL2GLSLConverterLib/include/GLSLDefinitions_inc.h \
+ --exclude ../../Graphics/GraphicsEngineVulkan/shaders/GenerateMipsCS_inc.h \
+ --exclude ../../Tests/DiligentCoreAPITest/assets/*
+fi