aboutsummaryrefslogtreecommitdiffstats
path: root/src/blogc-make
diff options
context:
space:
mode:
Diffstat (limited to 'src/blogc-make')
-rw-r--r--src/blogc-make/exec.c31
-rw-r--r--src/blogc-make/exec.h1
-rw-r--r--src/blogc-make/rules.c20
-rw-r--r--src/blogc-make/settings.c5
4 files changed, 57 insertions, 0 deletions
diff --git a/src/blogc-make/exec.c b/src/blogc-make/exec.c
index 8b961e7..28dc73d 100644
--- a/src/blogc-make/exec.c
+++ b/src/blogc-make/exec.c
@@ -302,3 +302,34 @@ bm_exec_blogc(bm_settings_t *settings, bc_trie_t *variables, bool listing,
return rv;
}
+
+
+int
+bm_exec_blogc_runserver(bm_settings_t *settings, bool verbose)
+{
+ // use blogc binary from environment, if provided
+ const char *blogc_runserver = getenv("BLOGC_RUNSERVER");
+
+ char *cmd = bc_strdup_printf("%s -t %s -p %s -m %s %s",
+ blogc_runserver != NULL ? blogc_runserver : "blogc-runserver",
+ bc_trie_lookup(settings->settings, "runserver_host"),
+ bc_trie_lookup(settings->settings, "runserver_port"),
+ bc_trie_lookup(settings->settings, "runserver_threads"),
+ bc_trie_lookup(settings->settings, "output_dir"));
+
+ if (verbose)
+ printf("%s\n", cmd);
+ else
+ printf("\n");
+ fflush(stdout);
+
+ // we don't need pipes to run blogc-runserver, because it is "interactive"
+ int rv = system(cmd);
+ free(cmd);
+
+ if (rv != 0)
+ fprintf(stderr,
+ "error: Failed to execute command, returned status code: %d\n", rv);
+
+ return rv;
+}
diff --git a/src/blogc-make/exec.h b/src/blogc-make/exec.h
index 907109a..ecc7f2c 100644
--- a/src/blogc-make/exec.h
+++ b/src/blogc-make/exec.h
@@ -20,5 +20,6 @@ char* 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_filectx_t *template, bm_filectx_t *output, bc_slist_t *sources,
bool verbose, bool only_first_source);
+int bm_exec_blogc_runserver(bm_settings_t *settings, bool verbose);
#endif /* _MAKE_EXEC_H */
diff --git a/src/blogc-make/rules.c b/src/blogc-make/rules.c
index a471b0b..de7d6cc 100644
--- a/src/blogc-make/rules.c
+++ b/src/blogc-make/rules.c
@@ -548,6 +548,19 @@ clean_exec(bm_ctx_t *ctx, bc_slist_t *outputs, bool verbose)
static int all_exec(bm_ctx_t *ctx, bc_slist_t *outputs, bool verbose);
+
+// RUNSERVER RULE
+static int
+runserver_exec(bm_ctx_t *ctx, bc_slist_t *outputs, bool verbose)
+{
+ int rv = all_exec(ctx, NULL, verbose);
+ if (rv != 0)
+ return rv;
+
+ return bm_exec_blogc_runserver(ctx->settings, verbose);
+}
+
+
const bm_rule_t const rules[] = {
{
.name = "all",
@@ -619,6 +632,13 @@ const bm_rule_t const rules[] = {
.exec_func = clean_exec,
.generate_files = false,
},
+ {
+ .name = "runserver",
+ .help = "run blogc-runserver pointing to output directory, if available",
+ .outputlist_func = NULL,
+ .exec_func = runserver_exec,
+ .generate_files = false,
+ },
{NULL, NULL, NULL, NULL, false},
};
diff --git a/src/blogc-make/settings.c b/src/blogc-make/settings.c
index 3df410f..27b3d80 100644
--- a/src/blogc-make/settings.c
+++ b/src/blogc-make/settings.c
@@ -44,6 +44,11 @@ static const struct default_settings_map {
{"atom_prefix", "atom"},
{"atom_ext", ".xml"},
+ // runserver
+ {"runserver_host", "127.0.0.1"},
+ {"runserver_port", "8080"},
+ {"runserver_threads", "20"},
+
// generic
{"date_format", "%b %d, %Y, %I:%M %p GMT"},
{"locale", NULL},