Commit 570c9c55 authored by Rusty Russell's avatar Rusty Russell

Rename _info.c to _info: this means we can simple compile *.c.

parent 8f61c0bc
...@@ -10,8 +10,8 @@ ...@@ -10,8 +10,8 @@
# Especially tools/ccanlint/ccanlint and tools/namespacize. # Especially tools/ccanlint/ccanlint and tools/namespacize.
# distclean: destroy everything back to pristine state # distclean: destroy everything back to pristine state
# Anything with an _info.c file is a module. # Anything with an _info file is a module.
ALL=$(patsubst ccan/%/_info.c, %, $(wildcard ccan/*/_info.c)) ALL=$(patsubst ccan/%/_info, %, $(wildcard ccan/*/_info))
ALL_DEPENDS=$(patsubst %, ccan/%/.depends, $(ALL)) ALL_DEPENDS=$(patsubst %, ccan/%/.depends, $(ALL))
# Not all modules have tests. # Not all modules have tests.
ALL_TESTS=$(patsubst ccan/%/test/, %, $(wildcard ccan/*/test/)) ALL_TESTS=$(patsubst ccan/%/test/, %, $(wildcard ccan/*/test/))
...@@ -25,27 +25,27 @@ check: $(ALL_TESTS:%=check-%) ...@@ -25,27 +25,27 @@ check: $(ALL_TESTS:%=check-%)
distclean: clean distclean: clean
rm -f $(ALL_DEPENDS) rm -f $(ALL_DEPENDS)
$(ALL_DEPENDS): %/.depends: %/_info.c tools/ccan_depends $(ALL_DEPENDS): %/.depends: %/_info tools/ccan_depends
@tools/ccan_depends $* > $@ || ( rm -f $@; exit 1 ) @tools/ccan_depends $* > $@ || ( rm -f $@; exit 1 )
# Actual dependencies are created in inter-depends # Actual dependencies are created in inter-depends
check-%: tools/run_tests ccan/%/_info check-%: tools/run_tests ccan/%/info
@echo Testing $*... @echo Testing $*...
@if tools/run_tests $(V) $$(for f in `ccan/$*/_info libs`; do echo --lib=$$f; done) `[ ! -f ccan/$*.o ] || echo --apiobj=ccan/$*.o` ccan/$* $(filter-out ccan/$*.o, $(filter %.o, $^)) | grep ^'not ok'; then exit 1; else exit 0; fi @if tools/run_tests $(V) $$(for f in `ccan/$*/info libs`; do echo --lib=$$f; done) `[ ! -f ccan/$*.o ] || echo --apiobj=ccan/$*.o` ccan/$* $(filter-out ccan/$*.o, $(filter %.o, $^)) | grep ^'not ok'; then exit 1; else exit 0; fi
ccan/%/_info: ccan/%/_info.c ccan/%/info: ccan/%/_info
$(CC) $(CFLAGS) -o $@ $< $(CC) $(CFLAGS) -o $@ -x c $<
libccan.a(%.o): ccan/%.o libccan.a(%.o): ccan/%.o
$(AR) r $@ $< $(AR) r $@ $<
clean: tools-clean clean: tools-clean
$(RM) `find . -name '*.o'` `find . -name '.depends'` `find . -name '*.a'` `find . -name _info` `find . -name '*.d'` $(RM) `find . -name '*.o'` `find . -name '.depends'` `find . -name '*.a'` `find . -name info` `find . -name '*.d'`
$(RM) inter-depends lib-depends test-depends $(RM) inter-depends lib-depends test-depends
# Creates a dependency from the tests to the object files which it needs. # Creates a dependency from the tests to the object files which it needs.
inter-depends: $(ALL_DEPENDS) Makefile inter-depends: $(ALL_DEPENDS) Makefile
@for f in $(ALL_DEPENDS); do echo check-$$(basename $$(dirname $$f) ): $$(for dir in $$(cat $$f) $$(dirname $$f); do [ "$$(echo $$dir/[a-z]*.c)" = "$$dir/[a-z]*.c" ] || echo ccan/"$$(basename $$dir)".o; done); done > $@ @for f in $(ALL_DEPENDS); do echo check-$$(basename $$(dirname $$f) ): $$(for dir in $$(cat $$f) $$(dirname $$f); do [ "$$(echo $$dir/*.c)" = "$$dir/*.c" ] || echo ccan/"$$(basename $$dir)".o; done); done > $@
# Creates dependencies between tests, so if foo depends on bar, bar is tested # Creates dependencies between tests, so if foo depends on bar, bar is tested
# first # first
......
# Example makefile which makes a "libccan.a" of everything under ccan/. # Example makefile which makes a "libccan.a" of everything under ccan/.
# For simple projects you could just do: # For simple projects you could just do:
# SRCFILES += $(wildcard ccan/*/[a-z]*.c) # SRCFILES += $(wildcard ccan/*/*.c)
CFLAGS=-g -O3 -Wall -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Werror -I. $(DEPGEN) CFLAGS=-g -O3 -Wall -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Werror -I. $(DEPGEN)
...@@ -8,8 +8,8 @@ CFLAGS=-g -O3 -Wall -Wstrict-prototypes -Wold-style-definition -Wmissing-prototy ...@@ -8,8 +8,8 @@ CFLAGS=-g -O3 -Wall -Wstrict-prototypes -Wold-style-definition -Wmissing-prototy
DEPGEN=-MD DEPGEN=-MD
-include ccan/*/*.d -include ccan/*/*.d
# Every directory with .c files (other than _info.c) is included. # Every directory with .c files is included.
DIRS=$(patsubst %/, %, $(sort $(dir $(wildcard ccan/*/[a-z]*.c)))) DIRS=$(patsubst %/, %, $(sort $(dir $(wildcard ccan/*/*.c))))
# We compile all the ccan/foo/*.o files together into ccan/foo.o # We compile all the ccan/foo/*.o files together into ccan/foo.o
OBJFILES=$(DIRS:=.o) OBJFILES=$(DIRS:=.o)
...@@ -20,5 +20,5 @@ libccan.a: $(OBJFILES) ...@@ -20,5 +20,5 @@ libccan.a: $(OBJFILES)
# Dependencies are autogenerated in the .d files. # Dependencies are autogenerated in the .d files.
# We create all the .o files and link them together. # We create all the .o files and link them together.
$(OBJFILES): %.o: $(OBJFILES): %.o:
cd $* && $(CC) -I../.. $(CFLAGS) -c [a-z]*.c && cd ../.. && $(LD) -r -o $@ `echo $*/[a-z]*.c ' ' | sed 's/\.c /.o /g'` cd $* && $(CC) -I../.. $(CFLAGS) -c *.c && cd ../.. && $(LD) -r -o $@ `echo $*/*.c ' ' | sed 's/\.c /.o /g'`
...@@ -56,10 +56,10 @@ $(WEBDIR)/ccan.jpg: web/ccan.jpg ...@@ -56,10 +56,10 @@ $(WEBDIR)/ccan.jpg: web/ccan.jpg
$(WEBDIR)/info/%.html: $(WEBDIR)/tarballs/%.tar.bz2 $(WEBDIR)/tarballs/with-deps/%.tar.bz2 $(WEBDIR)/info/%.html: $(WEBDIR)/tarballs/%.tar.bz2 $(WEBDIR)/tarballs/with-deps/%.tar.bz2
@URLPREFIX=../ php5 web/staticmoduleinfo.php ccan/$* > $@ @URLPREFIX=../ php5 web/staticmoduleinfo.php ccan/$* > $@
$(WEBDIR)/tarballs/%.tar.bz2: ccan/%/_info.c $(WEBDIR)/tarballs/%.tar.bz2: ccan/%/_info
tar -c -j -f $@ `bzr ls --versioned --kind=file ccan/$*` tar -c -j -f $@ `bzr ls --versioned --kind=file ccan/$*`
$(WEBDIR)/tarballs/with-deps/%.tar.bz2: ccan/%/_info.c tools/ccan_depends $(WEBDIR)/tarballs/with-deps/%.tar.bz2: ccan/%/_info tools/ccan_depends
tar cfj $@ $$(echo ccan/$* $$(tools/ccan_depends ccan/$*) | xargs -n 1 bzr ls --versioned --kind=file) tar cfj $@ $$(echo ccan/$* $$(tools/ccan_depends ccan/$*) | xargs -n 1 bzr ls --versioned --kind=file)
distclean: distclean-web distclean: distclean-web
......
...@@ -20,8 +20,8 @@ static void *check_has_info(struct manifest *m) ...@@ -20,8 +20,8 @@ static void *check_has_info(struct manifest *m)
static const char *describe_has_info(struct manifest *m, void *check_result) static const char *describe_has_info(struct manifest *m, void *check_result)
{ {
return "You have no _info.c file.\n\n" return "You have no _info file.\n\n"
"The file _info.c contains the metadata for a ccan package: things\n" "The file _info contains the metadata for a ccan package: things\n"
"like the dependencies, the documentation for the package as a whole\n" "like the dependencies, the documentation for the package as a whole\n"
"and license information.\n"; "and license information.\n";
} }
...@@ -56,22 +56,22 @@ static void create_info_template(struct manifest *m, void *check_result) ...@@ -56,22 +56,22 @@ static void create_info_template(struct manifest *m, void *check_result)
{ {
FILE *info; FILE *info;
if (!ask("Should I create a template _info.c file for you?")) if (!ask("Should I create a template _info file for you?"))
return; return;
info = fopen("_info.c", "w"); info = fopen("_info", "w");
if (!info) if (!info)
err(1, "Trying to create a template _info.c"); err(1, "Trying to create a template _info");
if (fprintf(info, template, m->basename) < 0) { if (fprintf(info, template, m->basename) < 0) {
unlink_noerr("_info.c"); unlink_noerr("_info");
err(1, "Writing template into _info.c"); err(1, "Writing template into _info");
} }
fclose(info); fclose(info);
} }
struct ccanlint has_info = { struct ccanlint has_info = {
.name = "Has _info.c file", .name = "Has _info file",
.check = check_has_info, .check = check_has_info,
.describe = describe_has_info, .describe = describe_has_info,
.handle = create_info_template, .handle = create_info_template,
......
...@@ -71,7 +71,7 @@ static void add_files(struct manifest *m, const char *dir) ...@@ -71,7 +71,7 @@ static void add_files(struct manifest *m, const char *dir)
continue; continue;
} }
if (streq(f->name, "_info.c")) { if (streq(f->name, "_info")) {
m->info_file = f; m->info_file = f;
f->contents = grab_file(f, f->name, &f->contents_size); f->contents = grab_file(f, f->name, &f->contents_size);
if (!f->contents) if (!f->contents)
......
...@@ -48,12 +48,12 @@ extern struct ccanlint has_info_documentation; ...@@ -48,12 +48,12 @@ extern struct ccanlint has_info_documentation;
static void create_info_template_doc(struct manifest *m, void *check_result) static void create_info_template_doc(struct manifest *m, void *check_result)
{ {
int fd = open("_info.c.new", O_WRONLY|O_CREAT|O_EXCL, 0666); int fd = open("_info.new", O_WRONLY|O_CREAT|O_EXCL, 0666);
FILE *new; FILE *new;
char *oldcontents; char *oldcontents;
if (fd < 0 || !(new = fdopen(fd, "w"))) if (fd < 0 || !(new = fdopen(fd, "w")))
err(1, "Creating _info.c.new to insert documentation"); err(1, "Creating _info.new to insert documentation");
if (fprintf(new, if (fprintf(new,
"/**\n" "/**\n"
...@@ -64,26 +64,26 @@ static void create_info_template_doc(struct manifest *m, void *check_result) ...@@ -64,26 +64,26 @@ static void create_info_template_doc(struct manifest *m, void *check_result)
" * Followed by an Example: section with a standalone\n" " * Followed by an Example: section with a standalone\n"
" * (trivial and usually useless) program\n" " * (trivial and usually useless) program\n"
" */\n", m->basename, m->basename) < 0) { " */\n", m->basename, m->basename) < 0) {
unlink_noerr("_info.c.new"); unlink_noerr("_info.new");
err(1, "Writing to _info.c.new to insert documentation"); err(1, "Writing to _info.new to insert documentation");
} }
oldcontents = grab_file(m, "_info.c", NULL); oldcontents = grab_file(m, "_info", NULL);
if (!oldcontents) { if (!oldcontents) {
unlink_noerr("_info.c.new"); unlink_noerr("_info.new");
err(1, "Reading _info.c"); err(1, "Reading _info");
} }
if (fprintf(new, "%s", oldcontents) < 0) { if (fprintf(new, "%s", oldcontents) < 0) {
unlink_noerr("_info.c.new"); unlink_noerr("_info.new");
err(1, "Appending _info.c to _info.c.new"); err(1, "Appending _info to _info.new");
} }
if (fclose(new) != 0) { if (fclose(new) != 0) {
unlink_noerr("_info.c.new"); unlink_noerr("_info.new");
err(1, "Closing _info.c.new"); err(1, "Closing _info.new");
} }
if (rename("_info.c.new", "_info.c") != 0) { if (rename("_info.new", "_info") != 0) {
unlink_noerr("_info.c.new"); unlink_noerr("_info.new");
err(1, "Renaming _info.c.new to _info.c"); err(1, "Renaming _info.new to _info");
} }
} }
...@@ -96,20 +96,20 @@ static const char *describe_has_info_documentation(struct manifest *m, ...@@ -96,20 +96,20 @@ static const char *describe_has_info_documentation(struct manifest *m,
if (!id->summary) { if (!id->summary) {
has_info_documentation.handle = create_info_template_doc; has_info_documentation.handle = create_info_template_doc;
reason = talloc_asprintf_append(reason, reason = talloc_asprintf_append(reason,
"Your _info.c has no module documentation.\n\n" "Your _info file has no module documentation.\n\n"
"CCAN modules use /**-style comments for documentation: the\n" "CCAN modules use /**-style comments for documentation: the\n"
"overall documentation belongs in the _info.c metafile.\n"); "overall documentation belongs in the _info metafile.\n");
} }
if (!id->description) if (!id->description)
reason = talloc_asprintf_append(reason, reason = talloc_asprintf_append(reason,
"Your _info.c has no module description.\n\n" "Your _info file has no module description.\n\n"
"The lines after the first summary line in the _info.c file\n" "The lines after the first summary line in the _info file\n"
"documentation should describe the purpose and use of the\n" "documentation should describe the purpose and use of the\n"
"overall package\n"); "overall package\n");
if (!id->example) if (!id->example)
reason = talloc_asprintf_append(reason, reason = talloc_asprintf_append(reason,
"Your _info.c has no module example.\n\n" "Your _info file has no module example.\n\n"
"There should be an Example: section of the _info.c documentation\n" "There should be an Example: section of the _info documentation\n"
"which provides a concise toy program which uses your module\n"); "which provides a concise toy program which uses your module\n");
return reason; return reason;
} }
...@@ -122,7 +122,7 @@ static unsigned int has_info_documentation_score(struct manifest *m, ...@@ -122,7 +122,7 @@ static unsigned int has_info_documentation_score(struct manifest *m,
} }
struct ccanlint has_info_documentation = { struct ccanlint has_info_documentation = {
.name = "Documentation in _info.c", .name = "Documentation in _info file",
.total_score = 3, .total_score = 3,
.score = has_info_documentation_score, .score = has_info_documentation_score,
.check = check_has_info_documentation, .check = check_has_info_documentation,
......
...@@ -39,8 +39,8 @@ static int unlink_info(char *infofile) ...@@ -39,8 +39,8 @@ static int unlink_info(char *infofile)
/* Be careful about trying to compile over running programs (parallel make) */ /* Be careful about trying to compile over running programs (parallel make) */
static char *compile_info(const void *ctx, const char *dir) static char *compile_info(const void *ctx, const char *dir)
{ {
char *infofile = talloc_asprintf(ctx, "%s/_info.%u", dir, getpid()); char *infofile = talloc_asprintf(ctx, "%s/info.%u", dir, getpid());
char *cmd = talloc_asprintf(ctx, "cc " CFLAGS " -o %s %s/_info.c", char *cmd = talloc_asprintf(ctx, "cc " CFLAGS " -o %s -x c %s/_info",
infofile, dir); infofile, dir);
talloc_set_destructor(infofile, unlink_info); talloc_set_destructor(infofile, unlink_info);
if (system(cmd) != 0) if (system(cmd) != 0)
...@@ -98,7 +98,7 @@ static char **get_one_safe_deps(const void *ctx, ...@@ -98,7 +98,7 @@ static char **get_one_safe_deps(const void *ctx,
char **deps, **lines, *raw, *fname; char **deps, **lines, *raw, *fname;
unsigned int i, n = 0; unsigned int i, n = 0;
fname = talloc_asprintf(ctx, "%s/_info.c", dir); fname = talloc_asprintf(ctx, "%s/_info", dir);
raw = grab_file(fname, fname, NULL); raw = grab_file(fname, fname, NULL);
if (!raw) if (!raw)
errx(1, "Could not open %s", fname); errx(1, "Could not open %s", fname);
......
...@@ -507,14 +507,14 @@ static void adjust_dependents(const char *dir) ...@@ -507,14 +507,14 @@ static void adjust_dependents(const char *dir)
verbose("Looking for dependents in %s\n", parent); verbose("Looking for dependents in %s\n", parent);
verbose_indent(); verbose_indent();
for (file = get_dir(parent); *file; file++) { for (file = get_dir(parent); *file; file++) {
char *infoc, **deps; char *info, **deps;
bool isdep = false; bool isdep = false;
if (basename(*file, *file)[0] == '.') if (basename(*file, *file)[0] == '.')
continue; continue;
infoc = talloc_asprintf(*file, "%s/_info.c", *file); info = talloc_asprintf(*file, "%s/_info", *file);
if (access(infoc, R_OK) != 0) if (access(info, R_OK) != 0)
continue; continue;
for (deps = get_deps(*file, *file, false); *deps; deps++) { for (deps = get_deps(*file, *file, false); *deps; deps++) {
......
...@@ -10,10 +10,10 @@ ...@@ -10,10 +10,10 @@
#define CFLAGS "-O3 -Wall -Wundef -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Werror -Iccan/ -I." #define CFLAGS "-O3 -Wall -Wundef -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Werror -Iccan/ -I."
/* This actually compiles and runs the _info.c file to get dependencies. */ /* This actually compiles and runs the info file to get dependencies. */
char **get_deps(const void *ctx, const char *dir, bool recurse); char **get_deps(const void *ctx, const char *dir, bool recurse);
/* This is safer: just looks for ccan/ strings in _info.c */ /* This is safer: just looks for ccan/ strings in info */
char **get_safe_ccan_deps(const void *ctx, const char *dir, bool recurse); char **get_safe_ccan_deps(const void *ctx, const char *dir, bool recurse);
#endif /* CCAN_TOOLS_H */ #endif /* CCAN_TOOLS_H */
......
...@@ -21,7 +21,7 @@ $junkcode = "junkcode/"; ...@@ -21,7 +21,7 @@ $junkcode = "junkcode/";
$tempfolder = "temp/"; $tempfolder = "temp/";
//infofile //infofile
$infofile = '/_info.c'; $infofile = '/_info';
//temp repo //temp repo
$temprepo = "temprepo/"; $temprepo = "temprepo/";
......
...@@ -6,7 +6,7 @@ $tempfolder = "/home/ccan/upload-temp/"; ...@@ -6,7 +6,7 @@ $tempfolder = "/home/ccan/upload-temp/";
$uploadscript = "http://ccan.ozlabs.org/uploader.php"; $uploadscript = "http://ccan.ozlabs.org/uploader.php";
//infofile //infofile
$infofile = '/_info.c'; $infofile = '/_info';
//ccan admin //ccan admin
$ccanadmin = "rusty@rustcorp.com.au"; $ccanadmin = "rusty@rustcorp.com.au";
...@@ -22,7 +22,7 @@ $repo_base = 'http://ccan.ozlabs.org/repo/?cmd=inventory;path='; ...@@ -22,7 +22,7 @@ $repo_base = 'http://ccan.ozlabs.org/repo/?cmd=inventory;path=';
function extract_field($field,$module) function extract_field($field,$module)
{ {
return htmlspecialchars(shell_exec('tools/doc_extract '.$field.' '.$module.'/_info.c')); return htmlspecialchars(shell_exec('tools/doc_extract '.$field.' '.$module.'/_info'));
} }
// Convert double line breaks into paragraphs, and blank spaces into preformat. // Convert double line breaks into paragraphs, and blank spaces into preformat.
......
...@@ -28,7 +28,7 @@ Or you can just download the <a href="ccan.tar.bz2">tarball of everything includ ...@@ -28,7 +28,7 @@ Or you can just download the <a href="ccan.tar.bz2">tarball of everything includ
$d = dir($argv[1]); $d = dir($argv[1]);
$modules = array(); $modules = array();
while (false !== ($entry = $d->read())) { while (false !== ($entry = $d->read())) {
if ($entry[0] != '.' && is_file($argv[1].$entry."/_info.c")) { if ($entry[0] != '.' && is_file($argv[1].$entry."/_info")) {
array_push($modules, $entry); array_push($modules, $entry);
} }
} }
......
...@@ -16,7 +16,7 @@ Got C code sitting around which might help someone? Put it to work ...@@ -16,7 +16,7 @@ Got C code sitting around which might help someone? Put it to work
by uploading here; .tar.gz, .zip or even single C files. by uploading here; .tar.gz, .zip or even single C files.
</p> </p>
<p>If it has a valid _info.c file and a testsuite (see <a href="http://ccan.ozlabs.org/Wiki/ModuleGuide">the module creation guide</a>), it'll go into the <p>If it has a valid _info file and a testsuite (see <a href="http://ccan.ozlabs.org/Wiki/ModuleGuide">the module creation guide</a>), it'll go into the
main repository. Otherwise, it'll go into our "junkcode" area where main repository. Otherwise, it'll go into our "junkcode" area where
people can browse and download it. people can browse and download it.
</p> </p>
......
...@@ -12,7 +12,7 @@ include('configuration'); ...@@ -12,7 +12,7 @@ include('configuration');
by uploading here; .tar.gz, .zip or even single C files. by uploading here; .tar.gz, .zip or even single C files.
</p> </p>
<p>If it has a valid _info.c file and a testsuite, it'll go into the <p>If it has a valid _info file and a testsuite, it'll go into the
main repository. Otherwise, it'll go into our "junkcode" area where main repository. Otherwise, it'll go into our "junkcode" area where
people can browse and download it. people can browse and download it.
</p> </p>
......
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