summary refs log tree commit diff stats
path: root/plugins
diff options
context:
space:
mode:
authorPatrick Griffis <tingping@tingping.se>2016-12-13 16:12:03 -0500
committerPatrick Griffis <tingping@tingping.se>2017-06-13 23:54:51 -0400
commit628100c19f5d82747170acdf2917cba8c119ccbf (patch)
tree351a7e9714a1a58390ba349808df5703cef25c3e /plugins
parent2edf50d4ddc61ce6f73bf02263c9bdd09632c66b (diff)
build: Replace Autotools with Meson
Quick rundown of benefits:

- Much faster:
  - Autotools (with autogen): 22 seconds
  - Meson: 7 seconds
  - Meson (with ccache): 2 seconds

- Simpler:
  - ~1000 lines smaller
  - Single simple language

- Potentially better Windows (Visual Studio) support

What is not done:

- Complete Windows support
- OSX support (easy)

Closes #2013
Closes #1937
Closes #1803
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Makefile.am25
-rw-r--r--plugins/checksum/Makefile.am8
-rw-r--r--plugins/checksum/meson.build6
-rw-r--r--plugins/exec/meson.build5
-rw-r--r--plugins/fishlim/Makefile.am10
-rw-r--r--plugins/fishlim/meson.build18
-rw-r--r--plugins/lua/Makefile.am9
-rw-r--r--plugins/lua/meson.build12
-rw-r--r--plugins/meson.build39
-rw-r--r--plugins/perl/Makefile.am20
-rwxr-xr-xplugins/perl/generate_header.py29
-rw-r--r--plugins/perl/meson.build73
-rw-r--r--plugins/python/Makefile.am9
-rw-r--r--plugins/python/meson.build13
-rw-r--r--plugins/python/python.c2
-rw-r--r--plugins/sysinfo/Makefile.am17
-rw-r--r--plugins/sysinfo/meson.build46
-rw-r--r--plugins/upd/meson.build8
-rw-r--r--plugins/winamp/meson.build6
19 files changed, 257 insertions, 98 deletions
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
deleted file mode 100644
index 3880f15d..00000000
--- a/plugins/Makefile.am
+++ /dev/null
@@ -1,25 +0,0 @@
-if DO_LUA
-lua = lua
-endif
-
-if DO_PYTHON
-pythondir = python
-endif
-
-if DO_PERL
-perldir = perl
-endif
-
-if DO_FISHLIM
-fishlimdir = fishlim
-endif
-
-if DO_CHECKSUM
-checksumdir = checksum
-endif
-
-if DO_SYSINFO
-sysinfodir = sysinfo
-endif
-
-SUBDIRS = $(lua) $(pythondir) $(perldir) $(checksumdir) $(fishlimdir) $(sysinfodir)
diff --git a/plugins/checksum/Makefile.am b/plugins/checksum/Makefile.am
deleted file mode 100644
index a38ab732..00000000
--- a/plugins/checksum/Makefile.am
+++ /dev/null
@@ -1,8 +0,0 @@
-libdir = $(hexchatlibdir)
-
-lib_LTLIBRARIES = checksum.la
-checksum_la_SOURCES = checksum.c
-checksum_la_LDFLAGS = $(PLUGIN_LDFLAGS) -module
-checksum_la_LIBADD = $(GLIB_LIBS)
-checksum_la_CPPFLAGS = -I$(top_srcdir)/src/common
-checksum_la_CFLAGS = $(GLIB_CFLAGS)
diff --git a/plugins/checksum/meson.build b/plugins/checksum/meson.build
new file mode 100644
index 00000000..25835457
--- /dev/null
+++ b/plugins/checksum/meson.build
@@ -0,0 +1,6 @@
+shared_module('checksum', 'checksum.c',
+  dependencies: [libgio_dep, hexchat_plugin_dep],
+  install: true,
+  install_dir: plugindir,
+  name_prefix: '',
+)
diff --git a/plugins/exec/meson.build b/plugins/exec/meson.build
new file mode 100644
index 00000000..3f9e8a32
--- /dev/null
+++ b/plugins/exec/meson.build
@@ -0,0 +1,5 @@
+shared_module('exec', 'exec.c',
+  dependencies: hexchat_plugin_dep,
+  install: true,
+  install_dir: plugindir
+)
diff --git a/plugins/fishlim/Makefile.am b/plugins/fishlim/Makefile.am
deleted file mode 100644
index 96069069..00000000
--- a/plugins/fishlim/Makefile.am
+++ /dev/null
@@ -1,10 +0,0 @@
-EXTRA_DIST = LICENSE fish.h irc.h keystore.h plugin_hexchat.h dh1080.h
-
-libdir = $(hexchatlibdir)
-
-lib_LTLIBRARIES = fishlim.la
-fishlim_la_SOURCES = fish.c irc.c keystore.c plugin_hexchat.c dh1080.c
-fishlim_la_LDFLAGS = $(PLUGIN_LDFLAGS) -module
-fishlim_la_LIBADD = $(GLIB_LIBS) $(OPENSSL_LIBS)
-fishlim_la_CPPFLAGS = -I$(top_srcdir)/src/common
-fishlim_la_CFLAGS = $(GLIB_CFLAGS) $(OPENSSL_CFLAGS)
diff --git a/plugins/fishlim/meson.build b/plugins/fishlim/meson.build
new file mode 100644
index 00000000..894923aa
--- /dev/null
+++ b/plugins/fishlim/meson.build
@@ -0,0 +1,18 @@
+if not libssl_dep.found()
+  error('fish plugin requires openssl')
+endif
+
+fishlim_sources = [
+  'dh1080.c',
+  'fish.c',
+  'irc.c',
+  'keystore.c',
+  'plugin_hexchat.c'
+]
+
+shared_module('fishlim', fishlim_sources,
+  dependencies: [libgio_dep, hexchat_plugin_dep, libssl_dep],
+  install: true,
+  install_dir: plugindir,
+  name_prefix: '',
+)
diff --git a/plugins/lua/Makefile.am b/plugins/lua/Makefile.am
deleted file mode 100644
index b98d5f66..00000000
--- a/plugins/lua/Makefile.am
+++ /dev/null
@@ -1,9 +0,0 @@
-libdir = $(hexchatlibdir)
-
-lib_LTLIBRARIES = lua.la
-lua_la_SOURCES = lua.c
-lua_la_LDFLAGS = $(PLUGIN_LDFLAGS) -module
-lua_la_LIBADD = $(LUA_LIBS) $(GLIB_LIBS)
-lua_la_CPPFLAGS = -I$(top_srcdir)/src/common
-lua_la_CFLAGS = $(GLIB_CFLAGS) $(LUA_CFLAGS)
-
diff --git a/plugins/lua/meson.build b/plugins/lua/meson.build
new file mode 100644
index 00000000..7faa3054
--- /dev/null
+++ b/plugins/lua/meson.build
@@ -0,0 +1,12 @@
+if cc.get_id() == 'msvc'
+  lua_dep = cc.find_library('lua51')
+else
+  lua_dep = dependency(get_option('with-lua'))
+endif
+
+shared_module('lua', 'lua.c',
+  dependencies: [libgio_dep, hexchat_plugin_dep, lua_dep],
+  install: true,
+  install_dir: plugindir,
+  name_prefix: '',
+)
diff --git a/plugins/meson.build b/plugins/meson.build
new file mode 100644
index 00000000..9e7fae93
--- /dev/null
+++ b/plugins/meson.build
@@ -0,0 +1,39 @@
+plugindir = join_paths(get_option('libdir'), 'hexchat/plugins')
+
+if host_machine.system() == 'windows'
+  if get_option('with-exec')
+    subdir('exec')
+  endif
+
+  if get_option('with-upd')
+    subdir('upd')
+  endif
+
+  if get_option('with-winamp')
+    subdir('winamp')
+  endif
+endif
+
+if get_option('with-checksum')
+  subdir('checksum')
+endif
+
+if get_option('with-fishlim')
+  subdir('fishlim')
+endif
+
+if get_option('with-lua') != 'false'
+  subdir('lua')
+endif
+
+if get_option('with-perl')
+  subdir('perl')
+endif
+
+if get_option('with-python') != 'false'
+  subdir('python')
+endif
+
+if get_option('with-sysinfo')
+  subdir('sysinfo')
+endif
diff --git a/plugins/perl/Makefile.am b/plugins/perl/Makefile.am
deleted file mode 100644
index af721e7e..00000000
--- a/plugins/perl/Makefile.am
+++ /dev/null
@@ -1,20 +0,0 @@
-
-EXTRA_DIST=generate_header lib/HexChat.pm lib/Xchat.pm lib/HexChat/Embed.pm lib/HexChat/List/Network.pm \
-	lib/HexChat/List/Network/Entry.pm lib/HexChat/List/Network/AutoJoin.pm lib/IRC.pm
-
-libdir = $(hexchatlibdir)
-
-lib_LTLIBRARIES = perl.la
-perl_la_SOURCES = perl.c
-perl_la_LDFLAGS = $(PERL_LDFLAGS) $(PLUGIN_LDFLAGS) -module
-perl_la_LIBADD = $(GLIB_LIBS)
-perl_la_CPPFLAGS = -I$(top_srcdir)/src/common
-perl_la_CFLAGS = $(PERL_CFLAGS) $(GLIB_CFLAGS)
-
-BUILT_SOURCES = hexchat.pm.h irc.pm.h
-CLEANFILES = $(BUILT_SOURCES)
-
-hexchat.pm.h irc.pm.h: lib/HexChat.pm lib/Xchat.pm lib/HexChat/Embed.pm \
-	lib/HexChat/List/Network.pm lib/HexChat/List/Network/Entry.pm \
-	lib/HexChat/List/Network/AutoJoin.pm lib/IRC.pm
-	cd $(srcdir); perl generate_header
diff --git a/plugins/perl/generate_header.py b/plugins/perl/generate_header.py
new file mode 100755
index 00000000..ba7e02a3
--- /dev/null
+++ b/plugins/perl/generate_header.py
@@ -0,0 +1,29 @@
+#!/usr/bin/env python3
+
+import sys
+from os.path import basename
+
+out_file = sys.argv[1]
+in_files = sys.argv[2:]
+
+
+def escape_perl(file):
+    ret = ''
+    for line in file:
+        # Escape " and \, strip empty space, shove in C strings.
+        ret += '"' + line.strip().replace('\\', '\\\\').replace('"', '\\"') + '\\n"\n'
+    return ret
+
+
+with open(out_file, 'w') as o:
+    o.write('"BEGIN {\\n"\n')
+    for in_file in in_files:
+        o.write("\"$INC{{'{}'}} = 'Compiled into the plugin.';\\n\"\n".format(basename(in_file)))
+    o.write('"}\\n"\n')
+
+    for in_file in in_files:
+        o.write('"{\\n"\n')
+        o.write('"#line 1 \\"{}\\"\\n"\n'.format(basename(in_file)))
+        with open(in_file) as i:
+            o.write(escape_perl(i))
+        o.write('"}\\n"\n')
diff --git a/plugins/perl/meson.build b/plugins/perl/meson.build
new file mode 100644
index 00000000..49011884
--- /dev/null
+++ b/plugins/perl/meson.build
@@ -0,0 +1,73 @@
+generate_perl_header = find_program('generate_header.py')
+
+hexchat_perl_module = custom_target('hexchat-perl-header',
+  input: [
+    'lib/HexChat.pm',
+    'lib/Xchat.pm',
+    'lib/HexChat/Embed.pm',
+    'lib/HexChat/List/Network.pm',
+    'lib/HexChat/List/Network/Entry.pm',
+    'lib/HexChat/List/Network/AutoJoin.pm',
+  ],
+  output: 'hexchat.pm.h',
+  command: [generate_perl_header, '@OUTPUT@', '@INPUT@']
+)
+
+irc_perl_module = custom_target('irc-perl-header',
+  input: 'lib/IRC.pm',
+  output: 'irc.pm.h',
+  command: [generate_perl_header, '@OUTPUT@', '@INPUT@']
+)
+
+perl = find_program('perl')
+
+ret = run_command([perl, '-MExtUtils::Embed', '-e', 'ccopts'])
+if ret.returncode() != 0
+  error('perl: Failed to get cflags')
+endif
+perl_cflags = []
+foreach flag : ret.stdout().strip().split(' ')
+  if flag.startswith('-I') or flag.startswith('-D')
+    perl_cflags += flag
+  endif
+endforeach
+
+ret = run_command([perl, '-MExtUtils::Embed', '-e', 'ldopts'])
+if ret.returncode() != 0
+  error('perl: Failed to get ldflags')
+endif
+perl_ldflags = []
+foreach flag : ret.stdout().strip().split(' ')
+  if flag.startswith('-L') or flag.startswith('-l')
+    perl_ldflags += flag
+  endif
+endforeach
+
+perl_cflags += [
+  # Perl has its own 'config.h' that we must override
+  # TODO: Just rename ours to something more unique.
+  '-include', meson.build_root() + '/config.h'
+]
+
+if not cc.links('''
+#define PERL_NO_INLINE_FUNCTIONS
+#include <EXTERN.h>
+#include <perl.h>
+
+int main(void) {
+  PerlInterpreter *my_perl = perl_alloc();
+  return 0;
+}
+''', args: perl_cflags + perl_ldflags)
+  error('found perl not suitable for plugin')
+endif
+
+shared_module('perl',
+  sources: ['perl.c', hexchat_perl_module, irc_perl_module],
+  dependencies: [libgio_dep, hexchat_plugin_dep],
+  c_args: perl_cflags,
+  link_args: perl_ldflags,
+  install: true,
+  install_dir: plugindir,
+  name_prefix: '',
+)
diff --git a/plugins/python/Makefile.am b/plugins/python/Makefile.am
deleted file mode 100644
index 3c574edf..00000000
--- a/plugins/python/Makefile.am
+++ /dev/null
@@ -1,9 +0,0 @@
-libdir = $(hexchatlibdir)
-
-lib_LTLIBRARIES = python.la
-python_la_SOURCES = python.c
-python_la_LDFLAGS = $(PLUGIN_LDFLAGS) -module
-python_la_LIBADD = $(PYTHON_LIBS) $(GLIB_LIBS)
-python_la_CPPFLAGS = -I$(top_srcdir)/src/common $(PYTHON_CPPFLAGS)
-python_la_CFLAGS = $(GLIB_CFLAGS)
-
diff --git a/plugins/python/meson.build b/plugins/python/meson.build
new file mode 100644
index 00000000..e24f0c6f
--- /dev/null
+++ b/plugins/python/meson.build
@@ -0,0 +1,13 @@
+python_opt = get_option('with-python')
+if python_opt.startswith('python3')
+  python_dep = dependency(python_opt, version: '>= 3.3')
+else
+  python_dep = dependency(python_opt, version: '>= 2.7')
+endif
+
+shared_module('python', 'python.c',
+  dependencies: [libgio_dep, hexchat_plugin_dep, python_dep],
+  install: true,
+  install_dir: plugindir,
+  name_prefix: '',
+)
diff --git a/plugins/python/python.c b/plugins/python/python.c
index 6d88e4dd..705fe9e6 100644
--- a/plugins/python/python.c
+++ b/plugins/python/python.c
@@ -69,6 +69,8 @@
 #include "hexchat-plugin.h"
 #undef _POSIX_C_SOURCE	/* Avoid warnings from /usr/include/features.h */
 #undef _XOPEN_SOURCE
