diff --git a/include/bake/config.h b/include/bake/config.h index 8cf95059..41519e94 100644 --- a/include/bake/config.h +++ b/include/bake/config.h @@ -49,6 +49,7 @@ typedef struct bake_repository { struct bake_config { const char *environment; /* Id of environment in use */ const char *configuration; /* Id of configuration in use */ + const char *architecture; /* Id of architecture in use */ /* Configuration attributes */ bool symbols; /* Enable symbols in binaries */ diff --git a/src/config.c b/src/config.c index 972c9608..13334b68 100644 --- a/src/config.c +++ b/src/config.c @@ -592,6 +592,7 @@ int16_t bake_config_load( /* Precompute bake paths */ cfg_out->configuration = ut_strdup(UT_CONFIG); + cfg_out->architecture = "x86"; cfg_out->platform = UT_PLATFORM_PATH; cfg_out->target = UT_TARGET_PATH; cfg_out->home = UT_HOME_PATH; diff --git a/src/main.c b/src/main.c index 354c21ca..6edeb743 100644 --- a/src/main.c +++ b/src/main.c @@ -30,6 +30,7 @@ ut_tls BAKE_CONFIG_KEY; /* Bake configuration */ const char *cfg = NULL; +const char *arch = NULL; const char *env = "default"; const char *action = "build"; const char *path = "."; @@ -94,6 +95,7 @@ void bake_usage(void) printf(" -v,--version Display version information\n"); printf("\n"); printf(" --cfg Specify configuration id\n"); + printf(" --arch Specify architecture id\n"); printf(" --env Specify environment id\n"); printf(" --strict Manually enable strict compiler options\n"); printf(" --optimize Manually enable compiler optimizations\n"); @@ -284,6 +286,7 @@ int bake_parse_args( bool parsed = false; ARG(0, "env", env = argv[i + 1]; i ++); ARG(0, "cfg", cfg = argv[i + 1]; i ++); + ARG(0, "arch", arch = argv[i + 1]; i ++); ARG(0, "strict", strict = true;); ARG(0, "optimize", optimize = true; i ++); @@ -1340,7 +1343,7 @@ int main(int argc, const char *argv[]) { ut_log_push("init"); /* Initialize package loader for default home, arch, os and config */ - ut_load_init(NULL, NULL, NULL, cfg); + ut_load_init(NULL, arch, NULL, cfg); /* If artefact is manually specified, translate to platform specific name */ if (artefact) { @@ -1363,6 +1366,7 @@ int main(int argc, const char *argv[]) { bake_config config = { .configuration = UT_CONFIG, .environment = env, + .architecture = arch, .symbols = true, .debug = true, .optimizations = false, diff --git a/src/setup.c b/src/setup.c index 883f982f..c386e1a6 100644 --- a/src/setup.c +++ b/src/setup.c @@ -113,7 +113,7 @@ int16_t bake_create_upgrade_script(void) } /* Create bake script for Windows */ -int16_t bake_create_script(bool local) +int16_t bake_create_script(bool local, const char* architecture) { char *script_path = ut_envparse(BAKE_SCRIPT); if (!script_path) { @@ -121,7 +121,7 @@ int16_t bake_create_script(bool local) goto error; } - char *vc_shell_cmd = ut_get_vc_shell_cmd(); + char *vc_shell_cmd = ut_get_vc_shell_cmd(architecture); FILE *f = fopen(script_path, "wb"); if (!f) { @@ -216,7 +216,7 @@ int16_t bake_create_upgrade_script(void) } /* Install script to global location that invokes local bake executable */ -int16_t bake_create_script(bool local) +int16_t bake_create_script(bool local, const char* architecture) { if (local) { return 0; @@ -277,6 +277,7 @@ int16_t bake_create_script(bool local) /* Utility function to bootstrap a bake project while bake is installing */ int16_t bake_build_make_project( + bake_config *config, const char *path, const char *id, const char *artefact) @@ -314,8 +315,7 @@ int16_t bake_build_make_project( bake_message(UT_OK, "done", "build '%s'", id); /* Create the bake bin path (makefiles copy binary to project root) */ - char *bin_path = ut_asprintf( - "%s"UT_OS_PS"bin"UT_OS_PS"%s-debug", path, UT_PLATFORM_STRING); + char *bin_path = ut_asprintf("%s"UT_OS_PS"bin"UT_OS_PS"%s-%s", path, UT_PLATFORM_STRING, config->configuration); ut_try(ut_mkdir(bin_path), "failed to create bin path for %s", id); /* Move binary from project root to bake bin path */ @@ -407,7 +407,7 @@ int16_t bake_setup( /* Create the global bake script, which allows for invoking bake without * first exporting the environment */ - ut_try( bake_create_script(local), + ut_try( bake_create_script(local, config->architecture), "failed to create global bake script, rerun setup with --local"); /* Copy bake executable to bake environment in user working directory */ @@ -426,13 +426,13 @@ int16_t bake_setup( bake_message(UT_OK, "done", "install bake include files"); /* Build bake util */ - ut_try( bake_build_make_project("util", "bake.util", "bake_util"), NULL); + ut_try( bake_build_make_project(config, "util", "bake.util", "bake_util"), NULL); /* Build the C and C++ drivers */ - ut_try( bake_build_make_project("drivers"UT_OS_PS"lang"UT_OS_PS"c", + ut_try( bake_build_make_project(config, "drivers"UT_OS_PS"lang"UT_OS_PS"c", "bake.lang.c", "bake_lang_c"), NULL); - ut_try( bake_build_make_project("drivers"UT_OS_PS"lang"UT_OS_PS"cpp", + ut_try( bake_build_make_project(config, "drivers"UT_OS_PS"lang"UT_OS_PS"cpp", "bake.lang.cpp", "bake_lang_cpp"), NULL); /* Build the bake test framework */ diff --git a/util/include/bake-util/win/vs.h b/util/include/bake-util/win/vs.h index f932ac84..81025cab 100755 --- a/util/include/bake-util/win/vs.h +++ b/util/include/bake-util/win/vs.h @@ -33,7 +33,7 @@ extern "C" { UT_EXPORT char * ut_get_vs_dir(); -UT_EXPORT char * ut_get_vc_shell_cmd(); +UT_EXPORT char * ut_get_vc_shell_cmd(const char* architecture); const char* ut_last_win_error_code(DWORD dw); diff --git a/util/src/win/vs.c b/util/src/win/vs.c index 8a72b228..308b03f8 100755 --- a/util/src/win/vs.c +++ b/util/src/win/vs.c @@ -37,14 +37,14 @@ char * ut_get_vs_dir() return vs_path_env; } -char * ut_get_vc_shell_cmd() +char * ut_get_vc_shell_cmd(const char* architecture) { char * vs_path_env = ut_get_vs_dir(); if (vs_path_env[strlen(vs_path_env) - 1] == '\\') vs_path_env[strlen(vs_path_env) - 1] = '\0'; char * vc_shell = ut_asprintf("%s\\VC\\Auxiliary\\Build\\vcvarsall.bat", vs_path_env); // Check file path exist - char * vc_shell_cmd = ut_asprintf("call \"%s\" x64", vc_shell); + char * vc_shell_cmd = ut_asprintf("call \"%s\" %s", vc_shell, architecture); return vc_shell_cmd; }