Add enable_python option to meson

This commit is contained in:
Florian Märkl 2019-02-13 23:24:22 +01:00
parent 2be8ec8456
commit f945ebf9ae
6 changed files with 25 additions and 14 deletions

View File

@ -103,6 +103,8 @@ or, if you don't want to build with Python at all, use -DCUTTER_ENABLE_PYTHON=OF
include_directories(${SHIBOKEN_INCLUDE_DIR}) include_directories(${SHIBOKEN_INCLUDE_DIR})
include_directories(${PYSIDE_INCLUDE_DIR} ${PYSIDE_INCLUDE_DIR}/QtCore ${PYSIDE_INCLUDE_DIR}/QtGui ${PYSIDE_INCLUDE_DIR}/QtWidgets) include_directories(${PYSIDE_INCLUDE_DIR} ${PYSIDE_INCLUDE_DIR}/QtCore ${PYSIDE_INCLUDE_DIR}/QtGui ${PYSIDE_INCLUDE_DIR}/QtWidgets)
add_definitions(-DCUTTER_ENABLE_PYTHON)
endif() endif()
endif() endif()

View File

@ -54,7 +54,9 @@ void PythonManager::initPythonHome()
} }
} }
#ifdef CUTTER_ENABLE_PYTHON_BINDINGS
extern "C" PyObject *PyInit_CutterBindings(); extern "C" PyObject *PyInit_CutterBindings();
#endif
void PythonManager::initialize() void PythonManager::initialize()
{ {
@ -65,7 +67,9 @@ void PythonManager::initialize()
PyImport_AppendInittab("cutter_internal", &PyInit_api_internal); PyImport_AppendInittab("cutter_internal", &PyInit_api_internal);
#endif #endif
PyImport_AppendInittab("_qtres", &PyInit_qtres); PyImport_AppendInittab("_qtres", &PyInit_qtres);
#ifdef CUTTER_ENABLE_PYTHON_BINDINGS
PyImport_AppendInittab("CutterBindings", &PyInit_CutterBindings); PyImport_AppendInittab("CutterBindings", &PyInit_CutterBindings);
#endif
Py_Initialize(); Py_Initialize();
PyEval_InitThreads(); PyEval_InitThreads();
pyThreadStateCounter = 1; // we have the thread now => 1 pyThreadStateCounter = 1; // we have the thread now => 1

View File

@ -5,17 +5,21 @@ py3_exe = import('python').find_installation('python3')
qt_modules = [] qt_modules = []
feature_define_args = [] feature_define_args = []
if get_option('enable_python')
message('Python is enabled')
feature_define_args += ['-DCUTTER_ENABLE_PYTHON']
if get_option('enable_jupyter') if get_option('enable_jupyter')
message('Jupyter support enabled') message('Jupyter support enabled')
add_project_arguments('-DCUTTER_ENABLE_JUPYTER', language: 'cpp')
feature_define_args += ['-DCUTTER_ENABLE_JUPYTER'] feature_define_args += ['-DCUTTER_ENABLE_JUPYTER']
if get_option('enable_webengine') if get_option('enable_webengine')
message('QtWebEngine support enabled') message('QtWebEngine support enabled')
add_project_arguments('-DCUTTER_ENABLE_QTWEBENGINE', language: 'cpp')
feature_define_args += ['-DCUTTER_ENABLE_QTWEBENGINE'] feature_define_args += ['-DCUTTER_ENABLE_QTWEBENGINE']
qt_modules += 'WebEngineWidgets' qt_modules += 'WebEngineWidgets'
endif endif
endif endif
endif
add_project_arguments(feature_define_args, language: 'cpp')
parse_cmd = [py3_exe, join_paths(meson.current_source_dir(), '../scripts/meson_parse_qmake.py')] parse_cmd = [py3_exe, join_paths(meson.current_source_dir(), '../scripts/meson_parse_qmake.py')]
@ -59,7 +63,7 @@ libr2_dep = r2.get_variable('libr2_dep')
qt5dep = dependency('qt5', modules: qt_modules) qt5dep = dependency('qt5', modules: qt_modules)
deps = [libr2_dep, qt5dep] deps = [libr2_dep, qt5dep]
if get_option('enable_jupyter') if get_option('enable_python')
deps += [dependency('python3')] deps += [dependency('python3')]
endif endif

View File

@ -1,2 +1,3 @@
option('enable_python', type: 'boolean', value: true)
option('enable_jupyter', type: 'boolean', value: false) option('enable_jupyter', type: 'boolean', value: false)
option('enable_webengine', type: 'boolean', value: false) option('enable_webengine', type: 'boolean', value: false)

View File

@ -1,5 +1,5 @@
#ifdef CUTTER_ENABLE_PYTHON #ifdef CUTTER_ENABLE_PYTHON_BINDINGS
#include <Python.h> #include <Python.h>
#include <cutterbindings_python.h> #include <cutterbindings_python.h>
#include "PythonManager.h" #include "PythonManager.h"
@ -51,7 +51,7 @@ void PluginManager::loadPlugins()
loadNativePlugins(nativePluginsDir); loadNativePlugins(nativePluginsDir);
} }
#ifdef CUTTER_ENABLE_PYTHON #ifdef CUTTER_ENABLE_PYTHON_BINDINGS
QDir pythonPluginsDir = pluginsDir; QDir pythonPluginsDir = pluginsDir;
pythonPluginsDir.mkdir("python"); pythonPluginsDir.mkdir("python");
if (pythonPluginsDir.cd("python")) { if (pythonPluginsDir.cd("python")) {
@ -87,7 +87,7 @@ void PluginManager::loadNativePlugins(const QDir &directory)
} }
} }
#ifdef CUTTER_ENABLE_PYTHON #ifdef CUTTER_ENABLE_PYTHON_BINDINGS
void PluginManager::loadPythonPlugins(const QDir &directory) void PluginManager::loadPythonPlugins(const QDir &directory)
{ {

View File

@ -34,7 +34,7 @@ private:
void loadNativePlugins(const QDir &directory); void loadNativePlugins(const QDir &directory);
#ifdef CUTTER_ENABLE_PYTHON #ifdef CUTTER_ENABLE_PYTHON_BINDINGS
void loadPythonPlugins(const QDir &directory); void loadPythonPlugins(const QDir &directory);
CutterPlugin *loadPythonPlugin(const char *moduleName); CutterPlugin *loadPythonPlugin(const char *moduleName);
#endif #endif