commit d015669

shrub  ·  2026-05-14 13:20:23 +0000 UTC
parent 5342b50
add manpage, rename compcmd to compdb
6 files changed,  +89, -20
+6, -3
 1@@ -1,7 +1,8 @@
 2-.POSIX: 
 3+.POSIX:
 4 PREFIX = /usr
 5 DESTDIR =
 6 BINDIR = $(DESTDIR)$(PREFIX)/bin
 7+MANDIR = $(DESTDIR)$(PREFIX)/share/man/man1
 8 
 9 BIN = shin
10 RUNNERBIN = tests/runner/runner
11@@ -17,7 +18,7 @@ SRCS =  cli/main.c \
12 	src/gnu/pattern.c \
13 	backends/ninja.c \
14 	backends/graphviz.c \
15-	backends/compcmd.c \
16+	backends/compdb.c \
17 	src/util.c \
18 	src/submake.c \
19 	src/gnu/functions.c 
20@@ -29,7 +30,7 @@ FMTSRCS = $(SRCS) \
21 	  src/gnu/pattern.h \
22 	  backends/ninja.h \
23 	  backends/graphviz.h \
24-	  backends/compcmd.h
25+	  backends/compdb.h
26 
27 OBJS = $(SRCS:.c=.o)
28 RUNNERSRCS = tests/runner/case.go \
29@@ -77,6 +78,8 @@ test: $(BIN) runner helper
30 install: $(BIN)
31 	install -d $(BINDIR)
32 	install -m 755 $(BIN) $(BINDIR)/$(BIN)
33+	install -d $(MANDIR)
34+	install -m 644 doc/shin.1 $(MANDIR)/shin.1
35 
36 clean:
37 	rm -f $(BIN) $(OBJS) $(RUNNERBIN) $(HELPERBIN)
+0, -8
1@@ -1,8 +0,0 @@
2-#ifndef COMPCMD_H
3-#define COMPCMD_H
4-
5-#include "shinobi.h"
6-
7-int gencompcmd(const struct Graph *graph, const char *path);
8-
9-#endif
R backends/compcmd.c => backends/compdb.c
+2, -2
 1@@ -1,4 +1,4 @@
 2-#include "compcmd.h"
 3+#include "compdb.h"
 4 #include "internal.h"
 5 
 6 #include <stdio.h>
 7@@ -77,7 +77,7 @@ iscompile(const struct Target *t)
 8 }
 9 
10 int
11-gencompcmd(const struct Graph *graph, const char *path)
12+gencompdb(const struct Graph *graph, const char *path)
13 {
14 	FILE *fp;
15 	size_t i;
+8, -0
1@@ -0,0 +1,8 @@
2+#ifndef COMPDB_H
3+#define COMPDB_H
4+
5+#include "shinobi.h"
6+
7+int gencompdb(const struct Graph *graph, const char *path);
8+
9+#endif
+7, -7
 1@@ -1,6 +1,6 @@
 2 #include "shinobi.h"
 3 #include "internal.h"
 4-#include "compcmd.h"
 5+#include "compdb.h"
 6 #include "graphviz.h"
 7 #include "ninja.h"
 8 
 9@@ -13,7 +13,7 @@
10 static void
11 usage(FILE *fp, const char *argv0)
12 {
13-	fprintf(fp, "usage: %s [-ag] [-G ninja|dot|compcmd] [-C dir] [-f file]\n", argv0);
14+	fprintf(fp, "usage: %s [-age] [-G ninja|dot|compdb] [-C dir] [-f file] [target ...]\n", argv0);
15 }
16 
17 static int
18@@ -211,7 +211,7 @@ main(int argc, char **argv)
19 	enum Generator {
20 		GEN_NINJA,
21 		GEN_DOT,
22-		GEN_COMPCMD,
23+		GEN_COMPDB,
24 	};
25 	const char *path;
26 	char *pathbuf;
27@@ -260,8 +260,8 @@ main(int argc, char **argv)
28 				gen = GEN_NINJA;
29 			} else if (strcmp(argv[i], "dot") == 0) {
30 				gen = GEN_DOT;
31-			} else if (strcmp(argv[i], "compcmd") == 0) {
32-				gen = GEN_COMPCMD;
33+			} else if (strcmp(argv[i], "compdb") == 0) {
34+				gen = GEN_COMPDB;
35 			} else {
36 				fprintf(stderr, "unknown generator: %s\n\n", argv[i]);
37 				usage(stderr, argv[0]);
38@@ -421,8 +421,8 @@ main(int argc, char **argv)
39 			return 2;
40 		}
41 	}
42-	if (gen == GEN_COMPCMD) {
43-		if (gencompcmd(&sg.graph, "compile_commands.json") < 0) {
44+	if (gen == GEN_COMPDB) {
45+		if (gencompdb(&sg.graph, "compile_commands.json") < 0) {
46 			fprintf(stderr, "compile_commands generation error\n");
47 			free(pathbuf);
48 			freesubgraph(&sg);
+66, -0
 1@@ -0,0 +1,66 @@
 2+.Dd $Mdocdate: May 14 2026 $
 3+.Dt SHINOBI 1
 4+.Os
 5+.Sh NAME
 6+.Nm shin
 7+.Nd public domain makefile compiler
 8+.Sh SYNOPSIS
 9+.Nm shin
10+.Op Fl age
11+.Op Fl G Ar ninja | dot | compcmd
12+.Op Fl C Ar dir
13+.Op Fl f Ar file
14+.Op Ar VAR=value ...
15+.Op Ar target ...
16+.Sh DESCRIPTION
17+The
18+.Nm
19+utility takes a makefile as input, and outputs an alternative representation
20+of said makefile's build graph to a file.
21+The default backend is for the ninja build system.
22+.Pp
23+The options are as follows:
24+.Bl -tag -width Ds
25+.It Fl a
26+Print the abstract syntax tree to stdout and exit.
27+.It Fl g
28+Print the build graph to stdout and exit.
29+.It Fl G Ar generator
30+Specify the output generator.
31+Valid generators are
32+.Ar ninja
33+(default, outputs to build.ninja),
34+.Ar dot
35+(outputs to build.dot for graphviz), and
36+.Ar compdb
37+(outputs to compile_commands.json).
38+.It Fl C Ar dir
39+Change to
40+.Ar dir
41+before reading the makefile.
42+.It Fl f Ar file
43+Read the makefile from
44+.Ar file
45+instead of the default
46+.Ar Makefile, GNUmakefile
47+or
48+.Ar makefile .
49+.It Fl e
50+Override environment variables when expanding makefile variables.
51+.El
52+.Pp
53+Variable assignments of the form
54+.Ar VAR=value
55+can be specified on the command line and will override makefile definitions.
56+One or more
57+.Ar target
58+arguments specifies the goals to build; if none are specified, the default
59+goal from the makefile is used.
60+.Sh SEE ALSO
61+.Xr make 1 ,
62+.Xr samu 1
63+.Sh STANDARDS
64+The makefile format parsed by
65+.Nm
66+aims to follow the POSIX make specification (IEEE Std 1003.1-2024) with
67+extensions from GNU make. other extensions may be implemented in the future.