From bfb00b243e0f95348a588189947b36b3bac454c6 Mon Sep 17 00:00:00 2001 From: Pasukhin Dmitry Date: Mon, 3 Feb 2025 23:25:29 +0100 Subject: [PATCH] Configuration - TCL OCCT version extraction issue #337 Enhance version detection in OCCDoc_DetectCasVersion Refactor documentation build workflow and integrate into multiplatform CI --- .../build-docs/action.yml} | 23 +++-------- .../build-and-test-multiplatform.yml | 11 +++++ adm/occaux.tcl | 41 ++++++++++++++----- 3 files changed, 46 insertions(+), 29 deletions(-) rename .github/{workflows/build-docs.yml => actions/build-docs/action.yml} (69%) diff --git a/.github/workflows/build-docs.yml b/.github/actions/build-docs/action.yml similarity index 69% rename from .github/workflows/build-docs.yml rename to .github/actions/build-docs/action.yml index ec257120cd..13e47251dc 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/actions/build-docs/action.yml @@ -1,27 +1,14 @@ -# This workflow builds the OCCT reference manual and overview documentations. -# It is triggered on pushes to the 'master' branch. -# The workflow includes steps to checkout the repository, install dependencies, build the documentation, and upload the generated documentation and logs as artifacts. - name: Build Documentation +description: 'Build OCCT documentation using doxygen' -on: - push: - branches: - - 'master' - -jobs: - build: - name: Build Refman Documentation - runs-on: windows-2022 - - steps: - - name: Checkout repository - uses: actions/checkout@v4.2.1 - +runs: + using: composite + steps: - name: Install dependencies run: | choco install -y graphviz choco install -y doxygen.install + shell: pwsh - name: Build refman documentation run: | diff --git a/.github/workflows/build-and-test-multiplatform.yml b/.github/workflows/build-and-test-multiplatform.yml index 1cd4fd3963..afa19066eb 100644 --- a/.github/workflows/build-and-test-multiplatform.yml +++ b/.github/workflows/build-and-test-multiplatform.yml @@ -33,6 +33,17 @@ jobs: with: base-ref: ${{ github.event.pull_request.base.ref || 'master' }} + documentation: + name: Build Documentation + runs-on: windows-2022 + + steps: + - name: Checkout repository + uses: actions/checkout@v4.2.1 + + - name: Build documentation + uses: ./.github/actions/build-docs + prepare-and-build-windows-x64: name: Prepare and Build on Windows with MSVC (x64) runs-on: windows-2022 diff --git a/adm/occaux.tcl b/adm/occaux.tcl index a2c87bc5d1..5e3861a58e 100644 --- a/adm/occaux.tcl +++ b/adm/occaux.tcl @@ -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 }