aboutsummaryrefslogtreecommitdiffstats
path: root/src/blogc-make/ctx.c
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2017-04-28 00:26:32 +0200
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2017-04-28 00:29:21 +0200
commitf3b6c03f21e45edd2220cb6fc996fe4b5fa11bb8 (patch)
tree4561ae8996aa56ef9377974c1faec93a0f344e3c /src/blogc-make/ctx.c
parent434afc5ac1ccf97394c38eaa3b4f5de176fbdce0 (diff)
downloadblogc-f3b6c03f21e45edd2220cb6fc996fe4b5fa11bb8.tar.gz
blogc-f3b6c03f21e45edd2220cb6fc996fe4b5fa11bb8.tar.bz2
blogc-f3b6c03f21e45edd2220cb6fc996fe4b5fa11bb8.zip
make: settings: do not read output_dir from blogcfile
now it is only possible to override output directory using environment variable. this commit also reduces the number trie lookups.
Diffstat (limited to 'src/blogc-make/ctx.c')
-rw-r--r--src/blogc-make/ctx.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/blogc-make/ctx.c b/src/blogc-make/ctx.c
index c7d6ca9..e062474 100644
--- a/src/blogc-make/ctx.c
+++ b/src/blogc-make/ctx.c
@@ -130,13 +130,6 @@ bm_ctx_new(bm_ctx_t *base, const char *settings_file, const char *argv0,
}
free(content);
- // fix output_dir, if forced from environment variable
- const char *output_dir_env = getenv("OUTPUT_DIR");
- if (output_dir_env != NULL) {
- bc_trie_insert(settings->settings, "output_dir",
- bc_strdup(output_dir_env));
- }
-
char *atom_template = bm_atom_deploy(settings, err);
if (*err != NULL) {
return NULL;
@@ -162,12 +155,15 @@ bm_ctx_new(bm_ctx_t *base, const char *settings_file, const char *argv0,
rv->root_dir = realpath(dirname(real_filename), NULL);
free(real_filename);
- const char *output_dir = bc_trie_lookup(settings->settings, "output_dir");
- if (output_dir[0] == '/') {
- rv->output_dir = bc_strdup(output_dir);
+ const char *output_dir = getenv("OUTPUT_DIR");
+ rv->short_output_dir = bc_strdup(output_dir != NULL ? output_dir : "_build");
+
+ if (rv->short_output_dir[0] == '/') {
+ rv->output_dir = bc_strdup(rv->short_output_dir);
}
else {
- rv->output_dir = bc_strdup_printf("%s/%s", rv->root_dir, output_dir);
+ rv->output_dir = bc_strdup_printf("%s/%s", rv->root_dir,
+ rv->short_output_dir);
}
// can't return null and set error after this!
@@ -272,6 +268,8 @@ bm_ctx_free_internal(bm_ctx_t *ctx)
free(ctx->root_dir);
ctx->root_dir = NULL;
+ free(ctx->short_output_dir);
+ ctx->short_output_dir = NULL;
free(ctx->output_dir);
ctx->output_dir = NULL;