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

WIP: Extensions #129

Open
wants to merge 28 commits into
base: dev/vcpkg
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
6465d3e
Move to VCPKG.
Holt59 Jul 7, 2024
5f7658e
Move to custom semver versioning for MO2. (#154)
Holt59 Aug 5, 2024
d7faaf8
Update Qt version in CI and bump MO2 VCPKG registry baseline.
Holt59 Aug 5, 2024
10f6f71
Allow for external mo2-cmake (#160)
Holt59 Aug 9, 2024
265b189
Start working on extensions.
Holt59 May 14, 2022
d4f9d14
Add theme and translation for extensions.
Holt59 May 23, 2022
57b4f9b
Implement loading theme and translation extensions.
Holt59 May 23, 2022
7bf2d15
Update for extensions.
Holt59 May 24, 2022
d120497
Implement theme and translation additions for plugin extension.
Holt59 May 24, 2022
2a40eb7
Allow specifying plugins in extensions.
Holt59 May 26, 2022
ee70f02
Add extension list interface. Start working on requirements.
Holt59 Jul 16, 2023
1b62541
Add autodetect for translations to match mob/base-translations behavior.
Holt59 Jul 16, 2023
c2e37dc
Allow missing requirements in extensions.
Holt59 Jul 22, 2023
8d69d87
Re-organize extension metadata.
Holt59 Jul 22, 2023
bfa3fdf
Remove irrelevant methods from IPlugin.
Holt59 Jul 22, 2023
ede5d44
Add author, contributors and icon to metadata.
Holt59 Jul 22, 2023
8b07371
Default icon for extension.
Holt59 Jul 31, 2023
7d93e43
Compute language name when missing for translations.
Holt59 Jul 31, 2023
f058a72
Cleaning for C++20/23.
Holt59 Jun 29, 2024
10e9c7f
Add formatter for std::filesystem::path.
Holt59 Jun 29, 2024
39caa95
Move extension-related headers to an extensions/ subfolder.
Holt59 Aug 4, 2024
e4c47ea
Add version constraint system.
Holt59 Aug 8, 2024
0367e32
Implement requirements for extension.
Holt59 Aug 9, 2024
e2216d9
Improve tests for extension metadata.
Holt59 Aug 9, 2024
3f5e093
Fix translations for tests.
Holt59 Aug 9, 2024
5c1d8c5
Start refactoring setting system for plugins/extensions.
Holt59 Aug 10, 2024
3a64b4c
Add possibility to specify homepage for authors/contributors.
Holt59 Aug 10, 2024
2d4ffb4
Add back IPlugin::requirements.
Holt59 Aug 10, 2024
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
89 changes: 78 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,92 @@ name: Build UIBase
on:
push:
branches: master
tags:
- "*"
pull_request:
types: [opened, synchronize, reopened]

env:
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"

jobs:
build:
runs-on: windows-2022
steps:
- name: Build UI Base
id: build-uibase
uses: ModOrganizer2/build-with-mob-action@master
# https://learn.microsoft.com/en-us/vcpkg/consume/binary-caching-github-actions-cache
- name: Export GitHub Actions cache environment variables
uses: actions/github-script@v7
with:
mo2-third-parties: gtest spdlog boost
mo2-dependencies: cmake_common
mo2-cmake-command: -DUIBASE_TESTS=1 ..
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
with:
version: 6.7.1
modules:
cache: true

- uses: actions/checkout@v4
- uses: lukka/run-vcpkg@v11

- name: Build UI Base Tests
run: cmake --build vsbuild --config RelWithDebInfo -j4 --target uibase-tests
working-directory: ${{ steps.build-uibase.outputs.working-directory }}
- name: Configure UI Base build
shell: pwsh
run: |
cmake --preset vs2022-windows-standalone `
"-DCMAKE_PREFIX_PATH=${env:QT_ROOT_DIR}\msvc2019_64" `
"-DCMAKE_INSTALL_PREFIX=install" -DUIBASE_TESTING=ON

# build both Debug and RelWithDebInfo for package
- name: Build UI Base
run: |
cmake --build vsbuild --config Debug --target uibase-tests --verbose
cmake --build vsbuild --config RelWithDebInfo --target uibase-tests --verbose

- name: Test UI Base
run: ctest --test-dir vsbuild -C RelWithDebInfo --output-on-failure
working-directory: ${{ steps.build-uibase.outputs.working-directory }}
run: |
ctest --test-dir vsbuild -C Debug --output-on-failure
ctest --test-dir vsbuild -C RelWithDebInfo --output-on-failure

- name: Install UI Base
run: |
cmake --install vsbuild --config Debug
cmake --install vsbuild --config RelWithDebInfo

# this tests that UI Base can be properly used as a CMake package
- name: Test UI Base package
run: |
cmake -B build . "-DCMAKE_PREFIX_PATH=${env:QT_ROOT_DIR}\msvc2019_64;..\..\install\lib\cmake\"
cmake --build build --config Debug
cmake --build build --config Release
cmake --build build --config RelWithDebInfo
working-directory: tests/cmake

- name: Upload UI Base artifact
uses: actions/upload-artifact@master
with:
name: uibase
path: ./install

publish:
if: github.ref_type == 'tag'
needs: build
runs-on: windows-2022
permissions:
contents: write
steps:
- name: Download Artifact
uses: actions/download-artifact@master
with:
name: uibase
path: ./install

- name: Create UI Base archive
run: 7z a uibase_${{ github.ref_name }}.7z ./install/*

- name: Publish Release
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
run: gh release create --draft=false --notes="${{ github.ref_name }}" "${{ github.ref_name }}" ./uibase_${{ github.ref_name }}.7z
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
edit
.vscode
CMakeLists.txt.user
/msbuild.log
/*std*.log
/*build
/src/uibasetests_en.ts
/install
/tests/cmake/build
41 changes: 34 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,44 @@
cmake_minimum_required(VERSION 3.16)

include(CMakePackageConfigHelpers)

project(uibase)

if(DEFINED DEPENDENCIES_DIR)
include(${DEPENDENCIES_DIR}/modorganizer_super/cmake_common/mo2.cmake)
else()
include(${CMAKE_CURRENT_LIST_DIR}/../cmake_common/mo2.cmake)
endif()
find_package(mo2-cmake CONFIG REQUIRED)

add_subdirectory(src)

set(UIBASE_TESTS ${UIBASE_TESTS} CACHE BOOL "build tests for uibase")
if (UIBASE_TESTS)
mo2_set_project_to_run_from_install(uibase EXECUTABLE ${CMAKE_INSTALL_PREFIX}/bin/ModOrganizer.exe)
set_property(DIRECTORY ${PROJECT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT uibase)

configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/mo2-uibase-config.cmake"
INSTALL_DESTINATION "lib/cmake/mo2-uibase"
NO_SET_AND_CHECK_MACRO
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)

file(READ "${CMAKE_CURRENT_SOURCE_DIR}/src/version.rc" uibase_version)
string(REGEX MATCH "#define VER_FILEVERSION\\s*([0-9]+),([0-9]+),([0-9]+)" _ ${uibase_version})
set(uibase_version_major ${CMAKE_MATCH_1})
set(uibase_version_minor ${CMAKE_MATCH_2})
set(uibase_version_patch ${CMAKE_MATCH_3})

write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/mo2-uibase-config-version.cmake"
VERSION "${uibase_version_major}.${uibase_version_minor}.${uibase_version_patch}"
COMPATIBILITY AnyNewerVersion
ARCH_INDEPENDENT
)

install(FILES
${CMAKE_CURRENT_BINARY_DIR}/mo2-uibase-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/mo2-uibase-config-version.cmake
DESTINATION lib/cmake/mo2-uibase
)

set(UIBASE_TESTING ${UIBASE_TESTING} CACHE BOOL "build tests for uibase")
if (UIBASE_TESTING)
enable_testing()
add_subdirectory(tests)
endif()
66 changes: 66 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"configurePresets": [
{
"errors": {
"deprecated": true
},
"hidden": true,
"name": "cmake-dev",
"warnings": {
"deprecated": true,
"dev": true
}
},
{
"cacheVariables": {
"VCPKG_MANIFEST_NO_DEFAULT_FEATURES": {
"type": "BOOL",
"value": "ON"
}
},
"toolchainFile": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"hidden": true,
"name": "vcpkg"
},
{
"cacheVariables": {
"VCPKG_MANIFEST_FEATURES": {
"type": "STRING",
"value": "testing"
}
},
"hidden": true,
"inherits": ["vcpkg"],
"name": "vcpkg-dev"
},
{
"binaryDir": "${sourceDir}/vsbuild",
"architecture": {
"strategy": "set",
"value": "x64"
},
"cacheVariables": {
"CMAKE_CXX_FLAGS": "/EHsc /MP /W4",
"VCPKG_TARGET_TRIPLET": {
"type": "STRING",
"value": "x64-windows-static-md"
}
},
"generator": "Visual Studio 17 2022",
"inherits": ["cmake-dev", "vcpkg-dev"],
"name": "vs2022-windows",
"toolset": "v143"
},
{
"cacheVariables": {
"VCPKG_MANIFEST_FEATURES": {
"type": "STRING",
"value": "standalone;testing"
}
},
"inherits": "vs2022-windows",
"name": "vs2022-windows-standalone"
}
],
"version": 4
}
57 changes: 55 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,56 @@
[![Build status](https://ci.appveyor.com/api/projects/status/g8c6tujn0pne6tsk?svg=true)](https://ci.appveyor.com/project/Modorganizer2/modorganizer-uibase)

# modorganizer-uibase

[![Build status](https://github.com/ModOrganizer2/modorganizer-uibase/actions/workflows/build.yml/badge.svg?branch=dev/vcpkg)](https://github.com/ModOrganizer2/modorganizer-uibase/actions)
[![Lint status]](https://github.com/ModOrganizer2/modorganizer-uibase/actions/workflows/linting.yml/badge.svg?branch=dev/vcpkg)](<https://github.com/ModOrganizer2/modorganizer-uibase/actions>)

## How to build?

```pwsh
# set to the appropriate path for Qt
$env:QT_ROOT = "C:\Qt\6.7.0\msvc2019_64"

# set to the appropriate path for VCPKG
$env:VCPKG_ROOT = "C:\vcpkg"

cmake --preset vs2022-windows "-DCMAKE_PREFIX_PATH=$env:QT_ROOT" `
-DCMAKE_INSTALL_PREFIX=install `
-DUIBASE_TESTING=ON

# build uibase
cmake --build vsbuild --config RelWithDebInfo

# install uibase
cmake --install vsbuild --config RelWithDebInfo

# test uibase
ctest --test-dir vsbuild -C RelWithDebInfo --output-on-failure
```

Check [`CMakePresets.json`](CMakePresets.json) for some predefined values. Extra options
include:

- `UIBASE_TESTING` - if specified, build tests for UIBase, requires the VCPKG `testing`
feature to be enabled (enabled in the preset).

## How to use?

### As a VCPKG dependency

**Not implemented yet.**

### As a CMake target

Once the CMake targets for `uibase` are generated (see _How to build?_), you can include
`mo2::uibase` in your project:

1. Add `install/lib` to your `CMAKE_PREFIX_PATH` (replace `install` by the install
location specified during build).
2. Use `uibase` in your `CMakeLists.txt`:

```cmake
find_package(mo2-uibase CONFIG REQUIRED)

add_library(myplugin SHARED)

target_link_libraries(myplugin PRIVATE mo2::uibase)
```
13 changes: 13 additions & 0 deletions cmake/config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@PACKAGE_INIT@

set(_UIBASE_PREFIX_DIR ${PACKAGE_PREFIX_DIR})

find_package(Qt6 CONFIG REQUIRED COMPONENTS Network QuickWidgets Widgets)

include ( "${CMAKE_CURRENT_LIST_DIR}/mo2-uibase-targets.cmake" )


if (MO2_CMAKE_DEPRECATED_UIBASE_INCLUDE)
target_include_directories(mo2::uibase INTERFACE
${_UIBASE_PREFIX_DIR}/include/uibase ${_UIBASE_PREFIX_DIR}/include/uibase/game_features)
endif()
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions src/exceptions.h → include/uibase/exceptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <stdexcept>

#include <QObject>
#include <QString>

#include "dllimport.h"
Expand All @@ -19,6 +20,8 @@ namespace MOBase
class QDLLEXPORT Exception : public std::exception
{
public:
Exception(const char* text) : m_Message(text) {}
Exception(const std::string& text) : m_Message(QByteArray::fromStdString(text)) {}
Exception(const QString& text) : m_Message(text.toUtf8()) {}

virtual const char* what() const noexcept override { return m_Message.constData(); }
Expand Down
File renamed without changes.
File renamed without changes.
Loading
Loading