diff --git a/.github/actions/build-sample-csharp/action.yml b/.github/actions/build-sample-csharp/action.yml new file mode 100644 index 0000000000..9a96eecc60 --- /dev/null +++ b/.github/actions/build-sample-csharp/action.yml @@ -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 'v100', 'v143' | Set-Content OCCTProxy\OCCTProxy.vcxproj" + powershell -Command "(Get-Content OCCTProxy_D3D\OCCTProxy_D3D.vcxproj) -replace 'v100', 'v143' | 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 index 0000000000..60192fa5bf --- /dev/null +++ b/.github/actions/build-sample-mfc/action.yml @@ -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 index 0000000000..4ee2d8933d --- /dev/null +++ b/.github/actions/build-sample-qt/action.yml @@ -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 diff --git a/.github/actions/build-tinspector/action.yml b/.github/actions/build-tinspector/action.yml index 3670400143..da9434e453 100644 --- a/.github/actions/build-tinspector/action.yml +++ b/.github/actions/build-tinspector/action.yml @@ -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 diff --git a/.github/workflows/build-and-test-multiplatform.yml b/.github/workflows/build-and-test-multiplatform.yml index 1b63a21850..ab88cc90a9 100644 --- a/.github/workflows/build-and-test-multiplatform.yml +++ b/.github/workflows/build-and-test-multiplatform.yml @@ -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 diff --git a/adm/templates/custom.build.sh.in b/adm/templates/custom.build.sh.in index bcf340164e..1fc041f87a 100644 --- a/adm/templates/custom.build.sh.in +++ b/adm/templates/custom.build.sh.in @@ -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" diff --git a/adm/templates/env.build.sh.in b/adm/templates/env.build.sh.in index 5eda5a5b35..48eec43240 100644 --- a/adm/templates/env.build.sh.in +++ b/adm/templates/env.build.sh.in @@ -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 ----- diff --git a/adm/templates/env.install.sh.in b/adm/templates/env.install.sh.in index 8bb43081bd..215ac4f219 100644 --- a/adm/templates/env.install.sh.in +++ b/adm/templates/env.install.sh.in @@ -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 ----- diff --git a/samples/qt/FuncDemo/FuncDemo.pro b/samples/qt/FuncDemo/FuncDemo.pro index 6e0ad68f61..3147a44ac3 100644 --- a/samples/qt/FuncDemo/FuncDemo.pro +++ b/samples/qt/FuncDemo/FuncDemo.pro @@ -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 diff --git a/samples/qt/IESample/IESample.pro b/samples/qt/IESample/IESample.pro index 1a0396d112..ed146e47aa 100755 --- a/samples/qt/IESample/IESample.pro +++ b/samples/qt/IESample/IESample.pro @@ -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 diff --git a/samples/qt/OCCTOverview/OCCTOverview.pro b/samples/qt/OCCTOverview/OCCTOverview.pro index 79bf0ee3ed..a8d0d1650a 100644 --- a/samples/qt/OCCTOverview/OCCTOverview.pro +++ b/samples/qt/OCCTOverview/OCCTOverview.pro @@ -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 \ diff --git a/samples/qt/Tutorial/Tutorial.pro b/samples/qt/Tutorial/Tutorial.pro index 336a9b352e..9100db3409 100755 --- a/samples/qt/Tutorial/Tutorial.pro +++ b/samples/qt/Tutorial/Tutorial.pro @@ -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 \