summaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
authorruki <[email protected]>2016-07-05 17:40:50 +0800
committerruki <[email protected]>2016-07-05 17:41:31 +0800
commit09317b8b9ba669d5d957455e1a658645efbbc2cb (patch)
treef935a2a3341b98b1e7fefae9116892262f2c9df7 /core/src
parent7af1dcdeed9e2ecbfc0ba0f4c34e52c99e1cdd89 (diff)
modify install script for windows
Diffstat (limited to 'core/src')
-rwxr-xr-xcore/src/xmake/machine.c25
1 files changed, 23 insertions, 2 deletions
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 <windows.h>
+#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);