]> OCCT Git - occt.git/commitdiff
Configuration - TCL OCCT version extraction issue #337
authorPasukhin Dmitry <dpasukhi@opencascade.com>
Mon, 3 Feb 2025 22:25:29 +0000 (23:25 +0100)
committerGitHub <noreply@github.com>
Mon, 3 Feb 2025 22:25:29 +0000 (22:25 +0000)
Enhance version detection in OCCDoc_DetectCasVersion
Refactor documentation build workflow and integrate into multiplatform CI

.github/actions/build-docs/action.yml [new file with mode: 0644]
.github/workflows/build-and-test-multiplatform.yml
.github/workflows/build-docs.yml [deleted file]
adm/occaux.tcl

diff --git a/.github/actions/build-docs/action.yml b/.github/actions/build-docs/action.yml
new file mode 100644 (file)
index 0000000..13e4725
--- /dev/null
@@ -0,0 +1,46 @@
+name: Build Documentation
+description: 'Build OCCT documentation using doxygen'
+
+runs:
+  using: composite
+  steps:
+    - name: Install dependencies
+      run: |
+        choco install -y graphviz
+        choco install -y doxygen.install
+      shell: pwsh
+
+    - name: Build refman documentation
+      run: |
+        set PATH=%PATH%;C:\Program Files\doxygen\bin;C:\Program Files\Graphviz\bin;C:\Program Files\doxygen
+        cd adm
+        bash gendoc -refman
+      shell: cmd
+
+    - name: Upload refman documentation
+      uses: actions/upload-artifact@v4.4.3
+      with:
+        name: refman-doc
+        path: doc/refman
+        retention-days: 90
+
+    - name: Upload generation log
+      uses: actions/upload-artifact@v4.4.3
+      with:
+        name: doxygen.log
+        path: doc/html_doxygen_err.log
+        retention-days: 90
+
+    - name: Build documentation Overview
+      run: |
+        set PATH=%PATH%;C:\Program Files\doxygen\bin;C:\Program Files\Graphviz\bin;C:\Program Files\doxygen
+        cd adm
+        bash gendoc -overview
+      shell: cmd
+
+    - name: Upload overview documentation
+      uses: actions/upload-artifact@v4.4.3
+      with:
+        name: overview-doc
+        path: doc/overview
+        retention-days: 90
index 1cd4fd39635e272a7090ae2a1f6c04490fed6fe3..afa19066eb841bf8c018f9dafa3c8b94aab6f68f 100644 (file)
@@ -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/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml
deleted file mode 100644 (file)
index ec25712..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-# 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
-
-on:
-  push:
-    branches:
-      - 'master'
-
-jobs:
-  build:
-    name: Build Refman Documentation
-    runs-on: windows-2022
-
-    steps:
-    - name: Checkout repository
-      uses: actions/checkout@v4.2.1
-
-    - name: Install dependencies
-      run: |
-        choco install -y graphviz
-        choco install -y doxygen.install
-
-    - name: Build refman documentation
-      run: |
-        set PATH=%PATH%;C:\Program Files\doxygen\bin;C:\Program Files\Graphviz\bin;C:\Program Files\doxygen
-        cd adm
-        bash gendoc -refman
-      shell: cmd
-
-    - name: Upload refman documentation
-      uses: actions/upload-artifact@v4.4.3
-      with:
-        name: refman-doc
-        path: doc/refman
-        retention-days: 90
-
-    - name: Upload generation log
-      uses: actions/upload-artifact@v4.4.3
-      with:
-        name: doxygen.log
-        path: doc/html_doxygen_err.log
-        retention-days: 90
-
-    - name: Build documentation Overview
-      run: |
-        set PATH=%PATH%;C:\Program Files\doxygen\bin;C:\Program Files\Graphviz\bin;C:\Program Files\doxygen
-        cd adm
-        bash gendoc -overview
-      shell: cmd
-
-    - name: Upload overview documentation
-      uses: actions/upload-artifact@v4.4.3
-      with:
-        name: overview-doc
-        path: doc/overview
-        retention-days: 90
index a2c87bc5d12b87a9e08a991bb13de96505fbbd66..5e3861a58e98b39f23447c65bef1dd9a5e3a6c64 100644 (file)
@@ -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
 }