summaryrefslogtreecommitdiffstats
path: root/b.c
diff options
context:
space:
mode:
Diffstat (limited to 'b.c')
-rw-r--r--b.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/b.c b/b.c
index 6ac5db6..ddcb811 100644
--- a/b.c
+++ b/b.c
@@ -115,6 +115,34 @@ bool build_templates(B_Cmd *cmd, const char **templates, size_t len) {
return true;
}
+bool
+build_tests(B_Cmd *cmd, const char * output_path) {
+ int rebuild_is_needed =
+ b_needs_rebuild1(B_COMPILE, output_path, "tests/example_test.c");
+
+ /* int dep_rebuild = 0; */
+ /* if (rebuild_is_needed == 0) */
+ /* dep_rebuild = */
+ /* b_needs_rebuild(B_COMPILE, output_path, dep_paths, dep_paths_len); */
+
+
+ if (rebuild_is_needed < 0 /* || dep_rebuild < 0 */) return false;
+
+
+ if (force || rebuild_is_needed /* || dep_rebuild */) {
+ cmd->count = 0;
+ cc(cmd);
+ b_cmd_append(cmd, "-o", output_path);
+ b_cmd_append(cmd, "-l", "check");
+ b_cmd_append(cmd, "tests/example_test.c");
+ synth_libs(cmd);
+ return b_cmd_run_sync(*cmd);
+ }
+
+ b_log(B_INFO, "%s is up-to-date", output_path);
+ return true;
+}
+
int
main(int argc, char *argv[])
{
@@ -203,5 +231,7 @@ main(int argc, char *argv[])
B_ARRAY_LEN(synth_deps), BUILD_DIR "synth"))
return 1;
+ if (!build_tests(&cmd, BUILD_DIR "test"))
+ return 1;
return 0;
}