aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/blogc-make/ctx.c1
-rw-r--r--src/blogc-make/ctx.h2
-rw-r--r--src/blogc-make/exec.c24
-rw-r--r--src/blogc-make/exec.h8
-rw-r--r--src/blogc-make/main.c1
-rw-r--r--src/blogc-make/rules.c36
6 files changed, 39 insertions, 33 deletions
diff --git a/src/blogc-make/ctx.c b/src/blogc-make/ctx.c
index b584fcc..7d3489b 100644
--- a/src/blogc-make/ctx.c
+++ b/src/blogc-make/ctx.c
@@ -138,6 +138,7 @@ bm_ctx_new(bm_ctx_t *base, const char *settings_file, bc_error_t **err)
bm_ctx_t *rv = NULL;
if (base == NULL) {
rv = bc_malloc(sizeof(bm_ctx_t));
+ rv->verbose = false;
}
else {
bm_ctx_free_internal(base);
diff --git a/src/blogc-make/ctx.h b/src/blogc-make/ctx.h
index e761a26..eb25145 100644
--- a/src/blogc-make/ctx.h
+++ b/src/blogc-make/ctx.h
@@ -29,6 +29,8 @@ typedef struct {
} bm_filectx_t;
typedef struct {
+ bool verbose;
+
bm_settings_t *settings;
char *root_dir;
diff --git a/src/blogc-make/exec.c b/src/blogc-make/exec.c
index 1dab7fd..157254b 100644
--- a/src/blogc-make/exec.c
+++ b/src/blogc-make/exec.c
@@ -256,10 +256,13 @@ bm_exec_build_blogc_cmd(bm_settings_t *settings, bc_trie_t *variables,
int
-bm_exec_blogc(bm_settings_t *settings, bc_trie_t *variables, bool listing,
+bm_exec_blogc(bm_ctx_t *ctx, bc_trie_t *variables, bool listing,
bm_filectx_t *template, bm_filectx_t *output, bc_slist_t *sources,
- bool verbose, bool only_first_source)
+ bool only_first_source)
{
+ if (ctx == NULL)
+ return 3;
+
bc_string_t *input = bc_string_new();
for (bc_slist_t *l = sources; l != NULL; l = l->next) {
bc_string_append_printf(input, "%s\n", ((bm_filectx_t*) l->data)->path);
@@ -267,10 +270,10 @@ bm_exec_blogc(bm_settings_t *settings, bc_trie_t *variables, bool listing,
break;
}
- char *cmd = bm_exec_build_blogc_cmd(settings, variables, listing,
+ char *cmd = bm_exec_build_blogc_cmd(ctx->settings, variables, listing,
template->path, output->path, input->len > 0);
- if (verbose)
+ if (ctx->verbose)
printf("%s\n", cmd);
else
printf(" BLOGC %s\n", output->short_path);
@@ -293,7 +296,7 @@ bm_exec_blogc(bm_settings_t *settings, bc_trie_t *variables, bool listing,
}
if (rv != 0) {
- if (verbose) {
+ if (ctx->verbose) {
fprintf(stderr,
"blogc-make: error: Failed to execute command.\n"
"\n"
@@ -337,9 +340,12 @@ bm_exec_blogc(bm_settings_t *settings, bc_trie_t *variables, bool listing,
int
-bm_exec_blogc_runserver(const char *output_dir, const char *host,
- const char *port, const char *threads, bool verbose)
+bm_exec_blogc_runserver(bm_ctx_t *ctx, const char *host, const char *port,
+ const char *threads)
{
+ if (ctx == NULL)
+ return 3;
+
bc_string_t *cmd = bc_string_new();
char *blogc_runserver = bm_exec_find_binary("blogc-runserver",
@@ -365,11 +371,11 @@ bm_exec_blogc_runserver(const char *output_dir, const char *host,
free(tmp);
}
- char *tmp = bc_shell_quote(output_dir);
+ char *tmp = bc_shell_quote(ctx->output_dir);
bc_string_append_printf(cmd, " %s", tmp);
free(tmp);
- if (verbose)
+ if (ctx->verbose)
printf("%s\n", cmd->str);
else
printf("\n");
diff --git a/src/blogc-make/exec.h b/src/blogc-make/exec.h
index 901e53d..ec52eec 100644
--- a/src/blogc-make/exec.h
+++ b/src/blogc-make/exec.h
@@ -20,10 +20,10 @@ int bm_exec_command(const char *cmd, const char *input, char **output,
char **error, bc_error_t **err);
char* bm_exec_build_blogc_cmd(bm_settings_t *settings, bc_trie_t *variables,
bool listing, const char *template, const char *output, bool sources_stdin);
-int bm_exec_blogc(bm_settings_t *settings, bc_trie_t *variables, bool listing,
+int bm_exec_blogc(bm_ctx_t *ctx, bc_trie_t *variables, bool listing,
bm_filectx_t *template, bm_filectx_t *output, bc_slist_t *sources,
- bool verbose, bool only_first_source);
-int bm_exec_blogc_runserver(const char *output_dir, const char *host,
- const char *port, const char *threads, bool verbose);
+ bool only_first_source);
+int bm_exec_blogc_runserver(bm_ctx_t *ctx, const char *host, const char *port,
+ const char *threads);
#endif /* _MAKE_EXEC_H */
diff --git a/src/blogc-make/main.c b/src/blogc-make/main.c
index e5a5ac4..c27c302 100644
--- a/src/blogc-make/main.c
+++ b/src/blogc-make/main.c
@@ -120,6 +120,7 @@ main(int argc, char **argv)
rv = 3;
goto cleanup;
}
+ ctx->verbose = verbose;
rv = bm_rule_executor(ctx, rules, verbose);
diff --git a/src/blogc-make/rules.c b/src/blogc-make/rules.c
index 8a3bfc4..cdcc838 100644
--- a/src/blogc-make/rules.c
+++ b/src/blogc-make/rules.c
@@ -71,9 +71,8 @@ index_exec(bm_ctx_t *ctx, bc_slist_t *outputs, bc_trie_t *args, bool verbose)
if (bm_rule_need_rebuild(ctx->posts_fctx, ctx->settings_fctx,
ctx->main_template_fctx, fctx, false))
{
- rv = bm_exec_blogc(ctx->settings, variables, true,
- ctx->main_template_fctx, fctx, ctx->posts_fctx, verbose,
- false);
+ rv = bm_exec_blogc(ctx, variables, true, ctx->main_template_fctx,
+ fctx, ctx->posts_fctx, false);
if (rv != 0)
break;
}
@@ -129,9 +128,8 @@ atom_exec(bm_ctx_t *ctx, bc_slist_t *outputs, bc_trie_t *args, bool verbose)
if (bm_rule_need_rebuild(ctx->posts_fctx, ctx->settings_fctx, NULL,
fctx, false))
{
- rv = bm_exec_blogc(ctx->settings, variables, true,
- ctx->atom_template_fctx, fctx, ctx->posts_fctx, verbose,
- false);
+ rv = bm_exec_blogc(ctx, variables, true, ctx->atom_template_fctx,
+ fctx, ctx->posts_fctx, false);
if (rv != 0)
break;
}
@@ -195,9 +193,8 @@ atom_tags_exec(bm_ctx_t *ctx, bc_slist_t *outputs, bc_trie_t *args, bool verbose
if (bm_rule_need_rebuild(ctx->posts_fctx, ctx->settings_fctx, NULL,
fctx, false))
{
- rv = bm_exec_blogc(ctx->settings, variables, true,
- ctx->atom_template_fctx, fctx, ctx->posts_fctx, verbose,
- false);
+ rv = bm_exec_blogc(ctx, variables, true, ctx->atom_template_fctx,
+ fctx, ctx->posts_fctx, false);
if (rv != 0)
break;
}
@@ -265,8 +262,8 @@ pagination_exec(bm_ctx_t *ctx, bc_slist_t *outputs, bc_trie_t *args, bool verbos
if (bm_rule_need_rebuild(ctx->posts_fctx, ctx->settings_fctx,
ctx->main_template_fctx, fctx, false))
{
- rv = bm_exec_blogc(ctx->settings, variables, true,
- ctx->main_template_fctx, fctx, ctx->posts_fctx, verbose, false);
+ rv = bm_exec_blogc(ctx, variables, true, ctx->main_template_fctx,
+ fctx, ctx->posts_fctx, false);
if (rv != 0)
break;
}
@@ -329,8 +326,8 @@ posts_exec(bm_ctx_t *ctx, bc_slist_t *outputs, bc_trie_t *args, bool verbose)
if (bm_rule_need_rebuild(s, ctx->settings_fctx,
ctx->main_template_fctx, o_fctx, true))
{
- rv = bm_exec_blogc(ctx->settings, variables, false,
- ctx->main_template_fctx, o_fctx, s, verbose, true);
+ rv = bm_exec_blogc(ctx, variables, false, ctx->main_template_fctx,
+ o_fctx, s, true);
if (rv != 0)
break;
}
@@ -395,9 +392,8 @@ tags_exec(bm_ctx_t *ctx, bc_slist_t *outputs, bc_trie_t *args, bool verbose)
if (bm_rule_need_rebuild(ctx->posts_fctx, ctx->settings_fctx,
ctx->main_template_fctx, fctx, false))
{
- rv = bm_exec_blogc(ctx->settings, variables, true,
- ctx->main_template_fctx, fctx, ctx->posts_fctx, verbose,
- false);
+ rv = bm_exec_blogc(ctx, variables, true, ctx->main_template_fctx,
+ fctx, ctx->posts_fctx, false);
if (rv != 0)
break;
}
@@ -459,8 +455,8 @@ pages_exec(bm_ctx_t *ctx, bc_slist_t *outputs, bc_trie_t *args, bool verbose)
if (bm_rule_need_rebuild(s, ctx->settings_fctx,
ctx->main_template_fctx, o_fctx, true))
{
- rv = bm_exec_blogc(ctx->settings, variables, false,
- ctx->main_template_fctx, o_fctx, s, verbose, true);
+ rv = bm_exec_blogc(ctx, variables, false, ctx->main_template_fctx,
+ o_fctx, s, true);
if (rv != 0)
break;
}
@@ -625,8 +621,8 @@ runserver_exec(bm_ctx_t *ctx, bc_slist_t *outputs, bc_trie_t *args, bool verbose
return 3;
}
- rv = bm_exec_blogc_runserver(ctx->output_dir, bc_trie_lookup(args, "host"),
- bc_trie_lookup(args, "port"), bc_trie_lookup(args, "threads"), verbose);
+ rv = bm_exec_blogc_runserver(ctx, bc_trie_lookup(args, "host"),
+ bc_trie_lookup(args, "port"), bc_trie_lookup(args, "threads"));
r_args->running = false;