]> OCCT Git - occt.git/commitdiff
Testing - Samples build on GH #331
authorPasukhin Dmitry <dpasukhi@opencascade.com>
Sun, 9 Feb 2025 23:00:37 +0000 (00:00 +0100)
committerGitHub <noreply@github.com>
Sun, 9 Feb 2025 23:00:37 +0000 (23:00 +0000)
Add GitHub Action to build CSharp sample on Windows
Add MFC and Qt sample build actions
Improve CASROOT assignment logic in env.build.sh and env.install.sh for better compatibility with binary directories

12 files changed:
.github/actions/build-sample-csharp/action.yml [new file with mode: 0644]
.github/actions/build-sample-mfc/action.yml [new file with mode: 0644]
.github/actions/build-sample-qt/action.yml [new file with mode: 0644]
.github/actions/build-tinspector/action.yml
.github/workflows/build-and-test-multiplatform.yml
adm/templates/custom.build.sh.in
adm/templates/env.build.sh.in
adm/templates/env.install.sh.in
samples/qt/FuncDemo/FuncDemo.pro
samples/qt/IESample/IESample.pro
samples/qt/OCCTOverview/OCCTOverview.pro
samples/qt/Tutorial/Tutorial.pro

diff --git a/.github/actions/build-sample-csharp/action.yml b/.github/actions/build-sample-csharp/action.yml
new file mode 100644 (file)
index 0000000..9a96eec
--- /dev/null
@@ -0,0 +1,57 @@
+name: 'Build CSharp Sample'
+description: 'Build CSharp sample using OCCT installation'
+
+inputs:
+  platform:
+    description: 'Build platform (windows)'
+    required: true
+  install-artifact-name:
+    description: 'OCCT installation artifact name'
+    required: true
+
+runs:
+  using: "composite"
+  steps:
+    - name: Download OCCT installation
+      uses: actions/download-artifact@v4.1.7
+      with:
+        name: ${{ inputs.install-artifact-name }}
+        path: occt-install
+
+    - name: Build CSharp Sample
+      if: inputs.platform == 'windows'
+      shell: cmd
+      run: |
+        REM Setup environment
+        call "${{ github.workspace }}\occt-install\env.bat" vc14 win64 Release
+        call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" x64
+        set "PATH=C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE;%PATH%"
+
+        cd ${{ github.workspace }}/samples/CSharp
+
+        REM First upgrade solutions to VS2022
+        echo "Upgrading solution files to VS2022..."
+        devenv.exe CSharp.sln /upgrade
+        devenv.exe CSharp_D3D.sln /upgrade
+
+        REM Update project platform toolset
+        powershell -Command "(Get-Content OCCTProxy\OCCTProxy.vcxproj) -replace '<PlatformToolset>v100</PlatformToolset>', '<PlatformToolset>v143</PlatformToolset>' | Set-Content OCCTProxy\OCCTProxy.vcxproj"
+        powershell -Command "(Get-Content OCCTProxy_D3D\OCCTProxy_D3D.vcxproj) -replace '<PlatformToolset>v100</PlatformToolset>', '<PlatformToolset>v143</PlatformToolset>' | Set-Content OCCTProxy_D3D\OCCTProxy_D3D.vcxproj"
+
+        REM Restore NuGet packages
+        echo "Upgrading solution files..."
+        msbuild.exe CSharp.sln -t:Restore -p:Configuration=Release -p:Platform=x64 /consoleloggerparameters:Verbosity=normal;Summary /flp:LogFile=restore_csharp.log;Verbosity=detailed
+        msbuild.exe CSharp_D3D.sln -t:Restore -p:Configuration=Release -p:Platform=x64 /consoleloggerparameters:Verbosity=normal;Summary /flp:LogFile=restore_d3d.log;Verbosity=detailed
+        
+        REM Build solutions with real-time console output
+        echo "Building CSharp.sln..."
+        msbuild.exe CSharp.sln /p:Configuration=Release /p:Platform=x64 /consoleloggerparameters:Verbosity=normal;Summary /flp:LogFile=build_csharp.log;Verbosity=detailed /m
+        echo "Building CSharp_D3D.sln..."
+        msbuild.exe CSharp_D3D.sln /p:Configuration=Release /p:Platform=x64 /consoleloggerparameters:Verbosity=normal;Summary /flp:LogFile=build_d3d.log;Verbosity=detailed /m
+
+    - name: Upload CSharp Sample
+      uses: actions/upload-artifact@v4.4.3
+      with:
+        name: csharp-sample-${{ inputs.platform }}-x64
+        path: samples/CSharp
+        retention-days: 7
diff --git a/.github/actions/build-sample-mfc/action.yml b/.github/actions/build-sample-mfc/action.yml
new file mode 100644 (file)
index 0000000..60192fa
--- /dev/null
@@ -0,0 +1,54 @@
+name: 'Build MFC Sample'
+description: 'Build MFC sample using OCCT installation'
+
+inputs:
+  platform:
+    description: 'Build platform (windows)'
+    required: true
+  install-artifact-name:
+    description: 'OCCT installation artifact name'
+    required: true
+
+runs:
+  using: "composite"
+  steps:
+    - name: Download OCCT installation 
+      uses: actions/download-artifact@v4.1.7
+      with:
+        name: ${{ inputs.install-artifact-name }}
+        path: occt-install
+
+    - name: Build MFC Sample
+      if: inputs.platform == 'windows'
+      shell: cmd
+      run: |
+        REM Setup environment
+        call "${{ github.workspace }}\occt-install\env.bat" vc14 win64 Release
+        call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" x64
+
+        cd ${{ github.workspace }}/samples/mfc/standard
+        set "PATH=C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE;%PATH%"
+        
+        REM First restore the solution
+        echo "Restoring solution..."
+        msbuild.exe ALL-vc14.sln -t:Restore -p:Configuration=Release -p:Platform=x64 /consoleloggerparameters:Verbosity=normal;Summary /flp:LogFile=restore.log;Verbosity=detailed
+        
+        REM Build solution with detailed logging
+        echo "Building solution..."
+        msbuild.exe ALL-vc14.sln /p:Configuration=Release /p:Platform=x64 /p:PlatformToolset=v143 /consoleloggerparameters:Verbosity=normal;Summary /flp:LogFile=build.log;Verbosity=detailed /m
+
+        REM Display logs if build fails
+        if errorlevel 1 (
+          echo "Build failed. Contents of restore.log:"
+          type restore.log
+          echo "Contents of build.log:"
+          type build.log
+          exit /b 1
+        )
+
+    - name: Upload MFC Sample
+      uses: actions/upload-artifact@v4.4.3
+      with:
+        name: mfc-sample-${{ inputs.platform }}-x64
+        path: samples/mfc/
+        retention-days: 7
diff --git a/.github/actions/build-sample-qt/action.yml b/.github/actions/build-sample-qt/action.yml
new file mode 100644 (file)
index 0000000..4ee2d89
--- /dev/null
@@ -0,0 +1,108 @@
+name: 'Build Qt Sample'
+description: 'Build Qt samples using OCCT installation'
+
+inputs:
+  platform:
+    description: 'Build platform (windows/linux)'
+    required: true
+  install-artifact-name:
+    description: 'OCCT installation artifact name'
+    required: true
+  thirdparty_url:
+    description: 'URL to download 3rdparty dependencies'
+    required: false
+    default: 'https://github.com/Open-Cascade-SAS/OCCT/releases/download/V7_9_0_beta1/3rdparty-vc14-64.zip'
+
+runs:
+  using: "composite"
+  steps:
+    - name: Download OCCT installation
+      uses: actions/download-artifact@v4.1.7
+      with:
+        name: ${{ inputs.install-artifact-name }}
+        path: occt-install
+
+    - name: Install Windows dependencies
+      if: inputs.platform == 'windows'
+      shell: pwsh
+      run: |
+          Invoke-WebRequest -Uri ${{ inputs.thirdparty_url }} -OutFile 3rdparty-vc14-64.zip
+          Expand-Archive -Path 3rdparty-vc14-64.zip -DestinationPath .
+          Remove-Item 3rdparty-vc14-64.zip
+
+    - name: Install Linux dependencies
+      if: inputs.platform == 'linux'
+      shell: bash
+      run: sudo apt-get update && sudo apt-get install -y tcl-dev tk-dev cmake gcc g++ make libbtbb-dev libx11-dev libglu1-mesa-dev tcllib tcl-thread tcl libvtk9-dev libopenvr-dev libdraco-dev libfreeimage-dev libegl1-mesa-dev libgles2-mesa-dev libfreetype-dev qtbase5-dev qt5-qmake qtbase5-dev-tools qtdeclarative5-dev qttools5-dev qttools5-dev-tools
+
+    - name: Setup MSBuild
+      if: inputs.platform == 'windows'
+      uses: microsoft/setup-msbuild@v2
+
+    - name: Build Qt Samples - Windows
+      if: inputs.platform == 'windows'
+      shell: cmd
+      run: |
+        REM Setup environment
+        cd ${{ github.workspace }}/occt-install/
+        call env.bat vc14 win64 Release
+
+        call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" x64
+
+        REM Setup Qt environment
+        set "QTDIR=${{ github.workspace }}\3rdparty-vc14-64\qt5.11.2-vc14-64"
+        set "PATH=%QTDIR%\bin;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE;%PATH%"
+
+        cd ${{ github.workspace }}/samples/qt
+
+        for %%s in (IESample Tutorial FuncDemo) do (
+          cd %%s
+          echo "Generating project for %%s..."
+          qmake -tp vc -r -o %%s.sln %%s0.pro
+
+          echo "Restoring %%s..."
+          msbuild.exe %%s.sln -t:Restore -p:Configuration=Release -p:Platform=x64 /consoleloggerparameters:Verbosity=normal;Summary /flp:LogFile=%%s_restore.log;Verbosity=detailed
+          
+          echo "Building %%s..."
+          msbuild.exe %%s.sln /p:Configuration=Release /p:Platform=x64 /p:PlatformToolset=v143 /consoleloggerparameters:Verbosity=normal;Summary /flp:LogFile=%%s_build.log;Verbosity=detailed /m
+          
+          REM Display logs if build fails
+          if errorlevel 1 (
+            echo "Build failed for %%s. Contents of restore log:"
+            type %%s_restore.log
+            echo "Contents of build log:"
+            type %%s_build.log
+            exit /b 1
+          )
+          
+          cd ..
+        )
+
+    - name: Build Qt Samples - Linux
+      if: inputs.platform == 'linux'
+      shell: bash
+      run: |
+        cd ${{ github.workspace }}/occt-install/bin
+        source env.sh
+        cd ${{ github.workspace }}/samples/qt
+        
+        for sample in IESample Tutorial FuncDemo; do
+          cd $sample
+          aQMakePath=`which qmake`
+          host=`uname -s`
+          export STATION=$host
+          export RES_DIR="${{ github.workspace }}/samples/qt/${sample}/result"
+          qmake $sample.pro
+          aNbJobs="$(getconf _NPROCESSORS_ONLN)"
+          make -j$aNbJobs release
+          cd ..
+        done
+
+    - name: Upload Qt Samples
+      uses: actions/upload-artifact@v4.4.3
+      with:
+        name: qt-samples-${{ inputs.platform }}-x64
+        path: |
+          samples/qt/
+          samples/qt/
+        retention-days: 7
index 367040014358907e3b33929341ca439f19d365a8..da9434e4532c8b9d664cb998213bc936c905dbaa 100644 (file)
@@ -16,9 +16,6 @@ inputs:
 runs:
   using: "composite"
   steps:
