aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2017-03-11 15:58:30 +0100
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2017-03-11 15:58:30 +0100
commit2b485906cfa6d2e0431b0fa0120e1c267074b4e8 (patch)
tree152720e5925a6f772fc8275c32bd3976f8943a25
parentacf14b6fafd39e46ba343fd069bed205d7c35fb9 (diff)
downloadblogc-2b485906cfa6d2e0431b0fa0120e1c267074b4e8.tar.gz
blogc-2b485906cfa6d2e0431b0fa0120e1c267074b4e8.tar.bz2
blogc-2b485906cfa6d2e0431b0fa0120e1c267074b4e8.zip
make: all builds are "production" by default, enable "dev" on cli.
this is more consistent with other similar tools, and enables us to add something like a [copy:dev] section later, that will avoid copying dev files to production builds.
-rw-r--r--man/blogc-make.1.ronn9
-rw-r--r--src/blogc-git-receiver/pre-receive.c2
-rw-r--r--src/blogc-github-lambda/lambda_function.py2
-rw-r--r--src/blogc-make/ctx.c2
-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.c18
-rw-r--r--tests/blogc-make/check_exec.c11
9 files changed, 28 insertions, 29 deletions
diff --git a/man/blogc-make.1.ronn b/man/blogc-make.1.ronn
index 4f9fe8c..97ffd1b 100644
--- a/man/blogc-make.1.ronn
+++ b/man/blogc-make.1.ronn
@@ -14,16 +14,17 @@ EXPAND-ME!
## OPTIONS
+ * `-D`:
+ Builds for development environment. This option is useful to load local,
+ non-optimized assets for development purposes. It adds two global
+ variables to all blogc(1) calls: `MAKE_ENV_DEV=1` and `MAKE_ENV=dev`.
+
* `-V`:
Activates verbose mode, that will give more details of commands runs.
* `-f` <FILE>:
Reads <FILE> as `blogcfile`.
- * `-p`:
- Builds for production environment. Adds two global variables to all blogc(1)
- calls: `MAKE_ENV_PRODUCTION=1` and `MAKE_ENV=production`.
-
* `-v`:
Show program name, version and exit.
diff --git a/src/blogc-git-receiver/pre-receive.c b/src/blogc-git-receiver/pre-receive.c
index 3b05e07..c2fe080 100644
--- a/src/blogc-git-receiver/pre-receive.c
+++ b/src/blogc-git-receiver/pre-receive.c
@@ -202,7 +202,7 @@ bgr_pre_receive_hook(int argc, char *argv[])
rv = 3;
goto cleanup;
}
- build_cmd = bc_strdup_printf("OUTPUT_DIR=\"%s\" blogc-make -p -V all",
+ build_cmd = bc_strdup_printf("OUTPUT_DIR=\"%s\" blogc-make -V all",
output_dir);
}
else if ((0 == access("Makefile", F_OK)) || (0 == access("GNUMakefile", F_OK))) {
diff --git a/src/blogc-github-lambda/lambda_function.py b/src/blogc-github-lambda/lambda_function.py
index fb8492f..3f41eeb 100644
--- a/src/blogc-github-lambda/lambda_function.py
+++ b/src/blogc-github-lambda/lambda_function.py
@@ -165,7 +165,7 @@ def sns_handler(message):
if os.path.isfile(blogcfile):
# deploy using blogc-make
- args = [os.path.join(cwd, 'blogc'), '-m', '-p', '-f', blogcfile,
+ args = [os.path.join(cwd, 'blogc'), '-m', '-f', blogcfile,
'all']
if debug:
args.append('-V')
diff --git a/src/blogc-make/ctx.c b/src/blogc-make/ctx.c
index 636a39a..c7d6ca9 100644
--- a/src/blogc-make/ctx.c
+++ b/src/blogc-make/ctx.c
@@ -148,7 +148,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->dev = false;
rv->verbose = false;
}
else {
diff --git a/src/blogc-make/ctx.h b/src/blogc-make/ctx.h
index 67d0a7d..14e913f 100644
--- a/src/blogc-make/ctx.h
+++ b/src/blogc-make/ctx.h
@@ -45,7 +45,7 @@ typedef struct {
char *blogc;
char *blogc_runserver;
- bool production;
+ bool dev;
bool verbose;
bm_settings_t *settings;
diff --git a/src/blogc-make/exec.c b/src/blogc-make/exec.c
index ca57e62..425f728 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 production, bool sources_stdin)
+ const char *output, bool dev, bool sources_stdin)
{
bc_string_t *rv = bc_string_new();
@@ -228,9 +228,8 @@ 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 (dev) {
+ bc_string_append(rv, " -D MAKE_ENV_DEV=1 -D MAKE_ENV='dev'");
}
if (listing) {
@@ -273,7 +272,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, ctx->production, input->len > 0);
+ listing, template->path, output->path, ctx->dev, 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 fadaafe..715c903 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 production, bool sources_stdin);
+ const char *output, bool dev, 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 eb7f504..8c73e13 100644
--- a/src/blogc-make/main.c
+++ b/src/blogc-make/main.c
@@ -25,7 +25,7 @@ print_help(void)
{
printf(
"usage:\n"
- " blogc-make [-h] [-v] [-V] [-f FILE] [RULE ...]\n"
+ " blogc-make [-h] [-v] [-D] [-V] [-f FILE] [RULE ...]\n"
" - A simple build tool for blogc.\n"
"\n"
"positional arguments:\n"
@@ -35,9 +35,9 @@ print_help(void)
"optional arguments:\n"
" -h show this help message and exit\n"
" -v show version and exit\n"
+ " -D build for development environment\n"
" -V be verbose when executing commands\n"
- " -f FILE read FILE as blogcfile\n"
- " -p build for production environment\n");
+ " -f FILE read FILE as blogcfile\n");
bm_rule_print_help();
}
@@ -45,7 +45,7 @@ print_help(void)
static void
print_usage(void)
{
- printf("usage: blogc-make [-h] [-v] [-V] [-f FILE] [-p] [RULE ...]\n");
+ printf("usage: blogc-make [-h] [-v] [-D] [-V] [-f FILE] [RULE ...]\n");
}
@@ -63,7 +63,7 @@ main(int argc, char **argv)
bc_slist_t *rules = NULL;
bool verbose = false;
- bool production = false;
+ bool dev = false;
char *blogcfile = NULL;
bm_ctx_t *ctx = NULL;
@@ -76,6 +76,9 @@ main(int argc, char **argv)
case 'v':
printf("%s\n", PACKAGE_STRING);
goto cleanup;
+ case 'D':
+ dev = true;
+ break;
case 'V':
verbose = true;
break;
@@ -85,9 +88,6 @@ 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.
@@ -117,7 +117,7 @@ main(int argc, char **argv)
rv = 3;
goto cleanup;
}
- ctx->production = production;
+ ctx->dev = dev;
ctx->verbose = verbose;
rv = bm_rule_executor(ctx, rules);
diff --git a/tests/blogc-make/check_exec.c b/tests/blogc-make/check_exec.c
index 081aa25..1dac6b2 100644
--- a/tests/blogc-make/check_exec.c
+++ b/tests/blogc-make/check_exec.c
@@ -107,7 +107,7 @@ test_build_blogc_cmd_with_settings(void **state)
static void
-test_build_blogc_cmd_with_settings_and_production(void **state)
+test_build_blogc_cmd_with_settings_and_dev(void **state)
{
bm_settings_t *settings = bc_malloc(sizeof(bm_settings_t));
settings->settings = bc_trie_new(free);
@@ -122,22 +122,21 @@ test_build_blogc_cmd_with_settings_and_production(void **state)
"main.tmpl", "foo.html", true, true);
assert_string_equal(rv,
"LC_ALL='en_US.utf8' blogc -D FOO='BAR' -D BAR='BAZ' -D LOL='HEHE' "
- "-D MAKE_ENV_PRODUCTION=1 -D MAKE_ENV='production' -l -t 'main.tmpl' "
- "-o 'foo.html' -i");
+ "-D MAKE_ENV_DEV=1 -D MAKE_ENV='dev' -l -t 'main.tmpl' -o 'foo.html' -i");
free(rv);
rv = bm_exec_build_blogc_cmd("blogc", settings, variables, false, NULL, NULL,
true, false);
assert_string_equal(rv,
"LC_ALL='en_US.utf8' blogc -D FOO='BAR' -D BAR='BAZ' -D LOL='HEHE' "
- "-D MAKE_ENV_PRODUCTION=1 -D MAKE_ENV='production'");
+ "-D MAKE_ENV_DEV=1 -D MAKE_ENV='dev'");
free(rv);
rv = bm_exec_build_blogc_cmd("blogc", settings, NULL, false, NULL, NULL,
true, false);
assert_string_equal(rv,
"LC_ALL='en_US.utf8' blogc -D FOO='BAR' -D BAR='BAZ' "
- "-D MAKE_ENV_PRODUCTION=1 -D MAKE_ENV='production'");
+ "-D MAKE_ENV_DEV=1 -D MAKE_ENV='dev'");
free(rv);
bc_trie_free(variables);
@@ -181,7 +180,7 @@ main(void)
const UnitTest tests[] = {
unit_test(test_find_binary),
unit_test(test_build_blogc_cmd_with_settings),
- unit_test(test_build_blogc_cmd_with_settings_and_production),
+ unit_test(test_build_blogc_cmd_with_settings_and_dev),
unit_test(test_build_blogc_cmd_without_settings),
};
return run_tests(tests);