aboutsummaryrefslogtreecommitdiffstats
path: root/src/blogc-make
diff options
context:
space:
mode:
Diffstat (limited to 'src/blogc-make')
-rw-r--r--src/blogc-make/ctx.c1
-rw-r--r--src/blogc-make/ctx.h2
-rw-r--r--src/blogc-make/exec.c9
-rw-r--r--src/blogc-make/exec.h2
-rw-r--r--src/blogc-make/main.c10
5 files changed, 19 insertions, 5 deletions
diff --git a/src/blogc-make/ctx.c b/src/blogc-make/ctx.c
index fc59457..753aadf 100644
--- a/src/blogc-make/ctx.c
+++ b/src/blogc-make/ctx.c
@@ -143,6 +143,7 @@ bm_ctx_new(bm_ctx_t *base, const char *settings_file, const char *argv0,
rv->blogc = bm_exec_find_binary(argv0, "blogc", "BLOGC");
rv->blogc_runserver = bm_exec_find_binary(argv0, "blogc-runserver",
"BLOGC_RUNSERVER");
+ rv->production = false;
rv->verbose = false;
}
else {
diff --git a/src/blogc-make/ctx.h b/src/blogc-make/ctx.h
index 8d87163..e36fa4c 100644
--- a/src/blogc-make/ctx.h
+++ b/src/blogc-make/ctx.h
@@ -31,6 +31,8 @@ typedef struct {
typedef struct {
char *blogc;
char *blogc_runserver;
+
+ bool production;
bool verbose;
bm_settings_t *settings;
diff --git a/src/blogc-make/exec.c b/src/blogc-make/exec.c
index df028c2..db20cae 100644
--- a/src/blogc-make/exec.c
+++ b/src/blogc-make/exec.c
@@ -205,7 +205,7 @@ list_variables(const char *key, const char *value, bc_string_t *str)
char*
bm_exec_build_blogc_cmd(const char *blogc_bin, bm_settings_t *settings,
bc_trie_t *variables, bool listing, const char *template,
- const char *output, bool sources_stdin)
+ const char *output, bool production, bool sources_stdin)
{
bc_string_t *rv = bc_string_new();
@@ -228,6 +228,11 @@ bm_exec_build_blogc_cmd(const char *blogc_bin, bm_settings_t *settings,
bc_trie_foreach(variables, (bc_trie_foreach_func_t) list_variables, rv);
+ if (production) {
+ bc_string_append(rv,
+ " -D MAKE_ENV_PRODUCTION=1 -D MAKE_ENV='production'");
+ }
+
if (listing) {
bc_string_append(rv, " -l");
}
@@ -268,7 +273,7 @@ bm_exec_blogc(bm_ctx_t *ctx, bc_trie_t *variables, bool listing,
}
char *cmd = bm_exec_build_blogc_cmd(ctx->blogc, ctx->settings, variables,
- listing, template->path, output->path, input->len > 0);
+ listing, template->path, output->path, ctx->production, input->len > 0);
if (ctx->verbose)
printf("%s\n", cmd);
diff --git a/src/blogc-make/exec.h b/src/blogc-make/exec.h
index 08cc608..fadaafe 100644
--- a/src/blogc-make/exec.h
+++ b/src/blogc-make/exec.h
@@ -20,7 +20,7 @@ int bm_exec_command(const char *cmd, const char *input, char **output,
char **error, bc_error_t **err);
char* bm_exec_build_blogc_cmd(const char *blogc_bin, bm_settings_t *settings,
bc_trie_t *variables, bool listing, const char *template,
- const char *output, bool sources_stdin);
+ const char *output, bool production, bool sources_stdin);
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 only_first_source);
diff --git a/src/blogc-make/main.c b/src/blogc-make/main.c
index 8e15981..eb7f504 100644
--- a/src/blogc-make/main.c
+++ b/src/blogc-make/main.c
@@ -36,7 +36,8 @@ print_help(void)
" -h show this help message and exit\n"
" -v show version and exit\n"
" -V be verbose when executing commands\n"
- " -f FILE read FILE as blogcfile\n");
+ " -f FILE read FILE as blogcfile\n"
+ " -p build for production environment\n");
bm_rule_print_help();
}
@@ -44,7 +45,7 @@ print_help(void)
static void
print_usage(void)
{
- printf("usage: blogc-make [-h] [-v] [-V] [-f FILE] [RULE ...]\n");
+ printf("usage: blogc-make [-h] [-v] [-V] [-f FILE] [-p] [RULE ...]\n");
}
@@ -62,6 +63,7 @@ main(int argc, char **argv)
bc_slist_t *rules = NULL;
bool verbose = false;
+ bool production = false;
char *blogcfile = NULL;
bm_ctx_t *ctx = NULL;
@@ -83,6 +85,9 @@ main(int argc, char **argv)
else if (i + 1 < argc)
blogcfile = bc_strdup(argv[++i]);
break;
+ case 'p':
+ production = true;
+ break;
#ifdef MAKE_EMBEDDED
case 'm':
// no-op, for embedding into blogc binary.
@@ -112,6 +117,7 @@ main(int argc, char **argv)
rv = 3;
goto cleanup;
}
+ ctx->production = production;
ctx->verbose = verbose;
rv = bm_rule_executor(ctx, rules);