Skip to content

Commit 8504e55

Browse files
committed
Fixing compilation for windows (release only)
1 parent 4d8364c commit 8504e55

16 files changed

+204
-47
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
UnigineEditorPlugin_Python3Scripting/python-bin
1+
UnigineEditorPlugin_Python3Scripting/python-bin*
22
linux_UnigineEditorPlugin_Python3Scripting*
3+
lib/
34

45
# Prerequisites
56
*.d

DEVELOPMENT.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ $ sudo apt install qt5-default cmake gcc git-core
1818

1919
Windows:
2020
- install cmake >= 3.20
21-
- install visual studio
21+
- install Visual Studio 2017
2222
- install qt 5.12.x (And set system environment variable `QTDIR=C:\Qt\Qt5.12.3\5.12.3\`)
2323
- install python3 (for command scripts)
2424

@@ -47,6 +47,13 @@ $ cd UnigineEditorPlugin_Python3Scripting
4747
$ ./build_python.sh
4848
```
4949

50+
Windows (Visual Studio 2017):
51+
```
52+
> cd my_project
53+
> cd UnigineEditorPlugin_Python3Scripting
54+
> PCBuild\build.bat
55+
```
56+
5057
### step 4: build plugin
5158

5259
Ubuntu/Debian:

UnigineEditorPlugin_Python3Scripting/CMakeLists.txt

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ add_subdirectory(QCodeEditor)
1313

1414
include(${PROJECT_SOURCE_DIR}/cmake/Unigine.cmake)
1515

16-
if (EXISTS ${PROJECT_SOURCE_DIR}/${proj_name}.json.in)
16+
if (EXISTS ${PROJECT_SOURCE_DIR}/UnigineEditorPlugin_Python3Scripting.json.in)
1717
set(PLUGIN_VERSION ${UNIGINE_VERSION})
1818
set(PLUGIN_COMPAT_VERSION ${PYTHON3SCRIPTING_VERSION})
1919
configure_file(
20-
${PROJECT_SOURCE_DIR}/${proj_name}.json.in
20+
${PROJECT_SOURCE_DIR}/UnigineEditorPlugin_Python3Scripting.json.in
2121
${CMAKE_CURRENT_BINARY_DIR}/Plugin.json
2222
)
2323
endif()
@@ -63,14 +63,26 @@ add_library(${proj_name} SHARED
6363
${PROJECT_SOURCE_DIR}/src/python3_wrapper/pytypesobjects/python3_unigine_node.cpp
6464
)
6565

66+
IF (WIN32)
67+
# windows
68+
set(PYTHON3_INCLUDES "")
69+
list (APPEND PYTHON3_INCLUDES "${CMAKE_SOURCE_DIR}/Python-3.10.1/Include")
70+
list (APPEND PYTHON3_INCLUDES "${CMAKE_SOURCE_DIR}/Python-3.10.1/PC")
71+
set(PYTHON3_LIB "${CMAKE_SOURCE_DIR}/python-bin-windows/python310.lib")
72+
ELSE()
73+
# linux
74+
set(PYTHON3_INCLUDES "${PROJECT_SOURCE_DIR}/python-bin-linux/include/python3.10")
75+
set(PYTHON3_LIB "${CMAKE_SOURCE_DIR}/python-bin-linux/lib/libpython3.10.a")
76+
ENDIF()
77+
6678
target_include_directories(${proj_name} SYSTEM
6779
PRIVATE
6880
${PROJECT_SOURCE_DIR}/QCodeEditor/include
6981
${PROJECT_SOURCE_DIR}/include
7082
${PROJECT_SOURCE_DIR}/src/
7183
${PROJECT_SOURCE_DIR}/src/python3_wrapper
7284
${PROJECT_SOURCE_DIR}/src/python3_wrapper/pytypesobjects/
73-
${PROJECT_SOURCE_DIR}/python-bin/include/python3.10
85+
${PYTHON3_INCLUDES}
7486
${CMAKE_CURRENT_BINARY_DIR}
7587
)
7688

@@ -113,7 +125,7 @@ target_link_libraries(${proj_name}
113125
Qt5::Gui
114126
Qt5::Widgets
115127
QCodeEditor
116-
${CMAKE_SOURCE_DIR}/python-bin/lib/libpython3.10.a
128+
${PYTHON3_LIB}
117129
)
118130

119131

UnigineEditorPlugin_Python3Scripting/Python-3.10.1/PCbuild/_asyncio.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
<Import Project="python.props" />
7575
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
7676
<PropertyGroup Label="Configuration">
77-
<ConfigurationType>DynamicLibrary</ConfigurationType>
77+
<ConfigurationType>StaticLibrary</ConfigurationType>
7878
<CharacterSet>NotSet</CharacterSet>
7979
</PropertyGroup>
8080
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />

UnigineEditorPlugin_Python3Scripting/Python-3.10.1/PCbuild/python3dll.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
<Import Project="python.props" />
7777
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
7878
<PropertyGroup Label="Configuration">
79-
<ConfigurationType>DynamicLibrary</ConfigurationType>
79+
<ConfigurationType>StaticLibrary</ConfigurationType>
8080
</PropertyGroup>
8181
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
8282
<ImportGroup Label="ExtensionSettings">

UnigineEditorPlugin_Python3Scripting/Python-3.10.1/PCbuild/regen.targets

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@
2222
<_OpcodeSources Include="$(PySourcePath)Tools\scripts\generate_opcode_h.py;$(PySourcePath)Lib\opcode.py" />
2323
<_OpcodeOutputs Include="$(PySourcePath)Include\opcode.h;$(PySourcePath)Python\opcode_targets.h" />
2424
<_TokenSources Include="$(PySourcePath)Grammar\Tokens" />
25-
<_TokenOutputs Include="$(PySourcePath)Doc\library\token-list.inc">
26-
<Format>rst</Format>
27-
</_TokenOutputs>
2825
<_TokenOutputs Include="$(PySourcePath)Include\token.h">
2926
<Format>h</Format>
3027
</_TokenOutputs>

UnigineEditorPlugin_Python3Scripting/Python-3.10.1/PCbuild/winsound.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
<Import Project="python.props" />
7676
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
7777
<PropertyGroup Label="Configuration">
78-
<ConfigurationType>DynamicLibrary</ConfigurationType>
78+
<ConfigurationType>StaticLibrary</ConfigurationType>
7979
<CharacterSet>NotSet</CharacterSet>
8080
</PropertyGroup>
8181
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />

UnigineEditorPlugin_Python3Scripting/Python-3.10.1/PCbuild/xxlimited.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
<Import Project="python.props" />
7575
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
7676
<PropertyGroup Label="Configuration">
77-
<ConfigurationType>DynamicLibrary</ConfigurationType>
77+
<ConfigurationType>StaticLibrary</ConfigurationType>
7878
<CharacterSet>NotSet</CharacterSet>
7979
<SupportPGO>false</SupportPGO>
8080
</PropertyGroup>

UnigineEditorPlugin_Python3Scripting/Python-3.10.1/PCbuild/xxlimited_35.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
<Import Project="python.props" />
7575
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
7676
<PropertyGroup Label="Configuration">
77-
<ConfigurationType>DynamicLibrary</ConfigurationType>
77+
<ConfigurationType>StaticLibrary</ConfigurationType>
7878
<CharacterSet>NotSet</CharacterSet>
7979
<SupportPGO>false</SupportPGO>
8080
</PropertyGroup>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
@echo off
2+
3+
endlocal
4+
setlocal
5+
6+
cd Python-3.10.1
7+
8+
9+
10+
call PCbuild\build.bat
11+
if %ERRORLEVEL% GEQ 1 (
12+
echo "Problem with prepare configuration"
13+
EXIT /B 1
14+
)
15+
16+
XCOPY /F PCbuild\amd64\* ../python-bin-windows
17+
18+
IF EXIST ..\python-bin-windows\ RMDIR /S /Q ..\python-bin-windows\
19+
20+
MKDIR ..\python-bin-windows\
21+
22+
XCOPY /K /D /Y /H PCbuild\amd64\* ..\python-bin-windows\

UnigineEditorPlugin_Python3Scripting/build_python.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ cd Python-3.10.1
2020
export CFLAGS="$CFLAGS -fPIC"
2121
./configure \
2222
--enable-optimizations \
23-
--prefix=`pwd`/../python-bin \
23+
--prefix=`pwd`/../python-bin-linux \
2424
--with-static-libpython
2525
check_ret $? "Configure python"
2626

UnigineEditorPlugin_Python3Scripting/src/CollectorMenuSelected.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ class CollectorMenuSelected : public QObject {
2222
void addAction(QAction *pAction);
2323
void setEnabled(bool bEnabled);
2424

25-
private slots:
26-
void processSelected();
25+
// private slots:
26+
// void processSelected();
2727

2828
private:
2929
QMenu *m_pMenuSelected;

UnigineEditorPlugin_Python3Scripting/src/python3_wrapper/pytypesobjects/python3_unigine_material.cpp

Lines changed: 61 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,17 +86,68 @@ static PyMethodDef unigine_Material_methods[] = {
8686

8787
static PyTypeObject unigine_MaterialType = {
8888
// PyVarObject_HEAD_INIT(&PyType_Type, 0)
89+
// PyVarObject_HEAD_INIT(NULL, 0)
90+
// .tp_name = "unigine.Material",
91+
// .tp_basicsize = sizeof(unigine_Material) + 16, // magic!!!
92+
// .tp_dealloc = (destructor)unigine_Material_dealloc,
93+
// .tp_flags = Py_TPFLAGS_DEFAULT, // | Py_TPFLAGS_BASETYPE,
94+
// .tp_doc = "Material Object",
95+
// .tp_methods = unigine_Material_methods,
96+
// .tp_members = 0,
97+
// .tp_dict = 0,
98+
// .tp_init = (initproc)unigine_Material_init,
99+
// .tp_new = unigine_Material_new,
100+
101+
89102
PyVarObject_HEAD_INIT(NULL, 0)
90-
.tp_name = "unigine.Material",
91-
.tp_basicsize = sizeof(unigine_Material) + 16, // magic!!!
92-
.tp_dealloc = (destructor)unigine_Material_dealloc,
93-
.tp_flags = Py_TPFLAGS_DEFAULT, // | Py_TPFLAGS_BASETYPE,
94-
.tp_doc = "Material Object",
95-
.tp_methods = unigine_Material_methods,
96-
.tp_members = 0,
97-
.tp_dict = 0,
98-
.tp_init = (initproc)unigine_Material_init,
99-
.tp_new = unigine_Material_new,
103+
"unigine.Material", // tp_name
104+
sizeof(unigine_Material) + 16, // tp_basicsize (magic 16 bytes!!!)
105+
0, // tp_itemsize
106+
(destructor)unigine_Material_dealloc, // tp_dealloc
107+
0, // tp_vectorcall_offset
108+
0, // tp_getattr
109+
0, // tp_setattr
110+
0, // tp_as_async
111+
0, // tp_repr
112+
0, // tp_as_number
113+
0, // tp_as_sequence
114+
0, // tp_as_mapping
115+
0, // tp_hash
116+
0, // tp_call
117+
0, // tp_str
118+
0, // tp_getattro
119+
0, // tp_setattro
120+
0, // tp_as_buffer
121+
Py_TPFLAGS_DEFAULT, // tp_flags
122+
"Material Object", // tp_doc
123+
0, // traverseproc tp_traverse
124+
0, // inquiry tp_clear
125+
0, // richcmpfunc tp_richcompare
126+
0, // Py_ssize_t tp_weaklistoffset
127+
0, // getiterfunc tp_iter
128+
0, // iternextfunc tp_iternext
129+
unigine_Material_methods, // tp_methods
130+
0, // tp_members
131+
0, // tp_getset
132+
0, // tp_base
133+
0, // tp_dict
134+
0, // tp_descr_get
135+
0, // tp_descr_set
136+
0, // tp_dictoffset
137+
(initproc)unigine_Material_init, // tp_init
138+
0, // tp_alloc
139+
unigine_Material_new, // tp_new
140+
// 0, // tp_free
141+
// 0, /* inquiry tp_is_gc; */
142+
// 0, /* PyObject *tp_bases; */
143+
// 0, /* PyObject *tp_mro; */
144+
// 0, /* PyObject *tp_cache; */
145+
// 0, /* PyObject *tp_subclasses; */
146+
// 0, /* PyObject *tp_weaklist; */
147+
// 0, /* destructor tp_del; */
148+
// 0, /* unsigned int tp_version_tag; */
149+
// 0, /* destructor tp_finalize; */
150+
// 0, /* vectorcallfunc tp_vectorcall; */
100151
};
101152

102153
PyObject * PyUnigineMaterial::NewObject(Unigine::Ptr<Unigine::Material> unigine_object_ptr) {

UnigineEditorPlugin_Python3Scripting/src/python3_wrapper/pytypesobjects/python3_unigine_node.cpp

Lines changed: 59 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -193,17 +193,66 @@ static PyMethodDef unigine_Node_methods[] = {
193193
};
194194

195195
static PyTypeObject unigine_NodeType = {
196+
// PyVarObject_HEAD_INIT(&PyType_Type, 0)
197+
// // PyVarObject_HEAD_INIT(NULL, 0)
198+
// .tp_name = "unigine.Node",
199+
// .tp_basicsize = sizeof(unigine_Node),
200+
// .tp_dealloc = (destructor)unigine_Node_dealloc,
201+
// .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
202+
// .tp_doc = "Node objects",
203+
// .tp_methods = unigine_Node_methods,
204+
// .tp_members = unigine_Node_members,
205+
// .tp_init = (initproc)unigine_Node_init,
206+
// .tp_new = unigine_Node_new,
196207
PyVarObject_HEAD_INIT(&PyType_Type, 0)
197-
// PyVarObject_HEAD_INIT(NULL, 0)
198-
.tp_name = "unigine.Node",
199-
.tp_basicsize = sizeof(unigine_Node),
200-
.tp_dealloc = (destructor)unigine_Node_dealloc,
201-
.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
202-
.tp_doc = "Node objects",
203-
.tp_methods = unigine_Node_methods,
204-
.tp_members = unigine_Node_members,
205-
.tp_init = (initproc)unigine_Node_init,
206-
.tp_new = unigine_Node_new,
208+
"unigine.Node", // tp_name
209+
sizeof(unigine_Node), // tp_basicsize (magic 16 bytes!!!)
210+
0, // tp_itemsize
211+
(destructor)unigine_Node_dealloc, // tp_dealloc
212+
0, // tp_vectorcall_offset
213+
0, // tp_getattr
214+
0, // tp_setattr
215+
0, // tp_as_async
216+
0, // tp_repr
217+
0, // tp_as_number
218+
0, // tp_as_sequence
219+
0, // tp_as_mapping
220+
0, // tp_hash
221+
0, // tp_call
222+
0, // tp_str
223+
0, // tp_getattro
224+
0, // tp_setattro
225+
0, // tp_as_buffer
226+
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, // tp_flags
227+
"Material Object", // tp_doc
228+
0, // traverseproc tp_traverse
229+
0, // inquiry tp_clear
230+
0, // richcmpfunc tp_richcompare
231+
0, // Py_ssize_t tp_weaklistoffset
232+
0, // getiterfunc tp_iter
233+
0, // iternextfunc tp_iternext
234+
unigine_Node_methods, // tp_methods
235+
unigine_Node_members, // tp_members
236+
0, // tp_getset
237+
0, // tp_base
238+
0, // tp_dict
239+
0, // tp_descr_get
240+
0, // tp_descr_set
241+
0, // tp_dictoffset
242+
(initproc)unigine_Node_init, // tp_init
243+
0, // tp_alloc
244+
unigine_Node_new, // tp_new
245+
// 0, // tp_free
246+
// 0, /* inquiry tp_is_gc; */
247+
// 0, /* PyObject *tp_bases; */
248+
// 0, /* PyObject *tp_mro; */
249+
// 0, /* PyObject *tp_cache; */
250+
// 0, /* PyObject *tp_subclasses; */
251+
// 0, /* PyObject *tp_weaklist; */
252+
// 0, /* destructor tp_del; */
253+
// 0, /* unsigned int tp_version_tag; */
254+
// 0, /* destructor tp_finalize; */
255+
// 0, /* vectorcallfunc tp_vectorcall; */
207256
};
208257

209258
PyObject * PyUnigineNode::NewObject(Unigine::Ptr<Unigine::Node> pNode) {

build_plugin.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@
77

88

99
_platform = platform.platform().lower()
10+
_cmake_gen = ""
1011
is_linux = False
1112
is_windows = False
1213
if _platform.startswith("linux"):
1314
_platform = "linux"
1415
is_linux = True
1516
elif _platform.startswith("windows"):
1617
_platform = "windows"
18+
_cmake_gen = " -G \"Visual Studio 15 2017 Win64\""
1719
is_windows = True
1820
else:
1921
sys.exit("Unknown platform")
@@ -23,17 +25,17 @@
2325
build_commands = [
2426
{
2527
"name": "cmake configure release",
26-
"command": "cmake -H. -Bjunk/release_" + _platform + " -DCMAKE_BUILD_TYPE=Release \
28+
"command": "cmake -H. -Bjunk/release_" + _platform + " " + _cmake_gen + " -DCMAKE_BUILD_TYPE=Release \
2729
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
2830
-DCMAKE_INSTALL_PREFIX=../bin",
2931
},
3032
{
3133
"name": "cmake build release",
32-
"command": "cmake --build junk/release_" + _platform + " --parallel 8 --config Release",
34+
"command": 'cmake --build junk/release_' + _platform + ' --parallel 8 --config Release',
3335
},
3436
{
3537
"name": "cmake configure debug",
36-
"command": "cmake -H. -Bjunk/debug_" + _platform + " -DCMAKE_BUILD_TYPE=Debug \
38+
"command": "cmake -H. -Bjunk/debug_" + _platform + " " + _cmake_gen + "-DCMAKE_BUILD_TYPE=Debug \
3739
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
3840
-DCMAKE_INSTALL_PREFIX=../bin",
3941
},

0 commit comments

Comments
 (0)