Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add KDSME as submodule for CI testing #905

Merged
merged 1 commit into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ jobs:

- name: Checkout sources
uses: actions/checkout@v4
with:
submodules: recursive

- name: Install Dependencies on Linux
if: ${{ runner.os == 'Linux' }}
run: |
sudo apt update -qq
sudo apt install -y gdb doxygen libgraphviz-dev

- name: Install ninja-build tool (must be after Qt due PATH changes)
uses: turtlesec-no/get-ninja@main
Expand All @@ -59,17 +67,12 @@ jobs:
- name: Configure project
run: >
cmake -S . -G Ninja --preset ${{ matrix.config.preset }}
-DGAMMARAY_WITH_KDSME=${{ runner.os == 'Linux' }}
-DGAMMARAY_BUILD_DOCS=${{ runner.os == 'Linux' }}

- name: Build Project
run: cmake --build ./build-${{ matrix.config.preset }}

- name: Install dependencies on Ubuntu
if: ${{ runner.os == 'Linux' }}
run: |
sudo apt update -qq
sudo apt install -y gdb

- name: Enable gdb attaching
if: ${{ runner.os == 'Linux' }}
run: echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
Expand Down
12 changes: 12 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This file is part of GammaRay, the Qt application inspection and manipulation tool.
#
# SPDX-FileCopyrightText: 2010 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]>
#
# SPDX-License-Identifier: GPL-2.0-or-later
#
# Contact KDAB at <[email protected]> for commercial licensing options.
#

[submodule "3rdparty/KDStateMachineEditor"]
path = 3rdparty/KDStateMachineEditor
url = https://github.com/KDAB/KDStateMachineEditor.git
36 changes: 36 additions & 0 deletions 3rdparty/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# This file is part of GammaRay, the Qt application inspection and manipulation tool.
#
# SPDX-FileCopyrightText: 2024 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]>
#
# SPDX-License-Identifier: GPL-2.0-or-later
#
# Contact KDAB at <[email protected]> for commercial licensing options.
#

if(GAMMARAY_WITH_KDSME)
function(add_ksme_subdirectory)
# Function creates extra scope to keep these variables local
set(BUILD_DOCS OFF)
set(BUILD_EXAMPLES OFF)
set(BUILD_TESTS OFF)

set(KDSME_PACKAGE_NAME KDSME)
if(QT_VERSION_MAJOR GREATER_EQUAL 6)
set(KDSME_PACKAGE_NAME KDSME-qt6)
set(BUILD_QT6 ON)
endif()
set_package_properties(
${KDSME_PACKAGE_NAME} PROPERTIES
URL "https://github.com/KDAB/KDStateMachineEditor"
DESCRIPTION "KDAB State Machine Editor framework"
TYPE RECOMMENDED
PURPOSE "Graphical state machine debugging."
)

gammaray_ensure_submodule_exists(KDStateMachineEditor)
add_subdirectory(KDStateMachineEditor)
endfunction()
add_ksme_subdirectory()
endif()

add_subdirectory(kde)
1 change: 1 addition & 0 deletions 3rdparty/KDStateMachineEditor
Submodule KDStateMachineEditor added at 2567f4
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@
# Enable Precompiled Headers support
# Default=false
#
# -DGAMMARAY_WITH_KDSME=[true|false]
# Enable State Machine Viewer Plugin UI by requiring KDAB State Machine Editor
# Default=false
#
# -DENABLE_GOLD_LINKER=[true|false]
# Use GNU gold linker
# Default=false
Expand Down Expand Up @@ -250,6 +254,7 @@ endif()
gammaray_option(GAMMARAY_INSTALL_QT_LAYOUT "Install into Qt directory layout." OFF)
gammaray_option(GAMMARAY_MULTI_BUILD "Build multiple applicable probe configurations." ON)
gammaray_option(GAMMARAY_BUILD_CLI_INJECTOR "Build command line injector on Windows." ON)
gammaray_option(GAMMARAY_WITH_KDSME "Enable State Machine UI with KDSME" OFF)