-    - name: Checkout repository
-      uses: actions/checkout@v4.1.7
-
     - name: Download OCCT installation
       uses: actions/download-artifact@v4.1.7
       with:
@@ -33,7 +30,6 @@ runs:
           Expand-Archive -Path 3rdparty-vc14-64.zip -DestinationPath .
           Remove-Item 3rdparty-vc14-64.zip
 
-
     - name: Install Linux dependencies
       if: inputs.platform == 'linux'
       shell: bash
index 1b63a2185026ef617201c45ed8c39d2ee67b8037..ab88cc90a935a5b9cdc752dd2b3c5bdecd2b06ed 100644 (file)
@@ -85,6 +85,7 @@ jobs:
                 -D CMAKE_BUILD_TYPE=Release `
                 -D 3RDPARTY_DIR=${{ github.workspace }}/3rdparty-vc14-64 `
                 -D INSTALL_DIR=${{ github.workspace }}/install `
+                -D USE_D3D=ON `
                 -D USE_DRACO=ON `
                 -D USE_FFMPEG=ON `
                 -D USE_FREEIMAGE=ON `
@@ -159,6 +160,7 @@ jobs:
                 -D CMAKE_BUILD_TYPE=Release `
                 -D 3RDPARTY_DIR=${{ github.workspace }}/3rdparty-vc14-64 `
                 -D INSTALL_DIR=${{ github.workspace }}/install `
