Skip to content
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
74 changes: 63 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,78 @@ name: Build UIBase

on:
push:
branches: master
branches: [master]
tags:
- "*"
pull_request:
types: [opened, synchronize, reopened]

env:
VCPKG_BINARY_SOURCES: clear;x-azblob,${{ vars.AZ_BLOB_VCPKG_URL }},${{ secrets.AZ_BLOB_SAS }},readwrite

jobs:
build:
runs-on: windows-2022
steps:
- name: Build UI Base
id: build-uibase
- name: Configure UIBase
id: configure-uibase
uses: ModOrganizer2/build-with-mob-action@master
with:
mo2-third-parties: gtest spdlog boost
mo2-dependencies: cmake_common
mo2-cmake-command: -DUIBASE_TESTS=1 ..
# skip build because we are going to build both Debug and RelWithDebInfo here
mo2-skip-build: true

- name: Build UI Base Tests
run: cmake --build vsbuild --config RelWithDebInfo -j4 --target uibase-tests
working-directory: ${{ steps.build-uibase.outputs.working-directory }}
# build both Debug and RelWithDebInfo for package
- name: Build UI Base
working-directory: ${{ steps.configure-uibase.outputs.working-directory }}
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 }}
working-directory: ${{ steps.configure-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
working-directory: ${{ steps.configure-uibase.outputs.working-directory }}
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}\msvc2022_64;${{ github.workspace }}\install\lib\cmake\"
cmake --build build --config Debug
cmake --build build --config Release
cmake --build build --config RelWithDebInfo
working-directory: ${{ steps.configure-uibase.outputs.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
20 changes: 20 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-merge-conflict
- id: check-case-conflict
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v19.1.5
hooks:
- id: clang-format
'types_or': [c++, c]

ci:
autofix_commit_msg: "[pre-commit.ci] Auto fixes from pre-commit.com hooks."
autofix_prs: true
autoupdate_commit_msg: "[pre-commit.ci] Pre-commit autoupdate."
autoupdate_schedule: quarterly
submodules: false
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(BUILD_TESTING ${BUILD_TESTING} CACHE BOOL "build tests for uibase")
if (BUILD_TESTING)
enable_testing()
add_subdirectory(tests)
endif()
73 changes: 73 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"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"
}
],
"buildPresets": [
{
"name": "vs2022-windows",
"resolvePackageReferences": "on",
"configurePreset": "vs2022-windows"
}
],
"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 `
-DBUILD_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:

- `BUILD_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.
1 change: 1 addition & 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 Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/formatters.h → include/uibase/formatters.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
#include "./formatters/enums.h"
#include "./formatters/qt.h"
#include "./formatters/random_access_containers.h"
#include "./formatters/strings.h"
#include "./formatters/strings.h"
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,4 @@ class IGameFeatures

} // namespace MOBase

#endif
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

#include <QDir>

#include "../filemapping.h"
#include "./game_feature.h"
#include "filemapping.h"

namespace MOBase
{
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/ifiletree.h → include/uibase/ifiletree.h
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ class QDLLEXPORT IFileTree : public virtual FileTreeEntry
*/
QString pathTo(std::shared_ptr<const FileTreeEntry> entry, QString sep = "\\") const
{
return entry->pathFrom(astree());
return entry->pathFrom(astree(), sep);
}

public: // Walk operations
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 8 additions & 2 deletions src/imoinfo.h → include/uibase/imoinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#include <any>
#include <functional>

#include "game_feature.h"
#include "game_features/game_feature.h"
#include "guessedvalue.h"
#include "imodlist.h"
#include "iprofile.h"
#include "versioninfo.h"
#include "versioning.h"

namespace MOBase
{
Expand Down Expand Up @@ -121,7 +122,12 @@ class QDLLEXPORT IOrganizer : public QObject
/**
* @return the running version of Mod Organizer
*/
virtual VersionInfo appVersion() const = 0;
[[deprecated]] virtual VersionInfo appVersion() const = 0;

/**
* @return the running version of Mod Organizer
*/
virtual Version version() const = 0;

/**
* @brief create a new mod with the specified name
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading