Skip to content

Commit

Permalink
Configuration - TCL OCCT version extraction issue
Browse files Browse the repository at this point in the history
Enhance version detection in OCCDoc_DetectCasVersion
  • Loading branch information
dpasukhi committed Feb 3, 2025
1 parent cc30b93 commit 1bf2655
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 11 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ on:
push:
branches:
- 'master'
pull_request:
branches:
- '**'

jobs:
build:
Expand Down
41 changes: 30 additions & 11 deletions adm/occaux.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -144,20 +144,39 @@ proc OCCDoc_GetRelPath {thePathFrom thePathTo} {

# Returns OCCT version string from version.cmake (if available)
proc OCCDoc_DetectCasVersion {} {
# Default version in case the file is not found or readable
set occt_ver "7.8.0"
set occt_ver_add ""
set filename "[OCCDoc_GetSourceDir]/../adm/cmake/version.cmake"
if { [file exists $filename] } {
set fh [open $filename "r"]
set fh_loaded [read $fh]
close $fh
regexp {set\s+OCC_VERSION_MAJOR\s+([0-9]+)} $fh_loaded dummy major
regexp {set\s+OCC_VERSION_MINOR\s+([0-9]+)} $fh_loaded dummy minor
regexp {set\s+OCC_VERSION_MAINTENANCE\s+([0-9]+)} $fh_loaded dummy maint
regexp {set\s+OCC_VERSION_DEVELOPMENT\s+\"([^\"]+)\"} $fh_loaded dummy occt_ver_add
set occt_ver "$major.$minor.$maint"
if { "$occt_ver_add" != "" } { set occt_ver ${occt_ver}.$occt_ver_add }

# Construct path to version.cmake relative to script location
set filename "[file normalize [file dirname [info script]]/cmake/version.cmake]"

if { [file exists $filename] && [file readable $filename] } {
if {[catch {
set fh [open $filename "r"]
set fh_loaded [read $fh]
close $fh

# Use more robust regular expressions
regexp {OCC_VERSION_MAJOR\s+(\d+)} $fh_loaded -> major
regexp {OCC_VERSION_MINOR\s+(\d+)} $fh_loaded -> minor
regexp {OCC_VERSION_MAINTENANCE\s+(\d+)} $fh_loaded -> maint
regexp {OCC_VERSION_DEVELOPMENT\s+\"([^\"]+)\"} $fh_loaded -> occt_ver_add

if {[info exists major] && [info exists minor] && [info exists maint]} {
puts "Info: Open CASCADE Technology version $major.$minor.$maint"
set occt_ver "$major.$minor.$maint"
if { [info exists occt_ver_add] && $occt_ver_add != "" } {
set occt_ver ${occt_ver}.$occt_ver_add
}
}
} err]} {
puts "Warning: Error reading version from $filename: $err"
}
} else {
puts "Warning: Version file $filename not found or not readable"
}

return $occt_ver
}

Expand Down

0 comments on commit 1bf2655

Please sign in to comment.