diff --git a/plugins/extensions/pykrita/CMakeLists.txt b/plugins/extensions/pykrita/CMakeLists.txt index cb95a6c08b..6ee22cafaa 100644 --- a/plugins/extensions/pykrita/CMakeLists.txt +++ b/plugins/extensions/pykrita/CMakeLists.txt @@ -1,35 +1,60 @@ find_package(PythonLibrary) set_package_properties(PythonLibrary PROPERTIES DESCRIPTION "Python Library" URL "http://www.python.org" TYPE OPTIONAL PURPOSE "Required by the Krita PyQt plugin") macro_bool_to_01(PYTHONLIBS_FOUND HAVE_PYTHONLIBS) - -find_package(SIP "4.18.0") -set_package_properties(SIP PROPERTIES - DESCRIPTION "Support for generating SIP Python bindings" - URL "https://www.riverbankcomputing.com/software/sip/download" - TYPE OPTIONAL +find_package(PythonModuleGeneration) +set_package_properties(PythonModuleGeneration PROPERTIES + DESCRIPTION "Automatic generation of SIP bindings" + URL "https://api.kde.org/ecm/" + TYPE REQUIRED PURPOSE "Required by the Krita PyQt plugin") -macro_bool_to_01(SIP_FOUND HAVE_SIP) -find_package(PyQt5 "5.6.0") -set_package_properties(PyQt5 PROPERTIES - DESCRIPTION "Python bindings for Qt5." - URL "https://www.riverbankcomputing.com/software/pyqt/download5" - TYPE OPTIONAL - PURPOSE "Required by the Krita PyQt plugin") -macro_bool_to_01(PYQT5_FOUND HAVE_PYQT5) - -if (HAVE_PYQT5 AND HAVE_SIP AND HAVE_PYTHONLIBS) - -include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${SIP_INCLUDE_DIR} ${PYTHON_INCLUDE_PATH}) - -add_subdirectory(libkis) -add_subdirectory(sip) -add_subdirectory(plugin) +if (PythonModuleGeneration_FOUND) + add_subdirectory(libkis) + ecm_generate_python_binding( + TARGET kritalibkis + PYTHONNAMESPACE krita + MODULENAME PyKrita + RULES_FILE "${CMAKE_CURRENT_SOURCE_DIR}/libkis/rules_PyKrita.py" + SIP_DEPENDS + QtCore/QtCoremod.sip + QtOpenGL/QtOpenGLmod.sip + Qt/Qtmod.sip + QtXml/QtXmlmod.sip + QtGui/QtGuimod.sip + QtWidgets/QtWidgetsmod.sip + HEADERS + libkis/Action.h + libkis/Canvas.h + libkis/Channel.h + libkis/ColorDepth.h + libkis/ColorManager.h + libkis/ColorModel.h + libkis/ColorProfile.h + libkis/DockWidgetFactoryBase.h + libkis/DockWidget.h + libkis/Document.h + libkis/Exporter.h + libkis/Filter.h + libkis/Generator.h + libkis/Importer.h + libkis/InfoObject.h + libkis/Krita.h + libkis/libkis.h + libkis/Node.h + libkis/Notifier.h + libkis/Resource.h + libkis/Selection.h + libkis/Transformation.h + libkis/ViewExtension.h + libkis/View.h + libkis/Window.h + ) + add_subdirectory(plugin) endif () diff --git a/plugins/extensions/pykrita/libkis/rules_PyKrita.py b/plugins/extensions/pykrita/libkis/rules_PyKrita.py new file mode 100644 index 0000000000..160747be6d --- /dev/null +++ b/plugins/extensions/pykrita/libkis/rules_PyKrita.py @@ -0,0 +1,58 @@ +# +# Copyright 2016 by Boudewijn Rempt +# +# This program 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. +# +# This program 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 this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301 USA. +# +""" +SIP binding customisation for PyKrita.Krita. This modules describes: + + * The SIP file generator rules. +""" + +import os, sys + +import rules_engine +sys.path.append(os.path.dirname(os.path.dirname(rules_engine.__file__))) +import Qt5Ruleset + +from clang.cindex import AccessSpecifier + +def discard_base(container, sip, matcher): + sip["base_specifiers"] = "" + +def local_container_rules(): + return [ + ] + +def local_parameter_rules(): + return [ + ] + +def local_function_rules(): + return [ + ] + +class RuleSet(Qt5Ruleset.RuleSet): + """ + SIP file generator rules. This is a set of (short, non-public) functions + and regular expression-based matching rules. + """ + def __init__(self): + Qt5Ruleset.RuleSet.__init__(self) + self._param_db = rules_engine.ParameterRuleDb(lambda: local_parameter_rules() + Qt5Ruleset.parameter_rules()) + self._fn_db = rules_engine.FunctionRuleDb(lambda: local_function_rules() + Qt5Ruleset.function_rules()) + self._container_db = rules_engine.ContainerRuleDb(lambda: local_container_rules() + Qt5Ruleset.container_rules()) +