1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-02 17:46:22 +03:00

Configuration - Version detection on MacOS #313

Improve version extraction and add error handling for missing version file
This commit is contained in:
Pasukhin Dmitry 2025-02-01 00:04:27 +01:00 committed by GitHub
parent 2027acc3de
commit 8a067c43b7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,8 +1,30 @@
#!/bin/bash
# Ensure script dir is defined
if [ -z "$aScriptDir" ]; then
aScriptDir=$(dirname "$0")
fi
# Check if version file exists
versionFile="$aScriptDir/../cmake/version.cmake"
if [ ! -f "$versionFile" ]; then
echo "Error: version.cmake not found"
exit 1
fi
# Extract version info from version.cmake
anOcctVerSuffix=`grep -e "OCC_VERSION_DEVELOPMENT" "$aScriptDir/../cmake/version.cmake" | grep -o '".*"' | tr -d '"'`
OCC_VERSION_MAJOR=`grep -e "OCC_VERSION_MAJOR" "$aScriptDir/../cmake/version.cmake" | awk '{print $3}'`
OCC_VERSION_MINOR=`grep -e "OCC_VERSION_MINOR" "$aScriptDir/../cmake/version.cmake" | awk '{print $3}'`
OCC_VERSION_MAINTENANCE=`grep -e "OCC_VERSION_MAINTENANCE" "$aScriptDir/../cmake/version.cmake" | awk '{print $3}'`
anOcctVersion="$OCC_VERSION_MAJOR.$OCC_VERSION_MINOR.$OCC_VERSION_MAINTENANCE"
OCC_VERSION_MAJOR=$(awk '/set.*OCC_VERSION_MAJOR/ {print $3}' "$versionFile")
OCC_VERSION_MINOR=$(awk '/set.*OCC_VERSION_MINOR/ {print $3}' "$versionFile")
OCC_VERSION_MAINTENANCE=$(awk '/set.*OCC_VERSION_MAINTENANCE/ {print $3}' "$versionFile")
anOcctVerSuffix=$(awk '/set.*OCC_VERSION_DEVELOPMENT/ {
if (NF > 2) {
gsub(/[)" ]/, "", $3)
print $3
} else {
print ""
}
}' "$versionFile")
# Combine version string
anOcctVersion="${OCC_VERSION_MAJOR}.${OCC_VERSION_MINOR}.${OCC_VERSION_MAINTENANCE}"