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
33 changes: 23 additions & 10 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,37 @@ name: Build & Test Plugin Python

on:
push:
branches: master
branches: [master]
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 Plugin Python
id: build-plugin-python
- uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Configure Plugin Python
id: configure-plugin-python
uses: ModOrganizer2/build-with-mob-action@master
with:
mo2-third-parties: gtest python spdlog boost sip pyqt pybind11
mo2-dependencies: cmake_common uibase
mo2-cmake-command: -DPLUGIN_PYTHON_TESTS=1 ..
- name: Build Plugin Python Tests
run: cmake --build vsbuild --config RelWithDebInfo -j4 --target python-tests --target runner-tests
working-directory: ${{ steps.build-plugin-python.outputs.working-directory }}
mo2-dependencies: uibase
mo2-skip-build: true

- name: Build Plugin Python
working-directory: ${{ steps.configure-plugin-python.outputs.working-directory }}
run: cmake --build vsbuild --config RelWithDebInfo --verbose `
--target python-tests --target runner-tests --target proxy

- name: Test Plugin Python
working-directory: ${{ steps.configure-plugin-python.outputs.working-directory }}
run: ctest --test-dir vsbuild -C RelWithDebInfo --output-on-failure
working-directory: ${{ steps.build-plugin-python.outputs.working-directory }}

- name: Install Plugin Python
working-directory: ${{ steps.configure-plugin-python.outputs.working-directory }}
run: cmake --build vsbuild --config RelWithDebInfo --target INSTALL
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
40 changes: 14 additions & 26 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,32 @@ cmake_minimum_required(VERSION 3.16)

cmake_policy(SET CMP0144 NEW)

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

project(plugin_python CXX)

set(PYTHON_BUILD_PATH ${PYTHON_ROOT}/PCBuild/amd64)
set(Python_FIND_VIRTUALENV STANDARD)

# find Python - lots of "Hints" since we have a weird setup
set(Python_USE_STATIC_LIBS False)
set(Python_INCLUDE_DIR ${PYTHON_ROOT}/Include)
set(Python_EXECUTABLE ${PYTHON_BUILD_PATH}/python.exe)
if (EXISTS "${PYTHON_BUILD_PATH}/python_d.exe")
set(Python_EXECUTABLE ${PYTHON_BUILD_PATH}/python_d.exe)
endif()
file(GLOB Python_LIBRARY ${PYTHON_BUILD_PATH}/python[0-9][0-9]*.lib)
find_package(Python COMPONENTS Interpreter Development REQUIRED)
# find Python before include mo2-cmake, otherwise this will trigger a bunch of CMP0111
# due to the imported configuration mapping variables defined in mo2.cmake
find_package(Python ${MO2_PYTHON_VERSION} COMPONENTS Interpreter Development REQUIRED)
find_package(pybind11 CONFIG REQUIRED)

# pybind11 needs uppercase (at least EXECUTABLE and LIBRARY)
set(PYTHON_EXECUTABLE ${Python_EXECUTABLE})
set(PYTHON_INCLUDE_DIR ${Python_INCLUDE_DIR})
set(PYTHON_LIBRARY ${Python_LIBRARY})
find_package(mo2-cmake CONFIG REQUIRED)

get_filename_component(Python_HOME ${Python_EXECUTABLE} PATH)
set(Python_DLL_DIR "${Python_HOME}/DLLs")
set(Python_LIB_DIR "${Python_HOME}/Lib")

mo2_python_install_pyqt()

# useful for naming DLL, zip, etc. (3.10 -> 310)
set(Python_VERSION_SHORT ${Python_VERSION_MAJOR}${Python_VERSION_MINOR})

# pybind11
add_subdirectory(${MO2_BUILD_PATH}/pybind11 ${CMAKE_CURRENT_BINARY_DIR}/pybind11)

# projects
add_subdirectory(src)
set_property(DIRECTORY ${PROJECT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT proxy)

# tests (if requested)
set(PLUGIN_PYTHON_TESTS ${PLUGIN_PYTHON_TESTS} CACHE BOOL "build tests for plugin_python")
if (PLUGIN_PYTHON_TESTS)
set(BUILD_TESTING ${BUILD_TESTING} CACHE BOOL "build tests for plugin_python")
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
}
34 changes: 30 additions & 4 deletions src/mobase/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,38 @@
cmake_minimum_required(VERSION 3.16)

find_package(Qt6 COMPONENTS Core)
find_package(mo2-uibase CONFIG REQUIRED)

pybind11_add_module(mobase MODULE)
mo2_configure_library(mobase
SOURCE_TREE
mo2_default_source_group()
mo2_configure_target(mobase
NO_SOURCES
WARNINGS 4
EXTERNAL_WARNINGS 4
AUTOMOC ON
TRANSLATIONS OFF
PRIVATE_DEPENDS uibase Qt::Core
)
target_link_libraries(mobase PRIVATE pybind11::qt pybind11::utils)
mo2_target_sources(mobase
FOLDER src
PRIVATE
deprecation.cpp
deprecation.h
mobase.cpp
pybind11_all.h
)
mo2_target_sources(mobase
FOLDER src/wrappers
PRIVATE
./wrappers/basic_classes.cpp
./wrappers/game_features.cpp
./wrappers/known_folders.h
./wrappers/pyfiletree.cpp
./wrappers/pyfiletree.h
./wrappers/pyplugins.cpp
./wrappers/pyplugins.h
./wrappers/utils.cpp
./wrappers/widgets.cpp
./wrappers/wrappers.cpp
./wrappers/wrappers.h
)
target_link_libraries(mobase PRIVATE pybind11::qt pybind11::utils mo2::uibase Qt6::Core)
2 changes: 1 addition & 1 deletion src/mobase/deprecation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include <QCoreApplication>

#include "log.h"
#include <uibase/log.h>

namespace py = pybind11;

Expand Down
17 changes: 0 additions & 17 deletions src/mobase/mobase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,6 @@
#include "wrappers/pyfiletree.h"
#include "wrappers/wrappers.h"

// TODO: remove these include (only for testing)
#include <QDir>
#include <QFile>
#include <QWidget>
#include <iplugin.h>
#include <iplugindiagnose.h>
#include <ipluginfilemapper.h>
#include <iplugingame.h>
#include <iplugininstaller.h>
#include <iplugininstallersimple.h>
#include <ipluginlist.h>
#include <ipluginmodpage.h>
#include <ipluginpreview.h>
#include <iplugintool.h>
#include <isavegame.h>
#include <isavegameinfowidget.h>

using namespace MOBase;
namespace py = pybind11;

Expand Down
6 changes: 3 additions & 3 deletions src/mobase/pybind11_all.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
#include "pybind11_utils/shared_cpp_owner.h"
#include "pybind11_utils/smart_variant_wrapper.h"

#include <game_feature.h>
#include <isavegame.h>
#include <pluginrequirements.h>
#include <uibase/game_features/game_feature.h>
#include <uibase/isavegame.h>
#include <uibase/pluginrequirements.h>

namespace mo2::python {

Expand Down
Loading