~mcf/samurai

58ca03bee29f70f71a0311ea9812d7c26c925b96 — Paolo Bonzini a month ago 43ea5c0
Implement "list" tool
4 files changed, 29 insertions(+), 5 deletions(-)

M Makefile
M samu.1
M tool.c
M tool.h
M Makefile => Makefile +1 -1
@@ 3,7 3,7 @@
PREFIX=/usr/local
BINDIR=$(PREFIX)/bin
MANDIR=$(PREFIX)/share/man
ALL_CFLAGS=$(CFLAGS) -std=c99 -Wall -Wextra -Wpedantic
ALL_CFLAGS=$(CFLAGS) -std=c99 -Wall -Wextra -Wpedantic -Wno-unused-parameter
OBJ=\
	build.o\
	deps.o\

M samu.1 => samu.1 +7 -1
@@ 1,4 1,4 @@
.Dd January 26, 2020
.Dd October 23, 2020
.Dt SAMU 1
.Os
.Sh NAME


@@ 42,6 42,8 @@
.Op Fl f Ar buildfile
.Fl t Cm targets
.Cm all
.Nm
.Fl t Cm list
.Sh DESCRIPTION
.Nm
loads a build manifest from


@@ 95,6 97,10 @@ Otherwise, a list of source files will be displayed.
.It Cm all
A list of all targets will be displayed.
.El
.Pp
If the
.Cm list
tool is used, a list of available tools is displayed.
.Sh OPTIONS
.Bl -tag -width Ds
.It Fl C

M tool.c => tool.c +20 -3
@@ 298,12 298,29 @@ targets(int argc, char *argv[])
	return 0;
}

static int list(int argc, char *argv[]);

static const struct tool tools[] = {
	{"clean", clean},
	{"compdb", compdb},
	{"targets", targets},
	{"clean", "remove build outputs", clean},
	{"compdb", "dump compilation database", compdb},
	{"list", NULL, list},
	{"targets", "list targets", targets},
};

static int
list(int argc, char *argv[])
{
	size_t i;

	printf("%s subtools:\n", argv0);
	for (i = 0; i < LEN(tools); ++i) {
		if (tools[i].description)
			printf("%10s  %s\n", tools[i].name, tools[i].description);
	}

	return 0;
}

const struct tool *
toolget(const char *name)
{

M tool.h => tool.h +1 -0
@@ 1,5 1,6 @@
struct tool {
	const char *name;
	const char *description;
	int (*run)(int, char *[]);
};