~elly/build

1297575826d785981f8a644546a8f3d371cb278f — Elly Fong-Jones 1 year, 1 month ago a829ade
fix missing dep rebuild yikes
24 files changed, 41 insertions(+), 14 deletions(-)

M build.c
D t/buildfile
D t/cmd/test.c
D t/cmd/y/0.c
D t/cmd/y/1.c
D t/cmd/y/y0.c
D t/cmd/z.c
D t/etc/2
D t/etc/d/0
D t/etc/d/1
D t/etc/t-3
D t/etc/t-4
D t/inc/a.h
D t/inc/b.h
D t/inc/c/0.h
D t/inc/c/1.h
D t/inc/c/t-c.h
D t/inc/t-foo.h
D t/src/a/0.c
D t/src/a/1.c
D t/src/b.c
D t/src/c.c
D t/src/t-bar.c
D t/src/t-foo.c
M build.c => build.c +41 -10
@@ 118,6 118,7 @@ enum {
	NF_TEST = (1 << 0),
	NF_CMD = (1 << 1),
	NF_DONE = (1 << 2),
	NF_FRESH = (1 << 3),
};

const unsigned int NF_COPYMASK = NF_TEST | NF_CMD;


@@ 292,6 293,27 @@ mtimeof(const char *name) {
	return 0;
}

time_t
now() {
	return time(NULL);
}

bool
is_input_type(NodeType type) {
	switch (type) {
		case NT_SOURCE:
		case NT_HEADER:
		case NT_ETC:
		case NT_CONFIG:
			return true;
		case NT_OBJECT:
		case NT_BINARY:
		case NT_ARCHIVE:
		case NT_SYNTHETIC:
			return false;
	}
}

Node *
node_make(NodeType type, const char *name) {
	Node *n = malloc(sizeof *n);


@@ 309,6 331,8 @@ node_make(NodeType type, const char *name) {
		n->flags |= NF_TEST;
	if (is_cmd_name(name))
		n->flags |= NF_CMD;
	if (is_input_type(type))
		n->flags |= NF_DONE | NF_FRESH;
	edges_init(&n->outs);
	return n;
}


@@ 320,11 344,9 @@ node_addout(Node *n, Node *o) {

int
node_fresh(const Node *n) {
	if (n->flags & NF_DONE)
		return 1;
	for (size_t i = 0; i < n->outs.num; i++) {
		Node *o = n->outs.edges[i].to;
		if (o->mtime >= n->mtime)
		if (o->mtime > n->mtime)
			return 0;
	}
	return 1;


@@ 332,11 354,12 @@ node_fresh(const Node *n) {

int
node_ready(const Node *n) {
	if (n->flags & NF_DONE)
	if (n->flags & (NF_DONE | NF_FRESH))
		return 0;
	for (size_t i = 0; i < n->outs.num; i++)
		if (!(n->outs.edges[i].to->flags & NF_DONE))
	for (size_t i = 0; i < n->outs.num; i++) {
		if (!(n->outs.edges[i].to->flags & (NF_DONE | NF_FRESH)))
			return 0;
	}
	return 1;
}



@@ 376,14 399,21 @@ size_t
graph_findready(Graph *g, Node **ts, size_t nts) {
	size_t ti = 0;
	memset(ts, 0, nts * sizeof(*ts));

	for (size_t i = 0; i < g->num; i++) {
		Node *n = g->nodes[i];
		if (node_fresh(n))
			n->flags |= NF_DONE;
		if (!node_ready(n))
			continue;
		ts[ti++] = n;
			n->flags |= NF_FRESH;
		else
			n->flags &= ~NF_FRESH;
	}

	for (size_t i = 0; i < g->num; i++) {
		Node *n = g->nodes[i];
		if (node_ready(n))
			ts[ti++] = n;
	}

	return ti;
}



@@ 746,6 776,7 @@ build_some(Buildconf *bc, Node **ts, size_t nts) {
		assert(!(ts[i]->flags & NF_DONE));
		if (build_one(bc, ts[i]))
			return 1;
		ts[i]->mtime = now();
		ts[i]->flags |= NF_DONE;
	}
	return 0;

D t/buildfile => t/buildfile +0 -1
@@ 1,1 0,0 @@
cflags -Wall

D t/cmd/test.c => t/cmd/test.c +0 -0
D t/cmd/y/0.c => t/cmd/y/0.c +0 -0
D t/cmd/y/1.c => t/cmd/y/1.c +0 -0
D t/cmd/y/y0.c => t/cmd/y/y0.c +0 -0
D t/cmd/z.c => t/cmd/z.c +0 -0
D t/etc/2 => t/etc/2 +0 -1
@@ 1,1 0,0 @@
these are the contents of 2

D t/etc/d/0 => t/etc/d/0 +0 -1
@@ 1,1 0,0 @@
this is the contents of d0

D t/etc/d/1 => t/etc/d/1 +0 -1
@@ 1,1 0,0 @@
this is the contents of d1

D t/etc/t-3 => t/etc/t-3 +0 -0
D t/etc/t-4 => t/etc/t-4 +0 -0
D t/inc/a.h => t/inc/a.h +0 -0
D t/inc/b.h => t/inc/b.h +0 -0
D t/inc/c/0.h => t/inc/c/0.h +0 -0
D t/inc/c/1.h => t/inc/c/1.h +0 -0
D t/inc/c/t-c.h => t/inc/c/t-c.h +0 -0
D t/inc/t-foo.h => t/inc/t-foo.h +0 -0
D t/src/a/0.c => t/src/a/0.c +0 -0
D t/src/a/1.c => t/src/a/1.c +0 -0
D t/src/b.c => t/src/b.c +0 -0
D t/src/c.c => t/src/c.c +0 -0
D t/src/t-bar.c => t/src/t-bar.c +0 -0
D t/src/t-foo.c => t/src/t-foo.c +0 -0