diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 7ab9e8f9..53bc0239 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -8,11 +8,11 @@ jobs: strategy: matrix: - os: [ubuntu-22.04, ubuntu-24.04, ubuntu-26.04] + os: [ubuntu-24.04, ubuntu-26.04] steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v2 + - uses: actions/checkout@v7 - name: Update APT cache run: sudo apt-get update --quiet diff --git a/bin/meson.build b/bin/meson.build index 41d5e5f1..c60b8739 100644 --- a/bin/meson.build +++ b/bin/meson.build @@ -1,3 +1,13 @@ -vsgi_loader = executable('vsgi-loader-@0@'.format(api_version), 'vsgi-loader.vala', - dependencies: [glib, gobject, gio, gmodule, soup, vsgi_dep], - install: true) +vsgi_loader = executable( + 'vsgi-loader-@0@'.format(api_version), + 'vsgi-loader.vala', + dependencies: [ + glib_dep, + gobject_dep, + gio_dep, + gmodule_dep, + soup_dep, + vsgi_dep, + ], + install: true, +) diff --git a/meson.build b/meson.build index 28ef8b07..640b3fc4 100644 --- a/meson.build +++ b/meson.build @@ -1,23 +1,32 @@ -project('vsgi', 'vala', 'c', - version: '0.4.0-dev', - license: 'LGPL', - meson_version: '>=0.46.0') +project( + 'vsgi', + 'vala', + 'c', + version: '0.4.0-dev', + license: 'LGPL', + meson_version: '>=1.3', +) api_version = '0.4' -add_project_arguments(['--enable-experimental', - '--enable-deprecated', - '--vapidir', join_paths(meson.current_source_dir(), 'vapi')], - language: 'vala') +add_project_arguments( + [ + '--enable-experimental', + '--target-glib=2.80', + '--vapidir', + meson.current_source_dir() / 'vapi', + ], + language: 'vala', +) -glib = dependency('glib-2.0', version: '>=2.56') -gobject = dependency('gobject-2.0', version: '>=2.56') -gio = dependency('gio-2.0', version: '>=2.56') -gio_unix = dependency('gio-unix-2.0', version: '>=2.56') -gmodule = dependency('gmodule-2.0', version: '>=2.40') -soup = dependency('libsoup-2.4', version: '>=2.62') -openssl = dependency('openssl') -posix = meson.get_compiler('vala').find_library('posix') +glib_dep = dependency('glib-2.0', version: '>=2.80') +gobject_dep = dependency('gobject-2.0', version: '>=2.80') +gio_dep = dependency('gio-2.0', version: '>=2.80') +gio_unix_dep = dependency('gio-unix-2.0', version: '>=2.80') +gmodule_dep = dependency('gmodule-2.0', version: '>=2.80') +soup_dep = dependency('libsoup-2.4', version: '>=2.74') +openssl_dep = dependency('openssl') +posix_dep = meson.get_compiler('vala').find_library('posix') if meson.get_compiler('c').has_function('memmem') add_project_arguments('--define=HAVE_MEMMEM', language: 'vala') diff --git a/src/meson.build b/src/meson.build index 58c79b12..b6b8958c 100644 --- a/src/meson.build +++ b/src/meson.build @@ -16,39 +16,75 @@ vsgi_sources = files( 'vsgi-server-module.vala', 'vsgi-server.vala', 'vsgi-socket-server.vala', - 'vsgi-tee-output-stream.vala') -vsgi_lib = library('vsgi-' + api_version, vsgi_sources, - dependencies: [glib, gobject, gio, gio_unix, gmodule, soup, openssl, posix], - vala_header: 'vsgi.h', - vala_gir: 'VSGI-@0@.gir'.format(api_version), - build_rpath: join_paths(meson.current_build_dir(), 'servers'), - link_args: ['-Wl,--disable-new-dtags'], - install: true, - install_dir: [true, 'include/vsgi-' + api_version, true, true], - install_rpath: join_paths(get_option('prefix'), get_option('libdir'), 'vsgi-@0@/servers'.format(api_version))) + 'vsgi-tee-output-stream.vala', +) -install_data('vsgi-@0@.deps'.format(api_version), - install_dir: 'share/vala/vapi') +vsgi_lib_extra_args = { + 'install_dir': [true, 'include/vsgi-' + api_version, true, true], +} -vsgi_dep = declare_dependency(include_directories: include_directories('.'), - link_with: vsgi_lib) +vsgi_lib = library( + 'vsgi-' + api_version, + vsgi_sources, + dependencies: [ + glib_dep, + gobject_dep, + gio_dep, + gio_unix_dep, + gmodule_dep, + soup_dep, + openssl_dep, + posix_dep, + ], + vala_header: 'vsgi.h', + vala_gir: 'VSGI-@0@.gir'.format(api_version), + build_rpath: meson.current_build_dir() / 'servers', + link_args: ['-Wl,--disable-new-dtags'], + install: true, + install_rpath: get_option('prefix') / get_option('libdir') / 'vsgi-@0@/servers'.format( + api_version, + ), + kwargs: vsgi_lib_extra_args, +) + +install_data('vsgi-@0@.deps'.format(api_version), install_dir: 'share/vala/vapi') + +vsgi_dep = declare_dependency( + include_directories: include_directories('.'), + link_with: vsgi_lib, +) +meson.override_dependency('vsgi', vsgi_dep) if get_option('with_introspection') g_ir_compiler = find_program('g-ir-compiler') - custom_target('VSGI typelib', - command: [g_ir_compiler, '--shared-library', vsgi_lib.full_path(), '--output', '@OUTPUT@', join_paths(meson.current_build_dir(), 'VSGI-@0@.gir'.format(api_version))], - output: 'VSGI-@0@.typelib'.format(api_version), - depends: vsgi_lib, - install: true, - install_dir: join_paths(get_option('libdir'), 'girepository-1.0')) + custom_target( + 'VSGI typelib', + command: [ + g_ir_compiler, + '--shared-library', + vsgi_lib.full_path(), + '--output', + '@OUTPUT@', + join_paths( + meson.current_build_dir(), + 'VSGI-@0@.gir'.format(api_version), + ), + ], + output: 'VSGI-@0@.typelib'.format(api_version), + depends: vsgi_lib, + install: true, + install_dir: join_paths(get_option('libdir'), 'girepository-1.0'), + ) endif pkgconfig = import('pkgconfig') -pkgconfig.generate(vsgi_lib, - version: meson.project_version(), - name: 'VSGI', - filebase: 'vsgi-' + api_version, - description: 'Interface and implementations for various web server technologies', - subdirs: 'vsgi-' + api_version) +pkgconfig.generate( + vsgi_lib, + version: meson.project_version(), + name: 'VSGI', + filebase: 'vsgi-' + api_version, + description: 'Interface and implementations for various web server technologies', + subdirs: 'vsgi-' + api_version, +) subdir('servers') diff --git a/src/servers/meson.build b/src/servers/meson.build index ffa21f0f..5e5d154b 100644 --- a/src/servers/meson.build +++ b/src/servers/meson.build @@ -1,24 +1,75 @@ -shared_module('vsgi-http', ['vsgi-http.vala'], - dependencies: [glib, gobject, gio, soup, vsgi_dep], - install: true, - install_dir: join_paths(get_option('libdir'), 'vsgi-@0@/servers'.format(api_version))) +shared_module( + 'vsgi-http', + ['vsgi-http.vala'], + dependencies: [glib_dep, gobject_dep, gio_dep, soup_dep, vsgi_dep], + install: true, + install_dir: join_paths( + get_option('libdir'), + 'vsgi-@0@/servers'.format(api_version), + ), +) -shared_module('vsgi-cgi', 'vsgi-cgi.vala', - dependencies: [glib, gobject, gio, gio_unix, soup, vsgi_dep], - install: true, - install_dir: join_paths(get_option('libdir'), 'vsgi-@0@/servers'.format(api_version))) +shared_module( + 'vsgi-cgi', + 'vsgi-cgi.vala', + dependencies: [ + glib_dep, + gobject_dep, + gio_dep, + gio_unix_dep, + soup_dep, + vsgi_dep, + ], + install: true, + install_dir: join_paths( + get_option('libdir'), + 'vsgi-@0@/servers'.format(api_version), + ), +) if get_option('with_fcgi') fcgi = meson.get_compiler('c').find_library('fcgi') - fcgi_vapi = meson.get_compiler('vala').find_library('fcgi', dirs: meson.current_source_dir()) - vsgi_fastcgi_internal = meson.get_compiler('vala').find_library('vsgi-fastcgi-internal', dirs: meson.current_source_dir()) - shared_module('vsgi-fastcgi', ['vsgi-fastcgi.vala', 'vsgi-fastcgi-input-stream.c', 'vsgi-fastcgi-output-stream.c'], - dependencies: [glib, gobject, gio, gio_unix, soup, vsgi_dep, fcgi, fcgi_vapi, vsgi_fastcgi_internal], - install: true, - install_dir: join_paths(get_option('libdir'), 'vsgi-@0@/servers'.format(api_version))) + fcgi_vapi = meson.get_compiler('vala').find_library( + 'fcgi', + dirs: meson.current_source_dir(), + ) + vsgi_fastcgi_internal = meson.get_compiler('vala').find_library( + 'vsgi-fastcgi-internal', + dirs: meson.current_source_dir(), + ) + shared_module( + 'vsgi-fastcgi', + [ + 'vsgi-fastcgi.vala', + 'vsgi-fastcgi-input-stream.c', + 'vsgi-fastcgi-output-stream.c', + ], + dependencies: [ + glib_dep, + gobject_dep, + gio_dep, + gio_unix_dep, + soup_dep, + vsgi_dep, + fcgi, + fcgi_vapi, + vsgi_fastcgi_internal, + ], + install: true, + install_dir: join_paths( + get_option('libdir'), + 'vsgi-@0@/servers'.format(api_version), + ), + ) endif -shared_module('vsgi-scgi', 'vsgi-scgi.vala', - dependencies: [glib, gobject, gio, soup, vsgi_dep], - install: true, - install_dir: join_paths(get_option('libdir'), 'vsgi-@0@/servers'.format(api_version))) +shared_module( + 'vsgi-scgi', + 'vsgi-scgi.vala', + dependencies: [glib_dep, gobject_dep, gio_dep, soup_dep, vsgi_dep], + install: true, + install_dir: join_paths( + get_option('libdir'), + 'vsgi-@0@/servers'.format(api_version), + ), +) diff --git a/src/vsgi-application.vala b/src/vsgi-application.vala index 2f9807ee..360bb001 100644 --- a/src/vsgi-application.vala +++ b/src/vsgi-application.vala @@ -161,6 +161,10 @@ public class VSGI.Application : GLib.Application { // default listening interface if (addresses == null && ports == null && sockets == null && fds == null) { + if (ipv4_only != null || ipv6_only != null) { + critical ("The --ipv4-only and --ipv6-only options only work if a port (via --port) is supplied."); + return 1; + } server.listen (); } diff --git a/src/vsgi-handler-module.vala b/src/vsgi-handler-module.vala index c5cbe908..8dab7ab5 100644 --- a/src/vsgi-handler-module.vala +++ b/src/vsgi-handler-module.vala @@ -57,7 +57,8 @@ public class VSGI.HandlerModule : TypeModule { } construct { - path = Module.build_path (directory, name)[0:-Module.SUFFIX.length - 1]; + string module_name = name.has_prefix ("lib") ? name : "lib%s".printf (name); + path = directory != null ? Path.build_filename (directory, module_name) : module_name; } public override bool load () { diff --git a/src/vsgi-server-module.vala b/src/vsgi-server-module.vala index 8b2a7354..694f27c5 100644 --- a/src/vsgi-server-module.vala +++ b/src/vsgi-server-module.vala @@ -57,8 +57,8 @@ public class VSGI.ServerModule : TypeModule { } construct { - // trim the suffix from 'build_path' - path = Module.build_path (directory, "vsgi-%s".printf (name))[0:- Module.SUFFIX.length - 1]; + string module_name = "libvsgi-%s".printf (name); + path = directory != null ? Path.build_filename (directory, module_name) : module_name; } public override bool load () { diff --git a/tests/meson.build b/tests/meson.build index 8cec6fab..1dfc254e 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -9,29 +9,87 @@ vsgi_tests = [ 'request', 'response', 'server', - 'socket-server'] + 'socket-server', +] foreach name : vsgi_tests - test(name, executable(name + '-test', name + '-test.vala', - dependencies: [glib, gobject, gio, gio_unix, soup, vsgi_dep]), - env: ['G_TEST_SRCDIR=' + meson.current_source_dir()]) + test( + name, + executable( + name + '-test', + name + '-test.vala', + dependencies: [ + glib_dep, + gobject_dep, + gio_dep, + gio_unix_dep, + soup_dep, + vsgi_dep, + ], + ), + env: ['G_TEST_SRCDIR=' + meson.current_source_dir()], + ) endforeach if get_option('with_fcgi') - test('fastcgi server', executable('fastcgi-server-test', 'fastcgi-server-test.vala', - dependencies: [glib, gobject, gio, gio_unix, soup, vsgi_dep])) + test( + 'fastcgi server', + executable( + 'fastcgi-server-test', + 'fastcgi-server-test.vala', + dependencies: [ + glib_dep, + gobject_dep, + gio_dep, + gio_unix_dep, + soup_dep, + vsgi_dep, + ], + ), + ) endif -loader_test_lib = shared_library('loader-test', 'loader-test.vala', - dependencies: [glib, gobject, gio, gio_unix, soup, vsgi_dep]) -test('loader', vsgi_loader, - args: ['--directory', meson.current_build_dir(), '--server=cgi', 'loader-test'], - env: ['VSGI_SERVER_PATH=' + join_paths(meson.current_build_dir(), '../src/servers')]) +loader_test_lib = shared_library( + 'loader-test', + 'loader-test.vala', + dependencies: [ + glib_dep, + gobject_dep, + gio_dep, + gio_unix_dep, + soup_dep, + vsgi_dep, + ], +) +test( + 'loader', + vsgi_loader, + args: [ + '--directory', + meson.current_build_dir(), + '--server=cgi', + 'loader-test', + ], + env: [ + 'VSGI_SERVER_PATH=' + join_paths( + meson.current_build_dir(), + '../src/servers', + ), + ], +) python = find_program('python3') if get_option('with_introspection') - test('gi', python, - args: meson.current_source_dir() + '/gi-test.py' , - env: ['GI_TYPELIB_PATH=' + join_paths(meson.current_build_dir(), '../src'), - 'VSGI_SERVER_PATH=' + join_paths(meson.current_build_dir(), '../src/servers')]) + test( + 'gi', + python, + args: meson.current_source_dir() + '/gi-test.py', + env: [ + 'GI_TYPELIB_PATH=' + join_paths(meson.current_build_dir(), '../src'), + 'VSGI_SERVER_PATH=' + join_paths( + meson.current_build_dir(), + '../src/servers', + ), + ], + ) endif