From 250c55694368e3193f3807be0bcec6ba2ba3c6fa Mon Sep 17 00:00:00 2001 From: Mike Gilbert Date: Tue, 28 May 2024 21:59:54 -0400 Subject: [PATCH] meson: de-duplicate binaries using symlinks --- meson.build | 2 +- src/einfo/meson.build | 21 ++++++++++++++------- src/mark_service/meson.build | 21 ++++++++++++++------- src/service/meson.build | 21 ++++++++++++++------- src/value/meson.build | 21 ++++++++++++++------- 5 files changed, 57 insertions(+), 29 deletions(-) diff --git a/meson.build b/meson.build index 6ee4466ba..af6ed3182 100644 --- a/meson.build +++ b/meson.build @@ -6,7 +6,7 @@ project('OpenRC', 'c', 'prefix=/usr', 'warning_level=3', ], - meson_version : '>=0.53.2') + meson_version : '>=0.61.0') cc = meson.get_compiler('c') fs = import('fs') diff --git a/src/einfo/meson.build b/src/einfo/meson.build index df11d5fd2..dbeb04748 100644 --- a/src/einfo/meson.build +++ b/src/einfo/meson.build @@ -1,6 +1,5 @@ einfo_execs = [ 'einfon', - 'einfo', 'ewarnn', 'ewarn', 'eerrorn', @@ -22,11 +21,19 @@ einfo_execs = [ 'veoutdent', ] +executable('einfo', + ['einfo.c', version_h], + include_directories: [incdir, einfo_incdir, rc_incdir], + link_with: [libeinfo, librc], + install: true, + install_dir: rc_bindir) + foreach exec: einfo_execs - executable(exec, - ['einfo.c', version_h], - include_directories: [incdir, einfo_incdir, rc_incdir], - link_with: [libeinfo, librc], - install: true, - install_dir: rc_bindir) + custom_target(exec, + build_by_default: true, + command: ['ln', '-fns', 'einfo', '@OUTPUT@'], + output: exec) + install_symlink(exec, + install_dir: rc_bindir, + pointing_to: 'einfo') endforeach diff --git a/src/mark_service/meson.build b/src/mark_service/meson.build index ba046dcb5..78a6c4da5 100644 --- a/src/mark_service/meson.build +++ b/src/mark_service/meson.build @@ -1,5 +1,4 @@ mark_service_execs = [ - 'mark_service_starting', 'mark_service_started', 'mark_service_stopping', 'mark_service_stopped', @@ -10,11 +9,19 @@ mark_service_execs = [ 'mark_service_crashed', ] +executable('mark_service_starting', + ['mark_service.c', misc_c, version_h], + include_directories: [incdir, einfo_incdir, rc_incdir], + link_with: [libeinfo,librc], + install: true, + install_dir: rc_sbindir) + foreach exec : mark_service_execs - executable(exec, - ['mark_service.c', misc_c, version_h], - include_directories: [incdir, einfo_incdir, rc_incdir], - link_with: [libeinfo,librc], - install: true, - install_dir: rc_sbindir) + custom_target(exec, + build_by_default: true, + command: ['ln', '-fns', 'mark_service_starting', '@OUTPUT@'], + output: exec) + install_symlink(exec, + install_dir: rc_sbindir, + pointing_to: 'mark_service_starting') endforeach diff --git a/src/service/meson.build b/src/service/meson.build index b3a86f6df..eb3668d3b 100644 --- a/src/service/meson.build +++ b/src/service/meson.build @@ -1,5 +1,4 @@ service_execs = [ - 'service_starting', 'service_started', 'service_stopping', 'service_stopped', @@ -10,11 +9,19 @@ service_execs = [ 'service_crashed', ] +executable('service_starting', + ['service.c', misc_c, version_h], + include_directories: [incdir, einfo_incdir, rc_incdir], + link_with: [libeinfo, librc], + install: true, + install_dir: rc_bindir) + foreach exec : service_execs - executable(exec, - ['service.c', misc_c, version_h], - include_directories: [incdir, einfo_incdir, rc_incdir], - link_with: [libeinfo, librc], - install: true, - install_dir: rc_bindir) + custom_target(exec, + build_by_default: true, + command: ['ln', '-fns', 'service_starting', '@OUTPUT@'], + output: exec) + install_symlink(exec, + install_dir: rc_bindir, + pointing_to: 'service_starting') endforeach diff --git a/src/value/meson.build b/src/value/meson.build index da958f01f..784c5a5ed 100644 --- a/src/value/meson.build +++ b/src/value/meson.build @@ -1,15 +1,22 @@ value_execs = [ - 'service_get_value', 'service_set_value', 'get_options', 'save_options', ] +executable('service_get_value', + ['value.c', misc_c, version_h], + include_directories: [incdir, einfo_incdir, rc_incdir], + link_with: [libeinfo, librc], + install: true, + install_dir: rc_bindir) + foreach exec : value_execs - executable(exec, - ['value.c', misc_c, version_h], - include_directories: [incdir, einfo_incdir, rc_incdir], - link_with: [libeinfo, librc], - install: true, - install_dir: rc_bindir) + custom_target(exec, + build_by_default: true, + command: ['ln', '-fns', 'service_get_value', '@OUTPUT@'], + output: exec) + install_symlink(exec, + install_dir: rc_bindir, + pointing_to: 'service_get_value') endforeach