+                -D USE_D3D=ON `
                 -D USE_DRACO=ON `
                 -D USE_FFMPEG=ON `
                 -D USE_FREEIMAGE=ON `
@@ -430,6 +432,66 @@ jobs:
         platform: linux
         install-artifact-name: install-linux-clang-x64
 
+  build-csharp-windows:
+    name: Build CSharp Sample on Windows
+    needs: prepare-and-build-windows-x64
+    runs-on: windows-2022
+    
+    steps:
+    - name: Checkout repository
+      uses: actions/checkout@v4.1.7
+
+    - name: Build CSharp Sample
+      uses: ./.github/actions/build-sample-csharp
+      with:
+        platform: windows
+        install-artifact-name: install-windows-x64
+
+  build-mfc-windows:
+    name: Build MFC Sample on Windows
+    needs: prepare-and-build-windows-x64
+    runs-on: windows-2022
+    
+    steps:
+    - name: Checkout repository
+      uses: actions/checkout@v4.1.7
+
+    - name: Build MFC Sample
+      uses: ./.github/actions/build-sample-mfc
+      with:
+        platform: windows
+        install-artifact-name: install-windows-x64
+
+  build-qt-windows:
+    name: Build Qt Sample on Windows
+    needs: prepare-and-build-windows-x64
+    runs-on: windows-2022
+    
+    steps:
+    - name: Checkout repository
+      uses: actions/checkout@v4.1.7
+
+    - name: Build Qt Sample
+      uses: ./.github/actions/build-sample-qt
+      with:
+        platform: windows
+        install-artifact-name: install-windows-x64
+
+  build-qt-linux:
+    name: Build Qt Sample on Linux
+    needs: prepare-and-build-linux-clang-x64
+    runs-on: ubuntu-24.04
+    
+    steps:
+    - name: Checkout repository
+      uses: actions/checkout@v4.1.7
+
+    - name: Build Qt Sample
+      uses: ./.github/actions/build-sample-qt
+      with:
+        platform: linux
+        install-artifact-name: install-linux-clang-x64
+
   test-windows-x64:
     name: Test on Windows (x64)
     runs-on: windows-2022
