mirror of
https://github.com/ModOrganizer2/modorganizer-plugin_python.git
synced 2026-07-27 14:03:33 -07:00
Compare commits
266
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
67abab0779 | ||
|
|
b0ef81214a | ||
|
|
b2ae43a0e5 | ||
|
|
52dd7454be | ||
|
|
059dc8b9d2 | ||
|
|
b8bcecbed4 | ||
|
|
42e559b59c | ||
|
|
b7d343a8dd | ||
|
|
63a6c504b0 | ||
|
|
19dcdd95c0 | ||
|
|
ac5540ba87 | ||
|
|
0708bdedbf | ||
|
|
2b6f453fbc | ||
|
|
4f86e542cc | ||
|
|
e280b07cb6 | ||
|
|
0c11e75f0f | ||
|
|
ab72c2f42f | ||
|
|
cbe679aad8 | ||
|
|
59e5f1acf2 | ||
|
|
d0598cd849 | ||
|
|
174abb3cea | ||
|
|
dee8825960 | ||
|
|
46a4ee8653 | ||
|
|
4721ab35df | ||
|
|
352e5c2103 | ||
|
|
78278ae57d | ||
|
|
3eb85cd17f | ||
|
|
208965b96d | ||
|
|
c17d703b15 | ||
|
|
65eb0c6374 | ||
|
|
97a20d522a | ||
|
|
caee1fb7f6 | ||
|
|
bab649af43 | ||
|
|
30ab7b8e14 | ||
|
|
956d481ca4 | ||
|
|
41a4f273d6 | ||
|
|
66391098b6 | ||
|
|
c9d77cf948 | ||
|
|
b939f7e88e | ||
|
|
be6b102599 | ||
|
|
a1bc87e75a | ||
|
|
4160dea823 | ||
|
|
1bd5dda7d8 | ||
|
|
9780aeb477 | ||
|
|
f6d41a1a81 | ||
|
|
69ff972b12 | ||
|
|
ada342e818 | ||
|
|
051c14fe72 | ||
|
|
f841a3b13a | ||
|
|
60701b6ba0 | ||
|
|
a8cf8d45f3 | ||
|
|
84c04c32dc | ||
|
|
6ce4138b31 | ||
|
|
d1f6766e16 | ||
|
|
aa2b0744f7 | ||
|
|
f1997b4788 | ||
|
|
423e6f8842 | ||
|
|
b5b547e041 | ||
|
|
61977d6149 | ||
|
|
fbf59519c0 | ||
|
|
08bcebe19c | ||
|
|
4900135130 | ||
|
|
b70fa8174e | ||
|
|
437d89fc04 | ||
|
|
51b59de04d | ||
|
|
19015289cb | ||
|
|
e004b56dc9 | ||
|
|
fba18c2b96 | ||
|
|
00c38f5f03 | ||
|
|
8919fbd351 | ||
|
|
6a3a257ecd | ||
|
|
ec4945db3e | ||
|
|
9f975b92b2 | ||
|
|
17c86ef540 | ||
|
|
7ab4b71ed3 | ||
|
|
61ecb68918 | ||
|
|
94886104f3 | ||
|
|
902024e508 | ||
|
|
0a9b4b9fc4 | ||
|
|
028c14a951 | ||
|
|
bf8f427cd8 | ||
|
|
8fe091ab48 | ||
|
|
8877fee4fa | ||
|
|
f13a5961df | ||
|
|
7b6ca76dec | ||
|
|
a35208d902 | ||
|
|
4feb06a099 | ||
|
|
0abbab9f8c | ||
|
|
86d859d430 | ||
|
|
5a730941db | ||
|
|
c70f78adfe | ||
|
|
e8af8819df | ||
|
|
de809c6d57 | ||
|
|
01168483c5 | ||
|
|
317f13177e | ||
|
|
c47b94d534 | ||
|
|
ca51a53d41 | ||
|
|
9722d5b093 | ||
|
|
2df983e22c | ||
|
|
52417d64e4 | ||
|
|
4a558d4caf | ||
|
|
8dd9a710b4 | ||
|
|
377199f233 | ||
|
|
18a73c2f54 | ||
|
|
fba28bb9ab | ||
|
|
cdbc0f3bdb | ||
|
|
ffbd4e3f11 | ||
|
|
e1ba01777d | ||
|
|
9cbb35d354 | ||
|
|
abff0e890d | ||
|
|
c076d7a8bb | ||
|
|
e277c9b56b | ||
|
|
d8ad6569ba | ||
|
|
e08b8be570 | ||
|
|
aca861194d | ||
|
|
fdffe6f277 | ||
|
|
341daf5c5f | ||
|
|
b272bd12fe | ||
|
|
d6b673f149 | ||
|
|
81ec421adb | ||
|
|
f3fa0baa41 | ||
|
|
9a3465cc7a | ||
|
|
277a2862b1 | ||
|
|
046e080943 | ||
|
|
af7823b920 | ||
|
|
d408512a2c | ||
|
|
10437e0aca | ||
|
|
c6e8a223e1 | ||
|
|
425ec8df5a | ||
|
|
39e17ebbe3 | ||
|
|
fc0a257b51 | ||
|
|
fe87c841a8 | ||
|
|
705d423839 | ||
|
|
9dff2ab02e | ||
|
|
1bc41a72b4 | ||
|
|
d212bff9e9 | ||
|
|
85cb9b18e4 | ||
|
|
6a5ab7f747 | ||
|
|
539b068b71 | ||
|
|
96dbb56467 | ||
|
|
ea408a05af | ||
|
|
fa66025024 | ||
|
|
3e61a88abb | ||
|
|
828e35a129 | ||
|
|
cc58ccc992 | ||
|
|
aa37f30c68 | ||
|
|
f9353e4da0 | ||
|
|
9a310229e7 | ||
|
|
a78db4cbdc | ||
|
|
9502ea561e | ||
|
|
179deda6e4 | ||
|
|
fa85cc89d3 | ||
|
|
ee31647014 | ||
|
|
4bb0994d71 | ||
|
|
4b8b75e641 | ||
|
|
2fcb932e16 | ||
|
|
40192cb583 | ||
|
|
163e3d4544 | ||
|
|
a65763fb58 | ||
|
|
d144d7c97b | ||
|
|
de99a71085 | ||
|
|
9bdb48c6bc | ||
|
|
a20b166290 | ||
|
|
d1b2259cc5 | ||
|
|
4bb048aa67 | ||
|
|
0b53e86e5a | ||
|
|
9077573b9d | ||
|
|
0fa436fc0f | ||
|
|
d75eda53fc | ||
|
|
a71566122e | ||
|
|
69b988eede | ||
|
|
c106d6f342 | ||
|
|
4a6f8e84f4 | ||
|
|
efc0b1962f | ||
|
|
8f408a77d2 | ||
|
|
dccc265364 | ||
|
|
aa9c6ead94 | ||
|
|
f94f37b635 | ||
|
|
9fdcde3bd5 | ||
|
|
11c92e7e96 | ||
|
|
287a82ed48 | ||
|
|
c9299bb623 | ||
|
|
7d6d51b213 | ||
|
|
e60121b21f | ||
|
|
7f7a3fb1ca | ||
|
|
9ba337ef17 | ||
|
|
1455bda2f8 | ||
|
|
cc62f15cc8 | ||
|
|
0b9a56fa7a | ||
|
|
fc8f6c77bc | ||
|
|
55e9c9c7b6 | ||
|
|
47e25da95e | ||
|
|
cb5d3b4e62 | ||
|
|
542ef73a30 | ||
|
|
f6d499e6c6 | ||
|
|
fe2169650e | ||
|
|
07798f2e23 | ||
|
|
86d2ce34f3 | ||
|
|
88846e52f5 | ||
|
|
27704407a3 | ||
|
|
3648690c5e | ||
|
|
97787553f7 | ||
|
|
10fd3e77d7 | ||
|
|
f806d29a75 | ||
|
|
25ac05622a | ||
|
|
f29d9ac993 | ||
|
|
d8f49b3906 | ||
|
|
25d9ad16c2 | ||
|
|
a5901d7975 | ||
|
|
a7b81418a5 | ||
|
|
560e1ce0c7 | ||
|
|
6edbec745d | ||
|
|
d6edcf4fa0 | ||
|
|
50a725a1b4 | ||
|
|
a1fdb54471 | ||
|
|
e602014dda | ||
|
|
90df417a8c | ||
|
|
cb9a7fcd2d | ||
|
|
9d2264aff8 | ||
|
|
0aeeb9365f | ||
|
|
3967d64437 | ||
|
|
a7e881869e | ||
|
|
3f66d206e8 | ||
|
|
9d48b75388 | ||
|
|
841b923751 | ||
|
|
23fd430605 | ||
|
|
1a89e42c0f | ||
|
|
42afc90c8d | ||
|
|
9b989e9f97 | ||
|
|
c7203bf9de | ||
|
|
a7d626c83c | ||
|
|
bbea63e7af | ||
|
|
9f607a5fcb | ||
|
|
b7edde6fa0 | ||
|
|
589325d91b | ||
|
|
994018a491 | ||
|
|
868ab93a1f | ||
|
|
7c8fafc196 | ||
|
|
dec620b5b7 | ||
|
|
29c66c621d | ||
|
|
5da6a9d3bd | ||
|
|
7b5f01b49d | ||
|
|
573be8c6b5 | ||
|
|
a738cef190 | ||
|
|
2c661da2da | ||
|
|
2bf3ba0984 | ||
|
|
fa09fd7635 | ||
|
|
b76c4a1869 | ||
|
|
84fe2b0307 | ||
|
|
e7e686c361 | ||
|
|
ae8b6a39b0 | ||
|
|
2dc9463951 | ||
|
|
1d4a4b485d | ||
|
|
d5838c7560 | ||
|
|
9cbf374166 | ||
|
|
f71bfff0e6 | ||
|
|
8aa2ab4eac | ||
|
|
46a0ce9e38 | ||
|
|
15e635741c | ||
|
|
f56c605479 | ||
|
|
617c76e9f8 | ||
|
|
96081888f1 | ||
|
|
af5958b0af | ||
|
|
b33293e49a | ||
|
|
dc3b60e578 | ||
|
|
fee774db45 |
@@ -0,0 +1,5 @@
|
|||||||
|
edit
|
||||||
|
CMakeLists.txt.user
|
||||||
|
/msbuild.log
|
||||||
|
/*std*.log
|
||||||
|
/*build
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12)
|
||||||
|
|
||||||
|
ADD_COMPILE_OPTIONS($<$<CXX_COMPILER_ID:MSVC>:/MP> $<$<CXX_COMPILER_ID:MSVC>:$<$<CONFIG:RELEASE>:/O2>> $<$<CXX_COMPILER_ID:MSVC>:$<$<CONFIG:RELWITHDEBINFO>:/O2>>)
|
||||||
|
|
||||||
|
SET(PROJ_NAME plugin_python)
|
||||||
|
|
||||||
|
PROJECT(${PROJ_NAME})
|
||||||
|
|
||||||
|
SET(DEPENDENCIES_DIR CACHE PATH "")
|
||||||
|
|
||||||
|
# hint to find qt in dependencies path
|
||||||
|
LIST(APPEND CMAKE_PREFIX_PATH ${QT_ROOT}/lib/cmake)
|
||||||
|
|
||||||
|
# need to install python
|
||||||
|
IF(EXISTS "${PYTHON_ROOT}/PCbuild/python37.dll")
|
||||||
|
INSTALL(FILES ${PYTHON_ROOT}/PCbuild/python37.dll DESTINATION bin)
|
||||||
|
INSTALL(FILES ${PYTHON_ROOT}/PCbuild/python37.pdb DESTINATION pdb)
|
||||||
|
ELSEIF(EXISTS "${PYTHON_ROOT}/PCbuild/amd64/python27.dll")
|
||||||
|
INSTALL(FILES ${PYTHON_ROOT}/PCbuild/amd64/python37.dll DESTINATION bin)
|
||||||
|
INSTALL(FILES ${PYTHON_ROOT}/PCbuild/amd64/python37.pdb DESTINATION pdb)
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
|
|
||||||
|
ADD_SUBDIRECTORY(src/runner)
|
||||||
|
ADD_SUBDIRECTORY(src/proxy)
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
version: 1.0.{build}
|
||||||
|
skip_branch_with_pr: true
|
||||||
|
image: Visual Studio 2019
|
||||||
|
environment:
|
||||||
|
WEBHOOK_URL:
|
||||||
|
secure: gOKbXaZM9ImtMD5XrYITvdyZUW/az082G9OIN1EC1Vbg57wBaeLhi49uGjxPw5GVujHku6kxN6ab89zhbS5GVeluR76GM83IbKV4Sh7udXzoYZZdg6YudtYHzdhCgUeiedpswbuczTq9ceIkkfSEWZuh/lMAAVVwvcGsJAnoPFw=
|
||||||
|
build:
|
||||||
|
parallel: true
|
||||||
|
build_script:
|
||||||
|
- cmd: >-
|
||||||
|
git clone --depth=1 --branch=%APPVEYOR_REPO_BRANCH% https://github.com/ModOrganizer2/modorganizer-umbrella.git c:\projects\modorganizer-umbrella 2> $null
|
||||||
|
|
||||||
|
mkdir c:\projects\modorganizer-build -type directory
|
||||||
|
|
||||||
|
cd c:\projects\modorganizer-umbrella
|
||||||
|
|
||||||
|
C:\Python37-x64\python.exe unimake.py -d c:\projects\modorganizer-build -s Appveyor_Build=True %APPVEYOR_PROJECT_NAME%
|
||||||
|
artifacts:
|
||||||
|
- path: build\src\proxy\plugin_python.dll
|
||||||
|
name: plugin_python_dll
|
||||||
|
- path: build\src\proxy\plugin_python.pdb
|
||||||
|
name: plugin_python_pdb
|
||||||
|
- path: build\src\proxy\plugin_python.lib
|
||||||
|
name: plugin_python_lib
|
||||||
|
- path: build\src\runner\pythonrunner.dll
|
||||||
|
name: pythonrunner_dll
|
||||||
|
- path: build\src\runner\pythonrunner.pdb
|
||||||
|
name: pythonrunner_pdb
|
||||||
|
- path: build\src\runner\pythonrunner.lib
|
||||||
|
name: pythonrunner_lib
|
||||||
|
on_success:
|
||||||
|
- ps: Set-Location -Path $env:APPVEYOR_BUILD_FOLDER
|
||||||
|
- ps: Invoke-RestMethod https://raw.githubusercontent.com/DiscordHooks/appveyor-discord-webhook/master/send.ps1 -o send.ps1
|
||||||
|
- ps: ./send.ps1 success $env:WEBHOOK_URL
|
||||||
|
on_failure:
|
||||||
|
- ps: Set-Location -Path $env:APPVEYOR_BUILD_FOLDER
|
||||||
|
- ps: Push-AppveyorArtifact ${env:APPVEYOR_BUILD_FOLDER}\stdout.log
|
||||||
|
- ps: Push-AppveyorArtifact ${env:APPVEYOR_BUILD_FOLDER}\stderr.log
|
||||||
|
- ps: Invoke-RestMethod https://raw.githubusercontent.com/DiscordHooks/appveyor-discord-webhook/master/send.ps1 -o send.ps1
|
||||||
|
- ps: ./send.ps1 failure $env:WEBHOOK_URL
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
CMAKE_MINIMUM_REQUIRED (VERSION 2.8.11)
|
||||||
|
|
||||||
|
CMAKE_POLICY(SET CMP0020 NEW)
|
||||||
|
CMAKE_POLICY(SET CMP0043 NEW)
|
||||||
|
|
||||||
|
SET(${PROJ_NAME}_SRCS proxypython.cpp)
|
||||||
|
|
||||||
|
SET(${PROJ_NAME}_HDRS
|
||||||
|
proxypython.h
|
||||||
|
resource.h)
|
||||||
|
|
||||||
|
SET(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||||
|
SET(CMAKE_AUTOMOC ON)
|
||||||
|
SET(CMAKE_AUTOUIC ON)
|
||||||
|
FIND_PACKAGE(Qt5Widgets REQUIRED)
|
||||||
|
FIND_PACKAGE(Qt5Network REQUIRED)
|
||||||
|
#QT5_WRAP_UI(${PROJ_NAME}_UIHDRS ${${PROJ_NAME}_FORMS})
|
||||||
|
|
||||||
|
SET(Boost_USE_STATIC_LIBS ON)
|
||||||
|
SET(Boost_USE_MULTITHREADED ON)
|
||||||
|
SET(Boost_USE_STATIC_RUNTIME OFF)
|
||||||
|
FIND_PACKAGE(Boost)
|
||||||
|
|
||||||
|
IF (Boost_FOUND)
|
||||||
|
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
|
||||||
|
ENDIF (Boost_FOUND)
|
||||||
|
|
||||||
|
SET(default_project_path "${DEPENDENCIES_DIR}/modorganizer_super")
|
||||||
|
GET_FILENAME_COMPONENT(${default_project_path} ${default_project_path} REALPATH)
|
||||||
|
|
||||||
|
SET(project_path "${default_project_path}" CACHE PATH "path to the other mo projects")
|
||||||
|
SET(lib_path "${project_path}/../../install/libs")
|
||||||
|
|
||||||
|
ADD_DEFINITIONS(-DUNICODE -D_UNICODE)
|
||||||
|
|
||||||
|
INCLUDE_DIRECTORIES(${project_path}/uibase/src
|
||||||
|
${CMAKE_SOURCE_DIR}/src/runner/
|
||||||
|
${PYTHON_ROOT}/Include)
|
||||||
|
LINK_DIRECTORIES(${lib_path})
|
||||||
|
|
||||||
|
|
||||||
|
ADD_LIBRARY(${PROJ_NAME} SHARED ${${PROJ_NAME}_HDRS} ${${PROJ_NAME}_SRCS} ${${PROJ_NAME}_UIHDRS})
|
||||||
|
TARGET_LINK_LIBRARIES(${PROJ_NAME}
|
||||||
|
Qt5::Widgets
|
||||||
|
Qt5::Network
|
||||||
|
${Boost_LIBRARIES}
|
||||||
|
uibase)
|
||||||
|
|
||||||
|
IF (MSVC)
|
||||||
|
SET_TARGET_PROPERTIES(${PROJ_NAME} PROPERTIES COMPILE_FLAGS "/std:c++latest")
|
||||||
|
ENDIF()
|
||||||
|
IF (MSVC AND CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||||
|
# 32 bits
|
||||||
|
SET_TARGET_PROPERTIES(${PROJ_NAME} PROPERTIES LINK_FLAGS "/LARGEADDRESSAWARE")
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
|
IF (NOT "${OPTIMIZE_COMPILE_FLAGS}" STREQUAL "")
|
||||||
|
SET_TARGET_PROPERTIES(${PROJ_NAME} PROPERTIES COMPILE_FLAGS_RELWITHDEBINFO ${OPTIMIZE_COMPILE_FLAGS})
|
||||||
|
ENDIF()
|
||||||
|
IF (NOT "${OPTIMIZE_LINK_FLAGS}" STREQUAL "")
|
||||||
|
SET_TARGET_PROPERTIES(${PROJ_NAME} PROPERTIES LINK_FLAGS_RELWITHDEBINFO ${OPTIMIZE_LINK_FLAGS})
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
|
###############
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
INSTALL(TARGETS ${PROJ_NAME}
|
||||||
|
RUNTIME DESTINATION bin/plugins)
|
||||||
|
INSTALL(FILES $<TARGET_PDB_FILE:${PROJ_NAME}>
|
||||||
|
DESTINATION pdb)
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
Import('qt_env')
|
||||||
|
|
||||||
|
env = qt_env.Clone()
|
||||||
|
|
||||||
|
env.AppendUnique(CPPDEFINES = [
|
||||||
|
'PROXYPYTHON_LIBRARY',
|
||||||
|
# suppress a few warnings caused by boost vs vc++ paranoia
|
||||||
|
'_SCL_SECURE_NO_WARNINGS'
|
||||||
|
])
|
||||||
|
|
||||||
|
env.AppendUnique(CPPPATH = [
|
||||||
|
'${BOOSTPATH}',
|
||||||
|
'..\\..\\pythonRunner'
|
||||||
|
])
|
||||||
|
|
||||||
|
env.AppendUnique(LIBS = 'shell32')
|
||||||
|
|
||||||
|
runner = env.File(os.path.join('..', '..', 'pythonRunner', 'pythonRunner.dll'))
|
||||||
|
|
||||||
|
runner_env = env.Clone()
|
||||||
|
runner_env.AppendUnique(CPPDEFINES = 'SCONS_BUILD')
|
||||||
|
runner_env.AppendUnique(CPPPATH = runner.dir)
|
||||||
|
|
||||||
|
# There's a whole load of unused C++ files in here.
|
||||||
|
lib = env.SharedLibrary('proxyPython', [ 'proxypython.cpp' ])
|
||||||
|
|
||||||
|
env.InstallModule(lib)
|
||||||
|
|
||||||
|
res = env['QT_USED_MODULES']
|
||||||
|
Return('res')
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef SCONS_BUILD
|
||||||
IDR_LOADER_DLL BINARY MOVEABLE PURE "..\\..\\pythonRunner\\debug\\pythonRunner.dll"
|
IDR_LOADER_DLL BINARY MOVEABLE PURE pythonRunner.dll
|
||||||
#else // _DEBUG
|
#else
|
||||||
IDR_LOADER_DLL BINARY MOVEABLE PURE "..\\..\\pythonRunner\\release\\pythonRunner.dll"
|
IDR_LOADER_DLL BINARY MOVEABLE PURE "..\\runner\\pythonRunner.dll"
|
||||||
#endif // _DEBUG
|
#endif
|
||||||
|
|||||||
@@ -8,9 +8,7 @@
|
|||||||
TARGET = proxyPython
|
TARGET = proxyPython
|
||||||
TEMPLATE = lib
|
TEMPLATE = lib
|
||||||
|
|
||||||
contains(QT_VERSION, "^5.*") {
|
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||||
QT += widgets
|
|
||||||
}
|
|
||||||
|
|
||||||
CONFIG += plugins
|
CONFIG += plugins
|
||||||
CONFIG += dll
|
CONFIG += dll
|
||||||
@@ -31,21 +29,20 @@ HEADERS += proxypython.h \
|
|||||||
|
|
||||||
OTHER_FILES += \
|
OTHER_FILES += \
|
||||||
proxypython.json \
|
proxypython.json \
|
||||||
embedrunner.rc
|
SConscript
|
||||||
|
|
||||||
RC_FILE += \
|
RC_FILE +=
|
||||||
embedrunner.rc
|
|
||||||
|
|
||||||
include(../plugin_template.pri)
|
include(../plugin_template.pri)
|
||||||
|
|
||||||
INCLUDEPATH += "../../pythonRunner" "$(BOOSTPATH)"
|
INCLUDEPATH += "../../pythonRunner" "$${BOOSTPATH}"
|
||||||
|
|
||||||
WINPWD = $$PWD
|
WINPWD = $$PWD
|
||||||
WINPWD ~= s,/,$$QMAKE_DIR_SEP,g
|
WINPWD ~= s,/,$$QMAKE_DIR_SEP,g
|
||||||
|
|
||||||
//QMAKE_POST_LINK += SET VS90COMNTOOLS=%VS100COMNTOOLS% $$escape_expand(\\n)
|
#QMAKE_POST_LINK += SET VS90COMNTOOLS=%VS100COMNTOOLS% $$escape_expand(\\n)
|
||||||
|
|
||||||
|
|
||||||
//QMAKE_POST_LINK += copy $$(PYTHONPATH)\\lib\\site-packages\\sip.pyd $$quote($$DSTDIR)\\plugins\\data\\ $$escape_expand(\\n)
|
#QMAKE_POST_LINK += copy $$(PYTHONPATH)\\lib\\site-packages\\sip.pyd $$quote($$DSTDIR)\\plugins\\data\\ $$escape_expand(\\n)
|
||||||
//QMAKE_POST_LINK += copy $$(PYTHONPATH)\\lib\\site-packages\\PyQt4\\QtCore.pyd $$quote($$DSTDIR)\\plugins\\data\\PyQt4\\ $$escape_expand(\\n)
|
#QMAKE_POST_LINK += copy $$(PYTHONPATH)\\lib\\site-packages\\PyQt4\\QtCore.pyd $$quote($$DSTDIR)\\plugins\\data\\PyQt4\\ $$escape_expand(\\n)
|
||||||
//QMAKE_POST_LINK += copy $$(PYTHONPATH)\\lib\\site-packages\\PyQt4\\QtGui.pyd $$quote($$DSTDIR)\\plugins\\data\\PyQt4\\ $$escape_expand(\\n)
|
#QMAKE_POST_LINK += copy $$(PYTHONPATH)\\lib\\site-packages\\PyQt4\\QtGui.pyd $$quote($$DSTDIR)\\plugins\\data\\PyQt4\\ $$escape_expand(\\n)
|
||||||
|
|||||||
@@ -1,213 +0,0 @@
|
|||||||
#include "proxypluginwrappers.h"
|
|
||||||
#include <boost/python.hpp>
|
|
||||||
#include <utility.h>
|
|
||||||
#include "error.h"
|
|
||||||
#include "gilock.h"
|
|
||||||
|
|
||||||
namespace bpy = boost::python;
|
|
||||||
|
|
||||||
using namespace MOBase;
|
|
||||||
|
|
||||||
|
|
||||||
#define PYCATCH catch (const bpy::error_already_set &) { reportPythonError(); throw MyException("unhandled exception"); }\
|
|
||||||
catch (...) { throw MyException("An unknown exception was thrown in python code"); }
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////
|
|
||||||
/// IPluginTool Wrapper
|
|
||||||
|
|
||||||
|
|
||||||
bool IPluginToolWrapper::init(MOBase::IOrganizer *moInfo)
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
return this->get_override("init")(bpy::ptr(moInfo));
|
|
||||||
} PYCATCH;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString IPluginToolWrapper::name() const
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
return this->get_override("name")();
|
|
||||||
} PYCATCH;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString IPluginToolWrapper::author() const
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
return this->get_override("author")();
|
|
||||||
} PYCATCH;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString IPluginToolWrapper::description() const
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
return this->get_override("description")();
|
|
||||||
} PYCATCH;
|
|
||||||
}
|
|
||||||
|
|
||||||
MOBase::VersionInfo IPluginToolWrapper::version() const
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
return this->get_override("version")();
|
|
||||||
} PYCATCH;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IPluginToolWrapper::isActive() const
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
return this->get_override("isActive")();
|
|
||||||
} PYCATCH;
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<MOBase::PluginSetting> IPluginToolWrapper::settings() const
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
return this->get_override("settings")();
|
|
||||||
} PYCATCH;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString IPluginToolWrapper::displayName() const
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
return this->get_override("displayName")();
|
|
||||||
} PYCATCH;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString IPluginToolWrapper::tooltip() const
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
return this->get_override("tooltip")();
|
|
||||||
} PYCATCH;
|
|
||||||
}
|
|
||||||
|
|
||||||
QIcon IPluginToolWrapper::icon() const
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
return this->get_override("icon")();
|
|
||||||
} PYCATCH;
|
|
||||||
}
|
|
||||||
|
|
||||||
void IPluginToolWrapper::setParentWidget(QWidget *parent)
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
this->get_override("setParentWidget")(parent);
|
|
||||||
} PYCATCH;
|
|
||||||
}
|
|
||||||
|
|
||||||
void IPluginToolWrapper::display() const
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
GILock lock;
|
|
||||||
|
|
||||||
this->get_override("display")();
|
|
||||||
} PYCATCH;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// end IPluginTool Wrapper
|
|
||||||
/////////////////////////////////////
|
|
||||||
/// IPluginInstallerCustom Wrapper
|
|
||||||
|
|
||||||
|
|
||||||
bool IPluginInstallerCustomWrapper::init(MOBase::IOrganizer *moInfo)
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
return this->get_override("init")(bpy::ptr(moInfo));
|
|
||||||
} PYCATCH;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString IPluginInstallerCustomWrapper::name() const
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
return this->get_override("name")();
|
|
||||||
} PYCATCH;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString IPluginInstallerCustomWrapper::author() const
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
return this->get_override("author")();
|
|
||||||
} PYCATCH;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString IPluginInstallerCustomWrapper::description() const
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
return this->get_override("description")();
|
|
||||||
} PYCATCH;
|
|
||||||
}
|
|
||||||
|
|
||||||
MOBase::VersionInfo IPluginInstallerCustomWrapper::version() const
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
return this->get_override("version")();
|
|
||||||
} PYCATCH;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IPluginInstallerCustomWrapper::isActive() const
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
return this->get_override("isActive")();
|
|
||||||
} PYCATCH;
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<MOBase::PluginSetting> IPluginInstallerCustomWrapper::settings() const
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
return this->get_override("settings")();
|
|
||||||
} PYCATCH;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int IPluginInstallerCustomWrapper::priority() const
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
return this->get_override("priority")();
|
|
||||||
} PYCATCH;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IPluginInstallerCustomWrapper::isManualInstaller() const
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
return this->get_override("isManualInstaller")();
|
|
||||||
} PYCATCH;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IPluginInstallerCustomWrapper::isArchiveSupported(const DirectoryTree &tree) const
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
//return this->get_override("isArchiveSupported")(tree);
|
|
||||||
return false;
|
|
||||||
} PYCATCH;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IPluginInstallerCustomWrapper::isArchiveSupported(const QString &archiveName) const
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
return this->get_override("isArchiveSupported")(archiveName);
|
|
||||||
} PYCATCH;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::set<QString> IPluginInstallerCustomWrapper::supportedExtensions() const
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
return this->get_override("supportedExtensions")();
|
|
||||||
} PYCATCH;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
IPluginInstaller::EInstallResult IPluginInstallerCustomWrapper::install(GuessedValue<QString> &modName, const QString &archiveName,
|
|
||||||
const QString &version, int modID)
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
return this->get_override("install")(modName, archiveName, version, modID);
|
|
||||||
} PYCATCH;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void IPluginInstallerCustomWrapper::setParentWidget(QWidget *parent)
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
this->get_override("setParentWidget")(parent);
|
|
||||||
} PYCATCH;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,80 +0,0 @@
|
|||||||
#ifndef PROXYPLUGINWRAPPERS_H
|
|
||||||
#define PROXYPLUGINWRAPPERS_H
|
|
||||||
|
|
||||||
|
|
||||||
#include <iplugintool.h>
|
|
||||||
#include <iplugininstallersimple.h>
|
|
||||||
#include <iplugininstallercustom.h>
|
|
||||||
#include <iplugindiagnose.h>
|
|
||||||
|
|
||||||
#ifndef Q_MOC_RUN
|
|
||||||
#include <boost/python.hpp>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
class IPluginWrapper : public boost::python::wrapper<MOBase::IPlugin>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual bool init(MOBase::IOrganizer *moInfo);
|
|
||||||
virtual QString name() const;
|
|
||||||
virtual QString author() const;
|
|
||||||
virtual QString description() const;
|
|
||||||
virtual MOBase::VersionInfo version() const;
|
|
||||||
virtual bool isActive() const;
|
|
||||||
virtual QList<MOBase::PluginSetting> settings() const;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class IPluginToolWrapper: public MOBase::IPluginTool, public boost::python::wrapper<MOBase::IPluginTool>
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
Q_INTERFACES(MOBase::IPlugin MOBase::IPluginTool)
|
|
||||||
|
|
||||||
public:
|
|
||||||
virtual bool init(MOBase::IOrganizer *moInfo);
|
|
||||||
virtual QString name() const;
|
|
||||||
virtual QString author() const;
|
|
||||||
virtual QString description() const;
|
|
||||||
virtual MOBase::VersionInfo version() const;
|
|
||||||
virtual bool isActive() const;
|
|
||||||
virtual QList<MOBase::PluginSetting> settings() const;
|
|
||||||
|
|
||||||
virtual QString displayName() const;
|
|
||||||
virtual QString tooltip() const;
|
|
||||||
virtual QIcon icon() const;
|
|
||||||
virtual void setParentWidget(QWidget *parent);
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
virtual void display() const;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class IPluginInstallerCustomWrapper: public MOBase::IPluginInstallerCustom, public boost::python::wrapper<MOBase::IPluginInstallerCustom>
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
Q_INTERFACES(MOBase::IPlugin MOBase::IPluginInstaller MOBase::IPluginInstallerCustom)
|
|
||||||
|
|
||||||
public:
|
|
||||||
virtual bool init(MOBase::IOrganizer *moInfo);
|
|
||||||
virtual QString name() const;
|
|
||||||
virtual QString author() const;
|
|
||||||
virtual QString description() const;
|
|
||||||
virtual MOBase::VersionInfo version() const;
|
|
||||||
virtual bool isActive() const;
|
|
||||||
virtual QList<MOBase::PluginSetting> settings() const;
|
|
||||||
|
|
||||||
virtual unsigned int priority() const;
|
|
||||||
virtual bool isManualInstaller() const;
|
|
||||||
virtual bool isArchiveSupported(const MOBase::DirectoryTree &tree) const;
|
|
||||||
virtual bool isArchiveSupported(const QString &archiveName) const;
|
|
||||||
virtual std::set<QString> supportedExtensions() const;
|
|
||||||
virtual EInstallResult install(MOBase::GuessedValue<QString> &modName, const QString &archiveName,
|
|
||||||
const QString &version, int modID);
|
|
||||||
virtual void setParentWidget(QWidget *parent);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif // PROXYPLUGINWRAPPERS_H
|
|
||||||
+39
-26
@@ -37,7 +37,7 @@ const char *ProxyPython::s_DownloadPythonURL = "http://www.python.org/download/r
|
|||||||
|
|
||||||
HMODULE GetOwnModuleHandle()
|
HMODULE GetOwnModuleHandle()
|
||||||
{
|
{
|
||||||
HMODULE hMod = NULL;
|
HMODULE hMod = nullptr;
|
||||||
GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
|
GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
|
||||||
reinterpret_cast<LPCWSTR>(&GetOwnModuleHandle), &hMod);
|
reinterpret_cast<LPCWSTR>(&GetOwnModuleHandle), &hMod);
|
||||||
|
|
||||||
@@ -50,29 +50,48 @@ QString ExtractResource(WORD resourceID, const QString &szFilename)
|
|||||||
HMODULE mod = GetOwnModuleHandle();
|
HMODULE mod = GetOwnModuleHandle();
|
||||||
|
|
||||||
HRSRC hResource = FindResourceW(mod, MAKEINTRESOURCE(resourceID), L"BINARY");
|
HRSRC hResource = FindResourceW(mod, MAKEINTRESOURCE(resourceID), L"BINARY");
|
||||||
if (hResource == NULL) {
|
if (hResource == nullptr) {
|
||||||
throw MyException("embedded dll not available: " + windowsErrorString(::GetLastError()));
|
throw MyException("embedded dll not available: " + windowsErrorString(::GetLastError()));
|
||||||
}
|
}
|
||||||
|
|
||||||
HGLOBAL hFileResource = LoadResource(mod, hResource);
|
HGLOBAL hFileResource = LoadResource(mod, hResource);
|
||||||
if (hFileResource == NULL) {
|
if (hFileResource == nullptr) {
|
||||||
throw MyException("failed to load embedded dll resource: " + windowsErrorString(::GetLastError()));
|
throw MyException("failed to load embedded dll resource: " + windowsErrorString(::GetLastError()));
|
||||||
}
|
}
|
||||||
|
|
||||||
LPVOID lpFile = LockResource(hFileResource);
|
LPVOID lpFile = LockResource(hFileResource);
|
||||||
|
if (lpFile == nullptr) {
|
||||||
|
throw MyException(QString("failed to lock resource: %1").arg(windowsErrorString(::GetLastError())));
|
||||||
|
}
|
||||||
|
|
||||||
DWORD dwSize = SizeofResource(mod, hResource);
|
DWORD dwSize = SizeofResource(mod, hResource);
|
||||||
|
|
||||||
QString outFile = QDir::tempPath() + "/" + szFilename;
|
QString outFile = QDir::tempPath() + "/" + szFilename;
|
||||||
|
|
||||||
HANDLE hFile = CreateFileW(ToWString(outFile).c_str(), GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
HANDLE hFile = CreateFileW(outFile.toStdWString().c_str(), GENERIC_READ | GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||||
HANDLE hFileMap = CreateFileMapping(hFile, NULL, PAGE_READWRITE, 0, dwSize, NULL);
|
if (hFile == INVALID_HANDLE_VALUE) {
|
||||||
|
if (::GetLastError() == ERROR_SHARING_VIOLATION) {
|
||||||
|
// dll exists and is opened by another instance of MO, shouldn't be outdated then...
|
||||||
|
return outFile;
|
||||||
|
} else {
|
||||||
|
throw MyException(QString("failed to open python runner: %1").arg(windowsErrorString(::GetLastError())));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
HANDLE hFileMap = CreateFileMapping(hFile, nullptr, PAGE_READWRITE, 0, dwSize, nullptr);
|
||||||
|
if (hFileMap == NULL) {
|
||||||
|
throw MyException(QString("failed to map python runner: %1").arg(windowsErrorString(::GetLastError())));
|
||||||
|
}
|
||||||
LPVOID lpAddress = MapViewOfFile(hFileMap, FILE_MAP_WRITE, 0, 0, 0);
|
LPVOID lpAddress = MapViewOfFile(hFileMap, FILE_MAP_WRITE, 0, 0, 0);
|
||||||
|
if (lpAddress == nullptr) {
|
||||||
|
throw MyException(QString("failed to map view of file: %1").arg(windowsErrorString(::GetLastError())));
|
||||||
|
}
|
||||||
|
|
||||||
CopyMemory(lpAddress, lpFile, dwSize);
|
CopyMemory(lpAddress, lpFile, dwSize);
|
||||||
|
|
||||||
UnmapViewOfFile(lpAddress);
|
UnmapViewOfFile(lpAddress);
|
||||||
|
|
||||||
CloseHandle(hFileMap);
|
CloseHandle(hFileMap);
|
||||||
|
::FlushFileBuffers(hFile);
|
||||||
CloseHandle(hFile);
|
CloseHandle(hFile);
|
||||||
|
|
||||||
return outFile;
|
return outFile;
|
||||||
@@ -80,7 +99,7 @@ QString ExtractResource(WORD resourceID, const QString &szFilename)
|
|||||||
|
|
||||||
|
|
||||||
ProxyPython::ProxyPython()
|
ProxyPython::ProxyPython()
|
||||||
: m_MOInfo(NULL), m_Runner(NULL), m_LoadFailure(FAIL_NOTINIT)
|
: m_MOInfo(nullptr), m_Runner(nullptr), m_LoadFailure(FAIL_NOTINIT)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,11 +135,10 @@ bool ProxyPython::init(IOrganizer *moInfo)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_TempRunnerFile = ExtractResource(IDR_LOADER_DLL, "__pythonRunner.dll");
|
m_RunnerLib = ::LoadLibraryW(QDir::toNativeSeparators(m_MOInfo->pluginDataPath() + "/pythonRunner.dll").toStdWString().c_str());
|
||||||
m_RunnerLib = ::LoadLibraryW(ToWString(m_TempRunnerFile).c_str());
|
if (m_RunnerLib != nullptr) {
|
||||||
if (m_RunnerLib != NULL) {
|
|
||||||
CreatePythonRunner_func CreatePythonRunner = (CreatePythonRunner_func)::GetProcAddress(m_RunnerLib, "CreatePythonRunner");
|
CreatePythonRunner_func CreatePythonRunner = (CreatePythonRunner_func)::GetProcAddress(m_RunnerLib, "CreatePythonRunner");
|
||||||
if (CreatePythonRunner == NULL) {
|
if (CreatePythonRunner == nullptr) {
|
||||||
throw MyException("embedded dll is invalid: " + windowsErrorString(::GetLastError()));
|
throw MyException("embedded dll is invalid: " + windowsErrorString(::GetLastError()));
|
||||||
}
|
}
|
||||||
if (m_MOInfo->persistent(name(), "tryInit", false).toBool()) {
|
if (m_MOInfo->persistent(name(), "tryInit", false).toBool()) {
|
||||||
@@ -145,7 +163,7 @@ bool ProxyPython::init(IOrganizer *moInfo)
|
|||||||
m_Runner = CreatePythonRunner(moInfo, pythonPath);
|
m_Runner = CreatePythonRunner(moInfo, pythonPath);
|
||||||
m_MOInfo->setPersistent(name(), "tryInit", false);
|
m_MOInfo->setPersistent(name(), "tryInit", false);
|
||||||
|
|
||||||
if (m_Runner != NULL) {
|
if (m_Runner != nullptr) {
|
||||||
m_LoadFailure = FAIL_NONE;
|
m_LoadFailure = FAIL_NONE;
|
||||||
} else {
|
} else {
|
||||||
m_LoadFailure = FAIL_INITFAIL;
|
m_LoadFailure = FAIL_INITFAIL;
|
||||||
@@ -153,7 +171,7 @@ bool ProxyPython::init(IOrganizer *moInfo)
|
|||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
DWORD error = ::GetLastError();
|
DWORD error = ::GetLastError();
|
||||||
qCritical("Failed to load python runner: %s", qPrintable(windowsErrorString(error)));
|
qCritical("Failed to load python runner (%s): %s", qUtf8Printable(m_TempRunnerFile), qUtf8Printable(windowsErrorString(error)));
|
||||||
if (error == ERROR_MOD_NOT_FOUND) {
|
if (error == ERROR_MOD_NOT_FOUND) {
|
||||||
m_LoadFailure = FAIL_MISSINGDEPENDENCIES;
|
m_LoadFailure = FAIL_MISSINGDEPENDENCIES;
|
||||||
}
|
}
|
||||||
@@ -163,7 +181,7 @@ bool ProxyPython::init(IOrganizer *moInfo)
|
|||||||
|
|
||||||
QString ProxyPython::name() const
|
QString ProxyPython::name() const
|
||||||
{
|
{
|
||||||
return tr("Python Proxy");
|
return "Python Proxy";
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ProxyPython::author() const
|
QString ProxyPython::author() const
|
||||||
@@ -178,12 +196,12 @@ QString ProxyPython::description() const
|
|||||||
|
|
||||||
VersionInfo ProxyPython::version() const
|
VersionInfo ProxyPython::version() const
|
||||||
{
|
{
|
||||||
return VersionInfo(1, 2, 0, VersionInfo::RELEASE_FINAL);
|
return VersionInfo(2, 1, 0, VersionInfo::RELEASE_FINAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ProxyPython::isActive() const
|
bool ProxyPython::isActive() const
|
||||||
{
|
{
|
||||||
return m_LoadFailure == FAIL_NONE;
|
return m_LoadFailure == FAIL_NOTINIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<PluginSetting> ProxyPython::settings() const
|
QList<PluginSetting> ProxyPython::settings() const
|
||||||
@@ -207,13 +225,13 @@ QStringList ProxyPython::pluginList(const QString &pluginPath) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QObject *ProxyPython::instantiate(const QString &pluginName)
|
QList<QObject*> ProxyPython::instantiate(const QString &pluginName)
|
||||||
{
|
{
|
||||||
if (m_Runner != NULL) {
|
if (m_Runner != nullptr) {
|
||||||
QObject *result = m_Runner->instantiate(pluginName);
|
QList<QObject*> result = m_Runner->instantiate(pluginName);
|
||||||
return result;
|
return result;
|
||||||
} else {
|
} else {
|
||||||
return NULL;
|
return QList<QObject*>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,7 +249,7 @@ std::vector<unsigned int> ProxyPython::activeProblems() const
|
|||||||
result.push_back(PROBLEM_INITFAIL);
|
result.push_back(PROBLEM_INITFAIL);
|
||||||
} else if (m_LoadFailure == FAIL_SEMICOLON) {
|
} else if (m_LoadFailure == FAIL_SEMICOLON) {
|
||||||
result.push_back(PROBLEM_SEMICOLON);
|
result.push_back(PROBLEM_SEMICOLON);
|
||||||
} else if (m_Runner != NULL) {
|
} else if (m_Runner != nullptr) {
|
||||||
if (!m_Runner->isPythonInstalled()) {
|
if (!m_Runner->isPythonInstalled()) {
|
||||||
// don't know how this could happen but wth
|
// don't know how this could happen but wth
|
||||||
result.push_back(PROBLEM_PYTHONMISSING);
|
result.push_back(PROBLEM_PYTHONMISSING);
|
||||||
@@ -317,11 +335,6 @@ bool ProxyPython::hasGuidedFix(unsigned int key) const
|
|||||||
void ProxyPython::startGuidedFix(unsigned int key) const
|
void ProxyPython::startGuidedFix(unsigned int key) const
|
||||||
{
|
{
|
||||||
if ((key == PROBLEM_PYTHONMISSING) || (key == PROBLEM_PYTHONWRONGVERSION)) {
|
if ((key == PROBLEM_PYTHONMISSING) || (key == PROBLEM_PYTHONWRONGVERSION)) {
|
||||||
::ShellExecuteA(NULL, "open", s_DownloadPythonURL, NULL, NULL, SW_SHOWNORMAL);
|
::ShellExecuteA(nullptr, "open", s_DownloadPythonURL, nullptr, nullptr, SW_SHOWNORMAL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
|
|
||||||
Q_EXPORT_PLUGIN2(proxyPython, ProxyPython)
|
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ along with python proxy plugin. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#include <pythonrunner.h>
|
#include <pythonrunner.h>
|
||||||
|
|
||||||
|
|
||||||
class ProxyPython : public QObject, MOBase::IPluginProxy, MOBase::IPluginDiagnose
|
class ProxyPython : public QObject, public MOBase::IPluginProxy, public MOBase::IPluginDiagnose
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_INTERFACES(MOBase::IPlugin MOBase::IPluginProxy MOBase::IPluginDiagnose)
|
Q_INTERFACES(MOBase::IPlugin MOBase::IPluginProxy MOBase::IPluginDiagnose)
|
||||||
@@ -49,7 +49,7 @@ public:
|
|||||||
virtual QList<MOBase::PluginSetting> settings() const;
|
virtual QList<MOBase::PluginSetting> settings() const;
|
||||||
|
|
||||||
QStringList pluginList(const QString &pluginPath) const;
|
QStringList pluginList(const QString &pluginPath) const;
|
||||||
QObject *instantiate(const QString &pluginName);
|
QList<QObject*> instantiate(const QString &pluginName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the parent widget for newly created dialogs
|
* @return the parent widget for newly created dialogs
|
||||||
|
|||||||
@@ -1,112 +0,0 @@
|
|||||||
#include "pythonpluginwrapper.h"
|
|
||||||
|
|
||||||
|
|
||||||
using boost::python::extract;
|
|
||||||
using boost::python::handle_exception;
|
|
||||||
|
|
||||||
|
|
||||||
PythonPluginWrapper::PythonPluginWrapper(const boost::python::object &initFunction,
|
|
||||||
const boost::python::object &nameFunction,
|
|
||||||
const boost::python::object &authorFunction,
|
|
||||||
const boost::python::object &descriptionFunction,
|
|
||||||
const boost::python::object &versionFunction,
|
|
||||||
const boost::python::object &isActiveFunction,
|
|
||||||
const boost::python::object &settingsFunction)
|
|
||||||
: m_InitFunction(initFunction)
|
|
||||||
, m_NameFunction(nameFunction)
|
|
||||||
, m_AuthorFunction(authorFunction)
|
|
||||||
, m_DescriptionFunction(descriptionFunction)
|
|
||||||
, m_VersionFunction(versionFunction)
|
|
||||||
, m_IsActiveFunction(isActiveFunction)
|
|
||||||
, m_SettingsFunction(settingsFunction)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void PythonPluginWrapper::reportPythonError() const
|
|
||||||
{
|
|
||||||
if (PyErr_Occurred()) {
|
|
||||||
PyErr_Print();
|
|
||||||
} else {
|
|
||||||
qCritical("An unexpected C++ exception was thrown in python code");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool PythonPluginWrapper::init(MOBase::IOrganizer *moInfo)
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
return boost::python::extract<bool>(m_InitFunction(boost::python::ptr(moInfo)));
|
|
||||||
} catch (const boost::python::error_already_set&) {
|
|
||||||
reportPythonError();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QString PythonPluginWrapper::name() const
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
return boost::python::extract<QString>(m_NameFunction());
|
|
||||||
} catch (const boost::python::error_already_set&) {
|
|
||||||
reportPythonError();
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QString PythonPluginWrapper::author() const
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
return boost::python::extract<QString>(m_AuthorFunction());
|
|
||||||
} catch (const boost::python::error_already_set&) {
|
|
||||||
reportPythonError();
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QString PythonPluginWrapper::description() const
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
return boost::python::extract<QString>(m_DescriptionFunction());
|
|
||||||
} catch (const boost::python::error_already_set&) {
|
|
||||||
reportPythonError();
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MOBase::VersionInfo PythonPluginWrapper::version() const
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
return boost::python::extract<MOBase::VersionInfo>(m_VersionFunction());
|
|
||||||
} catch (const boost::python::error_already_set&) {
|
|
||||||
reportPythonError();
|
|
||||||
return MOBase::VersionInfo();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PythonPluginWrapper::isActive() const
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
return boost::python::extract<bool>(m_IsActiveFunction());
|
|
||||||
} catch (const boost::python::error_already_set&) {
|
|
||||||
reportPythonError();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<MOBase::PluginSetting> PythonPluginWrapper::settings() const
|
|
||||||
{
|
|
||||||
QList<MOBase::PluginSetting> result;
|
|
||||||
try {
|
|
||||||
boost::python::object l = m_SettingsFunction();
|
|
||||||
if (!l.is_none()) {
|
|
||||||
// boost::python::list l = extract<boost::python::list>(temp);
|
|
||||||
for (int i = 0; i < boost::python::len(l); ++i) {
|
|
||||||
result.append(extract<MOBase::PluginSetting>(l[i]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (const boost::python::error_already_set&) {
|
|
||||||
reportPythonError();
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
#ifndef PYTHONPLUGINWRAPPER_H
|
|
||||||
#define PYTHONPLUGINWRAPPER_H
|
|
||||||
|
|
||||||
#include <iplugin.h>
|
|
||||||
#ifndef Q_MOC_RUN
|
|
||||||
#include <boost/python.hpp>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class PythonPluginWrapper : public virtual MOBase::IPlugin
|
|
||||||
{
|
|
||||||
|
|
||||||
public:
|
|
||||||
PythonPluginWrapper(const boost::python::object &initFunction,
|
|
||||||
const boost::python::object &nameFunction,
|
|
||||||
const boost::python::object &authorFunction,
|
|
||||||
const boost::python::object &descriptionFunction,
|
|
||||||
const boost::python::object &versionFunction,
|
|
||||||
const boost::python::object &isActiveFunction,
|
|
||||||
const boost::python::object &settingsFunction);
|
|
||||||
|
|
||||||
virtual bool init(MOBase::IOrganizer *moInfo);
|
|
||||||
virtual QString name() const;
|
|
||||||
virtual QString author() const;
|
|
||||||
virtual QString description() const;
|
|
||||||
virtual MOBase::VersionInfo version() const;
|
|
||||||
virtual bool isActive() const;
|
|
||||||
virtual QList<MOBase::PluginSetting> settings() const;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void reportPythonError() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
boost::python::object m_InitFunction;
|
|
||||||
boost::python::object m_NameFunction;
|
|
||||||
boost::python::object m_AuthorFunction;
|
|
||||||
boost::python::object m_DescriptionFunction;
|
|
||||||
boost::python::object m_VersionFunction;
|
|
||||||
boost::python::object m_IsActiveFunction;
|
|
||||||
boost::python::object m_SettingsFunction;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // PYTHONPLUGINWRAPPER_H
|
|
||||||
@@ -1,80 +0,0 @@
|
|||||||
#include "pythontoolwrapper.h"
|
|
||||||
#include <QApplication>
|
|
||||||
#include <QWidget>
|
|
||||||
|
|
||||||
using boost::python::extract;
|
|
||||||
using boost::python::handle_exception;
|
|
||||||
|
|
||||||
PythonToolWrapper::PythonToolWrapper(const boost::python::object &initFunction,
|
|
||||||
const boost::python::object &nameFunction,
|
|
||||||
const boost::python::object &authorFunction,
|
|
||||||
const boost::python::object &descriptionFunction,
|
|
||||||
const boost::python::object &versionFunction,
|
|
||||||
const boost::python::object &isActiveFunction,
|
|
||||||
const boost::python::object &settingsFunction,
|
|
||||||
const boost::python::object &displayNameFunction,
|
|
||||||
const boost::python::object &tooltipFunction,
|
|
||||||
const boost::python::object &iconFunction,
|
|
||||||
const boost::python::object &displayFunction,
|
|
||||||
const boost::python::object &setParentWidget)
|
|
||||||
: PythonPluginWrapper(initFunction, nameFunction, authorFunction, descriptionFunction,
|
|
||||||
versionFunction, isActiveFunction, settingsFunction)
|
|
||||||
, m_DisplayNameFunction(displayNameFunction)
|
|
||||||
, m_ToolTipFunction(tooltipFunction)
|
|
||||||
, m_IconFunction(iconFunction)
|
|
||||||
, m_DisplayFunction(displayFunction)
|
|
||||||
, m_SetParentWidget(setParentWidget)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QString PythonToolWrapper::displayName() const
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
return boost::python::extract<QString>(m_DisplayNameFunction());
|
|
||||||
} catch (const boost::python::error_already_set&) {
|
|
||||||
reportPythonError();
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QString PythonToolWrapper::tooltip() const
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
return boost::python::extract<QString>(m_ToolTipFunction());
|
|
||||||
} catch (const boost::python::error_already_set&) {
|
|
||||||
reportPythonError();
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QIcon PythonToolWrapper::icon() const
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
std::vector<const char*> rows;
|
|
||||||
boost::python::object l = m_IconFunction();
|
|
||||||
if (!l.is_none()) {
|
|
||||||
for (int i = 0; i < boost::python::len(l); ++i) {
|
|
||||||
rows.push_back(extract<const char*>(l[i]));
|
|
||||||
}
|
|
||||||
return QIcon(QPixmap(&rows[0]));
|
|
||||||
} else {
|
|
||||||
return QIcon();
|
|
||||||
}
|
|
||||||
} catch (const boost::python::error_already_set&) {
|
|
||||||
reportPythonError();
|
|
||||||
return QIcon();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void PythonToolWrapper::display() const
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
m_SetParentWidget(parentWidget());
|
|
||||||
|
|
||||||
m_DisplayFunction();
|
|
||||||
} catch (const boost::python::error_already_set&) {
|
|
||||||
reportPythonError();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
#ifndef PYTHONTOOLWRAPPER_H
|
|
||||||
#define PYTHONTOOLWRAPPER_H
|
|
||||||
|
|
||||||
|
|
||||||
#include <iplugintool.h>
|
|
||||||
#ifndef Q_MOC_RUN
|
|
||||||
#include <boost/python.hpp>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "pythonpluginwrapper.h"
|
|
||||||
|
|
||||||
|
|
||||||
class PythonToolWrapper : public QObject, public MOBase::IPluginTool, public PythonPluginWrapper
|
|
||||||
{
|
|
||||||
|
|
||||||
Q_OBJECT
|
|
||||||
Q_INTERFACES(MOBase::IPlugin MOBase::IPluginTool)
|
|
||||||
|
|
||||||
public:
|
|
||||||
PythonToolWrapper(const boost::python::object &initFunction,
|
|
||||||
const boost::python::object &nameFunction,
|
|
||||||
const boost::python::object &authorFunction,
|
|
||||||
const boost::python::object &descriptionFunction,
|
|
||||||
const boost::python::object &versionFunction,
|
|
||||||
const boost::python::object &isActiveFunction,
|
|
||||||
const boost::python::object &settingsFunction,
|
|
||||||
const boost::python::object &displayNameFunction,
|
|
||||||
const boost::python::object &tooltipFunction,
|
|
||||||
const boost::python::object &iconFunction,
|
|
||||||
const boost::python::object &displayFunction,
|
|
||||||
const boost::python::object &setParentWidget);
|
|
||||||
|
|
||||||
using PythonPluginWrapper::init;
|
|
||||||
using PythonPluginWrapper::name;
|
|
||||||
|
|
||||||
virtual QString displayName() const;
|
|
||||||
virtual QString tooltip() const;
|
|
||||||
virtual QIcon icon() const;
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
|
|
||||||
virtual void display() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
boost::python::object m_DisplayNameFunction;
|
|
||||||
boost::python::object m_ToolTipFunction;
|
|
||||||
boost::python::object m_IconFunction;
|
|
||||||
boost::python::object m_DisplayFunction;
|
|
||||||
|
|
||||||
boost::python::object m_SetParentWidget;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif // PYTHONTOOLWRAPPER_H
|
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!DOCTYPE TS>
|
||||||
|
<TS version="2.1" language="en_US">
|
||||||
|
<context>
|
||||||
|
<name>ProxyPython</name>
|
||||||
|
<message>
|
||||||
|
<location filename="proxy/proxypython.cpp" line="150"/>
|
||||||
|
<source>Python Initialization failed</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="proxy/proxypython.cpp" line="151"/>
|
||||||
|
<source>On a previous start the Python Plugin failed to initialize.
|
||||||
|
Either the value in Settings->Plugins->ProxyPython->plugin_dir is set incorrectly or it is empty and auto-detection doesn't work for whatever reason.
|
||||||
|
Do you want to try initializing python again (at the risk of another crash)?
|
||||||
|
Suggestion: Select "no", and click the warning sign for further help. Afterwards you have to re-enable the python plugin.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="proxy/proxypython.cpp" line="194"/>
|
||||||
|
<source>Proxy Plugin to allow plugins written in python to be loaded</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="proxy/proxypython.cpp" line="269"/>
|
||||||
|
<source>Python not installed or not found</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="proxy/proxypython.cpp" line="272"/>
|
||||||
|
<source>Python version is incompatible</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="proxy/proxypython.cpp" line="275"/>
|
||||||
|
<source>Invalid python path</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="proxy/proxypython.cpp" line="278"/>
|
||||||
|
<source>Initializing Python failed</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="proxy/proxypython.cpp" line="281"/>
|
||||||
|
<source>Python auto-detection failed</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="proxy/proxypython.cpp" line="284"/>
|
||||||
|
<source>ModOrganizer path contains a semicolon</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="proxy/proxypython.cpp" line="287"/>
|
||||||
|
<source>invalid problem key %1</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="proxy/proxypython.cpp" line="296"/>
|
||||||
|
<source>Some MO plugins require the python interpreter to be installed. These plugins will not even show up in settings-&gt;plugins.<br>If you want to use those plugins, please install the 32-bit version of Python 2.7.x from <a href="%1">%1</a>.<br>This is only required to use some extended functionality in MO, you do not need Python to play the game.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="proxy/proxypython.cpp" line="302"/>
|
||||||
|
<source>Your installed python version has a different version than 2.7. Some MO plugins may not work.<br>If you have multiple versions of python installed you may have to configure the path to 2.7 (32 bit) in the settings dialog.<br>This is only required to use some extended functionality in MO, you do not need Python to play the game.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="proxy/proxypython.cpp" line="309"/>
|
||||||
|
<source>Please set python_dir in Settings->Plugins->ProxyPython to the path of your python 2.7 (32 bit) installation.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="proxy/proxypython.cpp" line="312"/>
|
||||||
|
<source>The auto-detection of the python path failed. I don't know why this would happen but you can try to fix it by setting python_dir in Settings->Plugins->ProxyPython to the path of your python 2.7 (32 bit) installation.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="proxy/proxypython.cpp" line="316"/>
|
||||||
|
<source>Sorry, I don't know any details. Most likely your python installation is not supported.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="proxy/proxypython.cpp" line="319"/>
|
||||||
|
<source>The path to Mod Organizer (%1) contains a semicolon. <br>While this is legal on NTFS drives there is a lot of software that doesn't handle it correctly.<br>Unfortunately MO depends on libraries that seem to fall into that group.<br>As a result the python plugin can't be loaded.<br>The only solution I can offer is to remove the semicolon / move MO to a path without a semicolon.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
</TS>
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
CMAKE_MINIMUM_REQUIRED (VERSION 2.8.11)
|
||||||
|
|
||||||
|
SET(PROJ_NAME pythonrunner)
|
||||||
|
|
||||||
|
PROJECT(${PROJ_NAME})
|
||||||
|
|
||||||
|
CMAKE_POLICY(SET CMP0020 NEW)
|
||||||
|
|
||||||
|
|
||||||
|
FILE(GLOB ${PROJ_NAME}_SRCS *.cpp)
|
||||||
|
FILE(GLOB ${PROJ_NAME}_HDRS *.h)
|
||||||
|
|
||||||
|
SET(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||||
|
SET(CMAKE_AUTOMOC ON)
|
||||||
|
SET(CMAKE_AUTOUIC ON)
|
||||||
|
ADD_DEFINITIONS(-DQT_NO_KEYWORDS)
|
||||||
|
FIND_PACKAGE(Qt5Widgets REQUIRED)
|
||||||
|
FIND_PACKAGE(Qt5Network REQUIRED)
|
||||||
|
#QT5_WRAP_UI(${PROJ_NAME}_UIHDRS ${${PROJ_NAME}_FORMS})
|
||||||
|
FIND_PACKAGE(Qt5LinguistTools)
|
||||||
|
QT5_CREATE_TRANSLATION(${PROJ_NAME}_translations_qm ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/src/${PROJ_NAME}_en.ts)
|
||||||
|
|
||||||
|
SET(Boost_USE_STATIC_LIBS OFF)
|
||||||
|
SET(Boost_USE_MULTITHREADED ON)
|
||||||
|
SET(Boost_USE_STATIC_RUNTIME OFF)
|
||||||
|
FIND_PACKAGE(Boost REQUIRED)
|
||||||
|
|
||||||
|
IF (Boost_FOUND)
|
||||||
|
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
|
||||||
|
ENDIF (Boost_FOUND)
|
||||||
|
|
||||||
|
SET(default_project_path "${DEPENDENCIES_DIR}/modorganizer_super")
|
||||||
|
GET_FILENAME_COMPONENT(${default_project_path} ${default_project_path} REALPATH)
|
||||||
|
|
||||||
|
SET(project_path "${default_project_path}" CACHE PATH "path to the other mo projects")
|
||||||
|
SET(lib_path "${project_path}/../../install/libs")
|
||||||
|
|
||||||
|
INCLUDE_DIRECTORIES(${project_path}/uibase/src
|
||||||
|
${project_path}/game_features/src
|
||||||
|
${PYTHON_ROOT}/Include
|
||||||
|
${PYTHON_ROOT}/PC)
|
||||||
|
|
||||||
|
LINK_DIRECTORIES(${lib_path}
|
||||||
|
${PYTHON_ROOT}/PCbuild
|
||||||
|
${Boost_LIBRARY_DIRS})
|
||||||
|
|
||||||
|
ADD_LIBRARY(${PROJ_NAME} SHARED ${${PROJ_NAME}_HDRS} ${${PROJ_NAME}_SRCS} ${${PROJ_NAME}_translations_qm})
|
||||||
|
TARGET_LINK_LIBRARIES(${PROJ_NAME}
|
||||||
|
Qt5::Widgets
|
||||||
|
Qt5::Network
|
||||||
|
uibase)
|
||||||
|
|
||||||
|
ADD_DEFINITIONS(-DPYTHONRUNNER_LIBRARY)
|
||||||
|
|
||||||
|
IF (MSVC)
|
||||||
|
SET_TARGET_PROPERTIES(${PROJ_NAME} PROPERTIES COMPILE_FLAGS "/std:c++latest")
|
||||||
|
ENDIF()
|
||||||
|
IF (MSVC AND CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||||
|
# 32 bits
|
||||||
|
SET_TARGET_PROPERTIES(${PROJ_NAME} PROPERTIES LINK_FLAGS "/LARGEADDRESSAWARE")
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
|
IF (NOT "${OPTIMIZE_COMPILE_FLAGS}" STREQUAL "")
|
||||||
|
SET_TARGET_PROPERTIES(${PROJ_NAME} PROPERTIES COMPILE_FLAGS_RELWITHDEBINFO ${OPTIMIZE_COMPILE_FLAGS})
|
||||||
|
ENDIF()
|
||||||
|
IF (NOT "${OPTIMIZE_LINK_FLAGS}" STREQUAL "")
|
||||||
|
SET_TARGET_PROPERTIES(${PROJ_NAME} PROPERTIES LINK_FLAGS_RELWITHDEBINFO ${OPTIMIZE_LINK_FLAGS})
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
|
###############
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
INSTALL(TARGETS ${PROJ_NAME}
|
||||||
|
RUNTIME DESTINATION bin/plugins/data
|
||||||
|
ARCHIVE DESTINATION libs)
|
||||||
|
INSTALL(FILES $<TARGET_PDB_FILE:${PROJ_NAME}>
|
||||||
|
DESTINATION pdb)
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
Import('qt_env')
|
||||||
|
|
||||||
|
env = qt_env.Clone()
|
||||||
|
|
||||||
|
env.EnableQtModules('Core', 'Gui', 'Widgets')
|
||||||
|
|
||||||
|
env.AppendUnique(CPPDEFINES = 'PYTHONRUNNER_LIBRARY')
|
||||||
|
|
||||||
|
# suppress a few warnings caused by boost vs vc++ paranoia
|
||||||
|
# NB HAVE_ROUND causes a warning because it's defined in pythonrunner.cpp
|
||||||
|
env.AppendUnique(CPPDEFINES = [
|
||||||
|
'_SCL_SECURE_NO_WARNINGS',
|
||||||
|
'HAVE_ROUND'
|
||||||
|
])
|
||||||
|
|
||||||
|
# Boost produces very long names with msvc truncates. Doesn't seem to cause
|
||||||
|
# problems.
|
||||||
|
env.AppendUnique(CPPFLAGS = [ '-wd4503' ])
|
||||||
|
|
||||||
|
# QMAKE_CXXFLAGS += /Zi
|
||||||
|
# QMAKE_LFLAGS += /DEBUG
|
||||||
|
|
||||||
|
env.RequireLibraries('uibase')
|
||||||
|
|
||||||
|
# AppendUnique appears not to work with QT4
|
||||||
|
env['CPPPATH'] += [
|
||||||
|
'${BOOSTPATH}',
|
||||||
|
'${PYTHONPATH}\\include',
|
||||||
|
]
|
||||||
|
|
||||||
|
env.AppendUnique(LIBS = [
|
||||||
|
'python27', # Could be done better
|
||||||
|
])
|
||||||
|
|
||||||
|
env.AppendUnique(LIBPATH = [
|
||||||
|
'${PYTHONPATH}/libs', # Could be done better
|
||||||
|
])
|
||||||
|
|
||||||
|
# We have to 'persuade' moc to generate certain other targets and inject them
|
||||||
|
# into the list of cpps
|
||||||
|
targets = env.AddExtraMoc(env.Glob('*.h'))
|
||||||
|
|
||||||
|
# pythontoolwrapper doesnt compile and isn't in the project file
|
||||||
|
cpp_files = [
|
||||||
|
x for x in Glob('*.cpp') if x.name != 'pythontoolwrapper.cpp'
|
||||||
|
]
|
||||||
|
|
||||||
|
lib = env.SharedLibrary('pythonRunner', cpp_files + targets)
|
||||||
|
|
||||||
|
env.InstallModule(lib, 'plugins/data')
|
||||||
|
|
||||||
|
# However...
|
||||||
|
# we do need boost-python and pythonvv.dll and pythonvv.zip (though the last
|
||||||
|
# isn't needed to just bring up the module)
|
||||||
|
#env.Pseudo('install')
|
||||||
|
#env.Depends('install',
|
||||||
|
# (env.Install('${INSTALL_PATH}', 'pyCfg.py'),
|
||||||
|
# env.Install(os.path.join('${INSTALL_PATH}', 'data'),
|
||||||
|
# ( ui, rc, 'settings.json' )),
|
||||||
|
# ))
|
||||||
|
|
||||||
|
res = env['QT_USED_MODULES']
|
||||||
|
Return('res')
|
||||||
+49
-8
@@ -1,6 +1,9 @@
|
|||||||
|
#ifndef Q_MOC_RUN
|
||||||
#include <boost/python.hpp>
|
#include <boost/python.hpp>
|
||||||
#include <QString>
|
#endif
|
||||||
#include <utility.h>
|
#include <utility.h>
|
||||||
|
#include <QDebug>
|
||||||
|
#include "error.h"
|
||||||
|
|
||||||
using namespace MOBase;
|
using namespace MOBase;
|
||||||
namespace bpy = boost::python;
|
namespace bpy = boost::python;
|
||||||
@@ -8,17 +11,55 @@ namespace bpy = boost::python;
|
|||||||
void reportPythonError()
|
void reportPythonError()
|
||||||
{
|
{
|
||||||
if (PyErr_Occurred()) {
|
if (PyErr_Occurred()) {
|
||||||
// prints to s_ErrIO buffer
|
ErrWrapper &errWrapper = ErrWrapper::instance();
|
||||||
|
|
||||||
|
errWrapper.startRecordingExceptionMessage();
|
||||||
PyErr_Print();
|
PyErr_Print();
|
||||||
// extract data from python buffer
|
errWrapper.stopRecordingExceptionMessage();
|
||||||
bpy::object mainModule = bpy::import("__main__");
|
|
||||||
bpy::object mainNamespace = mainModule.attr("__dict__");
|
QString errMsg = errWrapper.getLastExceptionMessage();
|
||||||
bpy::object errMsgObj = bpy::eval("s_ErrIO.getvalue()", mainNamespace);
|
|
||||||
QString errMsg = bpy::extract<QString>(errMsgObj.ptr());
|
|
||||||
bpy::eval("s_ErrIO.truncate(0)", mainNamespace);
|
|
||||||
|
|
||||||
throw MyException(errMsg);
|
throw MyException(errMsg);
|
||||||
} else {
|
} else {
|
||||||
throw MyException("An unexpected C++ exception was thrown in python code");
|
throw MyException("An unexpected C++ exception was thrown in python code");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ErrWrapper & ErrWrapper::instance()
|
||||||
|
{
|
||||||
|
static ErrWrapper err;
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ErrWrapper::write(const char * message)
|
||||||
|
{
|
||||||
|
buffer << message;
|
||||||
|
if (buffer.tellp() != 0 && buffer.str().back() == '\n')
|
||||||
|
{
|
||||||
|
// actually put the string in a variable so it doesn't get destroyed as soon as we get a pointer to its data
|
||||||
|
std::string string = buffer.str().substr(0, buffer.str().length() - 1);
|
||||||
|
qCritical().nospace().noquote() << string.c_str();
|
||||||
|
buffer = std::stringstream();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (recordingExceptionMessage)
|
||||||
|
{
|
||||||
|
lastException << message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ErrWrapper::startRecordingExceptionMessage()
|
||||||
|
{
|
||||||
|
recordingExceptionMessage = true;
|
||||||
|
lastException = std::stringstream();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ErrWrapper::stopRecordingExceptionMessage()
|
||||||
|
{
|
||||||
|
recordingExceptionMessage = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString ErrWrapper::getLastExceptionMessage()
|
||||||
|
{
|
||||||
|
return QString::fromStdString(lastException.str());
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,7 +1,26 @@
|
|||||||
#ifndef ERROR_H
|
#ifndef ERROR_H
|
||||||
#define ERROR_H
|
#define ERROR_H
|
||||||
|
#include <QString>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
// turn an error from the python interpreter into an exception
|
// turn an error from the python interpreter into an exception
|
||||||
void reportPythonError();
|
void reportPythonError();
|
||||||
|
|
||||||
|
struct ErrWrapper
|
||||||
|
{
|
||||||
|
static ErrWrapper & instance();
|
||||||
|
|
||||||
|
void write(const char * message);
|
||||||
|
|
||||||
|
void startRecordingExceptionMessage();
|
||||||
|
|
||||||
|
void stopRecordingExceptionMessage();
|
||||||
|
|
||||||
|
QString getLastExceptionMessage();
|
||||||
|
|
||||||
|
std::stringstream buffer;
|
||||||
|
bool recordingExceptionMessage;
|
||||||
|
std::stringstream lastException;
|
||||||
|
};
|
||||||
|
|
||||||
#endif // ERROR_H
|
#endif // ERROR_H
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user