From f1c9f8d210493b604fc81fff7209e5abc74affbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Techet?= Date: Mon, 5 Aug 2024 11:53:16 +0200 Subject: [PATCH] Add meson build support Mostly copied from https://github.com/geany/geany-plugins/pull/1345 --- meson.build | 90 ++++++++++++++++++++++++++++++++++++++++ meson_config/config.h.in | 18 ++++++++ meson_config/meson.build | 38 +++++++++++++++++ 3 files changed, 146 insertions(+) create mode 100644 meson.build create mode 100644 meson_config/config.h.in create mode 100644 meson_config/meson.build diff --git a/meson.build b/meson.build new file mode 100644 index 000000000..9d2cbaa3b --- /dev/null +++ b/meson.build @@ -0,0 +1,90 @@ +project( + 'geany-lsp', + 'c', + license : 'GPL-2.0', + version : '2.1' +) + +plugin_name = 'lsp' + +i18n = import('i18n') +# define GETTEXT_PACKAGE +add_project_arguments('-DGETTEXT_PACKAGE="intltest"', language:'c') +i18n.gettext(meson.project_name()) + +subdir('meson_config') + + +geany_dep = dependency('geany') + +plugin_suffix = [] +if (host_machine.system() == 'darwin') + plugin_suffix = 'so' # use "so" instead of "dylib" so Geany finds plugins correctly +endif + +plugin_inc = [include_directories('lsp/deps/json-glib', 'lsp/deps/jsonrpc-glib', 'lsp/deps', 'lsp/src')] + +shared_module('lsp', + 'lsp/deps/json-glib/json-array.c', + 'lsp/deps/json-glib/json-builder.c', + 'lsp/deps/json-glib/json-debug.c', + 'lsp/deps/json-glib/json-gboxed.c', + 'lsp/deps/json-glib/json-generator.c', + 'lsp/deps/json-glib/json-gobject.c', + 'lsp/deps/json-glib/json-gvariant.c', + 'lsp/deps/json-glib/json-node.c', + 'lsp/deps/json-glib/json-object.c', + 'lsp/deps/json-glib/json-parser.c', + 'lsp/deps/json-glib/json-path.c', + 'lsp/deps/json-glib/json-reader.c', + 'lsp/deps/json-glib/json-scanner.c', + 'lsp/deps/json-glib/json-serializable.c', + 'lsp/deps/json-glib/json-utils.c', + 'lsp/deps/json-glib/json-value.c', + + 'lsp/deps/jsonrpc-glib/jsonrpc-client.c', + 'lsp/deps/jsonrpc-glib/jsonrpc-input-stream.c', + 'lsp/deps/jsonrpc-glib/jsonrpc-message.c', + 'lsp/deps/jsonrpc-glib/jsonrpc-output-stream.c', + 'lsp/deps/jsonrpc-glib/jsonrpc-server.c', + 'lsp/deps/jsonrpc-glib/jsonrpc-marshalers.c', + + 'lsp/src/lsp-autocomplete.c', + 'lsp/src/lsp-main.c', + 'lsp/src/lsp-server.c', + 'lsp/src/lsp-sync.c', + 'lsp/src/lsp-rpc.c', + 'lsp/src/lsp-diagnostics.c', + 'lsp/src/lsp-hover.c', + 'lsp/src/lsp-signature.c', + 'lsp/src/lsp-log.c', + 'lsp/src/lsp-goto.c', + 'lsp/src/lsp-progress.c', + 'lsp/src/lsp-symbols.c', + 'lsp/src/lsp-symbol-kinds.c', + 'lsp/src/lsp-semtokens.c', + 'lsp/src/lsp-goto-panel.c', + 'lsp/src/lsp-goto-anywhere.c', + 'lsp/src/lsp-format.c', + 'lsp/src/lsp-highlight.c', + 'lsp/src/lsp-rename.c', + 'lsp/src/lsp-command.c', + 'lsp/src/lsp-code-lens.c', + 'lsp/src/lsp-symbol.c', + 'lsp/src/lsp-extension.c', + 'lsp/src/lsp-utils.c', + 'lsp/src/lsp-workspace-folders.c', + name_prefix: '', # "lib" seems to be the default prefix + name_suffix: plugin_suffix, + include_directories: plugin_inc, + c_args: ['-DJSON_COMPILATION', '-DJSONRPC_GLIB_COMPILATION'], + dependencies: [config_dep, geany_dep], + install_dir: plugin_path, + install: true +) + + +lsp_conf = [ + 'lsp/data/lsp.conf', +] +install_data(sources: lsp_conf, install_dir: plugin_datadir) diff --git a/meson_config/config.h.in b/meson_config/config.h.in new file mode 100644 index 000000000..0d33a87fc --- /dev/null +++ b/meson_config/config.h.in @@ -0,0 +1,18 @@ +#pragma once + +#define VERSION "@version@" + +#define GEANY_VERSION "@geany_version@" + +#define PLUGIN "@plugin_name@" + +#define DOCDIR "@prefix@/@docdir@" +#define LIBDIR "@prefix@/@libdir@" +#define LOCALEDIR "@prefix@/@localedir@" + +#define GEANYPLUGINS_DATADIR "@prefix@/@plugin_datadir@" +#define DBGPLUG_DATA_DIR "@prefix@/@plugin_datadir@" +#define PLUGINDATADIR "@prefix@/@plugin_datadir@" + +#define PLUGINDOCDIR "@prefix@/@plugin_docdir@" +#define PLUGINHTMLDOCDIR "@prefix@/@plugin_docdir@/html" diff --git a/meson_config/meson.build b/meson_config/meson.build new file mode 100644 index 000000000..58b5c2eaa --- /dev/null +++ b/meson_config/meson.build @@ -0,0 +1,38 @@ +docdir = get_option('datadir') / 'doc' +project_datadir = get_option('datadir') / 'geany-plugins' +project_libdir = get_option('libdir') / 'geany-plugins' +project_docdir = docdir / 'geany-plugins' + +plugin_datadir = project_datadir / plugin_name +plugin_libdir = project_libdir / plugin_name +plugin_docdir = project_docdir / plugin_name + +plugin_path = get_option('libdir') / 'geany' + +conf_data = configuration_data() + +conf_data.set('plugin_name', plugin_name) +conf_data.set('plugin_path', plugin_path) + +conf_data.set('version', meson.project_version()) +conf_data.set('geany_version', '2.0.0') + +conf_data.set('prefix', get_option('prefix')) +conf_data.set('libdir', get_option('libdir')) +conf_data.set('docdir', docdir) +conf_data.set('localedir', get_option('localedir')) + +conf_data.set('plugin_datadir', plugin_datadir) +conf_data.set('plugin_libdir', plugin_libdir) +conf_data.set('plugin_docdir', plugin_docdir) + +configure_file( + input: 'config.h.in', + output: 'config.h', + configuration: conf_data, +) + +config_dep = declare_dependency( + include_directories: include_directories('.'), + compile_args: ['-DHAVE_CONFIG_H'], +)