set(GAMMARAY_BUILD_DOCS_DEFAULT ON)
set(GAMMARAY_DISABLE_FEEDBACK_DEFAULT OFF)
Expand Down Expand Up @@ -797,7 +802,7 @@ include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/3rdparty ${CMAKE_BIN

include(KDQtInstallPaths) #to set QT_INSTALL_FOO variables
add_subdirectory(cmake)
add_subdirectory(3rdparty/kde)
add_subdirectory(3rdparty)
add_subdirectory(common)
add_subdirectory(core)
add_subdirectory(probe)
Expand Down
16 changes: 16 additions & 0 deletions cmake/GammaRayMacrosInternal.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,19 @@ macro(gammaray_add_dummy_package _package _found)
list(APPEND _packages ${_package})
set_property(GLOBAL PROPERTY ${_property_name} "${_packages}")
endmacro()

# Check if some required submodule is initialized
function(gammaray_ensure_submodule_exists submodule)
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${submodule}/.git")
if(EXISTS "${appframework_SOURCE_DIR}/.git")
message(
FATAL_ERROR
"The git submodule ${submodule} is not initialized.\n"
"Please run the following command in the source directory (${appframework_SOURCE_DIR}):\n"
" git submodule update --init --recursive ${CMAKE_CURRENT_SOURCE_DIR}/${submodule}\n"
)
else()
message(FATAL_ERROR "The submodules are missing - please report a broken source package.\n")
endif()
endif()
endfunction()
16 changes: 1 addition & 15 deletions plugins/statemachineviewer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,8 @@ if(NOT GAMMARAY_CLIENT_ONLY_BUILD)
endif()
endif()

# UI part - dependencies
set(KDSME_PACKAGE_NAME KDSME)
if(QT_VERSION_MAJOR GREATER_EQUAL 6)
set(KDSME_PACKAGE_NAME KDSME-qt6)
endif()
set_package_properties(
${KDSME_PACKAGE_NAME} PROPERTIES
URL "https://github.com/KDAB/KDStateMachineEditor"
DESCRIPTION "KDAB State Machine Editor framework"
TYPE RECOMMENDED
PURPOSE "Graphical state machine debugging."
)
find_package(${KDSME_PACKAGE_NAME} 1.2 CONFIG QUIET)

# UI part
if(GAMMARAY_BUILD_UI AND ${KDSME_PACKAGE_NAME}_FOUND)
if(GAMMARAY_BUILD_UI AND GAMMARAY_WITH_KDSME)
Comment on lines -61 to +50
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks the ability to use a KDSME package installed separately on the system, doesn't it? Since find_package() is no longer even attempted, even if KDSME is installed, it won't be used — the submodule is the only option. And if the .git directory isn't present (e.g. package releases), there's no way to make it use a KDSME at all.

Distro packagers won't like that, for one. ...Unless I'm completely missing something?

Copy link
Contributor

@ferdnyc ferdnyc Jan 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FTR, my suggestion would be to keep the find_package(), but insert a condition to trigger the submodule stuff:

if(NOT ${KDSME_PACKAGE_NAME}_FOUND AND GAMMARAY_WITH_KDSME)

Maybe even change the option name to GAMMARAY_USE_INTERNAL_KDSME or something.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it breaks, I did that because of the includes.

  • We could include it on releases, remove/disable the git submodule check, and would also make more sense to static link to it.
  • Another option would be to #ifdef the includes
  • Fix KDSME includes, which isn't trivial
    @winterz @Waqar144 thoughts?

Copy link
Contributor

@ferdnyc ferdnyc Jan 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A fourth option:

  • Keep the submodule, but instead of using it in the build with add_subdirectory(), have the CI build-and-install KDSME from there before it configures GammaRay. Then pick it up with find_package() as usual.

The built KDSME could even be added to the GitHub cache, to speed things up.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or, in fact, you could use FetchContent to incorporate the submodule'd KDSME — with CMake 3.24+, if you give FetchContent_Declare() a FIND_PACKAGE_ARGS argument, it'll automatically automatically try a find_package() first, and use the installed package if it's found.

(FetchContent_Declare() doesn't have to download it from a remote repo. Like ExternalProject_Add(), you can give it a SOURCE_DIR argument with the path to existing sources.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FetchContent doesn't solve the include issue, it's just a little better ExternalProject_Add() but we are avoiding it in favor of submodules.


set(gammaray_statemachineviewer_ui_plugin_srcs statemachineviewerwidget.cpp statemachineviewerclient.cpp
statemodeldelegate.cpp
Expand Down
16 changes: 8 additions & 8 deletions plugins/statemachineviewer/statemachineviewerwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
#include <ui/contextmenuextension.h>
#include <ui/clientdecorationidentityproxymodel.h>

#include <kdstatemachineeditor/core/elementmodel.h>
#include <kdstatemachineeditor/core/layoutproperties.h>
#include <kdstatemachineeditor/core/state.h>
#include <kdstatemachineeditor/core/transition.h>
#include <kdstatemachineeditor/core/runtimecontroller.h>
#include <kdstatemachineeditor/view/statemachinescene.h>
#include <kdstatemachineeditor/view/statemachinetoolbar.h>
#include <kdstatemachineeditor/view/statemachineview.h>
#include <elementmodel.h>
#include <layoutproperties.h>
#include <state.h>
#include <transition.h>
#include <runtimecontroller.h>
#include <statemachinescene.h>
#include <statemachinetoolbar.h>
#include <statemachineview.h>

#include <QDebug>
#include <QMenu>
Expand Down