ccanlint: compile module with reduced-feature config.h
authorRusty Russell <rusty@rustcorp.com.au>
Tue, 1 Mar 2011 07:17:24 +0000 (17:47 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Tue, 1 Mar 2011 07:17:24 +0000 (17:47 +1030)
tools/ccanlint/compulsory_tests/build.h
tools/ccanlint/compulsory_tests/module_builds.c
tools/ccanlint/compulsory_tests/objects_build.c
tools/ccanlint/tests/objects_build_without_features.c [new file with mode: 0644]

index 633060dbac4176f6d337c274ac84177575674387..0e2f7e659b15b2604a15aa07aef1523ccbda86fe 100644 (file)
@@ -2,4 +2,6 @@
 #define CCANLINT_BUILD_H
 char *build_module(struct manifest *m, bool keep, char **errstr);
 char *build_submodule(struct manifest *m);
+void build_objects(struct manifest *m,
+                  bool keep, struct score *score, const char *flags);
 #endif /* CCANLINT_BUILD_H */
index 44c882ce357494fb1aadcb8331360c2b311da99c..40a345e5da8a8c0ae6003655722e9167103fb3de 100644 (file)
@@ -82,3 +82,4 @@ struct ccanlint module_builds = {
 };
 
 REGISTER_TEST(module_builds);
+
index 91bc12ce9b3965a37afa8c327d864d36145e649d..46fdbd4592ea5561ad350ac9ca3571de297b44b0 100644 (file)
@@ -13,6 +13,7 @@
 #include <err.h>
 #include <string.h>
 #include <ctype.h>
+#include "build.h"
 
 static const char *can_build(struct manifest *m)
 {
@@ -21,9 +22,8 @@ static const char *can_build(struct manifest *m)
        return NULL;
 }
 
-static void check_objs_build(struct manifest *m,
-                            bool keep,
-                            unsigned int *timeleft, struct score *score)
+void build_objects(struct manifest *m,
+                  bool keep, struct score *score, const char *flags)
 {
        struct ccan_file *i;
        bool errors = false, warnings = false;
@@ -38,7 +38,7 @@ static void check_objs_build(struct manifest *m,
                char *fullfile = talloc_asprintf(m, "%s/%s", m->dir, i->name);
 
                i->compiled = maybe_temp_file(m, "", keep, fullfile);
-               if (!compile_object(score, fullfile, ccan_dir, compiler, cflags,
+               if (!compile_object(score, fullfile, ccan_dir, compiler, flags,
                                    i->compiled, &output)) {
                        talloc_free(i->compiled);
                        score_file_error(score, i, 0,
@@ -60,6 +60,13 @@ static void check_objs_build(struct manifest *m,
        }
 }
 
+static void check_objs_build(struct manifest *m,
+                            bool keep,
+                            unsigned int *timeleft, struct score *score)
+{
+       build_objects(m, keep, score, cflags);
+}
+
 struct ccanlint objects_build = {
        .key = "objects_build",
        .name = "Module object files can be built",
diff --git a/tools/ccanlint/tests/objects_build_without_features.c b/tools/ccanlint/tests/objects_build_without_features.c
new file mode 100644 (file)
index 0000000..f30bde4
--- /dev/null
@@ -0,0 +1,21 @@
+#include <tools/ccanlint/ccanlint.h>
+#include <ccan/talloc/talloc.h>
+#include "../compulsory_tests/build.h"
+
+static void check_objs_build_without_features(struct manifest *m,
+                                             bool keep,
+                                             unsigned int *timeleft,
+                                             struct score *score)
+{
+       const char *flags = talloc_asprintf(score, "-I. %s", cflags);
+       build_objects(m, keep, score, flags);
+}
+
+struct ccanlint objects_build_without_features = {
+       .key = "objects_build_without_features",
+       .name = "Module object files can be built (without features)",
+       .check = check_objs_build_without_features,
+       .needs = "reduce_features objects_build"
+};
+REGISTER_TEST(objects_build_without_features);
+