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 @@
# Especially tools/ccanlint/ccanlint and tools/namespacize.
# distclean: destroy everything back to pristine state
# Anything with an _info.c file is a module.
ALL=$(patsubst ccan/%/_info.c, %, $(wildcard ccan/*/_info.c))
# Anything with an _info file is a module.
ALL=$(patsubst ccan/%/_info, %, $(wildcard ccan/*/_info))
ALL_DEPENDS=$(patsubst %, ccan/%/.depends, $(ALL))
# Not all modules have tests.
ALL_TESTS=$(patsubst ccan/%/test/, %, $(wildcard ccan/*/test/))
......@@ -25,27 +25,27 @@ check: $(ALL_TESTS:%=check-%)
distclean: clean
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 )
# Actual dependencies are created in inter-depends
check-%: tools/run_tests ccan/%/_info
check-%: tools/run_tests ccan/%/info
@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
$(CC) $(CFLAGS) -o $@ $<
ccan/%/info: ccan/%/_info
$(CC) $(CFLAGS) -o $@ -x c $<
libccan.a(%.o): ccan/%.o
$(AR) r $@ $<
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
# Creates a dependency from the tests to the object files which it needs.
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
# first
......
# Example makefile which makes a "libccan.a" of everything under ccan/.
# 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)
......@@ -8,8 +8,8 @@ CFLAGS=-g -O3 -Wall -Wstrict-prototypes -Wold-style-definition -Wmissing-prototy
DEPGEN=-MD
-include ccan/*/*.d
# Every directory with .c files (other than _info.c) is included.
DIRS=$(patsubst %/, %, $(sort $(dir $(wildcard ccan/*/[a-z]*.c))))
# Every directory with .c files is included.
DIRS=$(patsubst %/, %, $(sort $(dir $(wildcard ccan/*/*.c))))
# We compile all the ccan/foo/*.o files together into ccan/foo.o
OBJFILES=$(DIRS:=.o)
......@@ -20,5 +20,5 @@ libccan.a: $(OBJFILES)
# Dependencies are autogenerated in the .d files.
# We create all the .o files and link them together.
$(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
$(WEBDIR)/info/%.html: $(WEBDIR)/tarballs/%.tar.bz2 $(WEBDIR)/tarballs/with-deps/%.tar.bz2
@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/$*`
$(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)
distclean: distclean-web
......
......@@ -20,8 +20,8 @@ static void *check_has_info(struct manifest *m)
static const char *describe_has_info(struct manifest *m, void *check_result)
{
return "You have no _info.c file.\n\n"
"The file _info.c contains the metadata for a ccan package: things\n"
return "You have no _info file.\n\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"
"and license information.\n";
}
......@@ -56,22 +56,22 @@ static void create_info_template(struct manifest *m, void *check_result)
{
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;
info = fopen("_info.c", "w");
info = fopen("_info", "w");
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) {
unlink_noerr("_info.c");
err(1, "Writing template into _info.c");
unlink_noerr("_info");
err(1, "Writing template into _info");
}
fclose(info);
}
struct ccanlint has_info = {
.name = "Has _info.c file",
.name = "Has _info file",
.check = check_has_info,
.describe = describe_has_info,
.handle = create_info_template,
......
......@@ -71,7 +71,7 @@ static void add_files(struct manifest *m, const char *dir)
continue;
}
if (streq(f->name, "_info.c")) {
if (streq(f->name, "_info")) {
m->info_file = f;
f->contents = grab_file(f, f->name, &f->contents_size);
if (!f->contents)
......
......@@ -48,12 +48,12 @@ extern struct ccanlint has_info_documentation;
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;
char *oldcontents;
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,
"/**\n"
......@@ -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"
" * (trivial and usually useless) program\n"
" */\n", m->basename, m->basename) < 0) {
unlink_noerr("_info.c.new");
err(1, "Writing to _info.c.new to insert documentation");
unlink_noerr("_info.new");
err(1, "Writing to _info.new to insert documentation");
}
oldcontents = grab_file(m, "_info.c", NULL);
oldcontents = grab_file(m, "_info", NULL);
if (!oldcontents) {
unlink_noerr("_info.c.new");
err(1, "Reading _info.c");
unlink_noerr("_info.new");
err(1, "Reading _info");
}
if (fprintf(new, "%s", oldcontents) < 0) {
unlink_noerr("_info.c.new");
err(1, "Appending _info.c to _info.c.new");
unlink_noerr("_info.new");
err(1, "Appending _info to _info.new");
}
if (fclose(new) != 0) {
unlink_noerr("_info.c.new");
err(1, "Closing _info.c.new");
unlink_noerr("_info.new");
err(1, "Closing _info.new");
}
if (rename("_info.c.new", "_info.c") != 0) {
unlink_noerr("_info.c.new");
err(1, "Renaming _info.c.new to _info.c");
if (rename("_info.new", "_info") != 0) {
unlink_noerr("_info.new");
err(1, "Renaming _info.new to _info");
}
}
......@@ -96,20 +96,20 @@ static const char *describe_has_info_documentation(struct manifest *m,
if (!id->summary) {
has_info_documentation.handle = create_info_template_doc;
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"
"overall documentation belongs in the _info.c metafile.\n");
"overall documentation belongs in the _info metafile.\n");
}
if (!id->description)
reason = talloc_asprintf_append(reason,
"Your _info.c has no module description.\n\n"
"The lines after the first summary line in the _info.c file\n"
"Your _info file has no module description.\n\n"
"The lines after the first summary line in the _info file\n"
"documentation should describe the purpose and use of the\n"
"overall package\n");
if (!id->example)
reason = talloc_asprintf_append(reason,
"Your _info.c has no module example.\n\n"
"There should be an Example: section of the _info.c documentation\n"
"Your _info file has no module example.\n\n"
"There should be an Example: section of the _info documentation\n"
"which provides a concise toy program which uses your module\n");
return reason;
}
......@@ -122,7 +122,7 @@ static unsigned int has_info_documentation_score(struct manifest *m,
}
struct ccanlint has_info_documentation = {
.name = "Documentation in _info.c",
.name = "Documentation in _info file",
.total_score = 3,
.score = has_info_documentation_score,
.check = check_has_info_documentation,
......
......@@ -39,8 +39,8 @@ static int unlink_info(char *infofile)
/* Be careful about trying to compile over running programs (parallel make) */
static char *compile_info(const void *ctx, const char *dir)
{
char *infofile = talloc_asprintf(ctx, "%s/_info.%u", dir, getpid());
char *cmd = talloc_asprintf(ctx, "cc " CFLAGS " -o %s %s/_info.c",
char *infofile = talloc_asprintf(ctx, "%s/info.%u", dir, getpid());
char *cmd = talloc_asprintf(ctx, "cc " CFLAGS " -o %s -x c %s/_info",
infofile, dir);
talloc_set_destructor(infofile, unlink_info);
if (system(cmd) != 0)
......@@ -98,7 +98,7 @@ static char **get_one_safe_deps(const void *ctx,
char **deps, **lines, *raw, *fname;
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);
if (!raw)
errx(1, "Could not open %s", fname);
......
......@@ -507,14 +507,14 @@ static void adjust_dependents(const char *dir)
verbose("Looking for dependents in %s\n", parent);
verbose_indent();
for (file = get_dir(parent); *file; file++) {
char *infoc, **deps;
char *info, **deps;
bool isdep = false;
if (basename(*file, *file)[0] == '.')
continue;
infoc = talloc_asprintf(*file, "%s/_info.c", *file);
if (access(infoc, R_OK) != 0)
info = talloc_asprintf(*file, "%s/_info", *file);
if (access(info, R_OK) != 0)
continue;
for (deps = get_deps(*file, *file, false); *deps; deps++) {
......
......@@ -10,10 +10,10 @@
#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);
/* 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);
#endif /* CCAN_TOOLS_H */
......
......@@ -21,7 +21,7 @@ $junkcode = "junkcode/";
$tempfolder = "temp/";
//infofile
$infofile = '/_info.c';
$infofile = '/_info';
//temp repo
$temprepo = "temprepo/";
......
......@@ -6,7 +6,7 @@ $tempfolder = "/home/ccan/upload-temp/";
$uploadscript = "http://ccan.ozlabs.org/uploader.php";
//infofile
$infofile = '/_info.c';
$infofile = '/_info';
//ccan admin
$ccanadmin = "rusty@rustcorp.com.au";
......@@ -22,7 +22,7 @@ $repo_base = 'http://ccan.ozlabs.org/repo/?cmd=inventory;path=';
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.
......
......@@ -28,7 +28,7 @@ Or you can just download the <a href="ccan.tar.bz2">tarball of everything includ
$d = dir($argv[1]);
$modules = array();
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);
}
}
......
......@@ -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.
</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
people can browse and download it.
</p>
......
......@@ -12,7 +12,7 @@ include('configuration');
by uploading here; .tar.gz, .zip or even single C files.
</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
people can browse and download it.
</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