diff --git a/drivers/lang/c/src/main.c b/drivers/lang/c/src/main.c index 3f27738..8b4f034 100644 --- a/drivers/lang/c/src/main.c +++ b/drivers/lang/c/src/main.c @@ -95,8 +95,8 @@ static const char *cc( bake_src_lang lang) { - const char *default_cxx = NULL, *cxx = ut_getenv("CXX"); - const char *default_cc = NULL, *cc = ut_getenv("CC"); + const char *cxx = ut_getenv("CXX"); + const char *cc = ut_getenv("CC"); if (cc && !strlen(cc)) cc = NULL; if (cxx && !strlen(cxx)) cxx = NULL; diff --git a/src/main.c b/src/main.c index 0f50cc5..bc48408 100644 --- a/src/main.c +++ b/src/main.c @@ -44,6 +44,10 @@ bool load_bundles = false; /* Compile to target other than current */ const char *target = NULL; +/* Override CC/CXX */ +const char *env_cc = NULL; +const char *env_cxx = NULL; + /* Override configuration */ bool strict = false; bool optimize = false; @@ -112,6 +116,8 @@ void bake_usage(void) printf(" --cfg Specify configuration id\n"); printf(" --env Specify environment id\n"); printf(" --target Specify compilation target\n"); + printf(" --cc Override CC environment variable\n"); + printf(" --cxx Override CXX environment variable\n"); printf(" --strict Manually enable strict compiler options\n"); printf(" --optimize Manually enable compiler optimizations\n"); printf(" --loop-test Manually enable vectorization analysis\n"); @@ -306,6 +312,8 @@ int bake_parse_args( ARG(0, "env", env = argv[i + 1]; i ++); ARG(0, "cfg", cfg = argv[i + 1]; i ++); ARG(0, "target", target = argv[i + 1]; i ++); + ARG(0, "cc", env_cc = argv[i + 1]; i ++); + ARG(0, "cxx", env_cxx = argv[i + 1]; i ++); ARG(0, "strict", strict = true ); ARG(0, "profile-build", profile_build = true ); ARG(0, "optimize", optimize = true ); @@ -1339,7 +1347,6 @@ void bake_message( } int main(int argc, const char *argv[]) { - if (ut_getenv("BAKE_ENVIRONMENT")) { env = ut_getenv("BAKE_ENVIRONMENT"); } @@ -1378,6 +1385,19 @@ int main(int argc, const char *argv[]) { ut_log_pop(); } + if (env_cc) { + ut_setenv("CC", env_cc); + if (!strcmp(env_cc, "gcc")) { + ut_setenv("CXX", "g++"); + } else if (!strcmp(env_cc, "clang")) { + ut_setenv("CXX", "clang++"); + } + } + + if (env_cxx) { + ut_setenv("CXX", env_cc); + } + ut_log_push("init"); /* Initialize package loader for default home, arch, os and config */