+#undef HAVE_MEMRCHR /* Avoid redefinition in Python.h */
+#undef HAVE_STRINGS_H
 #include <Python.h>
 #include <structmember.h>
 #include <pythread.h>
diff --git a/plugins/sysinfo/Makefile.am b/plugins/sysinfo/Makefile.am
deleted file mode 100644
index 60042018..00000000
--- a/plugins/sysinfo/Makefile.am
+++ /dev/null
@@ -1,17 +0,0 @@
-libdir = $(hexchatlibdir)
-
-sources = sysinfo.c format.c shared/df.c
-
-if PLATFORM_OSX
-sources += osx/backend.m
-else
-sources += unix/backend.c unix/match.c unix/parse.c unix/pci.c
-endif
-
-EXTRA_DIST = osx unix win32 shared format.h sysinfo.h sysinfo-backend.h
-
-lib_LTLIBRARIES = sysinfo.la
-sysinfo_la_SOURCES = $(sources)
-sysinfo_la_LDFLAGS = $(PLUGIN_LDFLAGS) -module
-sysinfo_la_LIBADD = $(LIBPCI_LIBS) $(GLIB_LIBS)
-AM_CPPFLAGS = -I$(top_srcdir)/src/common -I$(srcdir)/shared $(LIBPCI_CFLAGS) $(GLIB_CFLAGS)
diff --git a/plugins/sysinfo/meson.build b/plugins/sysinfo/meson.build
new file mode 100644
index 00000000..2bee3e76
--- /dev/null
+++ b/plugins/sysinfo/meson.build
@@ -0,0 +1,46 @@
+sysinfo_sources = [
+  'format.c',
+  'sysinfo.c',
+]
+
+sysinfo_deps = [
+  libgio_dep,
+  hexchat_plugin_dep
+]
+
+sysinfo_includes = []
+
+system = host_machine.system()
+if system == 'linux' or system == 'darwin'
+  sysinfo_includes += 'shared'
+  sysinfo_sources += [
+    'shared/df.c'
+  ]
+
+  if system == 'linux'
+    sysinfo_deps += dependency('libpci')
+    sysinfo_includes += 'unix'
+    sysinfo_sources += [
+      'unix/backend.c',
+      'unix/match.c',
+      'unix/parse.c',
+      'unix/pci.c',
+    ]
+  elif system == 'darwin'
+    add_languages('objc')
+    sysinfo_sources += 'osx/backend.m'
+  endif
+
+elif system == 'windows'
+  sysinfo_sources += 'win32/backend.c'
+else
+  error('sysinfo: Unknown system?')
+endif
+
+shared_module('sysinfo', sysinfo_sources,
+  dependencies: sysinfo_deps,
+  include_directories: include_directories(sysinfo_includes),
+  install: true,
+  install_dir: plugindir,
+  name_prefix: '',
+)
\ No newline at end of file
diff --git a/plugins/upd/meson.build b/plugins/upd/meson.build
new file mode 100644
index 00000000..7ab9d830
--- /dev/null
+++ b/plugins/upd/meson.build
@@ -0,0 +1,8 @@
+winsparkle_dep = cc.find_library('WinSparkle')
+
+shared_module('upd', 'upd.c',
+  dependencies: [winsparkle_dep, hexchat_plugin_dep],
+  install: true,
+  install_dir: plugindir,
+  name_prefix: '',
+)
diff --git a/plugins/winamp/meson.build b/plugins/winamp/meson.build
new file mode 100644
index 00000000..b07e7071
--- /dev/null
+++ b/plugins/winamp/meson.build
@@ -0,0 +1,6 @@
+shared_module('winamp', 'winamp.c',
+  dependencies: [libgio_dep, hexchat_plugin_dep],
+  install: true,
+  install_dir: plugindir,
+  name_prefix: '',
+)