aboutsummaryrefslogtreecommitdiffstats
path: root/src/blogc-make/rules.c
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2018-05-13 02:39:28 +0200
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2018-05-13 19:38:32 +0200
commitf62faeb3ff69db2b1d27d775a7c30dbe4a78917c (patch)
tree217a48ef4e069369526f4438989849a0f17c3b2e /src/blogc-make/rules.c
parent3be45bbbdc3f231926a30b2585a69b2e82918460 (diff)
downloadblogc-f62faeb3ff69db2b1d27d775a7c30dbe4a78917c.tar.gz
blogc-f62faeb3ff69db2b1d27d775a7c30dbe4a78917c.tar.bz2
blogc-f62faeb3ff69db2b1d27d775a7c30dbe4a78917c.zip
make: added 'watch' rule. improved 'runserver' rule.
Diffstat (limited to 'src/blogc-make/rules.c')
-rw-r--r--src/blogc-make/rules.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/blogc-make/rules.c b/src/blogc-make/rules.c
index 8464bd2..5a23de7 100644
--- a/src/blogc-make/rules.c
+++ b/src/blogc-make/rules.c
@@ -16,6 +16,7 @@
#include "ctx.h"
#include "exec.h"
#include "exec-native.h"
+#include "httpd.h"
#include "reloader.h"
#include "settings.h"
#include "rules.h"
@@ -581,16 +582,16 @@ static int all_exec(bm_ctx_t *ctx, bc_slist_t *outputs, bc_trie_t *args);
static int
runserver_exec(bm_ctx_t *ctx, bc_slist_t *outputs, bc_trie_t *args)
{
- bm_reloader_t *reloader = bm_reloader_new(ctx, all_exec, outputs, args);
- if (reloader == NULL) {
- return 3;
- }
+ return bm_httpd_run(&ctx, all_exec, outputs, args);
+}
- int rv = bm_exec_blogc_runserver(ctx, bc_trie_lookup(args, "host"),
- bc_trie_lookup(args, "port"), bc_trie_lookup(args, "threads"));
- bm_reloader_stop(reloader);
- return rv;
+// WATCH RULE
+
+static int
+watch_exec(bm_ctx_t *ctx, bc_slist_t *outputs, bc_trie_t *args)
+{
+ return bm_reloader_run(&ctx, all_exec, outputs, args);
}
@@ -667,12 +668,20 @@ const bm_rule_t rules[] = {
},
{
.name = "runserver",
- .help = "run blogc-runserver pointing to output directory, if available\n"
+ .help = "run blogc-runserver pointing to output directory, if available,\n"
+ " rebuilding as needed\n"
" arguments: host (127.0.0.1), port (8080) and threads (20)",
.outputlist_func = NULL,
.exec_func = runserver_exec,
.generate_files = false,
},
+ {
+ .name = "watch",
+ .help = "watch for changes in the source files, rebuilding as needed",
+ .outputlist_func = NULL,
+ .exec_func = watch_exec,
+ .generate_files = false,
+ },
{NULL, NULL, NULL, NULL, false},
};