From 98c3052c933d988aa9e56aa433c433e7274164db Mon Sep 17 00:00:00 2001 From: OpportunityLiu Date: Mon, 22 Jul 2019 11:02:35 +0800 Subject: add level to error --- .gitignore | 1 + xmake/core/base/os.lua | 22 +++++++++++++++++----- xmake/core/sandbox/modules/utils.lua | 8 ++++---- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 36a3f457c..81f2662bb 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,7 @@ winenv/ *.exe *.zip *.run +/xmake/*.md # Makefile generation /core/xmake.config.h diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua index 2f17ebc27..b8d767efd 100644 --- a/xmake/core/base/os.lua +++ b/xmake/core/base/os.lua @@ -706,7 +706,10 @@ end -- -- the parent function will capture it if we uses pcall or xpcall -- -function os.raise(msg, ...) +function os.raiselevel(level, msg, ...) + + -- set level of this function + level = level + 1 -- flush log log:flush() @@ -716,19 +719,28 @@ function os.raise(msg, ...) -- raise it if type(msg) == "string" then - error(string.tryformat(msg, ...)) + error(string.tryformat(msg, ...), level) elseif type(msg) == "table" then local errobjstr, errors = string.serialize(msg, true) if errobjstr then - error("[@encode(error)]: " .. errobjstr) + error("[@encode(error)]: " .. errobjstr, level) else - error(errors) + error(errors, level) end else - error() + error(tostring(msg), level) end end +-- raise an exception and abort the current script +-- +-- the parent function will capture it if we uses pcall or xpcall +-- +function os.raise(msg, ...) + -- add return to make it a tail call + return os.raiselevel(1, msg, ...) +end + -- is executable program file? function os.isexec(filepath) diff --git a/xmake/core/sandbox/modules/utils.lua b/xmake/core/sandbox/modules/utils.lua index a81c84ded..f71d2a72b 100644 --- a/xmake/core/sandbox/modules/utils.lua +++ b/xmake/core/sandbox/modules/utils.lua @@ -20,6 +20,7 @@ -- load modules local io = require("base/io") +local os = require("base/os") local utils = require("base/utils") local colors = require("base/colors") local option = require("base/option") @@ -27,7 +28,6 @@ local log = require("base/log") local try = require("sandbox/modules/try") local catch = require("sandbox/modules/catch") local vformat = require("sandbox/modules/vformat") -local raise = require("sandbox/modules/raise") -- define module local sandbox_utils = sandbox_utils or {} @@ -173,13 +173,13 @@ function sandbox_utils.assert(value, format, ...) -- check if not value then if format ~= nil then - raise(format, ...) + os.raiselevel(2, format, ...) else - raise("assertion failed!") + os.raiselevel(2, "assertion failed!") end end - -- return it + -- return it return value end -- cgit v1.3.1 From 74924c6ef483e358cc22adef9a555bcdf3c4ce4d Mon Sep 17 00:00:00 2001 From: OpportunityLiu Date: Mon, 22 Jul 2019 11:52:22 +0800 Subject: fix vsxmake debugger settings --- xmake/plugins/project/vsxmake/vsproj/Xmake.props | 11 +++++++++++ xmake/plugins/project/vsxmake/vsproj/Xmake.targets | 15 ++++----------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/xmake/plugins/project/vsxmake/vsproj/Xmake.props b/xmake/plugins/project/vsxmake/vsproj/Xmake.props index 55fd2bdc5..0b60d77d2 100644 --- a/xmake/plugins/project/vsxmake/vsproj/Xmake.props +++ b/xmake/plugins/project/vsxmake/vsproj/Xmake.props @@ -126,6 +126,17 @@ $(XmakeBuilDir)\.vs\$(TargetName)\$(XmakeArch)\$(XmakeMode)\ + + $(XmakeRunDir) + $(XmakeRunEnvs) +$(LocalDebuggerEnvironment) + true + $(XmakeRunDir) + WindowsRemoteDebugger + $(XmakeRunEnvs) +$(RemoteDebuggerEnvironment) + + $([System.IO.Path]::GetFullPath('$(XmakeRunDirResolved)/')) - - $(XmakeRunDirResolved) - $(XmakeRunEnvs) -$(LocalDebuggerEnvironment) - true - $(XmakeRunDirResolved) - WindowsRemoteDebugger - $(XmakeRunEnvs) -$(RemoteDebuggerEnvironment) - - <_XmakeProjectFlag Condition="'$(XmakeProjectFile)' != ''">-F "$(XmakeProjectFile)" <_XmakeProjectFlag Condition="'$(XmakeProjectFile)' == ''">-P . @@ -150,15 +139,19 @@ MSBuild Properties: XmakeProjectDir: $(XmakeProjectDir) XmakeScriptDir: $(XmakeScriptDir) XmakeBuilDir: $(XmakeBuilDir) + XmakeTargetDir: $(XmakeTargetDir) XmakeConfigDir: $(XmakeConfigDir) XmakeConfigFileDir: $(XmakeConfigFileDir) + XmakeRunDir: $(XmakeRunDir) Xmake Resolved Path: XmakeProgramDir: $(XmakeProgramDirResolved) XmakeProjectDir: $(XmakeProjectDirResolved) XmakeScriptDir: $(XmakeScriptDirResolved) XmakeBuilDir: $(XmakeBuilDirResolved) + XmakeTargetDir: $(XmakeTargetDirResolved) XmakeConfigDir: $(XmakeConfigDirResolved) XmakeConfigFileDir: $(XmakeConfigFileDirResolved) + XmakeRunDir: $(XmakeRunDirResolved) Xmake Flags: XmakeWarning: $(XmakeWarning) XmakeVerbose: $(XmakeVerbose) -- cgit v1.3.1 From c97de7f445976868203f11a95be0c75fde42be28 Mon Sep 17 00:00:00 2001 From: OpportunityLiu Date: Mon, 22 Jul 2019 12:13:52 +0800 Subject: read as default mode --- core/src/xmake/io/open.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/core/src/xmake/io/open.c b/core/src/xmake/io/open.c index e77571230..4ca820371 100644 --- a/core/src/xmake/io/open.c +++ b/core/src/xmake/io/open.c @@ -180,13 +180,12 @@ tb_int_t xm_io_open(lua_State* lua) tb_assert_and_check_return_val(path && modestr, 0); // get file mode value - tb_size_t mode = TB_FILE_MODE_RW; + tb_size_t mode; switch (modestr[0]) { - case 'w': mode |= TB_FILE_MODE_CREAT | TB_FILE_MODE_TRUNC; break; - case 'a': mode |= TB_FILE_MODE_APPEND | TB_FILE_MODE_CREAT; break; - case 'r': mode = TB_FILE_MODE_RO; break; - default: break; + case 'w': mode = TB_FILE_MODE_RW | TB_FILE_MODE_CREAT | TB_FILE_MODE_TRUNC; break; + case 'a': mode = TB_FILE_MODE_RW | TB_FILE_MODE_APPEND | TB_FILE_MODE_CREAT; break; + case 'r': default: mode = TB_FILE_MODE_RO; break; } // get file encoding -- cgit v1.3.1 From a2a8f0177d20c7855e598a6ad47a871738bcf904 Mon Sep 17 00:00:00 2001 From: OpportunityLiu Date: Mon, 22 Jul 2019 12:20:12 +0800 Subject: fix vsxmake env --- xmake/plugins/project/vsxmake/vsproj/Xmake.targets | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/xmake/plugins/project/vsxmake/vsproj/Xmake.targets b/xmake/plugins/project/vsxmake/vsproj/Xmake.targets index 781a0468f..9276756a5 100644 --- a/xmake/plugins/project/vsxmake/vsproj/Xmake.targets +++ b/xmake/plugins/project/vsxmake/vsproj/Xmake.targets @@ -68,6 +68,7 @@ <_XmakeExecutable>"$([System.IO.Path]::GetFullPath('$(XmakeProgramDirResolved)xmake.exe'))" <_XmakeEnv> chcp 65001 > NUL + pushd $(XmakeProjectDirResolved) set XMAKE_CONFIGDIR=$(XmakeConfigDirResolved.TrimEnd('/\'.ToCharArray())) set XMAKE_PROGRAM_DIR=$(XmakeProgramDirResolved.TrimEnd('/\'.ToCharArray())) @@ -87,17 +88,17 @@ - - - @@ -110,12 +111,12 @@ --files="$(FileList)" - - -- cgit v1.3.1 From 145358ba831e7a90f275118a0556787754fe2fa6 Mon Sep 17 00:00:00 2001 From: OpportunityLiu Date: Mon, 22 Jul 2019 13:47:29 +0800 Subject: revert --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 81f2662bb..36a3f457c 100644 --- a/.gitignore +++ b/.gitignore @@ -19,7 +19,6 @@ winenv/ *.exe *.zip *.run -/xmake/*.md # Makefile generation /core/xmake.config.h -- cgit v1.3.1