diff --git a/.github/workflows/build_linux.yml b/.github/workflows/build_linux.yml index 4be4dcea..6a102a23 100644 --- a/.github/workflows/build_linux.yml +++ b/.github/workflows/build_linux.yml @@ -4,6 +4,8 @@ on: [push, pull_request, workflow_dispatch] env: BUILD_TYPE: Release # Change build type here. + VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" + VCPKG_ROOT: '${{ github.workspace }}/vcpkg' jobs: build: @@ -15,33 +17,67 @@ jobs: steps: - uses: actions/checkout@v2 + with: + submodules: recursive + + - name: Export GitHub Actions cache environment variables + uses: actions/github-script@v7 + with: + script: | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); + + # Since VCPKG take a lot of space for Qt install, we run out of free disk space on Ubuntu 20.04 + # This will remove some unused runner image dependencies + - name: Free Disk Space (Ubuntu) + uses: jlumbroso/free-disk-space@main + with: + # this might remove tools that are actually needed, + # if set to "true" but frees about 6 GB + tool-cache: false + + # all of these default to true, but feel free to set to + # "false" if necessary for your workflow + android: true + dotnet: true + haskell: true + large-packages: true + docker-images: true + swap-storage: true + - name: Prepare dependencies + shell: bash + run: | + ./vcpkg/bootstrap-vcpkg.sh -disableMetrics + sudo apt-get install -y '^libxcb.*-dev' libx11-xcb-dev libglu1-mesa-dev libxrender-dev libxi-dev libxkbcommon-dev libxkbcommon-x11-dev libegl1-mesa-dev + sudo apt-get install -y libxi-dev libgl1-mesa-dev libglu1-mesa-dev mesa-common-dev libxrandr-dev libxxf86vm-dev + - name: Install Qt - uses: jurplel/install-qt-action@v3 + uses: jurplel/install-qt-action@v4 with: version: 6.2.4 # Update Qt version here. aqtversion: '>=0.9.7' modules: 'qtimageformats' - - name: Install boost - uses: MarkusJx/install-boost@v2.4.5 - id: install-boost - with: - boost_version: 1.72.0 # Update Boost version here. - - name: Build shell: bash run: | cd build cmake .. cmake --build . --config $BUILD_TYPE --target Degate - env: - BOOST_ROOT: ${{ steps.install-boost.outputs.BOOST_ROOT }} - name: Tests shell: bash run: | cd build + cmake .. -DBUILD_TESTS=1 cmake --build . --config $BUILD_TYPE --target DegateTests cd tests/out/bin ./DegateTests + + - name: Upload vcpkg build logs + if: failure() + uses: actions/upload-artifact@v4 + with: + name: 'vcpkg-buildlogs-${{ matrix.triplet }}' + path: ${{ env.VCPKG_ROOT }}/buildtrees/**/*.log diff --git a/.github/workflows/build_mac.yml b/.github/workflows/build_mac.yml index 3e61e389..980e08e2 100644 --- a/.github/workflows/build_mac.yml +++ b/.github/workflows/build_mac.yml @@ -4,6 +4,8 @@ on: [push, pull_request, workflow_dispatch] env: BUILD_TYPE: Release # Change build type here. + VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" + VCPKG_ROOT: '${{ github.workspace }}/vcpkg' jobs: build: @@ -15,33 +17,50 @@ jobs: steps: - uses: actions/checkout@v2 - + with: + submodules: recursive + + - name: Export GitHub Actions cache environment variables + uses: actions/github-script@v7 + with: + script: | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); + + - name: Prepare dependencies + shell: bash + run: | + ./vcpkg/bootstrap-vcpkg.sh -disableMetrics + brew reinstall autoconf + brew install automake autoconf-archive + - name: Install Qt - uses: jurplel/install-qt-action@v3 + uses: jurplel/install-qt-action@v4 with: version: 6.2.4 # Update Qt version here. aqtversion: '>=0.9.7' modules: 'qtimageformats' - - name: Install boost - uses: MarkusJx/install-boost@v2.4.5 - id: install-boost - with: - boost_version: 1.72.0 # Update Boost version here. - - name: Build shell: bash run: | cd build cmake .. cmake --build . --config $BUILD_TYPE --target Degate - env: - BOOST_ROOT: ${{ steps.install-boost.outputs.BOOST_ROOT }} - name: Tests shell: bash run: | cd build + cmake .. -DBUILD_TESTS=1 cmake --build . --config $BUILD_TYPE --target DegateTests cd tests/out/bin ./DegateTests + + - name: Upload vcpkg build logs + if: failure() + uses: actions/upload-artifact@v4 + with: + name: 'vcpkg-buildlogs-${{ matrix.triplet }}' + path: ${{ env.VCPKG_ROOT }}/buildtrees/**/*.log + diff --git a/.github/workflows/build_windows.yml b/.github/workflows/build_windows.yml index be54625b..92007908 100644 --- a/.github/workflows/build_windows.yml +++ b/.github/workflows/build_windows.yml @@ -4,6 +4,8 @@ on: [push, pull_request, workflow_dispatch] env: BUILD_TYPE: Release # Change build type here. + VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" + VCPKG_ROOT: '${{ github.workspace }}/vcpkg' jobs: build: @@ -11,19 +13,27 @@ jobs: steps: - uses: actions/checkout@v2 + with: + submodules: recursive + - name: Export GitHub Actions cache environment variables + uses: actions/github-script@v7 + with: + script: | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); + - name: Install Qt - uses: jurplel/install-qt-action@v3 + uses: jurplel/install-qt-action@v4 with: version: 6.2.4 # Update Qt version here. aqtversion: '>=0.9.7' modules: 'qtimageformats' - - name: Install boost - uses: MarkusJx/install-boost@v2.4.5 - id: install-boost - with: - boost_version: 1.72.0 # Update Boost version here. + - name: Prepare dependencies + shell: cmd + run: | + .\vcpkg\bootstrap-vcpkg.bat -disableMetrics - name: Build shell: bash @@ -31,14 +41,25 @@ jobs: cd build cmake .. -A x64 cmake --build . --config $BUILD_TYPE --target Degate - env: - BOOST_ROOT: ${{ steps.install-boost.outputs.BOOST_ROOT }} - name: Tests shell: bash run: | cd build + cmake .. -DBUILD_TESTS=1 cmake --build . --config $BUILD_TYPE --target DegateTests + # Windeployqt is sooo broken when using vcpkg... + # ./vcpkg_installed/x64-windows/tools/Qt6/bin/windeployqt.exe ./tests/out/bin/$BUILD_TYPE + # mkdir -p tests/out/bin/$BUILD_TYPE/imageformats + # find . -name vcpkg_installed/x64-windows-degate/Qt6/plugins/imageformats/*.dll -exec cp {} tests/out/bin/$BUILD_TYPE/imageformats/ \; cd tests/out/bin/$BUILD_TYPE - $Qt6_DIR/bin/windeployqt.exe ./ + $QT_ROOT_DIR/bin/windeployqt.exe ./ ./DegateTests.exe + + - name: Upload vcpkg build logs + if: failure() + uses: actions/upload-artifact@v4 + with: + name: 'vcpkg-buildlogs-${{ matrix.triplet }}' + path: ${{ env.VCPKG_ROOT }}/buildtrees/**/*.log + diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 90e2dbc5..1c5126bb 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -2,6 +2,8 @@ name: "CodeQL" env: BUILD_TYPE: Release # Change build type here. + VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" + VCPKG_ROOT: '${{ github.workspace }}/vcpkg' on: push: @@ -25,44 +27,54 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v2 - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v1 with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - # queries: ./path/to/local/query, your-org/your-repo/queries@main + submodules: recursive - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - #- name: Autobuild - # uses: github/codeql-action/autobuild@v1 - - # ℹī¸ Command-line programs to run using the OS shell. - # 📚 https://git.io/JvXDl + - name: Export GitHub Actions cache environment variables + uses: actions/github-script@v7 + with: + script: | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); - # ✏ī¸ If the Autobuild fails above, remove it and uncomment the following three lines - # and modify them (or add more) to build your code if your project - # uses a compiled language + # Since VCPKG take a lot of space for Qt install, we run out of free disk space on Ubuntu 20.04 + # This will remove some unused runner image dependencies + - name: Free Disk Space (Ubuntu) + uses: jlumbroso/free-disk-space@main + with: + # this might remove tools that are actually needed, + # if set to "true" but frees about 6 GB + tool-cache: false + + # all of these default to true, but feel free to set to + # "false" if necessary for your workflow + android: true + dotnet: true + haskell: true + large-packages: true + docker-images: true + swap-storage: true - #- run: | - # make bootstrap - # make release - - name: Install Qt - uses: jurplel/install-qt-action@v2 + uses: jurplel/install-qt-action@v4 with: version: 6.2.4 # Update Qt version here. aqtversion: '>=0.9.7' + modules: 'qtimageformats' - - name: Install Boost + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + with: + languages: ${{ matrix.language }} + + - name: Prepare dependencies shell: bash run: | - sudo apt-get install -y libboost-all-dev - + ./vcpkg/bootstrap-vcpkg.sh -disableMetrics + sudo apt-get install -y '^libxcb.*-dev' libx11-xcb-dev libglu1-mesa-dev libxrender-dev libxi-dev libxkbcommon-dev libxkbcommon-x11-dev libegl1-mesa-dev + sudo apt-get install -y libxi-dev libgl1-mesa-dev libglu1-mesa-dev mesa-common-dev libxrandr-dev libxxf86vm-dev + - name: Build shell: bash run: | @@ -71,4 +83,4 @@ jobs: cmake --build . --config $BUILD_TYPE - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 + uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/deploy_linux.yml b/.github/workflows/deploy_linux.yml index 5e815cd8..76ddb326 100644 --- a/.github/workflows/deploy_linux.yml +++ b/.github/workflows/deploy_linux.yml @@ -4,6 +4,8 @@ on: [workflow_dispatch] env: BUILD_TYPE: Release # Change build type here. + VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" + VCPKG_ROOT: '${{ github.workspace }}/vcpkg' jobs: build: @@ -12,6 +14,40 @@ jobs: steps: - uses: actions/checkout@v2 + with: + submodules: recursive + + - name: Export GitHub Actions cache environment variables + uses: actions/github-script@v7 + with: + script: | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); + + # Since VCPKG take a lot of space for Qt install, we run out of free disk space on Ubuntu 20.04 + # This will remove some unused runner image dependencies + - name: Free Disk Space (Ubuntu) + uses: jlumbroso/free-disk-space@main + with: + # this might remove tools that are actually needed, + # if set to "true" but frees about 6 GB + tool-cache: false + + # all of these default to true, but feel free to set to + # "false" if necessary for your workflow + android: true + dotnet: true + haskell: true + large-packages: true + docker-images: true + swap-storage: true + + - name: Prepare dependencies + shell: bash + run: | + ./vcpkg/bootstrap-vcpkg.sh -disableMetrics + sudo apt-get install -y '^libxcb.*-dev' libx11-xcb-dev libglu1-mesa-dev libxrender-dev libxi-dev libxkbcommon-dev libxkbcommon-x11-dev libegl1-mesa-dev + sudo apt-get install -y libxi-dev libgl1-mesa-dev libglu1-mesa-dev mesa-common-dev libxrandr-dev libxxf86vm-dev - name: Install Qt uses: jurplel/install-qt-action@v4 @@ -21,20 +57,12 @@ jobs: modules: 'qtimageformats' tools: 'tools_ifw' - - name: Install boost - uses: MarkusJx/install-boost@v2.4.5 - id: install-boost - with: - boost_version: 1.72.0 # Update Boost version here. - - name: Build shell: bash run: | cd build cmake .. cmake --build . --config $BUILD_TYPE --target Degate - env: - BOOST_ROOT: ${{ steps.install-boost.outputs.BOOST_ROOT }} - name: Prepare Degate AppImage shell: bash @@ -103,3 +131,10 @@ jobs: with: name: Degate_update_Linux_x64 path: etc/installer/repository + + - name: Upload vcpkg build logs + if: failure() + uses: actions/upload-artifact@v4 + with: + name: 'vcpkg-buildlogs-${{ matrix.triplet }}' + path: ${{ env.VCPKG_ROOT }}/buildtrees/**/*.log diff --git a/.github/workflows/deploy_mac.yml b/.github/workflows/deploy_mac.yml index 13903875..7fa0bbcd 100644 --- a/.github/workflows/deploy_mac.yml +++ b/.github/workflows/deploy_mac.yml @@ -4,6 +4,8 @@ on: [workflow_dispatch] env: BUILD_TYPE: Release # Change build type here. + VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" + VCPKG_ROOT: '${{ github.workspace }}/vcpkg' jobs: build: @@ -12,6 +14,22 @@ jobs: steps: - uses: actions/checkout@v2 + with: + submodules: recursive + + - name: Export GitHub Actions cache environment variables + uses: actions/github-script@v7 + with: + script: | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); + + - name: Prepare dependencies + shell: bash + run: | + ./vcpkg/bootstrap-vcpkg.sh -disableMetrics + brew reinstall autoconf + brew install automake autoconf-archive - name: Install Qt uses: jurplel/install-qt-action@v4 @@ -22,20 +40,12 @@ jobs: tools: 'tools_ifw' add-tools-to-path: 'true' - - name: Install boost - uses: MarkusJx/install-boost@v2.4.5 - id: install-boost - with: - boost_version: 1.72.0 # Update Boost version here. - - name: Build shell: bash run: | cd build cmake .. cmake --build . --config $BUILD_TYPE --target Degate - env: - BOOST_ROOT: ${{ steps.install-boost.outputs.BOOST_ROOT }} - name: Prepare binaries shell: bash @@ -81,3 +91,10 @@ jobs: with: name: Degate_update_Mac_x64 path: etc/installer/repository + + - name: Upload vcpkg build logs + if: failure() + uses: actions/upload-artifact@v4 + with: + name: 'vcpkg-buildlogs-${{ matrix.triplet }}' + path: ${{ env.VCPKG_ROOT }}/buildtrees/**/*.log diff --git a/.github/workflows/deploy_windows.yml b/.github/workflows/deploy_windows.yml index 4fe67501..ada64ea8 100644 --- a/.github/workflows/deploy_windows.yml +++ b/.github/workflows/deploy_windows.yml @@ -4,6 +4,8 @@ on: [workflow_dispatch] env: BUILD_TYPE: Release # Change build type here. + VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" + VCPKG_ROOT: '${{ github.workspace }}/vcpkg' jobs: build: @@ -11,7 +13,16 @@ jobs: steps: - uses: actions/checkout@v2 - + with: + submodules: recursive + + - name: Export GitHub Actions cache environment variables + uses: actions/github-script@v7 + with: + script: | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); + - name: Install Qt uses: jurplel/install-qt-action@v4 with: @@ -20,11 +31,10 @@ jobs: modules: 'qtimageformats' tools: 'tools_ifw' - - name: Install boost - uses: MarkusJx/install-boost@v2.4.5 - id: install-boost - with: - boost_version: 1.72.0 # Update Boost version here. + - name: Prepare dependencies + shell: cmd + run: | + .\vcpkg\bootstrap-vcpkg.bat -disableMetrics - name: Build shell: bash @@ -32,8 +42,6 @@ jobs: cd build cmake .. -A x64 cmake --build . --config $BUILD_TYPE --target Degate - env: - BOOST_ROOT: ${{ steps.install-boost.outputs.BOOST_ROOT }} - name: Prepare binaries shell: bash @@ -87,3 +95,10 @@ jobs: with: name: Degate_update_Windows_x64 path: etc/installer/repository + + - name: Upload vcpkg build logs + if: failure() + uses: actions/upload-artifact@v4 + with: + name: 'vcpkg-buildlogs-${{ matrix.triplet }}' + path: ${{ env.VCPKG_ROOT }}/buildtrees/**/*.log diff --git a/.gitignore b/.gitignore index 87ba8835..f324b922 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,6 @@ doc/config/DoxyFile build.sh run.sh +release.sh +test.sh +doc.sh diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..abd44ec0 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "vcpkg"] + path = vcpkg + url = https://github.com/microsoft/vcpkg/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 8b3d48c0..21001fb1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,50 @@ ##################################################################### cmake_minimum_required(VERSION 3.12.0) + +# +# Custom triplets used by Degate (e.g. this allow mixing dynamic/static linking for dependencies) +# +set(VCPKG_OVERLAY_TRIPLETS "${CMAKE_CURRENT_SOURCE_DIR}/etc/vcpkg-triplets") + +# +# Use specific triplet for windows, that'll use static build for everything except qt +# +if (WIN32) + set(VCPKG_DEFAULT_TRIPLET "x64-windows-degate") + set(VCPKG_TARGET_TRIPLET "x64-windows-degate" CACHE STRING "target triplet" FORCE) +endif() + +# +# Use vcpkg +# +set(VCPKG_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/vcpkg) +set(CMAKE_TOOLCHAIN_FILE ${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake) + +# +# Configure tests +# +option(BUILD_TESTS "Build tests" OFF) +if(BUILD_TESTS) + list(APPEND VCPKG_MANIFEST_FEATURES "tests") +endif() + +# +# Configure vcpkg-qt +# +option(VCPKG_QT "Use vcpkg's Qt dependency. WARNING: this will not provide OpenGL software renderer fallback for Windows (mesa llvmpipe)" OFF) +if(VCPKG_QT) + message(STATUS "Using vcpkg's Qt dependency") + list(APPEND VCPKG_MANIFEST_FEATURES "vcpkg-qt") +endif() + +# +# Tell vcpkg to export dll to build folder (windows only) +# +if (WIN32) + set(X_VCPKG_APPLOCAL_DEPS_INSTALL ON) +endif() + project(Degate) # @@ -98,10 +142,13 @@ message(STATUS "Boost multithreaded libs: ${Boost_USE_MULTITHREADED}") find_package(Boost COMPONENTS filesystem system thread REQUIRED) include_directories(${Boost_INCLUDE_DIRS}) set(LIBS ${Boost_LIBRARIES}) +message(STATUS "Boost installation dir: ${Boost_DIR}") ############# Qt -find_package(Qt6 COMPONENTS Core Widgets Gui Xml OpenGL OpenGLWidgets Concurrent LinguistTools REQUIRED) +find_package(Qt6 COMPONENTS Core Widgets Gui Xml OpenGL OpenGLWidgets Concurrent LinguistTools CONFIG REQUIRED) set(LIBS ${LIBS} Qt6::Widgets Qt6::Gui Qt6::Core Qt6::Xml Qt6::OpenGL Qt6::OpenGLWidgets Qt6::Concurrent) +# qt_standard_project_setup() +message(STATUS "Qt installation dir: ${Qt6_DIR}") ############################################################################ @@ -204,14 +251,14 @@ endif () # # Link DegateCore # -add_library(DegateCore STATIC ${SRC_FILES} res/resources.qrc res/qdarkstyle/style.qrc ${CMAKE_BINARY_DIR}/translations.qrc ${TRANSLATION_FILES} ${QM_FILES} "Degate version") -target_link_libraries(DegateCore ${LIBS}) +qt_add_library(DegateCore STATIC ${SRC_FILES} res/resources.qrc res/qdarkstyle/style.qrc ${CMAKE_BINARY_DIR}/translations.qrc ${TRANSLATION_FILES} ${QM_FILES} "Degate version") +target_link_libraries(DegateCore PRIVATE ${LIBS}) # # Link main (Degate) # -add_executable(Degate "src/Main.cc" res/resources.qrc res/qdarkstyle/style.qrc ${CMAKE_BINARY_DIR}/translations.qrc ${TRANSLATION_FILES} ${QM_FILES} "res/resource.rc") -target_link_libraries(Degate ${LIBS} DegateCore) +qt_add_executable(Degate "src/Main.cc" res/resources.qrc res/qdarkstyle/style.qrc ${CMAKE_BINARY_DIR}/translations.qrc ${TRANSLATION_FILES} ${QM_FILES} "res/resource.rc") +target_link_libraries(Degate PRIVATE ${LIBS} DegateCore) # # Activate bundle for MacOS. @@ -223,6 +270,16 @@ set_target_properties(Degate PROPERTIES MACOSX_BUNDLE TRUE) # install (TARGETS Degate DESTINATION out/bin) +# +# Automatic Qt deploy (doesn't deploy everything...) +# +# qt_generate_deploy_app_script( +# TARGET Degate +# OUTPUT_SCRIPT deploy_script +# NO_UNSUPPORTED_PLATFORM_ERROR +# ) +# install(SCRIPT ${deploy_script}) + # # Output specifications # @@ -251,23 +308,31 @@ endif() # # Tests # -add_subdirectory(tests) +include(CTest) +if(BUILD_TESTS) + enable_testing() + add_subdirectory(tests) +endif() ############################################################################ ################################ Doc ####################################### ############################################################################ -find_package(Doxygen QUIET) -if(DOXYGEN_FOUND) - message(STATUS "Doxygen found") - - add_custom_target(Documentation ALL - COMMAND ${DOXYGEN_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/doc/config/DoxyFile" - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMENT "Generating documentation with Doxygen." - SOURCES "Degate version") - -else() - message(STATUS "Doxygen not found") +option(BUILD_DOCS "Build docs" OFF) +if(BUILD_DOCS) + find_package(Doxygen QUIET) + if(DOXYGEN_FOUND) + message(STATUS "Doxygen found") + + add_custom_target(Documentation ALL + COMMAND ${DOXYGEN_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/doc/config/DoxyFile" + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMENT "Generating documentation with Doxygen." + SOURCES "Degate version") + + else() + message(STATUS "Doxygen not found") + endif() endif() + diff --git a/README.md b/README.md index 574fb574..f8dcc9b5 100644 --- a/README.md +++ b/README.md @@ -126,69 +126,99 @@ Also, you can find [here](https://github.com/DegateCommunity/Degate/wiki) the of ## Dependencies -Degate has only 2 dependencies: Boost and Qt5. +Degate has only 2 dependencies: Boost and Qt6. -For Boost, you can specify to CMake a custom path with: -DBOOST_ROOT="custom_path_to_boost". Prebuilt versions for Windows are available here: https://sourceforge.net/projects/boost/files/boost-binaries/. +We use [vcpkg](https://vcpkg.io) to handle installation of those, please refer to the #Quick-start section below. -For Qt5, you can specify to CMake a custom path with: -DCMAKE_PREFIX_PATH="custom_path_to_qt". For example, on Windows: Qt/VERSION/COMPILER/lib/cmake/Qt5. You can download Qt5 here: https://www.qt.io/download. +## Dependencies list -For Linux, don't forget to install the Qt5 add-on module: ImageFormats (you just need to have the package installed, it will be embedded in the Qt5::Core module after). See https://doc.qt.io/qt-5/qtimageformats-index.html. For example, on debian, the package is: qt5-image-formats-plugins. Same problem with linguist tools, for example for debian you need the package: qttools5-dev. +- CMake 3.12.0 or newer, +- *(optional)* Qt 6.2.4 or newer, -## Dependencies version +For Linux (please read the Linux section below, some dependencies are **only needed if using VCPKG's Qt**): +- xcb-lib +- xrender-lib +- autoconf +- autoconf-archive +- xkbcommon +- egl1-mesa-lib +- xrandr-lib -- CMake 3.12.0 or newer, -- Boost 1.70.0 or newer, -- Qt 5.14.0 or newer. +For MacOS (please read the MacOS section below): +- automake +- autoconf +- autoconf-archive + +If you are using a local Qt6 installation: + +- For Qt6, you can specify to CMake a custom path with: -DCMAKE_PREFIX_PATH="custom_path_to_qt". For example, on Windows: Qt/VERSION/COMPILER/lib/cmake/Qt6. You can download Qt6 here: https://www.qt.io/download. +- For Linux, don't forget to install the Qt6 add-on module: ImageFormats (you just need to have the package installed, it will be embedded in the Qt6::Core module after). See https://doc.qt.io/qt-6/qtimageformats-index.html. For example, on debian, the package is: qt6-image-formats-plugins. Same problem with linguist tools, for example for debian you need the package: qttools6-dev. ## Quick start -Firstly, clone this repository (help [here](https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/cloning-a-repository)). +First, clone this repository (help [here](https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/cloning-a-repository)): +```console +> git clone https://github.com/DegateCommunity/Degate +> git submodule update --init --recursive +``` ### For Linux (debian-like) -Install dependencies: +Prepare the install of dependencies (some of them are **only needed if using VCPKG's Qt**): ```console -> sudo apt-get install cmake g++ qt5-default qt5-image-formats-plugins qttools5-dev libboost-all-dev +> ./vcpkg/bootstrap-vcpkg.sh -disableMetrics +> apt install '^libxcb.*-dev' libx11-xcb-dev libglu1-mesa-dev libxrender-dev libxi-dev libxkbcommon-dev + libxkbcommon-x11-dev libegl1-mesa-dev libglu1-mesa-dev mesa-common-dev libxrandr-dev libxxf86vm-dev + autoconf autoconf-archive ``` +If anything is missing, you should be prompted with help on how to install the needed tools. + Build (in the 'build' folder, for example): ```console -> cmake .. +> cmake .. -DVCPKG_QT=1 > make ``` Binaries are in the 'build/out/bin' folder. +If you prefer to use your local Qt installation (and to avoid rebuilding Qt through VCPKG) please use the `-DVCPKG_QT=0` option. + ### For Windows Install dependencies: - CMake: https://cmake.org/download/ - A compiler (for example MSVC): https://visualstudio.microsoft.com/ -- Qt: https://www.qt.io/download-qt-installer -- Boost: https://sourceforge.net/projects/boost/files/boost-binaries/ +```console +> .\vcpkg\bootstrap-vcpkg.bat -disableMetrics +``` Build (in the 'build' folder, for example): ```console -> cmake .. -DBOOST_ROOT="path_to_boost" -DCMAKE_PREFIX_PATH="path_to_qt" +> cmake .. -DVCPKG_QT=1 > cmake --build . ``` + Binaries are in the 'build/out/bin' folder. -### For MacOS +If you prefer to use your local Qt installation (and to avoid rebuilding Qt through VCPKG) please use the `-DVCPKG_QT=0` option and specify Qt6's path with `-DCMAKE_PREFIX_PATH="path_to_qt"`. -Install dependencies (we will use [Homebrew](https://brew.sh) here) : -- XCode: https://apps.apple.com/app/xcode/id497799835 +### For MacOS +Prepare the install of dependencies: ```console -> brew install boost -> brew install qt +> ./vcpkg/bootstrap-vcpkg.sh -disableMetrics +> brew install autoconf autoconf-archive automake ``` Build (in the 'build' folder, for example): ```console -> cmake .. +> cmake .. -DVCPKG_QT=1 > cmake --build . ``` + Binaries are in the 'build/out/bin' folder in the bundle ".app" format. +If you prefer to use your local Qt installation (and to avoid rebuilding Qt through VCPKG) please use the `-DVCPKG_QT=0` option. + ## Troubleshooting - `Could NOT find Boost (missing: filesystem system thread) (found version "1.71.0")` @@ -207,6 +237,14 @@ Binaries are in the 'build/out/bin' folder in the bundle ".app" format. This message can appear for MacOS users. The problem comes from spaces in directory names, this is a bug from CMake. Simply move your Degate folder to a file tree without spaces in directory names. +- `CMake Error at vcpkg_execute_required_process.cmake:127 (message): Command failed: vcpkg/downloads/tools/ninja/1.10.2-linux/ninja -v` + + Please refer to vcpkg output, this is linked to Qt installation that need pre-installed dependencies on some platforms. For example on linux you need to execute: + `sudo apt-get install '^libxcb.*-dev' + libx11-xcb-dev libglu1-mesa-dev libxrender-dev libxi-dev libxkbcommon-dev + libxkbcommon-x11-dev libegl1-mesa-dev` and `sudo apt-get install libxi-dev libgl1-mesa-dev libglu1-mesa-dev mesa-common-dev libxrandr-dev libxxf86vm-dev +`. + # Demo projects You can find demo projects [here](https://github.com/DegateCommunity/DegateDemoProjects). diff --git a/VERSION b/VERSION index 5edee128..b7bfea62 100644 --- a/VERSION +++ b/VERSION @@ -1,9 +1,9 @@ ############################ # Version ############################ -2.1.0-beta.2 +2.1.0-beta.3 ############################ # Release date ('unreleased' or 'YYYY-MM-DD') ############################ -2024-08-20 +unreleased diff --git a/etc/vcpkg-triplets/x64-windows-degate.cmake b/etc/vcpkg-triplets/x64-windows-degate.cmake new file mode 100644 index 00000000..79119fd3 --- /dev/null +++ b/etc/vcpkg-triplets/x64-windows-degate.cmake @@ -0,0 +1,7 @@ +set(VCPKG_TARGET_ARCHITECTURE x64) + +set(VCPKG_LIBRARY_LINKAGE static) +set(VCPKG_CRT_LINKAGE dynamic) +if(PORT MATCHES "qt") + set(VCPKG_LIBRARY_LINKAGE dynamic) +endif() diff --git a/src/Core/Utils/CrashReport.cc b/src/Core/Utils/CrashReport.cc index 911329b4..d8ba59c4 100644 --- a/src/Core/Utils/CrashReport.cc +++ b/src/Core/Utils/CrashReport.cc @@ -19,9 +19,8 @@ */ -#include "CrashReport.h" - #include "Core/Version.h" +#include "CrashReport.h" #include "Globals.h" #include @@ -59,7 +58,8 @@ namespace degate // Report button report_button.setText(tr("Report")); QObject::connect(&report_button, &QPushButton::clicked, this, [=]() { - QDesktopServices::openUrl(QUrl("https://github.com/DegateCommunity/Degate/issues/new?template=bug_report.md")); + QDesktopServices::openUrl( + QUrl("https://github.com/DegateCommunity/Degate/issues/new?template=bug_report.md")); }); buttons_layout.addWidget(&report_button); @@ -108,7 +108,8 @@ namespace degate .arg(QString::fromStdString(error)); std::ofstream log_file; - log_file.open(DEGATE_IN_CONFIGURATION(ERROR_FILE_NAME), std::fstream::in | std::fstream::out | std::fstream::app); + log_file.open(DEGATE_IN_CONFIGURATION(ERROR_FILE_NAME), + std::fstream::in | std::fstream::out | std::fstream::app); if (!log_file.is_open()) return; @@ -118,6 +119,8 @@ namespace degate log_file.close(); degate::create_error_dialog(message.toStdString()); + + exit(EXIT_FAILURE); } void create_error_dialog(const std::string& error) diff --git a/src/Core/Utils/FileSystem.cc b/src/Core/Utils/FileSystem.cc index a4b444c3..23344230 100644 --- a/src/Core/Utils/FileSystem.cc +++ b/src/Core/Utils/FileSystem.cc @@ -19,14 +19,12 @@ * */ -#include "Core/Utils/FileSystem.h" #include "Core/Configuration.h" +#include "Core/Utils/FileSystem.h" -#include +#include #include - -#include -#include +#include #include using namespace degate; @@ -92,7 +90,8 @@ std::string degate::get_basedir(std::string const& path) { resolved_path = get_realpath(path); - if (is_directory(resolved_path)) return resolved_path; + if (is_directory(resolved_path)) + return resolved_path; else { boost::filesystem::path p(path); @@ -119,7 +118,8 @@ std::string degate::get_file_suffix(std::string const& path) { return path.substr(last_occurance + 1, path.size() - last_occurance); } - else return std::string(); + else + return std::string(); } bool degate::remove_file(std::string const& path) @@ -147,7 +147,9 @@ void degate::remove_directory(std::string const& path) } } -void degate::clear_directory(std::string const& path, std::vector const& exclusion_list, std::string const& base_directory_path) +void degate::clear_directory(std::string const& path, + std::vector const& exclusion_list, + std::string const& base_directory_path) { if (path.empty()) return; @@ -158,7 +160,7 @@ void degate::clear_directory(std::string const& path, std::vector c base_directory = path; boost::filesystem::directory_iterator end_itr; - for(boost::filesystem::directory_iterator it(path); it != end_itr; it++) + for (boost::filesystem::directory_iterator it(path); it != end_itr; it++) { // If no exclusion list if (exclusion_list.empty()) @@ -179,11 +181,14 @@ void degate::clear_directory(std::string const& path, std::vector c { try { - if (boost::filesystem::equivalent(boost::filesystem::path(element), boost::filesystem::path(excluded_element)) || stripped_element == excluded_element) + if (boost::filesystem::equivalent(boost::filesystem::path(element), + boost::filesystem::path(excluded_element)) || + stripped_element == excluded_element) skip = true; } catch (const std::exception&) - {} + { + } } // If in exclusion list, skip the element clear @@ -230,7 +235,8 @@ std::string degate::get_temp_directory_path() std::string degate::generate_temp_file_pattern() { - boost::filesystem::path p(boost::filesystem::temp_directory_path() / boost::filesystem::path("degate_temp.%%%%%%%%")); + boost::filesystem::path p(boost::filesystem::temp_directory_path() / + boost::filesystem::path("degate_temp.%%%%%%%%")); return p.make_preferred().string(); } @@ -273,11 +279,11 @@ std::string degate::get_basename(std::string const& path) size_t last_occurance = filename.rfind(".", filename.size()); if (last_occurance < filename.size()) return filename.substr(0, last_occurance); - else return filename; + else + return filename; } -boost::filesystem::path -naive_uncomplete(boost::filesystem::path const p, boost::filesystem::path const base) +boost::filesystem::path naive_uncomplete(boost::filesystem::path const p, boost::filesystem::path const base) { using boost::filesystem::path; @@ -309,7 +315,7 @@ naive_uncomplete(boost::filesystem::path const p, boost::filesystem::path const #endif // Cache system-dependent dot, double-dot and slash strings - const std::string dot = "."; + const std::string dot = "."; const std::string dots = ".."; #ifdef WIN32 const std::string sep = "/"; @@ -363,8 +369,7 @@ naive_uncomplete(boost::filesystem::path const p, boost::filesystem::path const } -std::string degate::get_relative_path(std::string const& path, - std::string const& relative_to) +std::string degate::get_relative_path(std::string const& path, std::string const& relative_to) { return naive_uncomplete(path, relative_to).make_preferred().string(); } diff --git a/src/GUI/Workspace/WorkspaceRenderer.cc b/src/GUI/Workspace/WorkspaceRenderer.cc index 89cc8a8a..0735f104 100644 --- a/src/GUI/Workspace/WorkspaceRenderer.cc +++ b/src/GUI/Workspace/WorkspaceRenderer.cc @@ -19,67 +19,71 @@ * */ -#include "GUI/Workspace/WorkspaceRenderer.h" -#include "GUI/Dialog/GateEditDialog.h" +#include "Core/Utils/CrashReport.h" +#include "Core/Utils/DegateExceptions.h" #include "GUI/Dialog/AnnotationEditDialog.h" +#include "GUI/Dialog/GateEditDialog.h" #include "GUI/Preferences/PreferencesHandler.h" #include "GUI/Workspace/WorkspaceNotifier.h" +#include "GUI/Workspace/WorkspaceRenderer.h" +#include "Globals.h" namespace degate { - WorkspaceRenderer::WorkspaceRenderer(QWidget* parent) - : QOpenGLWidget(parent), - background(this), - gates(this), - annotations(this), - emarkers(this), - vias(this), - wires(this), - selection_tool(this), - wire_tool(this), - regular_grid(this) + WorkspaceRenderer::WorkspaceRenderer(QWidget* parent) + : QOpenGLWidget(parent), + background(this), + gates(this), + annotations(this), + emarkers(this), + vias(this), + wires(this), + selection_tool(this), + wire_tool(this), + regular_grid(this) { - setFocusPolicy(Qt::StrongFocus); - setCursor(Qt::CrossCursor); - setMouseTracking(true); + setFocusPolicy(Qt::StrongFocus); + setCursor(Qt::CrossCursor); + setMouseTracking(true); - selected_objects.set_object_update_function(std::bind(&WorkspaceRenderer::update_object, this, std::placeholders::_1)); - } + selected_objects.set_object_update_function( + std::bind(&WorkspaceRenderer::update_object, this, std::placeholders::_1)); + } - WorkspaceRenderer::~WorkspaceRenderer() - { + WorkspaceRenderer::~WorkspaceRenderer() + { // Prevent cleanup if OpenGL functions wheren't initialized if (!initialized) return; - makeCurrent(); + makeCurrent(); this->cleanup(); - doneCurrent(); + doneCurrent(); - auto updated_preferences = PREFERENCES_HANDLER.get_preferences(); + auto updated_preferences = PREFERENCES_HANDLER.get_preferences(); updated_preferences.show_grid = draw_grid; PREFERENCES_HANDLER.update(updated_preferences); - } + } - void WorkspaceRenderer::update_screen() - { - makeCurrent(); + void WorkspaceRenderer::update_screen() + { + makeCurrent(); - if (project == nullptr) - return; + if (project == nullptr) + return; background.update(); - gates.update(); - annotations.update(); + gates.update(); + annotations.update(); emarkers.update(); vias.update(); wires.update(); - update(); - } + update(); + } void WorkspaceRenderer::update_objects() { @@ -211,17 +215,17 @@ namespace degate update(); } - void WorkspaceRenderer::set_project(const Project_shptr& new_project) - { - reset_area_selection(); - reset_selection(); - reset_wire_tool(); + void WorkspaceRenderer::set_project(const Project_shptr& new_project) + { + reset_area_selection(); + reset_selection(); + reset_wire_tool(); - project = new_project; + project = new_project; - background.set_project(new_project); - gates.set_project(new_project); - annotations.set_project(new_project); + background.set_project(new_project); + gates.set_project(new_project); + annotations.set_project(new_project); emarkers.set_project(new_project); vias.set_project(new_project); wires.set_project(new_project); @@ -258,48 +262,48 @@ namespace degate // Otherwise, just center the view center_view(QPointF{width() / 2.0, height() / 2.0}); } - + update_screen(); - } + } - bool WorkspaceRenderer::has_area_selection() - { - return selection_tool.has_selection(); - } + bool WorkspaceRenderer::has_area_selection() + { + return selection_tool.has_selection(); + } - BoundingBox WorkspaceRenderer::get_area_selection() - { - return selection_tool.get_selection_box(); - } + BoundingBox WorkspaceRenderer::get_area_selection() + { + return selection_tool.get_selection_box(); + } BoundingBox WorkspaceRenderer::get_safe_area_selection() { - return get_safe_bounding_box(get_area_selection()); + return get_safe_bounding_box(get_area_selection()); } ObjectSet& WorkspaceRenderer::get_selected_objects() - { - return selected_objects; - } + { + return selected_objects; + } void WorkspaceRenderer::add_object_to_selection(PlacedLogicModelObject_shptr& object) { selected_objects.add(object, project->get_logic_model()); } - void WorkspaceRenderer::reset_area_selection() - { + void WorkspaceRenderer::reset_area_selection() + { selection_tool.set_selection_state(false); - update(); - } + update(); + } - void WorkspaceRenderer::reset_selection() - { - if (selected_objects.empty()) - return; + void WorkspaceRenderer::reset_selection() + { + if (selected_objects.empty()) + return; selected_objects.clear(); - } + } void WorkspaceRenderer::reset_wire_tool() { @@ -321,63 +325,63 @@ namespace degate void WorkspaceRenderer::use_wire_tool() { - reset_area_selection(); - reset_selection(); + reset_area_selection(); + reset_selection(); current_tool = WorkspaceTool::WIRE; update(); } - bool WorkspaceRenderer::has_selection() - { - if (selected_objects.empty()) - return false; - else - return true; - } + bool WorkspaceRenderer::has_selection() + { + if (selected_objects.empty()) + return false; + else + return true; + } - void WorkspaceRenderer::show_gates(bool value) - { - draw_gates = value; + void WorkspaceRenderer::show_gates(bool value) + { + draw_gates = value; - update(); - } + update(); + } - void WorkspaceRenderer::show_gates_name(bool value) - { - draw_gates_name = value; + void WorkspaceRenderer::show_gates_name(bool value) + { + draw_gates_name = value; - update(); - } + update(); + } - void WorkspaceRenderer::show_ports(bool value) - { - draw_ports = value; + void WorkspaceRenderer::show_ports(bool value) + { + draw_ports = value; - update(); - } + update(); + } - void WorkspaceRenderer::show_ports_name(bool value) - { - draw_ports_name = value; + void WorkspaceRenderer::show_ports_name(bool value) + { + draw_ports_name = value; - update(); - } + update(); + } - void WorkspaceRenderer::show_annotations(bool value) - { - draw_annotations = value; + void WorkspaceRenderer::show_annotations(bool value) + { + draw_annotations = value; - update(); - } + update(); + } - void WorkspaceRenderer::show_annotations_name(bool value) - { - draw_annotations_name = value; + void WorkspaceRenderer::show_annotations_name(bool value) + { + draw_annotations_name = value; - update(); - } + update(); + } void WorkspaceRenderer::show_emarkers(bool value) { @@ -436,10 +440,10 @@ namespace degate } } - void WorkspaceRenderer::free_textures() - { - background.free_textures(); - } + void WorkspaceRenderer::free_textures() + { + background.free_textures(); + } void WorkspaceRenderer::cleanup() { @@ -451,77 +455,77 @@ namespace degate Text::delete_context(); } - void WorkspaceRenderer::initializeGL() - { - makeCurrent(); + void WorkspaceRenderer::initializeGL() + { + makeCurrent(); - initializeOpenGLFunctions(); + initializeOpenGLFunctions(); initialized = true; - Text::init_context(); + Text::init_context(); //QColor color = QApplication::palette().color(QWidget::backgroundRole()); //glClearColor(color.red() / 255.0, color.green() / 255.0, color.blue() / 255.0, 1.0); - glClearColor(0.0, 0.0, 0.0, 1.0); - glEnable(GL_BLEND); + glClearColor(0.0, 0.0, 0.0, 1.0); + glEnable(GL_BLEND); glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ZERO, GL_ONE); glDisable(GL_LINE_SMOOTH); - background.init(); - gates.init(); - annotations.init(); + background.init(); + gates.init(); + annotations.init(); emarkers.init(); vias.init(); - selection_tool.init(); - wires.init(); + selection_tool.init(); + wires.init(); wire_tool.init(); regular_grid.init(); // Get and print OpenGL version - QOpenGLContext *ctx = QOpenGLContext::currentContext(); + QOpenGLContext* ctx = QOpenGLContext::currentContext(); QSurfaceFormat sf = ctx->format(); debug(TM, "OpenGL version: %d.%d.%d", sf.majorVersion(), sf.minorVersion(), sf.profile()); // Get and print GLSL version - QOpenGLFunctions *glFuncs = QOpenGLContext::currentContext()->functions(); + QOpenGLFunctions* glFuncs = QOpenGLContext::currentContext()->functions(); debug(TM, "GLSL version: %s", glFuncs->glGetString(GL_SHADING_LANGUAGE_VERSION)); // Define the draw notification for the workspace (renderer), just a repaint - WorkspaceNotifier::get_instance().define(WorkspaceTarget::Workspace, WorkspaceNotification::Draw, [=](){ + WorkspaceNotifier::get_instance().define(WorkspaceTarget::Workspace, WorkspaceNotification::Draw, [=]() { this->repaint(); }); - } + } - void WorkspaceRenderer::paintGL() - { - makeCurrent(); + void WorkspaceRenderer::paintGL() + { + makeCurrent(); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - background.draw(projection); + background.draw(projection); - if (draw_wires) - wires.draw(projection); + if (draw_wires) + wires.draw(projection); - if (draw_annotations) - annotations.draw(projection); + if (draw_annotations) + annotations.draw(projection); - if (draw_annotations_name) - annotations.draw_name(projection); + if (draw_annotations_name) + annotations.draw_name(projection); - if (draw_gates) - gates.draw(projection); + if (draw_gates) + gates.draw(projection); - if (draw_gates_name) - gates.draw_gates_name(projection); + if (draw_gates_name) + gates.draw_gates_name(projection); - if (draw_ports) - gates.draw_ports(projection); + if (draw_ports) + gates.draw_ports(projection); - if (draw_ports_name) - gates.draw_ports_name(projection); + if (draw_ports_name) + gates.draw_ports_name(projection); if (draw_emarkers) emarkers.draw(projection); @@ -536,45 +540,45 @@ namespace degate vias.draw_name(projection); if (current_tool == WorkspaceTool::AREA_SELECTION) - selection_tool.draw(projection); + selection_tool.draw(projection); if (current_tool == WorkspaceTool::WIRE) wire_tool.draw(projection); if (draw_grid) regular_grid.draw(projection); - } + } - void WorkspaceRenderer::resizeGL(int w, int h) - { - makeCurrent(); + void WorkspaceRenderer::resizeGL(int w, int h) + { + makeCurrent(); - glViewport(0, 0, w, h); + glViewport(0, 0, w, h); - set_projection(NO_ZOOM, center_x, center_y); - } + set_projection(NO_ZOOM, center_x, center_y); + } - QPointF WorkspaceRenderer::get_widget_mouse_position() const - { - const QPointF qt_widget_relative = mapFromGlobal(QCursor::pos()); - return QPointF(qt_widget_relative.x(), qt_widget_relative.y()); - } + QPointF WorkspaceRenderer::get_widget_mouse_position() const + { + const QPointF qt_widget_relative = mapFromGlobal(QCursor::pos()); + return QPointF(qt_widget_relative.x(), qt_widget_relative.y()); + } - QPointF WorkspaceRenderer::get_opengl_mouse_position() const - { - const QPointF widget_mouse_position = get_widget_mouse_position(); + QPointF WorkspaceRenderer::get_opengl_mouse_position() const + { + const QPointF widget_mouse_position = get_widget_mouse_position(); return QPointF(viewport_min_x + widget_mouse_position.x() * scale, viewport_min_y + widget_mouse_position.y() * scale); - } + } QPointF WorkspaceRenderer::get_safe_opengl_mouse_position() const { - return get_safe_position(get_opengl_mouse_position()); + return get_safe_position(get_opengl_mouse_position()); } WorkspaceTool WorkspaceRenderer::get_current_tool() const { - return current_tool; + return current_tool; } void WorkspaceRenderer::update_object(PlacedLogicModelObject_shptr object) @@ -621,68 +625,72 @@ namespace degate set_projection(NO_ZOOM, point.x(), point.y()); } - void WorkspaceRenderer::set_projection(float scale_factor, float new_center_x, float new_center_y) - { - scale *= scale_factor; + void WorkspaceRenderer::set_projection(float scale_factor, float new_center_x, float new_center_y) + { + scale *= scale_factor; - center_x = new_center_x; - center_y = new_center_y; + center_x = new_center_x; + center_y = new_center_y; - viewport_min_x = center_x - (static_cast(width()) * scale) / 2.0; - viewport_min_y = center_y - (static_cast(height()) * scale) / 2.0; - viewport_max_x = center_x + (static_cast(width()) * scale) / 2.0; - viewport_max_y = center_y + (static_cast(height()) * scale) / 2.0; + viewport_min_x = center_x - (static_cast(width()) * scale) / 2.0; + viewport_min_y = center_y - (static_cast(height()) * scale) / 2.0; + viewport_max_x = center_x + (static_cast(width()) * scale) / 2.0; + viewport_max_y = center_y + (static_cast(height()) * scale) / 2.0; - background.update_viewport(viewport_min_x, viewport_max_x, viewport_min_y, viewport_max_y, static_cast(width()), static_cast(height())); + background.update_viewport(viewport_min_x, + viewport_max_x, + viewport_min_y, + viewport_max_y, + static_cast(width()), + static_cast(height())); regular_grid.viewport_update(BoundingBox(viewport_min_x, viewport_max_x, viewport_min_y, viewport_max_y)); if (draw_grid) regular_grid.update(); - projection.setToIdentity(); - projection.ortho(viewport_min_x, viewport_max_x, viewport_max_y, viewport_min_y, -1, 1); - } + projection.setToIdentity(); + projection.ortho(viewport_min_x, viewport_max_x, viewport_max_y, viewport_min_y, -1, 1); + } - void WorkspaceRenderer::mousePressEvent(QMouseEvent* event) - { + void WorkspaceRenderer::mousePressEvent(QMouseEvent* event) + { makeCurrent(); - QOpenGLWidget::mousePressEvent(event); + QOpenGLWidget::mousePressEvent(event); - mouse_last_pos = get_opengl_mouse_position(); + mouse_last_pos = get_opengl_mouse_position(); - if (event->button() == Qt::LeftButton) - setCursor(Qt::ClosedHandCursor); + if (event->button() == Qt::LeftButton) + setCursor(Qt::ClosedHandCursor); // Area selection + CTRL - if (event->button() == Qt::RightButton && - current_tool == WorkspaceTool::AREA_SELECTION && + if (event->button() == Qt::RightButton && current_tool == WorkspaceTool::AREA_SELECTION && QApplication::keyboardModifiers().testFlag(Qt::ControlModifier)) { reset_area_selection(); } - } + } - void WorkspaceRenderer::mouseReleaseEvent(QMouseEvent* event) - { + void WorkspaceRenderer::mouseReleaseEvent(QMouseEvent* event) + { makeCurrent(); - QOpenGLWidget::mouseReleaseEvent(event); + QOpenGLWidget::mouseReleaseEvent(event); - if (event->button() == Qt::LeftButton) - setCursor(Qt::CrossCursor); + if (event->button() == Qt::LeftButton) + setCursor(Qt::CrossCursor); - // Selection - if (event->button() == Qt::LeftButton && !mouse_moved) - { - if (project == nullptr) - return; + // Selection + if (event->button() == Qt::LeftButton && !mouse_moved) + { + if (project == nullptr) + return; - QPointF pos = get_opengl_mouse_position(); + QPointF pos = get_opengl_mouse_position(); - LogicModel_shptr lmodel = project->get_logic_model(); - Layer_shptr layer = lmodel->get_current_layer(); + LogicModel_shptr lmodel = project->get_logic_model(); + Layer_shptr layer = lmodel->get_current_layer(); PlacedLogicModelObject_shptr plo = layer->get_object_at_position(pos.x(), pos.y(), 0, @@ -693,7 +701,7 @@ namespace degate !draw_vias, !draw_wires); - // Check if there is a gate or gate port on the logic layer + // Check if there is a gate or gate port on the logic layer try { PlacedLogicModelObject_shptr logic_plo; @@ -728,12 +736,12 @@ namespace degate } // If no CTRL reset selection (single selection) - if (!selected_objects.empty() && !QApplication::keyboardModifiers().testFlag(Qt::ControlModifier)) - reset_selection(); + if (!selected_objects.empty() && !QApplication::keyboardModifiers().testFlag(Qt::ControlModifier)) + reset_selection(); - if (plo != nullptr) - add_object_to_selection(plo); - } + if (plo != nullptr) + add_object_to_selection(plo); + } // Selection imply no area selection if (!mouse_moved && !selected_objects.empty() && current_tool == WorkspaceTool::AREA_SELECTION) @@ -753,7 +761,8 @@ namespace degate new_wire->set_diameter(project->get_default_wire_diameter()); // Registre wire - project->get_logic_model()->add_object(project->get_logic_model()->get_current_layer()->get_layer_pos(), new_wire); + project->get_logic_model()->add_object(project->get_logic_model()->get_current_layer()->get_layer_pos(), + new_wire); // Restart line drawing wire_tool.start_line_drawing(wire_tool.get_line().get_to_x(), wire_tool.get_line().get_to_y()); @@ -776,8 +785,7 @@ namespace degate } // Area selection + CTRL - if (event->button() == Qt::RightButton && - current_tool == WorkspaceTool::AREA_SELECTION && + if (event->button() == Qt::RightButton && current_tool == WorkspaceTool::AREA_SELECTION && selection_tool.is_object_selection_mode_active()) { BoundingBox bb = get_safe_area_selection(); @@ -822,36 +830,36 @@ namespace degate } // Emit signal (for mouse context menu) - if (event->button() == Qt::RightButton && !mouse_moved) - emit right_mouse_button_released(); + if (event->button() == Qt::RightButton && !mouse_moved) + emit right_mouse_button_released(); - mouse_moved = false; - } + mouse_moved = false; + } - void WorkspaceRenderer::mouseMoveEvent(QMouseEvent* event) - { + void WorkspaceRenderer::mouseMoveEvent(QMouseEvent* event) + { makeCurrent(); - QOpenGLWidget::mouseMoveEvent(event); + QOpenGLWidget::mouseMoveEvent(event); - // Movement - if (event->buttons() & Qt::LeftButton) - { + // Movement + if (event->buttons() & Qt::LeftButton) + { mouse_moved = true; - float dx = get_opengl_mouse_position().x() - mouse_last_pos.x(); - float dy = get_opengl_mouse_position().y() - mouse_last_pos.y(); + float dx = get_opengl_mouse_position().x() - mouse_last_pos.x(); + float dy = get_opengl_mouse_position().y() - mouse_last_pos.y(); - center_x -= dx; - center_y -= dy; - set_projection(NO_ZOOM, center_x, center_y); + center_x -= dx; + center_y -= dy; + set_projection(NO_ZOOM, center_x, center_y); - update(); - } + update(); + } - // Area selection - if (event->buttons() & Qt::RightButton && current_tool == WorkspaceTool::AREA_SELECTION) - { + // Area selection + if (event->buttons() & Qt::RightButton && current_tool == WorkspaceTool::AREA_SELECTION) + { mouse_moved = true; // If there is no area selection, start new one and set new origin @@ -869,16 +877,16 @@ namespace degate } // Update other area extremity on mouse position - selection_tool.update(get_opengl_mouse_position().x(), get_opengl_mouse_position().y()); + selection_tool.update(get_opengl_mouse_position().x(), get_opengl_mouse_position().y()); // If an object is selected, reset selection - if (!selected_objects.empty()) - reset_selection(); + if (!selected_objects.empty()) + reset_selection(); - update(); - } + update(); + } - if (event->buttons() & Qt::RightButton && current_tool == WorkspaceTool::WIRE) + if (event->buttons() & Qt::RightButton && current_tool == WorkspaceTool::WIRE) { mouse_moved = true; @@ -893,12 +901,12 @@ namespace degate update(); } - // Mouse coords signal - emit mouse_coords_changed(get_opengl_mouse_position().x(), get_opengl_mouse_position().y()); - } + // Mouse coords signal + emit mouse_coords_changed(get_opengl_mouse_position().x(), get_opengl_mouse_position().y()); + } - void WorkspaceRenderer::wheelEvent(QWheelEvent* event) - { + void WorkspaceRenderer::wheelEvent(QWheelEvent* event) + { makeCurrent(); QPoint wheel_delta = event->angleDelta(); @@ -910,107 +918,126 @@ namespace degate else QOpenGLWidget::wheelEvent(event); - event->accept(); - } + event->accept(); + } - void WorkspaceRenderer::keyPressEvent(QKeyEvent* event) - { + void WorkspaceRenderer::keyPressEvent(QKeyEvent* event) + { makeCurrent(); - QOpenGLWidget::keyPressEvent(event); - } + QOpenGLWidget::keyPressEvent(event); + } - void WorkspaceRenderer::keyReleaseEvent(QKeyEvent* event) - { + void WorkspaceRenderer::keyReleaseEvent(QKeyEvent* event) + { makeCurrent(); - QOpenGLWidget::keyReleaseEvent(event); + QOpenGLWidget::keyReleaseEvent(event); - if (event->key() == Qt::Key_Escape) + if (event->key() == Qt::Key_Escape) { wire_tool.reset_line_drawing(); update(); } - } + } - void WorkspaceRenderer::mouseDoubleClickEvent(QMouseEvent* event) - { + void WorkspaceRenderer::mouseDoubleClickEvent(QMouseEvent* event) + { makeCurrent(); - QOpenGLWidget::mouseDoubleClickEvent(event); - - if (event->button() == Qt::LeftButton) - { - if (project == nullptr) - return; - - QPointF pos = get_opengl_mouse_position(); - - LogicModel_shptr lmodel = project->get_logic_model(); - Layer_shptr layer = lmodel->get_current_layer(); - PlacedLogicModelObject_shptr plo = layer->get_object_at_position(pos.x(), pos.y(), 0, !draw_annotations, !draw_gates, !draw_ports, !draw_emarkers, !draw_vias, !draw_wires); - - // Check if there is a gate or gate port on the logic layer - if (plo == nullptr) - { - try - { - layer = get_first_logic_layer(lmodel); - plo = layer->get_object_at_position(pos.x(), pos.y(), 0, !draw_annotations, !draw_gates, !draw_ports, !draw_emarkers, !draw_vias, !draw_wires); - } - catch (CollectionLookupException const&) - { - } - } - - if (plo != nullptr) - { - if (SubProjectAnnotation_shptr sp = std::dynamic_pointer_cast(plo)) - { - std::string dir = join_pathes(project->get_project_directory(), sp->get_path()); - debug(TM, "Will open or create project at %s", dir.c_str()); - - emit project_changed(dir); - } - else if (Gate_shptr gate = std::dynamic_pointer_cast(plo)) - { - GateInstanceEditDialog dialog(this, gate, project); - dialog.exec(); + QOpenGLWidget::mouseDoubleClickEvent(event); + + if (event->button() == Qt::LeftButton) + { + if (project == nullptr) + return; + + QPointF pos = get_opengl_mouse_position(); + + LogicModel_shptr lmodel = project->get_logic_model(); + Layer_shptr layer = lmodel->get_current_layer(); + PlacedLogicModelObject_shptr plo = layer->get_object_at_position(pos.x(), + pos.y(), + 0, + !draw_annotations, + !draw_gates, + !draw_ports, + !draw_emarkers, + !draw_vias, + !draw_wires); + + // Check if there is a gate or gate port on the logic layer + if (plo == nullptr) + { + try + { + layer = get_first_logic_layer(lmodel); + plo = layer->get_object_at_position(pos.x(), + pos.y(), + 0, + !draw_annotations, + !draw_gates, + !draw_ports, + !draw_emarkers, + !draw_vias, + !draw_wires); + } + catch (CollectionLookupException const&) + { + } + } + + if (plo != nullptr) + { + if (SubProjectAnnotation_shptr sp = std::dynamic_pointer_cast(plo)) + { + std::string dir = join_pathes(project->get_project_directory(), sp->get_path()); + debug(TM, "Will open or create project at %s", dir.c_str()); + + emit project_changed(dir); + } + else if (Gate_shptr gate = std::dynamic_pointer_cast(plo)) + { + GateInstanceEditDialog dialog(this, gate, project); + dialog.exec(); project->get_logic_model()->update_ports(gate); - makeCurrent(); - gates.update(); - update(); + makeCurrent(); + gates.update(); + update(); emit project_changed(); - } - else if (GatePort_shptr gate_port = std::dynamic_pointer_cast(plo)) - { - { - PortPlacementDialog dialog(this, project, gate_port->get_gate()->get_gate_template(), gate_port->get_template_port()); - dialog.exec(); - } + } + else if (GatePort_shptr gate_port = std::dynamic_pointer_cast(plo)) + { + { + PortPlacementDialog dialog(this, + project, + gate_port->get_gate()->get_gate_template(), + gate_port->get_template_port()); + dialog.exec(); + } - project->get_logic_model()->update_ports(gate_port->get_gate()); + project->get_logic_model()->update_ports(gate_port->get_gate()); - makeCurrent(); - gates.update(); - update(); + makeCurrent(); + gates.update(); + update(); emit project_changed(); - } - else if (Annotation_shptr annotation = std::dynamic_pointer_cast(plo)) - { - AnnotationEditDialog dialog(this, annotation); - dialog.exec(); + } + else if (Annotation_shptr annotation = std::dynamic_pointer_cast(plo)) + { + AnnotationEditDialog dialog(this, annotation); + dialog.exec(); makeCurrent(); - annotations.update(); - update(); + annotations.update(); + update(); emit project_changed(); - } + } else if (EMarker_shptr emarker = std::dynamic_pointer_cast(plo)) { EMarkerEditDialog dialog(this, emarker); @@ -1033,25 +1060,25 @@ namespace degate emit project_changed(); } - } - } + } + } - setCursor(Qt::CrossCursor); - } + setCursor(Qt::CrossCursor); + } - void WorkspaceRenderer::zoom_in() - { - set_projection(ZOOM_IN, center_x, center_y); + void WorkspaceRenderer::zoom_in() + { + set_projection(ZOOM_IN, center_x, center_y); - update(); - } + update(); + } - void WorkspaceRenderer::zoom_out() - { - set_projection(ZOOM_OUT, center_x, center_y); + void WorkspaceRenderer::zoom_out() + { + set_projection(ZOOM_OUT, center_x, center_y); - update(); - } + update(); + } QPointF WorkspaceRenderer::get_safe_position(QPointF position) const { @@ -1108,4 +1135,50 @@ namespace degate return res; } -} + + bool WorkspaceRenderer::event(QEvent* event) + { + if (!this->context_initialized && event->type() == QEvent::Show) + { + auto result = QOpenGLWidget::event(event); + this->context_initialized = true; + + // Check OpenGL initialization + if (this->context() == nullptr || !this->context()->isValid()) + { + QMessageBox::critical( + this, + "Error", + "Degate couldn't create an OpenGL context. Please install appropriate drivers to run the " + "software."); + throw DegateRuntimeException("No OpenGL driver installed on the machine."); + } + + // Check that we are not using software OpenGL through llvmpipe + auto functions = this->context()->functions(); + if (functions != nullptr) + { + const std::string vendor = reinterpret_cast(functions->glGetString(GL_VENDOR)); + const std::string renderer = reinterpret_cast(functions->glGetString(GL_RENDERER)); + const std::string version = reinterpret_cast(functions->glGetString(GL_VERSION)); + debug(TM, "Detected OpenGL vendor: %s", vendor.c_str()); + debug(TM, "Detected OpenGL renderer: %s", renderer.c_str()); + debug(TM, "Detected OpenGL version: %s", version.c_str()); + + if (renderer.find("llvmpipe") != std::string::npos) + { + QMessageBox::warning(this, + "OpenGL", + "You are using a software implementation of OpenGL because no real driver has " + "been found. Please note that this will have an impact on performances, and " + "could even not work at all."); + } + } + return result; + } + else + { + return QOpenGLWidget::event(event); + } + } +} // namespace degate diff --git a/src/GUI/Workspace/WorkspaceRenderer.h b/src/GUI/Workspace/WorkspaceRenderer.h index 86f9fec3..3c69e18c 100644 --- a/src/GUI/Workspace/WorkspaceRenderer.h +++ b/src/GUI/Workspace/WorkspaceRenderer.h @@ -22,22 +22,22 @@ #ifndef __WORKSPACERENDERER_H__ #define __WORKSPACERENDERER_H__ -#include "Core/Project/Project.h" +#include "Core/LogicModel/Annotation/SubProjectAnnotation.h" #include "Core/LogicModel/HlObjectSet.h" -#include "GUI/Workspace/WorkspaceBackground.h" -#include "GUI/Workspace/WorkspaceGates.h" +#include "Core/LogicModel/LogicModelHelper.h" +#include "Core/Project/Project.h" +#include "GUI/Dialog/EMarkerEditDialog.h" +#include "GUI/Dialog/ViaEditDialog.h" #include "GUI/Text/Text.h" #include "GUI/Workspace/WorkspaceAnnotations.h" -#include "Core/LogicModel/Annotation/SubProjectAnnotation.h" -#include "Core/LogicModel/LogicModelHelper.h" -#include "GUI/Workspace/WorkspaceSelectionTool.h" +#include "GUI/Workspace/WorkspaceBackground.h" #include "GUI/Workspace/WorkspaceEMarkers.h" -#include "GUI/Dialog/EMarkerEditDialog.h" +#include "GUI/Workspace/WorkspaceGates.h" +#include "GUI/Workspace/WorkspaceRegularGrid.h" +#include "GUI/Workspace/WorkspaceSelectionTool.h" #include "GUI/Workspace/WorkspaceVias.h" -#include "GUI/Dialog/ViaEditDialog.h" -#include "GUI/Workspace/WorkspaceWires.h" #include "GUI/Workspace/WorkspaceWireTool.h" -#include "GUI/Workspace/WorkspaceRegularGrid.h" +#include "GUI/Workspace/WorkspaceWires.h" #include #include @@ -88,10 +88,9 @@ namespace degate */ class WorkspaceRenderer : public QOpenGLWidget, protected QOpenGLFunctions { - Q_OBJECT + Q_OBJECT public: - /** * Create a workspace renderer. * @@ -275,6 +274,11 @@ namespace degate */ void set_projection(float scale_factor, float new_center_x, float new_center_y); + /** + * + */ + bool event(QEvent* event) override; + public slots: /** * Zoom in. @@ -494,25 +498,27 @@ namespace degate bool draw_grid = false; // View parameters - bool draw_gates = true; - bool draw_gates_name = true; - bool draw_ports = true; - bool draw_ports_name = true; - bool draw_annotations = true; + bool draw_gates = true; + bool draw_gates_name = true; + bool draw_ports = true; + bool draw_ports_name = true; + bool draw_annotations = true; bool draw_annotations_name = true; - bool draw_emarkers = true; - bool draw_emarkers_name = true; - bool draw_vias = true; - bool draw_vias_name = true; - bool draw_wires = true; + bool draw_emarkers = true; + bool draw_emarkers_name = true; + bool draw_vias = true; + bool draw_vias_name = true; + bool draw_wires = true; // Used tool WorkspaceTool current_tool; - // Last create wire created with the wire tool + // Last wire created with the wire tool Wire_shptr last_created_wire = nullptr; + // Did we tried to initialize the OpenGL context + bool context_initialized = false; }; -} +} // namespace degate #endif diff --git a/src/Main.cc b/src/Main.cc index bbf6fb25..955419ba 100644 --- a/src/Main.cc +++ b/src/Main.cc @@ -19,15 +19,15 @@ * */ -#include +#include "Core/Utils/CrashReport.h" +#include "Core/Version.h" +#include "GUI/MainWindow.h" +#include "GUI/Preferences/PreferencesHandler.h" + #include #include #include - -#include "GUI/Preferences/PreferencesHandler.h" -#include "GUI/MainWindow.h" -#include "Core/Version.h" -#include "Core/Utils/CrashReport.h" +#include /** * @class Degate @@ -38,7 +38,6 @@ class Degate final : public QApplication { public: - /** * Constructor, @see QApplication. * @@ -87,22 +86,16 @@ int main(int argc, char* argv[]) std::signal(SIGSEGV, [](int signal) { std::string error = "A SIGSEGV occurred (" + std::to_string(signal) + ")."; degate::crash_report(error); - QApplication::closeAllWindows(); - exit(EXIT_FAILURE); }); std::signal(SIGFPE, [](int signal) { std::string error = "A SIGFPE occurred (" + std::to_string(signal) + ")."; degate::crash_report(error); - QApplication::closeAllWindows(); - exit(EXIT_FAILURE); }); std::signal(SIGILL, [](int signal) { std::string error = "A SIGILL occurred (" + std::to_string(signal) + ")."; degate::crash_report(error); - QApplication::closeAllWindows(); - exit(EXIT_FAILURE); }); try @@ -122,7 +115,8 @@ int main(int argc, char* argv[]) // If it's a first launch or an updated Degate version, show help menu. if (degate::PreferencesHandler::get_instance().get_settings().value("first_launch", true).toBool() || - degate::PreferencesHandler::get_instance().get_settings().value("last_launch_version", "") != DEGATE_VERSION) + degate::PreferencesHandler::get_instance().get_settings().value("last_launch_version", "") != + DEGATE_VERSION) { window.on_menu_help_about(); @@ -134,9 +128,8 @@ int main(int argc, char* argv[]) } catch (const std::exception& e) { + debug(TM, "Exception occured: %s", e.what()); degate::crash_report(e.what()); - - return EXIT_FAILURE; } return ret; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index acc5278e..ef95f8f4 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -19,8 +19,10 @@ # ##################################################################### -enable_testing() -include_directories("${CMAKE_CURRENT_SOURCE_DIR}/catch2/") +project(DegateTests LANGUAGES CXX) + +find_package(Catch2 CONFIG REQUIRED) +include(Catch) # # The tests source files @@ -32,22 +34,11 @@ file(GLOB_RECURSE TEST_SRC_FILES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" LIST_DIR "src/*.hpp" ) -# -# Include directories -# -include_directories("${CMAKE_CURRENT_SOURCE_DIR}/src") -include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../src") - -# -# Defines groups (to respect folders hierarchy) -# -source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}/src" PREFIX "src" FILES ${TEST_SRC_FILES}) - # # Link # -add_executable(DegateTests ${TEST_SRC_FILES}) -target_link_libraries(DegateTests ${LIBS} DegateCore) +qt_add_executable(DegateTests ${TEST_SRC_FILES}) +target_link_libraries(DegateTests PRIVATE ${LIBS} DegateCore Catch2::Catch2) # # Output specifications @@ -59,10 +50,19 @@ set_target_properties(DegateTests RUNTIME_OUTPUT_DIRECTORY "out/bin" ) +# +# Automatic Qt deploy +# +# qt_generate_deploy_app_script( +# TARGET DegateTests +# OUTPUT_SCRIPT deploy_script +# NO_UNSUPPORTED_PLATFORM_ERROR +# ) +# install(SCRIPT ${deploy_script}) + # # Link Catch2 tests to CTest # -include(catch2/Catch.cmake) catch_discover_tests(DegateTests) # @@ -72,4 +72,4 @@ add_custom_command( TARGET DegateTests POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/tests/tests_files/ - $/tests_files/) \ No newline at end of file + $/tests_files/) diff --git a/tests/src/FileSystemTests.cc b/tests/src/FileSystemTests.cc index ece1b783..eb231632 100644 --- a/tests/src/FileSystemTests.cc +++ b/tests/src/FileSystemTests.cc @@ -22,7 +22,7 @@ #include "Core/Utils/FileSystem.h" #include -#include "catch.hpp" +#include using namespace degate; @@ -186,4 +186,4 @@ TEST_CASE("Get basename", "[FileSystem]") REQUIRE(get_basename("resolv.conf") == "resolv"); REQUIRE(get_basename(".conf") == ""); -} \ No newline at end of file +} diff --git a/tests/src/GateLibraryExporterTests.cc b/tests/src/GateLibraryExporterTests.cc index e76b1c7c..82fd70a1 100644 --- a/tests/src/GateLibraryExporterTests.cc +++ b/tests/src/GateLibraryExporterTests.cc @@ -27,7 +27,7 @@ #include -#include "catch.hpp" +#include using namespace degate; @@ -61,4 +61,4 @@ TEST_CASE("Gate library exporter", "[GateLibraryExporter]") */ GateLibraryImporter reimporter; GateLibrary_shptr glib2(reimporter.import(filename)); -} \ No newline at end of file +} diff --git a/tests/src/GateLibraryImporterTests.cc b/tests/src/GateLibraryImporterTests.cc index f0837d00..8e94b41b 100644 --- a/tests/src/GateLibraryImporterTests.cc +++ b/tests/src/GateLibraryImporterTests.cc @@ -27,7 +27,7 @@ #include -#include "catch.hpp" +#include using namespace degate; @@ -68,4 +68,4 @@ TEST_CASE("Gate library importer", "[GateLibraryImporter]") } REQUIRE(i > 0); -} \ No newline at end of file +} diff --git a/tests/src/ImageProcessingTests.cc b/tests/src/ImageProcessingTests.cc index 66aebdb5..cddefc76 100644 --- a/tests/src/ImageProcessingTests.cc +++ b/tests/src/ImageProcessingTests.cc @@ -23,7 +23,7 @@ #include "Core/Image/Processor/IPPipe.h" #include "Core/Image/Processor/IPCopy.h" -#include "catch.hpp" +#include using namespace degate; @@ -62,4 +62,4 @@ TEST_CASE("Test pipe", "[ImageProcessingTests]") REQUIRE(pipe.size() == 2); REQUIRE_NOTHROW(pipe.run(in)); -} \ No newline at end of file +} diff --git a/tests/src/ImageTests.cc b/tests/src/ImageTests.cc index 3a349efb..160324b1 100644 --- a/tests/src/ImageTests.cc +++ b/tests/src/ImageTests.cc @@ -24,7 +24,7 @@ #include "Core/Image/TIFFWriter.h" #include "Core/Image/ImageReader.h" -#include "catch.hpp" +#include using namespace degate; @@ -151,4 +151,4 @@ TEST_CASE("Test pixel conversion", "[ImageTests]") rgba_pixel_t rd = convert_pixel(4.0); REQUIRE((unsigned)MERGE_CHANNELS(4, 4, 4, 255) == rd); -} \ No newline at end of file +} diff --git a/tests/src/LogicModelDOTExporterTests.cc b/tests/src/LogicModelDOTExporterTests.cc index 02a1036e..d7aa7325 100644 --- a/tests/src/LogicModelDOTExporterTests.cc +++ b/tests/src/LogicModelDOTExporterTests.cc @@ -26,7 +26,7 @@ #include -#include "catch.hpp" +#include using namespace degate; @@ -84,4 +84,4 @@ TEST_CASE("Test export", "[LogicModelDOTExporter]") exporter2.export_data(out_filename2, lmodel); REQUIRE(file_exists(out_filename2) == true); -} \ No newline at end of file +} diff --git a/tests/src/LogicModelImporterTests.cc b/tests/src/LogicModelImporterTests.cc index 6a568659..704f6769 100644 --- a/tests/src/LogicModelImporterTests.cc +++ b/tests/src/LogicModelImporterTests.cc @@ -22,7 +22,7 @@ #include "Core/LogicModel/Gate/GateLibraryImporter.h" #include "Core/LogicModel/LogicModelImporter.h" -#include "catch.hpp" +#include using namespace degate; diff --git a/tests/src/LogicModelTests.cc b/tests/src/LogicModelTests.cc index 26f0f1d0..2fa25a79 100644 --- a/tests/src/LogicModelTests.cc +++ b/tests/src/LogicModelTests.cc @@ -22,7 +22,7 @@ #include "Core/LogicModel/Wire/Wire.h" #include "Core/LogicModel/LogicModel.h" -#include "catch.hpp" +#include using namespace degate; @@ -125,4 +125,4 @@ TEST_CASE("Test add and retrieve wire", "[LogicModel]") } REQUIRE(i > 0); -} \ No newline at end of file +} diff --git a/tests/src/MainTests.cc b/tests/src/MainTests.cc index e4433cbf..5c80d357 100644 --- a/tests/src/MainTests.cc +++ b/tests/src/MainTests.cc @@ -21,7 +21,7 @@ #define CATCH_CONFIG_RUNNER -#include "catch.hpp" +#include #include #include @@ -33,4 +33,4 @@ int main( int argc, char* argv[] ) int result = Catch::Session().run( argc, argv ); return result; -} \ No newline at end of file +} diff --git a/tests/src/MemoryMapTests.cc b/tests/src/MemoryMapTests.cc index 7695e60e..d9b71cda 100644 --- a/tests/src/MemoryMapTests.cc +++ b/tests/src/MemoryMapTests.cc @@ -22,7 +22,7 @@ #include "Core/Utils/MemoryMap.h" #include "Core/Utils/FileSystem.h" -#include "catch.hpp" +#include using namespace degate; @@ -80,4 +80,4 @@ TEST_CASE("Persistent MemoryMap", "[MemoryMap]") REQUIRE(file_exists(filename) == true); REQUIRE(remove_file(filename) == true); -} \ No newline at end of file +} diff --git a/tests/src/ProjectExporterTests.cc b/tests/src/ProjectExporterTests.cc index cb975279..48a161bc 100644 --- a/tests/src/ProjectExporterTests.cc +++ b/tests/src/ProjectExporterTests.cc @@ -23,7 +23,7 @@ #include "Core/Project/ProjectExporter.h" #include "Core/Project/Project.h" -#include "catch.hpp" +#include using namespace degate; @@ -44,4 +44,4 @@ TEST_CASE("Test project export", "[ProjectExporter]") */ ProjectExporter exporter; REQUIRE_NOTHROW(exporter.export_all("tests_files/test_project", prj)); -} \ No newline at end of file +} diff --git a/tests/src/ProjectImporterTests.cc b/tests/src/ProjectImporterTests.cc index f96ad129..616186da 100644 --- a/tests/src/ProjectImporterTests.cc +++ b/tests/src/ProjectImporterTests.cc @@ -24,7 +24,7 @@ #include "Core/Project/Project.h" #include "Core/LogicModel/LogicModelHelper.h" -#include "catch.hpp" +#include using namespace degate; @@ -110,4 +110,4 @@ TEST_CASE("Test get object at", "[ProjectImporter]") REQUIRE(plo != nullptr); REQUIRE(plo->get_name() == "test_gate_1"); -} \ No newline at end of file +} diff --git a/tests/src/QuadTreeTests.cc b/tests/src/QuadTreeTests.cc index 18403eb0..73a36dd0 100644 --- a/tests/src/QuadTreeTests.cc +++ b/tests/src/QuadTreeTests.cc @@ -27,7 +27,7 @@ #include "Core/Primitive/QuadTree.h" #include "Core/LogicModel/Via/Via.h" -#include "catch.hpp" +#include using namespace degate; @@ -177,4 +177,4 @@ TEST_CASE("Test overlapping objects", "[QuadTree]") delete g; delete v; delete qtree; -} \ No newline at end of file +} diff --git a/tests/src/ScalingManagerTests.cc b/tests/src/ScalingManagerTests.cc index fed7d74e..2e7c2de4 100644 --- a/tests/src/ScalingManagerTests.cc +++ b/tests/src/ScalingManagerTests.cc @@ -23,7 +23,7 @@ #include "Core/Image/Image.h" #include "Core/Image/ImageReader.h" -#include "catch.hpp" +#include using namespace degate; @@ -48,4 +48,4 @@ TEST_CASE("Test scaling manager", "[ScalingManager]") ScalingManager sm(img, img->get_path(), ProjectType::Normal, 256); sm.create_scalings(); -} \ No newline at end of file +} diff --git a/tests/src/ShapeTests.cc b/tests/src/ShapeTests.cc index 0403bdea..114b56de 100644 --- a/tests/src/ShapeTests.cc +++ b/tests/src/ShapeTests.cc @@ -24,7 +24,7 @@ #include "Core/Primitive/Point.h" #include "Core/Primitive/Rectangle.h" -#include "catch.hpp" +#include using namespace degate; @@ -104,4 +104,4 @@ TEST_CASE("Test in shape line", "[Shape]") REQUIRE(v.in_shape(10, 110) == false); REQUIRE(v.in_shape(50, 50) == false); -} \ No newline at end of file +} diff --git a/vcpkg b/vcpkg new file mode 160000 index 00000000..dd3adcf0 --- /dev/null +++ b/vcpkg @@ -0,0 +1 @@ +Subproject commit dd3adcf020e69077e83e92a0a293ceca734f6288 diff --git a/vcpkg.json b/vcpkg.json new file mode 100644 index 00000000..2e400d1f --- /dev/null +++ b/vcpkg.json @@ -0,0 +1,70 @@ +{ + "name": "degate", + "dependencies": [ + "boost-filesystem", + "boost-system", + "boost-thread", + "boost-format", + "boost-algorithm", + "boost-core", + "boost-lexical-cast", + "boost-date-time", + "boost-optional", + "boost-range" + ], + "default-features": [], + "features": { + "tests": { + "description": "Dependencies for testing", + "dependencies": [ + "catch2" + ] + }, + "vcpkg-qt": { + "description": "Use vcpkg's Qt dependency. WARNING: this will not provide OpenGL software renderer fallback for Windows (mesa llvmpipe)", + "dependencies": [ + { + "name": "qtbase", + "default-features": false, + "features": [ + "concurrent", + "thread", + "gui", + "opengl", + "widgets", + "jpeg", + "png", + { + "name": "xrender", + "platform": "linux" + }, + { + "name": "xcb", + "platform": "linux" + }, + { + "name": "xcb-xlib", + "platform": "linux" + }, + { + "name": "fontconfig", + "platform": "linux" + }, + { + "name": "egl", + "platform": "linux" + } + ] + }, + { + "name": "qttools", + "default-features": false, + "features": [ + "linguist" + ] + }, + "qtimageformats" + ] + } + } +}