build: support selecting enabled utils in Meson

Add a new Meson array option, utils, to allow building only selected applets while keeping the default as all.

Gate source inclusion, dependencies, symlink/manpage/script install steps, and test registration by enabled util set, and make applet dispatch in src/main.c compile-time conditional via generated config defines.

Document selective build usage in README.
This commit is contained in:
2026-04-18 06:34:18 -05:00
parent e1b8aa1594
commit 26e2527492
4 changed files with 361 additions and 65 deletions
+50
View File
@@ -1,20 +1,46 @@
#include "vx-config.h"
#include <libgen.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#if VX_ENABLE_PATCH
int patch_main(int argc, char *argv[]);
#endif
#if VX_ENABLE_DIFF
int diff_main(int argc, char *argv[]);
#endif
#if VX_ENABLE_CMP
int cmp_main(int argc, char *argv[]);
#endif
#if VX_ENABLE_DIFF3
int diff3_main(int argc, char *argv[]);
#endif
#if VX_ENABLE_SDIFF
int sdiff_main(int argc, char *argv[]);
#endif
#if VX_ENABLE_WHICH
int which_main(int argc, char *argv[]);
#endif
#if VX_ENABLE_GZIP
int gzip_main(int argc, char *argv[]);
#endif
#if VX_ENABLE_GREP
int grep_main(int argc, char *argv[]);
#endif
#if VX_ENABLE_FIND
int find_main(int argc, char *argv[]);
#endif
#if VX_ENABLE_XARGS
int xargs_main(int argc, char *argv[]);
#endif
#if VX_ENABLE_LSPCI
int lspci_main(int argc, char *argv[]);
#endif
#if VX_ENABLE_SETPCI
int setpci_main(int argc, char *argv[]);
#endif
struct applet {
const char *name;
@@ -22,25 +48,49 @@ struct applet {
};
static const struct applet applets[] = {
#if VX_ENABLE_PATCH
{ "patch", patch_main },
#endif
#if VX_ENABLE_DIFF
{ "diff", diff_main },
#endif
#if VX_ENABLE_CMP
{ "cmp", cmp_main },
#endif
#if VX_ENABLE_DIFF3
{ "diff3", diff3_main },
#endif
#if VX_ENABLE_SDIFF
{ "sdiff", sdiff_main },
#endif
#if VX_ENABLE_WHICH
{ "which", which_main },
#endif
#if VX_ENABLE_GZIP
{ "gzip", gzip_main },
{ "gunzip", gzip_main },
{ "zcat", gzip_main },
{ "gzcat", gzip_main },
{ "uncompress", gzip_main },
#endif
#if VX_ENABLE_GREP
{ "grep", grep_main },
{ "egrep", grep_main },
{ "fgrep", grep_main },
{ "rgrep", grep_main },
#endif
#if VX_ENABLE_FIND
{ "find", find_main },
#endif
#if VX_ENABLE_XARGS
{ "xargs", xargs_main },
#endif
#if VX_ENABLE_LSPCI
{ "lspci", lspci_main },
#endif
#if VX_ENABLE_SETPCI
{ "setpci", setpci_main },
#endif
};
static const size_t n_applets = sizeof(applets) / sizeof(applets[0]);