1 #include <tools/ccanlint/ccanlint.h>
2 #include <tools/tools.h>
3 #include <ccan/tal/grab_file/grab_file.h>
4 #include <ccan/read_write_all/read_write_all.h>
5 #include <ccan/str/str.h>
18 static void check_info_compiles(struct manifest *m,
19 unsigned int *timeleft, struct score *score)
21 char *info_c_file, *info, *output;
24 /* We don't really fail if we're in safe mode: our dependencies
32 /* Copy it to a file with proper .c suffix. */
33 info = grab_file(score, m->info_file->fullname);
35 score_file_error(score, m->info_file, 0,
36 "could not be read: %s", strerror(errno));
40 info_c_file = temp_file(info, ".c", "_info");
41 fd = open(info_c_file, O_WRONLY|O_CREAT|O_EXCL, 0600);
42 if (fd < 0 || !write_all(fd, info, tal_count(info)-1))
43 err(1, "Copying _info file");
46 err(1, "Closing _info file");
48 m->info_file->compiled[COMPILE_NORMAL] = temp_file(m, "", "info");
49 if (!compile_and_link(score, info_c_file, find_ccan_dir(m->dir), "",
51 m->info_file->compiled[COMPILE_NORMAL],
53 score_file_error(score, m->info_file, 0,
54 "Errors compiling _info:\n%s", output);
62 struct ccanlint info_compiles = {
63 .key = "info_compiles",
64 .name = "_info compiles",
65 .check = check_info_compiles,
66 .needs = "info_exists",
70 REGISTER_TEST(info_compiles);