Browse Source

Add WIP Python REPL interface

- Requires Python >= 3.0.0 and linenoise or linenoise-ng
- WIP: not built into the browser itself
master
Aqua-sama 7 months ago
parent
commit
914e2be5f5
Signed by: Aqua-sama <aqua@iserlohn-fortress.net> GPG Key ID: 5378B8349C1D5ADA

+ 1
- 1
3rd-party/SingleApplication/meson.build View File

@@ -1,6 +1,6 @@
SingleApplication_inc = include_directories('SingleApplication.git')

SingleApplication_moc = qt5.preprocess(
SingleApplication_moc = mod_qt5.preprocess(
moc_headers: ['SingleApplication.git/singleapplication.h', 'SingleApplication.git/singleapplication_p.h'],
moc_extra_arguments: ['-DQAPPLICATION_CLASS=QApplication'],
dependencies: dep_qt5

+ 1
- 1
lang/meson.build View File

@@ -1,4 +1,4 @@

# translations
qt5.compile_translations(ts_files: 'bg.ts', install: get_option('translations').enabled(), install_dir: get_option('datadir') / 'smolbote/translations' , build_by_default: false)
mod_qt5.compile_translations(ts_files: 'bg.ts', install: get_option('translations').enabled(), install_dir: get_option('datadir') / 'smolbote/translations' , build_by_default: false)


+ 5
- 9
lib/about/meson.build View File

@@ -1,16 +1,12 @@
about_moc = qt5.preprocess(
about_moc = mod_qt5.preprocess(
moc_headers: ['aboutdialog.h', 'aboutplugin.h'],
ui_files: ['aboutdialog.ui', 'aboutplugin.ui'],
dependencies: dep_qt5
)

about_inc = include_directories('.')
about_lib = static_library('about', ['aboutdialog.cpp', 'aboutplugin.cpp', about_moc],
dependencies: [dep_qt5, dep_genheaders]
)

dep_about = declare_dependency(
include_directories: about_inc,
link_with: about_lib,
sources: ['aboutdialog.cpp', about_moc]
include_directories: include_directories('.'),
link_with: static_library('about',
['aboutdialog.cpp', 'aboutplugin.cpp', about_moc],
dependencies: [dep_qt5, dep_genheaders])
)

+ 2
- 3
lib/addressbar/meson.build View File

@@ -1,5 +1,5 @@
addressbar_inc = include_directories('.')
addressbar_moc = qt5.preprocess(
addressbar_moc = mod_qt5.preprocess(
moc_headers: ['addressbar.h', 'completer.h', 'urllineedit.h'],
ui_files: ['addressbar.ui'],
dependencies: dep_qt5
@@ -11,6 +11,5 @@ addressbar_lib = static_library('addressbar', ['addressbar.cpp', 'completer.cpp'

dep_addressbar = declare_dependency(
include_directories: addressbar_inc,
link_with: addressbar_lib,
sources: ['addressbar.cpp', 'completer.cpp', 'urllineedit.cpp', addressbar_moc]
link_with: addressbar_lib
)

+ 1
- 1
lib/bookmarks/meson.build View File

@@ -1,5 +1,5 @@
bookmarks_inc = include_directories('.')
bookmarks_moc = qt5.preprocess(
bookmarks_moc = mod_qt5.preprocess(
moc_headers: ['bookmarkswidget.h', 'model/bookmarkmodel.h', 'forms/editbookmarkdialog.h'],
ui_files: ['bookmarksform.ui', 'forms/editbookmarkdialog.ui'],
dependencies: dep_qt5

+ 1
- 1
lib/configuration/meson.build View File

@@ -1,5 +1,5 @@
configuration_inc = include_directories('.')
configuration_moc = qt5.preprocess(
configuration_moc = mod_qt5.preprocess(
moc_headers: ['configuration.h'],
dependencies: dep_qt5
)

+ 1
- 1
lib/downloads/meson.build View File

@@ -1,5 +1,5 @@
downloads_inc = include_directories('.')
downloads_moc = qt5.preprocess(
downloads_moc = mod_qt5.preprocess(
moc_headers: ['downloadswidget.h', 'widgets/downloaditemwidget.h', 'widgets/elidedlabel.h'],
ui_files: ['downloadsform.ui', 'widgets/downloaditemform.ui'],
dependencies: dep_qt5

+ 1
- 1
lib/webprofile/meson.build View File

@@ -1,6 +1,6 @@
webprofile_lib = static_library('webprofile',
['webprofilemanager.cpp', 'webprofile.cpp', interfaces_moc,
qt5.preprocess(moc_headers: ['webprofilemanager.h', 'webprofile.h'], dependencies: dep_qt5)],
mod_qt5.preprocess(moc_headers: ['webprofilemanager.h', 'webprofile.h'], dependencies: dep_qt5)],
dependencies: dep_qt5,
include_directories: [include]
)

+ 25
- 26
meson.build View File

@@ -1,7 +1,9 @@
project('smolbote', 'cpp',
version: 'master',
default_options: ['cpp_std=c++17', 'strip=true', 'warning_level=3'],
license: 'GPL3')
license: 'GPL3',
meson_version: '>=0.49.0'
)

# autogenerate qtcreator project files
# add_postconf_script(script_name, arg1, arg2, ...)
@@ -11,47 +13,46 @@ project('smolbote', 'cpp',

# add -DQT_NO_DEBUG to non-debug builds
if not get_option('debug')
add_global_arguments('-DQT_NO_DEBUG', language: 'cpp')
add_project_arguments('-DQT_NO_DEBUG', language: 'cpp')
endif

# Qt 5
qt5 = import('qt5')
dep_qt5 = dependency('qt5', modules: ['Core', 'Network', 'Widgets', 'WebEngineWidgets', 'Concurrent', 'Test'])
mod_qt5 = import('qt5')
dep_qt5 = dependency('qt5', modules: ['Core', 'Network', 'Widgets', 'WebEngineWidgets', 'Concurrent'])

mod_python = import('python')
python3 = mod_python.find_installation('python3')

# Boost
dep_boost = dependency('boost', modules: ['program_options'])

# spdlog
dep_spdlog = dependency('spdlog', fallback: ['spdlog', 'spdlog_dep'], version: '>=1.3.1')

# Breakpad
optional_deps = []

if get_option('Breakpad').enabled()
dep_breakpad = declare_dependency(
compile_args: '-DBREAKPAD',
dependencies: [dependency('breakpad-client'),
dependency('threads')]
optional_deps += declare_dependency(compile_args: '-DBREAKPAD',
dependencies: [dependency('breakpad-client'), dependency('threads')]
)
else
dep_breakpad = declare_dependency()
endif

# KDE
if get_option('Plasma').enabled()
dep_plasma = declare_dependency(
compile_args: '-DPLASMA',
dependencies: [ dependency('KF5WindowSystem', method: 'cmake'),
dependency('KF5Wallet', method: 'cmake')]
optional_deps += declare_dependency(compile_args: '-DPLASMA',
dependencies: [ dependency('KF5WindowSystem', method: 'cmake'), dependency('KF5Wallet', method: 'cmake')]
)
else
dep_plasma = declare_dependency()
endif

if get_option('Python').enabled()
optional_deps += declare_dependency(compile_args: '-DPYTHON',
dependencies: [ meson.get_compiler('cpp').find_library('linenoise'),
python3.dependency('python', version: '>=3.0.0')])
subdir('src/cli')
endif

dep_gtest = dependency('gtest', required: get_option('testing'))

# Generate config header
include = include_directories('include')

git = find_program('git').path()
pymod = import('python')
python3 = pymod.find_installation('python3')

dep_genheaders = declare_dependency(
include_directories: include_directories('.'),
@@ -70,13 +71,11 @@ dep_genheaders = declare_dependency(
)]
)

interfaces_moc = qt5.preprocess(
interfaces_moc = mod_qt5.preprocess(
moc_headers: 'include/profileinterface.h',
dependencies: dep_qt5
)

dep_gtest = dependency('gtest', required: get_option('testing'))

subdir('lib/about')
subdir('lib/addressbar')
subdir('lib/bookmarks')

+ 1
- 0
meson_options.txt View File

@@ -9,5 +9,6 @@ option('translations', description: 'Generate and install translations', type: '
# Feature options
option('Breakpad', description: 'Enable breakpad crash reporting', type: 'feature', value: 'auto')
option('Plasma', description: 'Enable KDE plasma integration', type: 'feature', value: 'auto')
option('Python', description: 'Enable Python interpreter', type: 'feature', value: 'auto')
option('testing', description: 'Build tests (requires gtest)', type: 'feature', value: 'auto')


+ 1
- 1
plugins/ConfigurationEditor/meson.build View File

@@ -1,4 +1,4 @@
ConfigurationEditorPlugin_moc = qt5.preprocess(
ConfigurationEditorPlugin_moc = mod_qt5.preprocess(
include_directories: include,
moc_headers: ['configurationeditorplugin.h', 'forms/configurationdialog.h'],
ui_files: ['forms/configurationdialog.ui'],

+ 1
- 1
plugins/ProfileEditor/meson.build View File

@@ -1,4 +1,4 @@
ProfileEditorPlugin_moc = qt5.preprocess(
ProfileEditorPlugin_moc = mod_qt5.preprocess(
include_directories: include,
moc_headers: ['profileeditorplugin.h', 'forms/profilemanagerdialog.h', 'forms/profileview.h', 'forms/newprofiledialog.h', 'forms/newhttpheaderdialog.h'],
ui_files: ['forms/profilemanagerdialog.ui', 'forms/profileview.ui', 'forms/newprofiledialog.ui', 'forms/newhttpheaderdialog.ui'],

+ 51
- 0
src/cli/cli.cpp View File

@@ -0,0 +1,51 @@
#include <stdio.h>
#include <stdlib.h>
//#include <string.h>
#include <linenoise.h>
#include <Python.h>

int main(int argc, char** argv)
{
printf("cli test application\n");

wchar_t *program = Py_DecodeLocale(argv[0], NULL);
if (program == NULL) {
fprintf(stderr, "Fatal error: cannot decode argv[0]\n");
exit(1);
}

// inform the interpreter about paths to run-time libraries
Py_SetProgramName(program); /* optional but recommended */


// Initialize the python interpreter
Py_Initialize();

PyRun_SimpleString("print('Python interpreter ready')\n");

const char* prompt = "poi> ";

while(true) {
char *cmd = linenoise(prompt);

if(cmd == nullptr || *cmd == '\0') {
printf("break\n");
free(cmd);
break;
}

//printf("echo(%i):'%s'\n", strlen(cmd), cmd);
PyRun_SimpleString(cmd);
free(cmd);
}

// finalize the interpreter
if (Py_FinalizeEx() < 0) {
exit(120);
}

//
PyMem_RawFree(program);

return 0;
}

+ 4
- 0
src/cli/meson.build View File

@@ -0,0 +1,4 @@
cli_demo = executable('cli', install: false, dependencies: [ optional_deps ],
sources: [ 'cli.cpp' ]
)


+ 2
- 2
src/meson.build View File

@@ -1,5 +1,5 @@
# poi
poi_moc = qt5.preprocess(
poi_moc = mod_qt5.preprocess(
moc_headers: ['browser.h',
'mainwindow/mainwindow.h', 'mainwindow/menubar.h', 'mainwindow/widgets/dockwidget.h', 'mainwindow/widgets/menusearch.h', 'mainwindow/widgets/navigationbar.h', 'mainwindow/widgets/searchform.h',
'session/savesessiondialog.h', 'session/sessiondialog.h', 'session/sessionform.h',
@@ -13,7 +13,7 @@ poi_moc = qt5.preprocess(

poi = executable(get_option('poiName'), install: true,
cpp_args: ['-DQAPPLICATION_CLASS=QApplication'],
dependencies: [dep_qt5, dep_boost, dep_SingleApplication, dep_genheaders, dep_breakpad, dep_plasma, dep_spdlog,
dependencies: [dep_qt5, dep_boost, dep_spdlog, dep_SingleApplication, dep_genheaders, optional_deps,
dep_about, dep_addressbar, dep_bookmarks, dep_configuration, dep_downloads, dep_urlfilter, dep_webprofile],
include_directories: [include],
sources: ['main.cpp', 'builtins.cpp', 'crashhandler.cpp', poi_moc,

Loading…
Cancel
Save