index bcf340164eab5098b1d0381e7f6ddd7e002c1a2e..1fc041f87a069d1786ad1a84d5e3f2286adf6e31 100644 (file)
@@ -23,7 +23,7 @@ if [ "$1" == "@BIN_LETTER@" ]; then
 
     export CSF_OCCTBinPath="@CMAKE_RUNTIME_OUTPUT_DIRECTORY@"
     export CSF_OCCTLibPath="@CMAKE_ARCHIVE_OUTPUT_DIRECTORY@"
-    export CSF_OCCTIncludePath="@CMAKE_BINARY_DIR@/inc"
+    export CSF_OCCTIncludePath="@CMAKE_BINARY_DIR@/@INSTALL_DIR_INCLUDE@"
     export CSF_OCCTResourcePath="@CMAKE_SOURCE_DIR@/src"
     export CSF_OCCTDataPath="@CMAKE_SOURCE_DIR@/data"
     export CSF_OCCTSamplesPath="@CMAKE_SOURCE_DIR@/samples"
index 5eda5a5b354423fea05dbcc890e3354df37c3082..48eec43240930723a2abb94be476ce261482f169 100644 (file)
@@ -1,10 +1,21 @@
 #!/bin/bash
-
+aCurrentPath="$PWD"
 aScriptPath=${BASH_SOURCE%/*}; if [ -d "${aScriptPath}" ]; then cd "$aScriptPath"; fi; aScriptPath="$PWD";
+cd ${aCurrentPath}
 
 # ----- For compatibility with external application using CASROOT -----
 if [ "${CASROOT}" == "" ]; then
-  export CASROOT="${aScriptPath}"
+  # Get the last directory name from the path
+  lastDir=$(basename "$aScriptPath")
+  # Check if last directory is exactly bin, bind, or bini
+  if [ "$lastDir" = "bin" ] || [ "$lastDir" = "bind" ] || [ "$lastDir" = "bini" ]; then
+    # If path contains binary folder, go one level up
+    export CASROOT=$(cd "$aScriptPath/.." && pwd)
+  else
+    # Keep current location
+    export CASROOT="${aScriptPath}"
+  fi
+  cd ${aCurrentPath}
 fi
 
 # ----- Define path to 3rdparty products -----
index 8bb43081bd79eda1280cfb23f3c90c0d6aa5aa7c..215ac4f2190b92525b57059a5c4f4c6b352d7959 100644 (file)
@@ -1,10 +1,21 @@
 #!/bin/bash
-
+aCurrentPath="$PWD"
 aScriptPath=${BASH_SOURCE%/*}; if [ -d "${aScriptPath}" ]; then cd "$aScriptPath"; fi; aScriptPath="$PWD";
+cd ${aCurrentPath}
 
 # ----- For compatibility with external application using CASROOT -----
 if [ "${CASROOT}" == "" ]; then
-  export CASROOT="@INSTALL_DIR@"
+  # Get the last directory name from the path
+  lastDir=$(basename "$aScriptPath")
+  # Check if last directory is exactly bin, bind, or bini
+  if [ "$lastDir" = "bin" ] || [ "$lastDir" = "bind" ] || [ "$lastDir" = "bini" ]; then
+    # If path contains binary folder, go one level up
+    export CASROOT=$(cd "$aScriptPath/.." && pwd)
+  else
+    # Keep current location
+    export CASROOT="${aScriptPath}"
+  fi
+  cd ${aCurrentPath}
 fi
 
 # ----- Define path to 3rdparty products -----
index 6e0ad68f6167851df3c2942b10f1efcd19a3155e..3147a44ac3c231ce4a9b7c2b4171adbe3db466d3 100644 (file)
@@ -3,7 +3,11 @@ CONFIG += debug_and_release qt
 
 TARGET = FuncDemo
 
-SAMPLESROOT = $$quote($$(CSF_OCCTSamplesPath)/qt)
+isEmpty(CSF_OCCTSamplesPath) {
+    SAMPLESROOT = $$PWD/..
+} else {
+    SAMPLESROOT = $$quote($$(CSF_OCCTSamplesPath)/qt)
+}
 
 HEADERS = src/*.h
 SOURCES = src/*.cpp
index 1a0396d112affe31380097db53dba778b12b8977..ed146e47aa8e5451d4ddfc0772b63a6841e4dc45 100755 (executable)
@@ -3,7 +3,11 @@ CONFIG += debug_and_release qt
 
 TARGET = IESample
 
-SAMPLESROOT = $$quote($$(CSF_OCCTSamplesPath)/qt)
+isEmpty(CSF_OCCTSamplesPath) {
+    SAMPLESROOT = $$PWD/..
+} else {
+    SAMPLESROOT = $$quote($$(CSF_OCCTSamplesPath)/qt)
+}
 
 HEADERS   = $${SAMPLESROOT}/Common/src/*.h \
             $${SAMPLESROOT}/Interface/src/*.h
index 79bf0ee3eda1b41a98224bb104f5f25813dc0807..a8d0d1650af5e645f044e3bb969176152df09732 100644 (file)
@@ -9,7 +9,11 @@ greaterThan(QT_MAJOR_VERSION, 4) {
 
 TARGET = OCCTOverview
 
-SAMPLESROOT = $$quote($$(CSF_OCCTSamplesPath)/qt)
+isEmpty(CSF_OCCTSamplesPath) {
+    SAMPLESROOT = $$PWD/..
+} else {
+    SAMPLESROOT = $$quote($$(CSF_OCCTSamplesPath)/qt)
+}
 
 
 HEADERS   = ./src/*.h \
index 336a9b352e6938a26f137cfe65c978e5b85da737..9100db3409b485b8f8f210fd4293f8a4f5bd7cec 100755 (executable)
@@ -3,7 +3,11 @@ CONFIG += debug_and_release qt
 
 TARGET = Tutorial
 
-SAMPLESROOT = $$quote($$(CSF_OCCTSamplesPath)/qt)
+isEmpty(CSF_OCCTSamplesPath) {
+    SAMPLESROOT = $$PWD/..
+} else {
+    SAMPLESROOT = $$quote($$(CSF_OCCTSamplesPath)/qt)
+}
 
 HEADERS   = src/*.h \
             $${SAMPLESROOT}/Common/src/*.h \