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 +++++++++++++++++++++++-- install.bat | 13 +------------ xmake/plugins/macro/macros/package.lua | 2 +- 3 files changed, 25 insertions(+), 15 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 +#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); diff --git a/install.bat b/install.bat index f1cb3e69a..38b61548a 100644 --- a/install.bat +++ b/install.bat @@ -42,23 +42,12 @@ cd .. rem install the xmake core file echo installing xmake-core... set xmake_core=core\bin\demo.pkg\bin\msvc\x86\demo.exe -set xmake_core_install=%xmake_dir_install%\xmake_core.exe +set xmake_core_install=%xmake_dir_install%\xmake.exe copy /Y "%xmake_core%" "%xmake_core_install%" > install.log rem install the xmake directory xcopy /S /Q /Y "xmake" "%xmake_dir_install%" >> install.log -rem make the xmake loader -echo installing xmake-loader... -set xmake_loader=%temp%\xmake_loader -echo @echo off > %xmake_loader% -echo set XMAKE_PROGRAM_DIR=%xmake_dir_install%>> %xmake_loader% -echo "%xmake_core_install%" %%* >> %xmake_loader% - -rem install the xmake loader -set xmake_loader_install=%xmake_dir_install%\xmake.bat -copy /Y "%xmake_loader%" "%xmake_loader_install%" >> install.log - rem set global PATH=%xmake_dir_install% echo register xmake... echo %path% | findstr /i /C:"%xmake_dir_install%" >> nul && (goto set_path_ok) diff --git a/xmake/plugins/macro/macros/package.lua b/xmake/plugins/macro/macros/package.lua index a6edaa5aa..04947c6d8 100755 --- a/xmake/plugins/macro/macros/package.lua +++ b/xmake/plugins/macro/macros/package.lua @@ -55,7 +55,7 @@ function main(argv) for _, arch in ipairs(platform.archs(plat)) do -- config it - os.exec("xmake f -p %s -a %s %s", plat, arch, args.config or "") + os.exec("xmake f -p %s -a %s %s -c", plat, arch, args.config or "") -- package it if args.outputdir then -- cgit v1.3.1