Skip to content

Commit

Permalink
Adapt Shiboken generation for Qt6
Browse files Browse the repository at this point in the history
  • Loading branch information
YakoYakoYokuYoku committed Dec 18, 2024
1 parent 24fc376 commit 8f54ccd
Show file tree
Hide file tree
Showing 13 changed files with 148 additions and 262 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ if(NATRON_QT6)
find_package(Shiboken6Tools 6.3 CONFIG REQUIRED COMPONENTS shiboken6)
find_package(PySide6 6.3 CONFIG REQUIRED COMPONENTS pyside6)
set(QT_VERSION_MAJOR 6)
set(PYSIDE_VERSION_MAJOR 6)

get_target_property(PYSIDE_INCLUDE_DIRS PySide6::pyside6 INTERFACE_INCLUDE_DIRECTORIES)
set(QTCORE_INCLUDE_DIRS ${Qt6Core_INCLUDE_DIRS})
Expand All @@ -88,6 +89,7 @@ else()

find_package(PySide2 5.15 CONFIG REQUIRED COMPONENTS pyside2)
set(QT_VERSION_MAJOR 5)
set(PYSIDE_VERSION_MAJOR 2)

get_target_property(PYSIDE_INCLUDE_DIRS PySide2::pyside2 INTERFACE_INCLUDE_DIRECTORIES)
set(QTCORE_INCLUDE_DIRS ${Qt5Core_INCLUDE_DIRS})
Expand Down
9 changes: 4 additions & 5 deletions Engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ set(PYENGINE_OUT ${CMAKE_CURRENT_BINARY_DIR}/Qt${QT_VERSION_MAJOR})
set(PYENGINE_INCLUDE_DIRS ${PYSIDE_INCLUDE_DIRS} ${PYSIDE_INCLUDE_DIRS}/QtCore)
list(APPEND PYENGINE_INCLUDE_DIRS ${QTCORE_INCLUDE_DIRS} ${Python3_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})
list(TRANSFORM PYENGINE_INCLUDE_DIRS PREPEND "-I" OUTPUT_VARIABLE PYENGINE_INCS)
set(PYENGINE_HEADER PySide2_Engine_Python.h)
set(POST_SHIBOKEN ../tools/utils/runPostShiboken2.sh)
set(PYENGINE_HEADER PySide${PYSIDE_VERSION_MAJOR}_Engine_Python.h)

set(shiboken_args
"-std=c++17" "--enable-parent-ctor-heuristic" "--use-isnull-as-nb_nonzero"
Expand All @@ -43,9 +42,9 @@ execute_process(COMMAND ${Python3_EXECUTABLE} ../tools/utils/sourceList.py types
OUTPUT_VARIABLE PyEngine_SOURCES)
set_property(SOURCE ${PyEngine_SOURCES} PROPERTY SKIP_AUTOGEN ON)
add_custom_command(OUTPUT ${PyEngine_SOURCES}
COMMAND Shiboken2::shiboken2 ${shiboken_args}
COMMAND bash ${POST_SHIBOKEN} ${PYENGINE_OUT}/NatronEngine natronengine
DEPENDS ${PYENGINE_HEADER} ${NatronEngine_HEADERS} ${POST_SHIBOKEN} typesystem_engine.xml
COMMAND $<TARGET_FILE:${SHIBOKEN_EXE}> ${shiboken_args}
COMMAND ${Python3_EXECUTABLE} ../tools/utils/sourceCleanup.py typesystem_engine.xml ${PYENGINE_OUT}
DEPENDS ${SHIBOKEN_EXE} ${PYENGINE_HEADER} ${NatronEngine_HEADERS} ../tools/utils/sourceCleanup.py typesystem_engine.xml
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})

if(UNIX AND NOT APPLE)
Expand Down
39 changes: 39 additions & 0 deletions Engine/PySide6_Engine_Python.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/* ***** BEGIN LICENSE BLOCK *****
* This file is part of Natron <https://natrongithub.github.io/>,
* (C) 2018-2024 The Natron developers
* (C) 2013-2018 INRIA and Alexandre Gauthier-Foichat
*
* Natron is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Natron is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Natron. If not, see <http://www.gnu.org/licenses/gpl-2.0.html>
* ***** END LICENSE BLOCK ***** */


#ifndef PYSIDE6_ENGINE_PYTHON_H
#define PYSIDE6_ENGINE_PYTHON_H

// Defined for shiboken6-specific tweaks
#define SBK6_RUN

#ifndef BOOST_SERIALIZATION_VERSION_HPP
#define BOOST_SERIALIZATION_VERSION_HPP
#define BOOST_CLASS_VERSION(T, N)
#endif /* BOOST_SERIALIZATION_VERSION_HPP */

#ifndef BOOST_SERIALIZATION_SPLIT_MEMBER_HPP
#define BOOST_SERIALIZATION_SPLIT_MEMBER_HPP
#define BOOST_SERIALIZATION_SPLIT_MEMBER()
#endif /* BOOST_SERIALIZATION_SPLIT_MEMBER_HPP */

#include "Pyside_Engine_Python.h"

