diff options
author | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2017-03-04 22:28:12 +0100 |
---|---|---|
committer | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2017-03-04 22:28:12 +0100 |
commit | bda4570a0273cffb60ff63743110bc7a8026216b (patch) | |
tree | 236799fc528b2c8027852b07029790235115430e /src | |
parent | 6f497276ca155173b4679e069de5b148af2905c0 (diff) | |
download | blogc-bda4570a0273cffb60ff63743110bc7a8026216b.tar.gz blogc-bda4570a0273cffb60ff63743110bc7a8026216b.tar.bz2 blogc-bda4570a0273cffb60ff63743110bc7a8026216b.zip |
make: make the reloader interface generic
this way it can run any rule, even if we don't need this feature now
Diffstat (limited to 'src')
-rw-r--r-- | src/blogc-make/reloader.c | 9 | ||||
-rw-r--r-- | src/blogc-make/reloader.h | 5 | ||||
-rw-r--r-- | src/blogc-make/rules.c | 2 |
3 files changed, 11 insertions, 5 deletions
diff --git a/src/blogc-make/reloader.c b/src/blogc-make/reloader.c index 0832ae8..a4b837d 100644 --- a/src/blogc-make/reloader.c +++ b/src/blogc-make/reloader.c @@ -30,7 +30,7 @@ bm_reloader_thread(void *arg) "reloader disabled!\n"); break; } - if (0 != reloader->rule_exec(reloader->ctx, NULL, NULL)) { + if (0 != reloader->rule_exec(reloader->ctx, reloader->outputs, reloader->args)) { fprintf(stderr, "blogc-make: error: failed to rebuild website. " "reloader disabled!\n"); break; @@ -44,10 +44,11 @@ bm_reloader_thread(void *arg) bm_reloader_t* -bm_reloader_new(bm_ctx_t *ctx, bm_rule_exec_func_t rule_exec) +bm_reloader_new(bm_ctx_t *ctx, bm_rule_exec_func_t rule_exec, + bc_slist_t *outputs, bc_trie_t *args) { // first rule_exec call is syncronous, to do a 'sanity check' - if (0 != rule_exec(ctx, NULL, NULL)) + if (0 != rule_exec(ctx, outputs, args)) return NULL; int err; @@ -70,6 +71,8 @@ bm_reloader_new(bm_ctx_t *ctx, bm_rule_exec_func_t rule_exec) bm_reloader_t *rv = bc_malloc(sizeof(bm_reloader_t)); rv->ctx = ctx; rv->rule_exec = rule_exec; + rv->outputs = outputs; + rv->args = args; rv->running = true; pthread_t thread; diff --git a/src/blogc-make/reloader.h b/src/blogc-make/reloader.h index 70464a8..d688ccf 100644 --- a/src/blogc-make/reloader.h +++ b/src/blogc-make/reloader.h @@ -16,10 +16,13 @@ typedef struct { bm_ctx_t *ctx; bm_rule_exec_func_t rule_exec; + bc_slist_t *outputs; + bc_trie_t *args; bool running; } bm_reloader_t; -bm_reloader_t* bm_reloader_new(bm_ctx_t *ctx, bm_rule_exec_func_t rule_exec); +bm_reloader_t* bm_reloader_new(bm_ctx_t *ctx, bm_rule_exec_func_t rule_exec, + bc_slist_t *outputs, bc_trie_t *args); void bm_reloader_stop(bm_reloader_t *reloader); #endif /* _MAKE_RELOADER_H */ diff --git a/src/blogc-make/rules.c b/src/blogc-make/rules.c index 1f4a121..ca4b376 100644 --- a/src/blogc-make/rules.c +++ b/src/blogc-make/rules.c @@ -553,7 +553,7 @@ 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); + bm_reloader_t *reloader = bm_reloader_new(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")); |