From c7fdeb683b6f4a7f10bce9ee24f165d77027397b Mon Sep 17 00:00:00 2001 From: mcb2003 Date: Sat, 10 Dec 2022 15:43:42 +0000 Subject: [PATCH 1/2] Create Meson build files Tolk can now be built with Meson. The Meson build system builds Tolk.dll, TolkDotNet.dll, and Tolk.jar, and is instructed on how to distribute tolk.py, and build and distribute README.html. Meson feature options are used to determine which bindings are built and distributed. By default, they're set to auto, so bindings will automatically be built if the corrisponding language compilers / runtimes are found. There is also a feature option for docs, which will build the documentation if Pandoc is found when set to auto. There is also a boolean feature that determines whether JNI support is enabled. If building Java bindings, this will be forced on. This makes it significantly easier to use Tolk from Meson projects as a subproject. It also means Tolk benefits from Meson's existing features and compiler / language support and integration, so theoretically one could more easily build Tolk with MinGW. --- docs/meson.build | 21 +++++++++++++++++++++ meson-install.bat | 10 ++++++++++ meson.build | 21 +++++++++++++++++++++ meson_options.txt | 5 +++++ src/dotnet/meson.build | 14 ++++++++++++++ src/java/meson.build | 9 +++++++++ src/meson.build | 34 ++++++++++++++++++++++++++++++++++ src/python/meson.build | 9 +++++++++ 8 files changed, 123 insertions(+) create mode 100644 docs/meson.build create mode 100644 meson-install.bat create mode 100644 meson.build create mode 100644 meson_options.txt create mode 100644 src/dotnet/meson.build create mode 100644 src/java/meson.build create mode 100644 src/meson.build create mode 100644 src/python/meson.build diff --git a/docs/meson.build b/docs/meson.build new file mode 100644 index 0000000..f4defa3 --- /dev/null +++ b/docs/meson.build @@ -0,0 +1,21 @@ +pandoc = find_program('pandoc', required: get_option('docs')) +if pandoc.found() + doctitle = meson.project_name() + docauthor = 'Davy Kager' + + tolk_docs = custom_target('docs', + output : 'README.html', + input : 'README.md', + command : [pandoc, + '-s', '--toc', + '-M', 'title="@0@"'.format(doctitle), + '-M', 'author="@0@"'.format(docauthor), + '-r', 'markdown', '-w', 'html5', + '-o', '@OUTPUT@', '@INPUT@' + ], + install : true, + install_dir : get_option('datadir') / 'doc' / meson.project_name() + ) +endif + +summary('Documentation', pandoc.found()) diff --git a/meson-install.bat b/meson-install.bat new file mode 100644 index 0000000..46feb1e --- /dev/null +++ b/meson-install.bat @@ -0,0 +1,10 @@ +@echo off + +if %1 == x86_64 ( + set arch=x64 +) else ( + set arch=%1 +) + +copy %MESON_SOURCE_ROOT%\libs\%arch%\* %MESON_INSTALL_DESTDIR_PREFIX%\bin +copy %MESON_SOURCE_ROOT%\LICENSE* %MESON_INSTALL_DESTDIR_PREFIX%\share\doc\tolk diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..fdc5dd7 --- /dev/null +++ b/meson.build @@ -0,0 +1,21 @@ +project('tolk', ['c', 'cpp'], + version: '1.0', + license: 'lgpl-3-or-later', + default_options: ['warning_level=3'], + meson_version: '>=0.59.0', +) + +windows = import('windows') + +# Determine if we need JNI support +building_java = add_languages('java', native: false, required: get_option('java')) +building_jni = get_option('jni') or building_java +summary('JNI support', building_jni) + +subdir('src') + subdir('src/dotnet') + subdir('src/java') + subdir('src/python') + subdir('docs') + +meson.add_install_script('meson-install.bat', build_machine.cpu_family()) diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 0000000..8bea713 --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,5 @@ +option('jni', type : 'boolean', value : false) +option('dotnet', type : 'feature', value : 'auto') +option('python', type : 'feature', value : 'auto') +option('java', type : 'feature', value : 'auto') +option('docs', type : 'feature', value : 'auto') diff --git a/src/dotnet/meson.build b/src/dotnet/meson.build new file mode 100644 index 0000000..113fc73 --- /dev/null +++ b/src/dotnet/meson.build @@ -0,0 +1,14 @@ +building_dotnet = add_languages('cs', native: false, required: get_option('dotnet')) +if building_dotnet + tolkdotnet_srcs = ['Tolk.cs'] + tolkdotnet_res = windows.compile_resources('TolkDotNet.rc') + tolkdotnet_srcs += tolkdotnet_res + + tolkdotnet_lib = library('TolkDotNet', + sources: tolkdotnet_srcs, + cs_args: '/nologo', + install: true + ) +endif + +summary('DotNet', building_dotnet, section: 'Bindings') diff --git a/src/java/meson.build b/src/java/meson.build new file mode 100644 index 0000000..cf5fd24 --- /dev/null +++ b/src/java/meson.build @@ -0,0 +1,9 @@ +if building_java + tolk_jar_srcs = ['com/davykager/tolk/Tolk.java'] + tolk_jar = jar('Tolk', + sources: tolk_jar_srcs, + install: true + ) +endif + +summary('Java', building_java, section: 'Bindings') diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 0000000..17cc68a --- /dev/null +++ b/src/meson.build @@ -0,0 +1,34 @@ +tolk_srcs = [ + 'fsapi.c', + 'ScreenReaderDriverJAWS.cpp', + 'ScreenReaderDriverNVDA.cpp', + 'ScreenReaderDriverSA.cpp', + 'ScreenReaderDriverSAPI.cpp', + 'ScreenReaderDriverSNova.cpp', + 'ScreenReaderDriverWE.cpp', + 'ScreenReaderDriverZT.cpp', + 'Tolk.cpp', + 'wineyes.c', + 'zt.c', +] +tolk_cflags = ['-D_EXPORTING', '-DUNICODE'] +tolk_incdir = include_directories('.') + +if building_jni + tolk_cflags += ['-D_WITH_JNI'] + tolk_srcs += 'TolkJNI.cpp' +endif + +tolk_res = windows.compile_resources('Tolk.rc') +tolk_srcs += tolk_res + + tolk_lib = library('Tolk', + sources: tolk_srcs, + c_args: tolk_cflags, + cpp_args: tolk_cflags, + include_directories: tolk_incdir, + install: true +) + + # Make this project usable as a Meson subproject +tolk_dep = declare_dependency(link_with: tolk_lib, include_directories: tolk_incdir) diff --git a/src/python/meson.build b/src/python/meson.build new file mode 100644 index 0000000..26c87e6 --- /dev/null +++ b/src/python/meson.build @@ -0,0 +1,9 @@ +pymod = import('python', required: get_option('python')) +if pymod.found() + python = pymod.find_installation('python3', required: get_option('python')) + if python.found() + python.install_sources('Tolk.py') + endif +endif + +summary('Python', pymod.found() and python.found(), section: 'Bindings') From f67e7cc916e3f91a93005ef65205741464adcb1e Mon Sep 17 00:00:00 2001 From: mcb2003 Date: Sat, 10 Dec 2022 16:27:04 +0000 Subject: [PATCH 2/2] Add descriptions to Meson options --- meson_options.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/meson_options.txt b/meson_options.txt index 8bea713..b0f07d1 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,5 +1,5 @@ -option('jni', type : 'boolean', value : false) -option('dotnet', type : 'feature', value : 'auto') -option('python', type : 'feature', value : 'auto') -option('java', type : 'feature', value : 'auto') -option('docs', type : 'feature', value : 'auto') +option('jni', type : 'boolean', value : false, description: 'Build with Java Native Interface support') +option('dotnet', type : 'feature', value : 'auto', description: 'Build DotNet bindings') +option('python', type : 'feature', value : 'auto', description: 'Install Python bindings') +option('java', type : 'feature', value : 'auto', description: 'Build Java bindings. Implies -Djni=true') +option('docs', type : 'feature', value : 'auto', description: 'Build documentation using Pandoc')