#endif // PYSIDE6_ENGINE_PYTHON_H
2 changes: 1 addition & 1 deletion Engine/Pyside_Engine_Python.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#ifdef SBK2_RUN
#include <pyside2_global.h>
#else
#include <pyside_global.h>
#include <pyside6_global.h>
#endif
#include <string>
//Global
Expand Down
4 changes: 4 additions & 0 deletions Engine/typesystem_engine.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1856,6 +1856,10 @@
</modify-function>
</object-type>

<inject-code class="target" position="declaration">
NATRON_NAMESPACE_USING NATRON_PYTHON_NAMESPACE_USING
</inject-code>


</typesystem>

Expand Down
9 changes: 4 additions & 5 deletions Gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ list(APPEND PYGUI_INCLUDE_DIRS ${PYSIDE_INCLUDE_DIRS} ${PYSIDE_INCLUDE_DIRS}/QtC
list(APPEND PYGUI_INCLUDE_DIRS ${QTCORE_INCLUDE_DIRS} ${QTGUI_INCLUDE_DIRS}
${QTWIDGETS_INCLUDE_DIRS} ${Python3_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})
list(TRANSFORM PYGUI_INCLUDE_DIRS PREPEND "-I" OUTPUT_VARIABLE PYGUI_INCS)
set(PYGUI_HEADER PySide2_Gui_Python.h)
set(POST_SHIBOKEN ../tools/utils/runPostShiboken2.sh)
set(PYGUI_HEADER PySide${PYSIDE_VERSION_MAJOR}_Gui_Python.h)

if(NATRON_QT6)
set(QT_OPENGLWIDGETS Qt::OpenGLWidgets)
Expand All @@ -47,9 +46,9 @@ execute_process(COMMAND ${Python3_EXECUTABLE} ../tools/utils/sourceList.py types
OUTPUT_VARIABLE PyGui_SOURCES)
set_property(SOURCE ${PyGui_SOURCES} PROPERTY SKIP_AUTOGEN ON)
add_custom_command(OUTPUT ${PyGui_SOURCES}
COMMAND Shiboken2::shiboken2 ${shiboken_args}
COMMAND bash ${POST_SHIBOKEN} ${PYGUI_OUT}/NatronGui natrongui
DEPENDS ${PYGUI_HEADER} ${NatronEngine_HEADERS} ${NatronGui_HEADERS} ${POST_SHIBOKEN} typesystem_natronGui.xml
COMMAND $<TARGET_FILE:${SHIBOKEN_EXE}> ${shiboken_args}
COMMAND ${Python3_EXECUTABLE} ../tools/utils/sourceCleanup.py typesystem_natronGui.xml ${PYGUI_OUT}
DEPENDS ${SHIBOKEN_EXE} ${PYGUI_HEADER} NatronEngine ${NatronGui_HEADERS} ../tools/utils/sourceCleanup.py typesystem_natronGui.xml
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})

if(APPLE)
Expand Down
39 changes: 39 additions & 0 deletions Gui/PySide6_Gui_Python.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/* ***** BEGIN LICENSE BLOCK *****
* This file is part of Natron <https://natrongithub.github.io/>,
* (C) 2018-2024 The Natron developers
* (C) 2013-2018 INRIA and Alexandre Gauthier-Foichat
*
* Natron is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Natron is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Natron. If not, see <http://www.gnu.org/licenses/gpl-2.0.html>
* ***** END LICENSE BLOCK ***** */


#ifndef PYSIDE6_GUI_PYTHON_H
#define PYSIDE6_GUI_PYTHON_H

// Defined for shiboken6-specific tweaks
#define SBK6_RUN

#ifndef BOOST_SERIALIZATION_VERSION_HPP
#define BOOST_SERIALIZATION_VERSION_HPP
#define BOOST_CLASS_VERSION(T, N)
#endif /* BOOST_SERIALIZATION_VERSION_HPP */

#ifndef BOOST_SERIALIZATION_SPLIT_MEMBER_HPP
#define BOOST_SERIALIZATION_SPLIT_MEMBER_HPP
#define BOOST_SERIALIZATION_SPLIT_MEMBER()
#endif /* BOOST_SERIALIZATION_SPLIT_MEMBER_HPP */

#include "Pyside_Gui_Python.h"

#endif // PYSIDE6_GUI_PYTHON_H
2 changes: 1 addition & 1 deletion Gui/Pyside_Gui_Python.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#ifdef SBK2_RUN
#include <pyside2_global.h>
#else
#include <pyside_global.h>
#include <pyside6_global.h>
#endif

#include <QSize>
Expand Down
4 changes: 4 additions & 0 deletions Gui/typesystem_natronGui.xml
Original file line number Diff line number Diff line change
Expand Up @@ -211,4 +211,8 @@
</inject-code>
</modify-function>
</object-type>

<inject-code class="target" position="declaration">
NATRON_NAMESPACE_USING NATRON_PYTHON_NAMESPACE_USING
</inject-code>
</typesystem>
31 changes: 0 additions & 31 deletions tools/utils/runPostShiboken.bat

This file was deleted.

108 changes: 0 additions & 108 deletions tools/utils/runPostShiboken.sh

This file was deleted.

Loading

0 comments on commit 8f54ccd

Please sign in to comment.