Browse Source

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

Rusty Russell 16 years ago
parent
commit
570c9c555f

+ 9 - 9
Makefile

@@ -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 

+ 4 - 4
Makefile-ccan

@@ -1,6 +1,6 @@
 # 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'`
 

+ 2 - 2
Makefile-web

@@ -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

+ 0 - 0
ccan/alignof/_info.c → ccan/alignof/_info


+ 0 - 0
ccan/alloc/_info.c → ccan/alloc/_info


+ 0 - 0
ccan/antithread/_info.c → ccan/antithread/_info


+ 0 - 0
ccan/array/_info.c → ccan/array/_info


+ 0 - 0
ccan/array_size/_info.c → ccan/array_size/_info


+ 0 - 0
ccan/build_assert/_info.c → ccan/build_assert/_info


+ 0 - 0
ccan/check_type/_info.c → ccan/check_type/_info


+ 0 - 0
ccan/ciniparser/_info.c → ccan/ciniparser/_info


+ 0 - 0
ccan/container_of/_info.c → ccan/container_of/_info


+ 0 - 0
ccan/crc/_info.c → ccan/crc/_info


+ 0 - 0
ccan/crcsync/_info.c → ccan/crcsync/_info


+ 0 - 0
ccan/daemonize/_info.c → ccan/daemonize/_info


+ 0 - 0
ccan/endian/_info.c → ccan/endian/_info


+ 0 - 0
ccan/grab_file/_info.c → ccan/grab_file/_info


+ 0 - 0
ccan/hash/_info.c → ccan/hash/_info


+ 0 - 0
ccan/ilog/_info.c → ccan/ilog/_info


+ 0 - 0
ccan/isaac/_info.c → ccan/isaac/_info


+ 0 - 0
ccan/list/_info.c → ccan/list/_info


+ 0 - 0
ccan/md4/_info.c → ccan/md4/_info


+ 0 - 0
ccan/noerr/_info.c → ccan/noerr/_info


+ 0 - 0
ccan/ogg_to_pcm/_info.c → ccan/ogg_to_pcm/_info


+ 0 - 0
ccan/read_write_all/_info.c → ccan/read_write_all/_info


+ 0 - 0
ccan/str/_info.c → ccan/str/_info


+ 0 - 0
ccan/str_talloc/_info.c → ccan/str_talloc/_info


+ 0 - 0
ccan/talloc/_info.c → ccan/talloc/_info


+ 0 - 0
ccan/tap/_info.c → ccan/tap/_info


+ 0 - 0
ccan/typesafe_cb/_info.c → ccan/typesafe_cb/_info


+ 0 - 0
ccan/wwviaudio/_info.c → ccan/wwviaudio/_info


+ 8 - 8
tools/ccanlint/compulsory_tests/has_info.c

@@ -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,

+ 1 - 1
tools/ccanlint/file_analysis.c

@@ -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)

+ 21 - 21
tools/ccanlint/tests/has_info_documentation.c

@@ -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,

+ 3 - 3
tools/depends.c

@@ -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);

+ 3 - 3
tools/namespacize.c

@@ -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++) {

+ 2 - 2
tools/tools.h

@@ -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 */

+ 1 - 1
web/configuration

@@ -21,7 +21,7 @@ $junkcode = "junkcode/";
 $tempfolder = "temp/";
 
 //infofile
-$infofile = '/_info.c';
+$infofile = '/_info';
 
 //temp repo
 $temprepo = "temprepo/";

+ 2 - 2
web/static-configuration

@@ -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.

+ 1 - 1
web/staticall.php

@@ -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);
 	}
 }

+ 1 - 1
web/staticupload.php

@@ -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>

+ 1 - 1
web/upload.php

@@ -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>