From 8135313396f590c97a5f1e6e39a55a820c831448 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 4 May 2019 14:52:00 +0200 Subject: [PATCH 01/13] post-merge: undo version changes --- PKGBUILD | 6 +++--- PKGBUILD.wayland-only | 6 +++--- meson.build | 1 - 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/PKGBUILD b/PKGBUILD index 5501465..49fdf0b 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -18,9 +18,9 @@ depends=( optdepends=('xcb-util-errors: better X error messages') source=() -# pkgver() { -# git describe --tags --long | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g' -# } +pkgver() { + git describe --tags --long | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g' +} build() { meson --buildtype=minsize --prefix=/usr -Dbackend-x11=enabled -Dbackend-wayland=enabled ../ diff --git a/PKGBUILD.wayland-only b/PKGBUILD.wayland-only index f520f7c..b0fa853 100644 --- a/PKGBUILD.wayland-only +++ b/PKGBUILD.wayland-only @@ -18,9 +18,9 @@ depends=( 'libmpdclient') source=() -# pkgver() { -# git describe --tags --long | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g' -# } +pkgver() { + git describe --tags --long | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g' +} build() { meson --buildtype=minsize --prefix=/usr -Dbackend-x11=disabled -Dbackend-wayland=enabled ../ diff --git a/meson.build b/meson.build index d7080ca..db82e1b 100644 --- a/meson.build +++ b/meson.build @@ -1,6 +1,5 @@ project('f00bar', 'c', license: 'MIT', - version: '1.0.0', default_options: ['c_std=c11', 'warning_level=1', 'werror=true']) add_project_arguments( From 121b2f15757945f0a7c62668c64218b6df20c42d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Mon, 6 May 2019 21:45:01 +0200 Subject: [PATCH 02/13] meson: enable_x11 -> backend_x11, enable_wayland -> backend_wayland --- bar/meson.build | 6 ++---- meson.build | 10 +++++----- modules/meson.build | 4 ++-- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/bar/meson.build b/bar/meson.build index c432817..2ef871d 100644 --- a/bar/meson.build +++ b/bar/meson.build @@ -1,14 +1,12 @@ bar_backends = [] -# TODO: X11 -if enable_x11 +if backend_x11 bar_x11 = declare_dependency(sources: ['xcb.c', 'xcb.h'], dependencies: [xcb_stuff, cairo, cairo_ft]) bar_backends += [bar_x11] endif -# TODO: conditional Wayland -if enable_wayland +if backend_wayland wayland_protocols = dependency('wayland-protocols') wayland_protocols_datadir = wayland_protocols.get_pkgconfig_variable('pkgdatadir') diff --git a/meson.build b/meson.build index db82e1b..3bbfe27 100644 --- a/meson.build +++ b/meson.build @@ -30,10 +30,10 @@ if xcb_aux.found() and xcb_cursor.found() and xcb_event.found() and \ xcb_ewmh.found() and xcb_randr.found() and xcb_render.found() and \ cairo_xcb.found() - enable_x11 = true + backend_x11 = true add_project_arguments('-DENABLE_X11', language: 'c') else - enable_x11 = false + backend_x11 = false endif wayland_client = dependency('wayland-client', required: get_option('backend-wayland')) @@ -41,13 +41,13 @@ wayland_cursor = dependency('wayland-cursor', required: get_option('backend-wayl wlroots = dependency('wlroots', required: get_option('backend-wayland')) if wayland_client.found() and wayland_cursor.found() and wlroots.found() - enable_wayland = true + backend_wayland = true add_project_arguments('-DENABLE_WAYLAND', language: 'c') else - enable_wayland = false + backend_wayland = false endif -if enable_x11 +if backend_x11 xcb_stuff_lib = static_library( 'xcb-stuff', 'xcb.c', 'xcb.h', dependencies: [xcb_aux, xcb_cursor, xcb_event, xcb_ewmh, xcb_randr, diff --git a/modules/meson.build b/modules/meson.build index 0d899c9..dd21bc7 100644 --- a/modules/meson.build +++ b/modules/meson.build @@ -21,7 +21,7 @@ deps = { 'removables': [[], [dynlist, udev]], } -if enable_x11 +if backend_x11 deps_x11_only = { 'xkb': [[], [xcb_stuff, xcb_xkb]], 'xwindow': [[], [xcb_stuff]], @@ -46,7 +46,7 @@ foreach mod, data : deps endif endforeach -if enable_x11 +if backend_x11 foreach mod, data : deps_x11_only sources = data[0] dep = data[1] From 08e21a4d3b001352ae6479c8739b02c5157a61bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Mon, 6 May 2019 21:49:20 +0200 Subject: [PATCH 03/13] meson: assign get_option('core-plugins-as-shared-libraries') to variable --- decorations/meson.build | 2 +- meson.build | 7 ++++--- modules/meson.build | 4 ++-- particles/meson.build | 7 +++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/decorations/meson.build b/decorations/meson.build index 1e20a4b..1b6daee 100644 --- a/decorations/meson.build +++ b/decorations/meson.build @@ -2,7 +2,7 @@ deco_sdk = declare_dependency(dependencies: [cairo, cairo_ft]) decorations = [] foreach deco : ['background', 'stack', 'underline'] - if get_option('core-plugins-as-shared-libraries') + if plugs_as_libs shared_module('@0@'.format(deco), '@0@.c'.format(deco), dependencies: deco_sdk, name_prefix: 'decoration_', diff --git a/meson.build b/meson.build index 3bbfe27..08b97af 100644 --- a/meson.build +++ b/meson.build @@ -2,10 +2,11 @@ project('f00bar', 'c', license: 'MIT', default_options: ['c_std=c11', 'warning_level=1', 'werror=true']) +plugs_as_libs = get_option('core-plugins-as-shared-libraries') + add_project_arguments( ['-D_GNU_SOURCE'] + - (get_option('core-plugins-as-shared-libraries') ? - ['-DCORE_PLUGINS_AS_SHARED_LIBRARIES'] : []), + (plugs_as_libs ? ['-DCORE_PLUGINS_AS_SHARED_LIBRARIES'] : []), language: 'c', ) @@ -53,7 +54,7 @@ if backend_x11 dependencies: [xcb_aux, xcb_cursor, xcb_event, xcb_ewmh, xcb_randr, xcb_render, cairo_xcb, xcb_errors], c_args: xcb_errors.found() ? '-DHAVE_XCB_ERRORS' : [], - pic: get_option('core-plugins-as-shared-libraries')) + pic: plugs_as_libs) xcb_stuff = declare_dependency(link_with: xcb_stuff_lib) install_headers('xcb.h', subdir: 'f00bar') endif diff --git a/modules/meson.build b/modules/meson.build index dd21bc7..de42d37 100644 --- a/modules/meson.build +++ b/modules/meson.build @@ -32,7 +32,7 @@ foreach mod, data : deps sources = data[0] dep = data[1] - if get_option('core-plugins-as-shared-libraries') + if plugs_as_libs shared_module(mod, '@0@.c'.format(mod), sources, dependencies: [module_sdk] + dep, name_prefix: 'module_', @@ -51,7 +51,7 @@ if backend_x11 sources = data[0] dep = data[1] - if get_option('core-plugins-as-shared-libraries') + if plugs_as_libs shared_module(mod, '@0@.c'.format(mod), sources, dependencies: [module_sdk] + dep, name_prefix: 'module_', diff --git a/particles/meson.build b/particles/meson.build index f016496..2b867c8 100644 --- a/particles/meson.build +++ b/particles/meson.build @@ -2,7 +2,7 @@ particle_sdk = declare_dependency(dependencies: [cairo, cairo_ft]) particles = [] foreach particle : ['empty', 'list', 'map', 'progress-bar', 'ramp', 'string'] - if get_option('core-plugins-as-shared-libraries') + if plugs_as_libs shared_module('@0@'.format(particle), '@0@.c'.format(particle), dependencies: particle_sdk, name_prefix: 'particle_', @@ -18,10 +18,9 @@ endforeach dynlist_lib = build_target( 'dynlist', 'dynlist.c', 'dynlist.h', dependencies: particle_sdk, - target_type: (get_option('core-plugins-as-shared-libraries') - ? 'shared_library' : 'static_library'), + target_type: plugs_as_libs ? 'shared_library' : 'static_library', override_options : ['b_lundef=false'], - install: get_option('core-plugins-as-shared-libraries'), + install: plugs_as_libs, install_dir: get_option('libdir') + '/f00bar', ) From c5fca9a92dcb750b3d5d145d4d2c417938aac8f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Mon, 6 May 2019 21:58:01 +0200 Subject: [PATCH 04/13] meson: cleanup --- meson.build | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/meson.build b/meson.build index 08b97af..c838beb 100644 --- a/meson.build +++ b/meson.build @@ -10,6 +10,7 @@ add_project_arguments( language: 'c', ) +# Common dependencies cc = meson.get_compiler('c') dl = cc.find_library('dl', required : false) threads = dependency('threads') @@ -18,6 +19,7 @@ cairo = dependency('cairo') cairo_ft = dependency('cairo-ft') yaml = dependency('yaml-0.1') +# X11/XCB dependencies xcb_aux = dependency('xcb-aux', required: get_option('backend-x11')) xcb_cursor = dependency('xcb-cursor', required: get_option('backend-x11')) xcb_event = dependency('xcb-event', required: get_option('backend-x11')) @@ -26,26 +28,22 @@ xcb_randr = dependency('xcb-randr', required: get_option('backend-x11')) xcb_render = dependency('xcb-render', required: get_option('backend-x11')) cairo_xcb = dependency('cairo-xcb', required: get_option('backend-x11')) xcb_errors = dependency('xcb-errors', required: false) +backend_x11 = xcb_aux.found() and xcb_cursor.found() and xcb_event.found() and \ + xcb_ewmh.found() and xcb_randr.found() and xcb_render.found() and \ + cairo_xcb.found() -if xcb_aux.found() and xcb_cursor.found() and xcb_event.found() and \ - xcb_ewmh.found() and xcb_randr.found() and xcb_render.found() and \ - cairo_xcb.found() - - backend_x11 = true +if backend_x11 add_project_arguments('-DENABLE_X11', language: 'c') -else - backend_x11 = false endif +# Wayland dependencies wayland_client = dependency('wayland-client', required: get_option('backend-wayland')) wayland_cursor = dependency('wayland-cursor', required: get_option('backend-wayland')) wlroots = dependency('wlroots', required: get_option('backend-wayland')) +backend_wayland = wayland_client.found() and wayland_cursor.found() and wlroots.found() -if wayland_client.found() and wayland_cursor.found() and wlroots.found() - backend_wayland = true +if backend_wayland add_project_arguments('-DENABLE_WAYLAND', language: 'c') -else - backend_wayland = false endif if backend_x11 @@ -55,6 +53,7 @@ if backend_x11 xcb_render, cairo_xcb, xcb_errors], c_args: xcb_errors.found() ? '-DHAVE_XCB_ERRORS' : [], pic: plugs_as_libs) + xcb_stuff = declare_dependency(link_with: xcb_stuff_lib) install_headers('xcb.h', subdir: 'f00bar') endif From a7e32f6a0791a33ebecebb4bc3cfdd93bed5697a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Mon, 6 May 2019 21:58:45 +0200 Subject: [PATCH 05/13] meson: bar: prefer single, long line --- bar/meson.build | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bar/meson.build b/bar/meson.build index 2ef871d..30dfffc 100644 --- a/bar/meson.build +++ b/bar/meson.build @@ -1,8 +1,8 @@ bar_backends = [] if backend_x11 - bar_x11 = declare_dependency(sources: ['xcb.c', 'xcb.h'], - dependencies: [xcb_stuff, cairo, cairo_ft]) + bar_x11 = declare_dependency( + sources: ['xcb.c', 'xcb.h'], dependencies: [xcb_stuff, cairo, cairo_ft]) bar_backends += [bar_x11] endif From 89538f96fad4dd2a18e44f0e444e0f7392147cab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Mon, 6 May 2019 22:03:19 +0200 Subject: [PATCH 06/13] meson: modules: dictionaries can be added --- modules/meson.build | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/modules/meson.build b/modules/meson.build index de42d37..dc6c67f 100644 --- a/modules/meson.build +++ b/modules/meson.build @@ -22,7 +22,7 @@ deps = { } if backend_x11 - deps_x11_only = { + deps += { 'xkb': [[], [xcb_stuff, xcb_xkb]], 'xwindow': [[], [xcb_stuff]], } @@ -45,23 +45,3 @@ foreach mod, data : deps compile_args: '-DHAVE_PLUGIN_@0@'.format(mod))] endif endforeach - -if backend_x11 - foreach mod, data : deps_x11_only - sources = data[0] - dep = data[1] - - if plugs_as_libs - shared_module(mod, '@0@.c'.format(mod), sources, - dependencies: [module_sdk] + dep, - name_prefix: 'module_', - install: true, - install_dir: join_paths(get_option('libdir'), 'f00bar')) - else - modules += [declare_dependency( - sources: ['@0@.c'.format(mod)] + sources, - dependencies: [module_sdk] + dep, - compile_args: '-DHAVE_PLUGIN_@0@'.format(mod))] - endif - endforeach -endif From e30a2fa35555fde790b1ace03e2f80251ba4baed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Mon, 6 May 2019 22:05:23 +0200 Subject: [PATCH 07/13] meson: require meson >= 0.48.0 --- meson.build | 1 + 1 file changed, 1 insertion(+) diff --git a/meson.build b/meson.build index c838beb..c1199ac 100644 --- a/meson.build +++ b/meson.build @@ -1,5 +1,6 @@ project('f00bar', 'c', license: 'MIT', + meson_version: '>=0.48.0', default_options: ['c_std=c11', 'warning_level=1', 'werror=true']) plugs_as_libs = get_option('core-plugins-as-shared-libraries') From 8af8157a95890af4d4cceee70fa9515cd8c5641d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Mon, 6 May 2019 22:08:13 +0200 Subject: [PATCH 08/13] meson: set project arguments in one place --- meson.build | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/meson.build b/meson.build index c1199ac..82c9cf6 100644 --- a/meson.build +++ b/meson.build @@ -5,12 +5,6 @@ project('f00bar', 'c', plugs_as_libs = get_option('core-plugins-as-shared-libraries') -add_project_arguments( - ['-D_GNU_SOURCE'] + - (plugs_as_libs ? ['-DCORE_PLUGINS_AS_SHARED_LIBRARIES'] : []), - language: 'c', -) - # Common dependencies cc = meson.get_compiler('c') dl = cc.find_library('dl', required : false) @@ -33,19 +27,19 @@ backend_x11 = xcb_aux.found() and xcb_cursor.found() and xcb_event.found() and \ xcb_ewmh.found() and xcb_randr.found() and xcb_render.found() and \ cairo_xcb.found() -if backend_x11 - add_project_arguments('-DENABLE_X11', language: 'c') -endif - # Wayland dependencies wayland_client = dependency('wayland-client', required: get_option('backend-wayland')) wayland_cursor = dependency('wayland-cursor', required: get_option('backend-wayland')) wlroots = dependency('wlroots', required: get_option('backend-wayland')) backend_wayland = wayland_client.found() and wayland_cursor.found() and wlroots.found() -if backend_wayland - add_project_arguments('-DENABLE_WAYLAND', language: 'c') -endif +add_project_arguments( + ['-D_GNU_SOURCE'] + + (backend_x11 ? ['-DENABLE_X11'] : []) + + (backend_wayland ? ['-DENABLE_WAYLAND'] : []) + + (plugs_as_libs ? ['-DCORE_PLUGINS_AS_SHARED_LIBRARIES'] : []), + language: 'c', +) if backend_x11 xcb_stuff_lib = static_library( From 8be1063d39b0b42dbb697ac2f9f302201455caaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Tue, 7 May 2019 20:02:39 +0200 Subject: [PATCH 09/13] meson: print configuration result --- meson.build | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/meson.build b/meson.build index 82c9cf6..c4c86a9 100644 --- a/meson.build +++ b/meson.build @@ -94,3 +94,10 @@ install_headers( 'tllist.h', 'yml.h', subdir: 'f00bar') + +message('') +message('Build type: @0@'.format(get_option('buildtype'))) +message('XCB backend: @0@'.format(backend_x11)) +message('Wayland backend: @0@'.format(backend_wayland)) +message('Core modules as plugins: @0@'.format(plugs_as_libs)) +message('') From 6753ee3dad6bc01b8ff1138dbc443e01679de277 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Tue, 7 May 2019 20:23:51 +0200 Subject: [PATCH 10/13] meson: set project version Export project version with -DF00BAR_VERSION. This is by default set to the meson project version. However, if git is found, and we manage to run 'git describe' and 'git branch' in the source directory, version is set to the output of that instead. --- doc/meson.build | 1 - meson.build | 26 +++++++++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/doc/meson.build b/doc/meson.build index f91e311..76967f8 100644 --- a/doc/meson.build +++ b/doc/meson.build @@ -1,4 +1,3 @@ -sh = find_program('sh', native: true) scdoc = dependency('scdoc', native: true) scdoc_prog = find_program(scdoc.get_pkgconfig_variable('scdoc'), native: true) diff --git a/meson.build b/meson.build index c4c86a9..cf4fa32 100644 --- a/meson.build +++ b/meson.build @@ -1,10 +1,33 @@ project('f00bar', 'c', + version: '1.0.0', license: 'MIT', meson_version: '>=0.48.0', default_options: ['c_std=c11', 'warning_level=1', 'werror=true']) plugs_as_libs = get_option('core-plugins-as-shared-libraries') +version = '"@0@"'.format(meson.project_version()) + +sh = find_program('sh', native: true) +git = find_program('git', required: false, native: true) + +if git.found() + commit_hash = run_command( + [sh.path(), '-c', + '@0@ --git-dir=$MESON_SOURCE_ROOT/.git describe --always --tags'.format( + git.path())]) + + branch = run_command( + [sh.path(), '-c', + '@0@ --git-dir=$MESON_SOURCE_ROOT/.git rev-parse --abbrev-ref HEAD'.format( + git.path())]) + + if commit_hash.returncode() == 0 and branch.returncode() == 0 + version = '"@0@ (" __DATE__ ", branch \'@1@\')"'.format( + commit_hash.stdout().strip(), branch.stdout().strip()) + endif +endif + # Common dependencies cc = meson.get_compiler('c') dl = cc.find_library('dl', required : false) @@ -34,7 +57,8 @@ wlroots = dependency('wlroots', required: get_option('backend-wayland')) backend_wayland = wayland_client.found() and wayland_cursor.found() and wlroots.found() add_project_arguments( - ['-D_GNU_SOURCE'] + + ['-D_GNU_SOURCE', + '-DF00BAR_VERSION=@0@'.format(version)] + (backend_x11 ? ['-DENABLE_X11'] : []) + (backend_wayland ? ['-DENABLE_WAYLAND'] : []) + (plugs_as_libs ? ['-DCORE_PLUGINS_AS_SHARED_LIBRARIES'] : []), From 37fe45b0d2bc617a3da630d3884a204a4958803f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Tue, 7 May 2019 20:24:51 +0200 Subject: [PATCH 11/13] main: add -v,--version command line option --- main.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/main.c b/main.c index 927b586..46be1d9 100644 --- a/main.c +++ b/main.c @@ -122,6 +122,13 @@ main(int argc, const char *const *argv) { setlocale(LC_ALL, ""); + for (int i = 1; i < argc; i++) { + if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--version") == 0) { + printf("f00bar version %s\n", F00BAR_VERSION); + return 0; + } + } + const struct sigaction sa = {.sa_handler = &signal_handler}; sigaction(SIGINT, &sa, NULL); sigaction(SIGTERM, &sa, NULL); From cc001b5702af7de2247874e1cd1ddd081a352755 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Tue, 7 May 2019 20:26:55 +0200 Subject: [PATCH 12/13] doc: document -v,--version option --- doc/f00bar.1.scd | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/doc/f00bar.1.scd b/doc/f00bar.1.scd index 3afc856..6116021 100644 --- a/doc/f00bar.1.scd +++ b/doc/f00bar.1.scd @@ -4,7 +4,12 @@ f00bar(1) f00bar - modular status panel for X11 and Wayland # SYNOPSIS -*f00bar* +*f00bar* [ -v ] + +# OPTIONS + +*-v, --version* + Show the version number and quit # DESCRIPTION *f00bar* is a light-weight and configurable status panel (_bar_, for From 1c9de3b7041f9c0cd45b707c3761166b6dcc8e0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Tue, 7 May 2019 20:27:41 +0200 Subject: [PATCH 13/13] meson: 1.0.0 has already been released, bump version to 1.0.1 --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index cf4fa32..4c359e7 100644 --- a/meson.build +++ b/meson.build @@ -1,5 +1,5 @@ project('f00bar', 'c', - version: '1.0.0', + version: '1.0.1', license: 'MIT', meson_version: '>=0.48.0', default_options: ['c_std=c11', 'warning_level=1', 'werror=true'])