Commit 650c775f authored by Rusty Russell's avatar Rusty Russell

Move modules to ccan/ tools to tools/

Requires minor fixups.  "depends" now prefixes ccan/ (allows for 
non-ccan deps later).
parent c8acddea
# Hacky makefile to compile everything and run the tests in some kind of sane order. # Hacky makefile to compile everything and run the tests in some kind of sane order.
# V=--verbose for verbose tests. # V=--verbose for verbose tests.
CFLAGS=-O3 -Wall -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Werror -I. CFLAGS=-O3 -Wall -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Werror -Iccan -I.
ALL=$(patsubst %/test, %, $(wildcard */test)) ALL=$(patsubst ccan/%/test, ccan/%, $(wildcard ccan/*/test))
ALL_DEPENDS=$(patsubst %, %/.depends, $(ALL)) ALL_DEPENDS=$(patsubst %, %/.depends, $(ALL))
test-all: $(ALL_DEPENDS) test-all: $(ALL_DEPENDS)
...@@ -16,13 +16,13 @@ distclean: clean ...@@ -16,13 +16,13 @@ distclean: clean
$(ALL_DEPENDS): %/.depends: %/_info $(ALL_DEPENDS): %/.depends: %/_info
@$< depends > $@ || ( rm -f $@; exit 1 ) @$< depends > $@ || ( rm -f $@; exit 1 )
test-%: ccan_tools/run_tests test-ccan/%: tools/run_tests
@echo Testing $*... @echo Testing $*...
@if ccan_tools/run_tests $(V) $* | grep ^'not ok'; then exit 1; else exit 0; fi @if tools/run_tests $(V) ccan/$* | grep ^'not ok'; then exit 1; else exit 0; fi
ccanlint: ccan_tools/ccanlint/ccanlint ccanlint: tools/ccanlint/ccanlint
clean: ccan_tools-clean clean: tools-clean
rm -f `find . -name '*.o'` rm -f `find . -name '*.o'` `find . -name '.depends'`
include ccan_tools/Makefile include tools/Makefile
ccan_tools: tools:
This is currently a bootstrap junkyard for ccan tools. This is currently a bootstrap junkyard for ccan tools.
It is expected that some of this code, being generally useful, will be It is expected that some of this code, being generally useful, will be
shuffled out to their own modules over time. shuffled out to their own modules over time.
other: ccan:
The beginnings of a ccan repository. The beginnings of a ccan repository.
...@@ -37,7 +37,7 @@ int main(int argc, char *argv[]) ...@@ -37,7 +37,7 @@ int main(int argc, char *argv[])
return 1; return 1;
if (strcmp(argv[1], "depends") == 0) { if (strcmp(argv[1], "depends") == 0) {
printf("build_assert\n"); printf("ccan/build_assert\n");
return 0; return 0;
} }
......
...@@ -95,7 +95,7 @@ int main(int argc, char *argv[]) ...@@ -95,7 +95,7 @@ int main(int argc, char *argv[])
return 1; return 1;
if (strcmp(argv[1], "depends") == 0) { if (strcmp(argv[1], "depends") == 0) {
printf("build_assert\n"); printf("ccan/build_assert\n");
return 0; return 0;
} }
......
...@@ -21,7 +21,7 @@ int main(int argc, char *argv[]) ...@@ -21,7 +21,7 @@ int main(int argc, char *argv[])
if (strcmp(argv[1], "depends") == 0) { if (strcmp(argv[1], "depends") == 0) {
#if !HAVE_TYPEOF #if !HAVE_TYPEOF
printf("build_assert\n"); printf("ccan/build_assert\n");
#endif #endif
return 0; return 0;
} }
......
...@@ -39,7 +39,7 @@ int main(int argc, char *argv[]) ...@@ -39,7 +39,7 @@ int main(int argc, char *argv[])
return 1; return 1;
if (strcmp(argv[1], "depends") == 0) { if (strcmp(argv[1], "depends") == 0) {
printf("check_type\n"); printf("ccan/check_type\n");
return 0; return 0;
} }
......
...@@ -55,7 +55,7 @@ int main(int argc, char *argv[]) ...@@ -55,7 +55,7 @@ int main(int argc, char *argv[])
return 1; return 1;
if (strcmp(argv[1], "depends") == 0) { if (strcmp(argv[1], "depends") == 0) {
printf("container_of\n"); printf("ccan/container_of\n");
return 0; return 0;
} }
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* the standard string.h. * the standard string.h.
* *
* Example: * Example:
* #include "ccan/string.h" * #include "string/string.h"
* *
* int main(int argc, char *argv[]) * int main(int argc, char *argv[])
* { * {
......
...@@ -95,7 +95,7 @@ int main(int argc, char *argv[]) ...@@ -95,7 +95,7 @@ int main(int argc, char *argv[])
return 1; return 1;
if (strcmp(argv[1], "depends") == 0) { if (strcmp(argv[1], "depends") == 0) {
printf("typesafe_cb\n"); printf("ccan/typesafe_cb\n");
return 0; return 0;
} }
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdarg.h> #include <stdarg.h>
#include "config.h" #include "config.h"
#include "typesafe_cb/typesafe_cb.h" #include "ccan/typesafe_cb/typesafe_cb.h"
/* /*
this uses a little trick to allow __LINE__ to be stringified this uses a little trick to allow __LINE__ to be stringified
......
...@@ -51,8 +51,5 @@ int main(int argc, char *argv[]) ...@@ -51,8 +51,5 @@ int main(int argc, char *argv[])
if (strcmp(argv[1], "depends") == 0) if (strcmp(argv[1], "depends") == 0)
return 0; return 0;
if (strcmp(argv[1], "license") == 0)
return "BSD";
return 1; return 1;
} }
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <limits.h> #include <limits.h>
#include <stdbool.h> #include <stdbool.h>
#include <fnmatch.h>
/* We dup stderr to here. */ /* We dup stderr to here. */
static int stderrfd; static int stderrfd;
...@@ -32,18 +33,18 @@ static void failmsg(const char *fmt, ...) ...@@ -32,18 +33,18 @@ static void failmsg(const char *fmt, ...)
_exit(1); _exit(1);
} }
static void expect(int fd, const char *str) static void expect(int fd, const char *pattern)
{ {
char buffer[PIPE_BUF]; char buffer[PIPE_BUF+1];
int r; int r;
r = read(fd, buffer, sizeof(buffer)); r = read(fd, buffer, sizeof(buffer)-1);
if (r < 0) if (r < 0)
failmsg("reading from pipe"); failmsg("reading from pipe");
buffer[r] = '\0';
if (strlen(str) != r || strncmp(str, buffer, r) != 0) if (fnmatch(pattern, buffer, 0) != 0)
failmsg("Expected '%s' got '%.*s'", failmsg("Expected '%s' got '%s'", pattern, buffer);
str, r, buffer);
} }
int main(int argc, char *argv[]) int main(int argc, char *argv[])
...@@ -75,21 +76,21 @@ int main(int argc, char *argv[]) ...@@ -75,21 +76,21 @@ int main(int argc, char *argv[])
ok(0, "msg2"); ok(0, "msg2");
expect(p[0], "not ok 2 - msg2\n" expect(p[0], "not ok 2 - msg2\n"
"# Failed test (tap/test/run.c:main() at line 76)\n"); "# Failed test (*tap/test/run.c:main() at line 77)\n");
ok1(true); ok1(true);
expect(p[0], "ok 3 - true\n"); expect(p[0], "ok 3 - true\n");
ok1(false); ok1(false);
expect(p[0], "not ok 4 - false\n" expect(p[0], "not ok 4 - false\n"
"# Failed test (tap/test/run.c:main() at line 83)\n"); "# Failed test (*tap/test/run.c:main() at line 84)\n");
pass("passed"); pass("passed");
expect(p[0], "ok 5 - passed\n"); expect(p[0], "ok 5 - passed\n");
fail("failed"); fail("failed");
expect(p[0], "not ok 6 - failed\n" expect(p[0], "not ok 6 - failed\n"
"# Failed test (tap/test/run.c:main() at line 90)\n"); "# Failed test (*tap/test/run.c:main() at line 91)\n");
skip(2, "skipping %s", "test"); skip(2, "skipping %s", "test");
expect(p[0], "ok 7 # skip skipping test\n" expect(p[0], "ok 7 # skip skipping test\n"
...@@ -98,7 +99,7 @@ int main(int argc, char *argv[]) ...@@ -98,7 +99,7 @@ int main(int argc, char *argv[])
todo_start("todo"); todo_start("todo");
ok1(false); ok1(false);
expect(p[0], "not ok 9 - false # TODO todo\n" expect(p[0], "not ok 9 - false # TODO todo\n"
"# Failed (TODO) test (tap/test/run.c:main() at line 99)\n"); "# Failed (TODO) test (*tap/test/run.c:main() at line 100)\n");
ok1(true); ok1(true);
expect(p[0], "ok 10 - true # TODO todo\n"); expect(p[0], "ok 10 - true # TODO todo\n");
todo_end(); todo_end();
......
ccan_tools/run_tests: ccan_tools/run_tests.o tap/tap.o talloc/talloc.o
ccan_tools/doc_extract: ccan_tools/doc_extract.c talloc/talloc.o
ccan_tools/namespacize: ccan_tools/namespacize.c talloc/talloc.o
ccan_tools-clean: ccanlint-clean
rm -f run_tests doc_extract
include ccan_tools/ccanlint/Makefile
OBJS := ccan_tools/ccanlint/no_info.o \
ccan_tools/ccanlint/has_main_header.o \
ccan_tools/ccanlint/has_tests.o \
ccan_tools/ccanlint/trailing_whitespace.o \
ccan_tools/ccanlint/idempotent.o \
FUTURE:=ccan_tools/ccanlint/if_have_not_ifdef.o \
ccan_tools/ccanlint/needs_depends.o \
ccan_tools/ccanlint/has_info_documentation.o \
ccan_tools/ccanlint/has_header_documentation.o \
ccan_tools/ccanlint/has_tests.o \
ccan_tools/ccanlint/builds_ok.o \
ccan_tools/ccanlint/builds_ok_all_have_variants.o \
ccan_tools/ccanlint/run_tests.o \
ccan_tools/ccanlint/test_coverage.o \
ccan_tools/ccanlint/generated-init-tests: $(OBJS)
cat $(OBJS:.o=.c) | sed -n 's/^struct ccanlint \([A-Za-z0-9_]*\) = {/{ extern struct ccanlint \1; list_add(\&tests, \&\1.list); }/p' >$@
ccan_tools/ccanlint/ccanlint.o: ccan_tools/ccanlint/generated-init-tests
ccan_tools/ccanlint/ccanlint: \
$(OBJS) \
ccan_tools/ccanlint/ccanlint.o \
ccan_tools/ccanlint/get_file_lines.o \
ccan_tools/ccanlint/file_analysis.o \
talloc/talloc.o noerr/noerr.o
ccanlint-clean:
$(RM) ccan_tools/ccanlint/generated-init-tests
tools/run_tests: tools/run_tests.o ccan/tap/tap.o ccan/talloc/talloc.o
tools/doc_extract: tools/doc_extract.c ccan/talloc/talloc.o
tools/namespacize: tools/namespacize.c ccan/talloc/talloc.o
tools-clean: ccanlint-clean
rm -f run_tests doc_extract namespacize
include tools/ccanlint/Makefile
OBJS := tools/ccanlint/no_info.o \
tools/ccanlint/has_main_header.o \
tools/ccanlint/has_tests.o \
tools/ccanlint/trailing_whitespace.o \
tools/ccanlint/idempotent.o \
FUTURE:=tools/ccanlint/if_have_not_ifdef.o \
tools/ccanlint/needs_depends.o \
tools/ccanlint/has_info_documentation.o \
tools/ccanlint/has_header_documentation.o \
tools/ccanlint/has_tests.o \
tools/ccanlint/builds_ok.o \
tools/ccanlint/builds_ok_all_have_variants.o \
tools/ccanlint/run_tests.o \
tools/ccanlint/test_coverage.o \
tools/ccanlint/generated-init-tests: $(OBJS)
cat $(OBJS:.o=.c) | sed -n 's/^struct ccanlint \([A-Za-z0-9_]*\) = {/{ extern struct ccanlint \1; list_add(\&tests, \&\1.list); }/p' >$@
tools/ccanlint/ccanlint.o: tools/ccanlint/generated-init-tests
tools/ccanlint/ccanlint: \
$(OBJS) \
tools/ccanlint/ccanlint.o \
tools/ccanlint/get_file_lines.o \
tools/ccanlint/file_analysis.o \
talloc/talloc.o noerr/noerr.o
ccanlint-clean:
$(RM) tools/ccanlint/generated-init-tests
$(RM) tools/ccanlint/ccanlint
...@@ -4,11 +4,11 @@ ...@@ -4,11 +4,11 @@
#include <dirent.h> #include <dirent.h>
#include <assert.h> #include <assert.h>
#include <unistd.h> #include <unistd.h>
#include "tap/tap.h" #include "ccan/tap/tap.h"
#include "talloc/talloc.h" #include "ccan/talloc/talloc.h"
#include "../string/string.h" #include "ccan/string/string.h"
#define CFLAGS "-O3 -Wall -Wundef -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Werror -I." #define CFLAGS "-O3 -Wall -Wundef -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Werror -Iccan -I."
/* FIXME: Use build bug later. */ /* FIXME: Use build bug later. */
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
...@@ -56,7 +56,7 @@ static char *obj_list(void) ...@@ -56,7 +56,7 @@ static char *obj_list(void)
list = talloc_asprintf_append(list, "%s ", i->name); list = talloc_asprintf_append(list, "%s ", i->name);
/* FIXME */ /* FIXME */
list = talloc_asprintf_append(list, "tap/tap.o"); list = talloc_asprintf_append(list, "ccan/tap/tap.o");
return list; return list;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment