build_objs.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #include <tools/ccanlint/ccanlint.h>
  2. #include <tools/tools.h>
  3. #include <ccan/talloc/talloc.h>
  4. #include <ccan/str/str.h>
  5. #include <sys/types.h>
  6. #include <sys/stat.h>
  7. #include <fcntl.h>
  8. #include <unistd.h>
  9. #include <limits.h>
  10. #include <errno.h>
  11. #include <stdlib.h>
  12. #include <stdio.h>
  13. #include <err.h>
  14. #include <string.h>
  15. #include <ctype.h>
  16. static const char *can_build(struct manifest *m)
  17. {
  18. if (safe_mode)
  19. return "Safe mode enabled";
  20. return NULL;
  21. }
  22. static void *check_objs_build(struct manifest *m)
  23. {
  24. char *report = NULL;
  25. struct ccan_file *i;
  26. list_for_each(&m->c_files, i, list) {
  27. char *err;
  28. char *fullfile = talloc_asprintf(m, "%s/%s", m->dir, i->name);
  29. /* One point for each obj file. */
  30. build_objs.total_score++;
  31. i->compiled = compile_object(m, fullfile, ccan_dir, &err);
  32. if (!i->compiled) {
  33. if (report)
  34. report = talloc_append_string(report, err);
  35. else
  36. report = err;
  37. }
  38. }
  39. return report;
  40. }
  41. static const char *describe_objs_build(struct manifest *m, void *check_result)
  42. {
  43. return check_result;
  44. }
  45. struct ccanlint build_objs = {
  46. .name = "Module object files can be built",
  47. .check = check_objs_build,
  48. .describe = describe_objs_build,
  49. .can_run = can_build,
  50. };
  51. REGISTER_TEST(build_objs, &depends_exist, NULL);