From 09317b8b9ba669d5d957455e1a658645efbbc2cb Mon Sep 17 00:00:00 2001 From: ruki Date: Tue, 5 Jul 2016 17:40:50 +0800 Subject: modify install script for windows --- core/src/xmake/machine.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'core/src') diff --git a/core/src/xmake/machine.c b/core/src/xmake/machine.c index 597765209..e7a032aa0 100755 --- a/core/src/xmake/machine.c +++ b/core/src/xmake/machine.c @@ -32,6 +32,9 @@ */ #include "xmake.h" #include "luajit/luajit.h" +#ifdef TB_CONFIG_OS_WINDOWS +# include +#endif /* ////////////////////////////////////////////////////////////////////////////////////// * types @@ -180,6 +183,24 @@ static tb_bool_t xm_machine_main_get_program_directory(xm_machine_impl_t* impl, tb_bool_t ok = tb_false; do { +#ifdef TB_CONFIG_OS_WINDOWS + // get the program directory + tb_size_t size = GetModuleFileName(tb_null, path, maxn); + tb_assert_and_check_break(size < maxn); + + // end + path[size] = '\0'; + + // get the directory + while (size-- > 0) + { + if (path[size] == '\\') + { + path[size] = '\0'; + break; + } + } +#else // get it from the environment variable tb_char_t data[TB_PATH_MAXN] = {0}; if (!tb_environment_first("XMAKE_PROGRAM_DIR", data, sizeof(data))) @@ -188,10 +209,10 @@ static tb_bool_t xm_machine_main_get_program_directory(xm_machine_impl_t* impl, tb_printf("error: please set XMAKE_PROGRAM_DIR first!\n"); break; } - + // get the full path if (!tb_path_absolute(data, path, maxn)) break; - +#endif // trace tb_trace_d("program: %s", path); -- cgit v1.3.1