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.
# 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))
test-all: $(ALL_DEPENDS)
......@@ -16,13 +16,13 @@ distclean: clean
$(ALL_DEPENDS): %/.depends: %/_info
@$< depends > $@ || ( rm -f $@; exit 1 )
test-%: ccan_tools/run_tests
test-ccan/%: tools/run_tests
@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
rm -f `find . -name '*.o'`
clean: tools-clean
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.
It is expected that some of this code, being generally useful, will be
shuffled out to their own modules over time.
other:
ccan:
The beginnings of a ccan repository.
......@@ -37,7 +37,7 @@ int main(int argc, char *argv[])
return 1;
if (strcmp(argv[1], "depends") == 0) {
printf("build_assert\n");
printf("ccan/build_assert\n");
return 0;
}
......
......@@ -95,7 +95,7 @@ int main(int argc, char *argv[])
return 1;
if (strcmp(argv[1], "depends") == 0) {
printf("build_assert\n");
printf("ccan/build_assert\n");
return 0;
}
......
......@@ -21,7 +21,7 @@ int main(int argc, char *argv[])
if (strcmp(argv[1], "depends") == 0) {
#if !HAVE_TYPEOF
printf("build_assert\n");
printf("ccan/build_assert\n");
#endif
return 0;
}
......
......@@ -39,7 +39,7 @@ int main(int argc, char *argv[])
return 1;
if (strcmp(argv[1], "depends") == 0) {
printf("check_type\n");
printf("ccan/check_type\n");
return 0;
}
......
......@@ -55,7 +55,7 @@ int main(int argc, char *argv[])
return 1;
if (strcmp(argv[1], "depends") == 0) {
printf("container_of\n");
printf("ccan/container_of\n");
return 0;
}
......
......@@ -9,7 +9,7 @@
* the standard string.h.
*
* Example:
* #include "ccan/string.h"
* #include "string/string.h"
*
* int main(int argc, char *argv[])
* {
......
......@@ -95,7 +95,7 @@ int main(int argc, char *argv[])
return 1;
if (strcmp(argv[1], "depends") == 0) {
printf("typesafe_cb\n");
printf("ccan/typesafe_cb\n");
return 0;
}
......
......@@ -27,7 +27,7 @@
#include <stdio.h>
#include <stdarg.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
......
......@@ -51,8 +51,5 @@ int main(int argc, char *argv[])
if (strcmp(argv[1], "depends") == 0)
return 0;
if (strcmp(argv[1], "license") == 0)
return "BSD";
return 1;
}
......@@ -11,6 +11,7 @@
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>
#include <fnmatch.h>
/* We dup stderr to here. */
static int stderrfd;
......@@ -32,18 +33,18 @@ static void failmsg(const char *fmt, ...)
_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;
r = read(fd, buffer, sizeof(buffer));
r = read(fd, buffer, sizeof(buffer)-1);
if (r < 0)
failmsg("reading from pipe");
buffer[r] = '\0';
if (strlen(str) != r || strncmp(str, buffer, r) != 0)
failmsg("Expected '%s' got '%.*s'",
str, r, buffer);
if (fnmatch(pattern, buffer, 0) != 0)
failmsg("Expected '%s' got '%s'", pattern, buffer);
}
int main(int argc, char *argv[])
......@@ -75,21 +76,21 @@ int main(int argc, char *argv[])
ok(0, "msg2");
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);
expect(p[0], "ok 3 - true\n");
ok1(false);
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");
expect(p[0], "ok 5 - passed\n");
fail("failed");
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");
expect(p[0], "ok 7 # skip skipping test\n"
......@@ -98,7 +99,7 @@ int main(int argc, char *argv[])
todo_start("todo");
ok1(false);
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);
expect(p[0], "ok 10 - true # TODO todo\n");
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 @@
#include <dirent.h>
#include <assert.h>
#include <unistd.h>
#include "tap/tap.h"
#include "talloc/talloc.h"
#include "../string/string.h"
#include "ccan/tap/tap.h"
#include "ccan/talloc/talloc.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. */
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
......@@ -56,7 +56,7 @@ static char *obj_list(void)
list = talloc_asprintf_append(list, "%s ", i->name);
/* FIXME */
list = talloc_asprintf_append(list, "tap/tap.o");
list = talloc_asprintf_append(list, "ccan/tap/tap.o");
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