Skip to content

Commit

Permalink
tool: Order functions according to tool list
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelforney committed Nov 11, 2021
1 parent fbf9c82 commit a883d98
Showing 1 changed file with 36 additions and 36 deletions.
72 changes: 36 additions & 36 deletions tool.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,42 @@ graph(int argc, char *argv[])
return ret;
}

static int
query(int argc, char *argv[])
{
struct node *n;
struct edge *e;
char *path;
int i;
size_t j, k;

if (argc == 1) {
fprintf(stderr, "usage: %s ... -t query target...\n", argv0);
exit(2);
}
for (i = 1; i < argc; ++i) {
path = argv[i];
n = nodeget(path, 0);
if (!n)
fatal("unknown target '%s'", path);
printf("%s:\n", argv[i]);
e = n->gen;
if (e) {
printf(" input: %s\n", e->rule->name);
for (j = 0; j < e->nin; ++j)
printf(" %s\n", e->in[j]->path->s);
}
puts(" outputs:");
for (j = 0; j < n->nuse; ++j) {
e = n->use[j];
for (k = 0; k < e->nout; ++k)
printf(" %s\n", e->out[k]->path->s);
}
}

return 0;
}

static void
targetsdepth(struct node *n, size_t depth, size_t indent)
{
Expand Down Expand Up @@ -407,42 +443,6 @@ targets(int argc, char *argv[])
return 0;
}

static int
query(int argc, char *argv[])
{
struct node *n;
struct edge *e;
char *path;
int i;
size_t j, k;

if (argc == 1) {
fprintf(stderr, "usage: %s ... -t query target...\n", argv0);
exit(2);
}
for (i = 1; i < argc; ++i) {
path = argv[i];
n = nodeget(path, 0);
if (!n)
fatal("unknown target '%s'", path);
printf("%s:\n", argv[i]);
e = n->gen;
if (e) {
printf(" input: %s\n", e->rule->name);
for (j = 0; j < e->nin; ++j)
printf(" %s\n", e->in[j]->path->s);
}
puts(" outputs:");
for (j = 0; j < n->nuse; ++j) {
e = n->use[j];
for (k = 0; k < e->nout; ++k)
printf(" %s\n", e->out[k]->path->s);
}
}

return 0;
}

static const struct tool tools[] = {
{"clean", clean},
{"commands", commands},
Expand Down

0 comments on commit a883d98

Please sign in to comment.