summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2019-09-21 00:49:28 +0800
committerruki <[email protected]>2019-09-20 22:56:48 +0800
commit8e57109a69c4c19be728e7797124f8ff5a4a6e35 (patch)
treec09f0509c7fa941444884e1a0dd628d6b9afdd98
parente037a04e699bd67832024fdd6729e0ea835784e2 (diff)
uses devenv to load and debug win program
-rw-r--r--xmake/modules/detect/tools/find_devenv.lua61
-rw-r--r--xmake/modules/detect/tools/find_rc.lua5
-rw-r--r--xmake/modules/detect/tools/find_vsjitdebugger.lua2
-rw-r--r--xmake/modules/devel/debugger/run.lua23
4 files changed, 90 insertions, 1 deletions
diff --git a/xmake/modules/detect/tools/find_devenv.lua b/xmake/modules/detect/tools/find_devenv.lua
new file mode 100644
index 000000000..ce633e649
--- /dev/null
+++ b/xmake/modules/detect/tools/find_devenv.lua
@@ -0,0 +1,61 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015 - 2019, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file find_devenv.lua
+--
+
+-- imports
+import("core.project.config")
+
+-- find devenv
+--
+-- @param opt the argument options, e.g. {version = true}
+--
+-- @return program, version
+--
+-- @code
+--
+-- local devenv = find_devenv()
+--
+-- @endcode
+--
+function main(opt)
+
+ -- not on windows?
+ if not is_host("windows") then
+ return
+ end
+
+ -- disable to check version
+ opt = opt or {}
+ opt.command = function () end
+
+ -- find it from %DevEnvdir%
+ -- e.g. C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE
+ --
+ local program = nil
+ local vcvarsall = config.get("__vcvarsall")
+ if vcvarsall then
+ for _, vsvars in pairs(vcvarsall) do
+ if vsvars.DevEnvdir and os.isexec(path.join(vsvars.DevEnvdir, "devenv.exe")) then
+ program = path.join(vsvars.DevEnvdir, "devenv.exe")
+ end
+ end
+ end
+ return program
+end
+
diff --git a/xmake/modules/detect/tools/find_rc.lua b/xmake/modules/detect/tools/find_rc.lua
index cadf9fc6e..4157bcca4 100644
--- a/xmake/modules/detect/tools/find_rc.lua
+++ b/xmake/modules/detect/tools/find_rc.lua
@@ -37,6 +37,11 @@ import("lib.detect.find_programver")
--
function main(opt)
+ -- not on windows?
+ if not is_host("windows") then
+ return
+ end
+
-- init options
opt = opt or {}
opt.check = opt.check or "-?"
diff --git a/xmake/modules/detect/tools/find_vsjitdebugger.lua b/xmake/modules/detect/tools/find_vsjitdebugger.lua
index 7f5c647af..b8fb6245f 100644
--- a/xmake/modules/detect/tools/find_vsjitdebugger.lua
+++ b/xmake/modules/detect/tools/find_vsjitdebugger.lua
@@ -39,7 +39,7 @@ import("lib.detect.find_programver")
function main(opt)
-- not on windows?
- if os.host() ~= "windows" then
+ if not is_host("windows") then
return
end
diff --git a/xmake/modules/devel/debugger/run.lua b/xmake/modules/devel/debugger/run.lua
index 2c08f1f9a..4369b3f5a 100644
--- a/xmake/modules/devel/debugger/run.lua
+++ b/xmake/modules/devel/debugger/run.lua
@@ -28,6 +28,7 @@ import("detect.tools.find_lldb")
import("detect.tools.find_windbg")
import("detect.tools.find_x64dbg")
import("detect.tools.find_ollydbg")
+import("detect.tools.find_devenv")
import("detect.tools.find_vsjitdebugger")
-- run gdb
@@ -198,6 +199,27 @@ function _run_vsjitdebugger(program, argv)
return true
end
+-- run devenv
+function _run_devenv(program, argv)
+
+ -- find devenv
+ local devenv = find_devenv({program = config.get("debugger")})
+ if not devenv then
+ return false
+ end
+
+ -- patch arguments
+ argv = argv or {}
+ table.insert(argv, 1, "/DebugExe")
+ table.insert(argv, 2, program)
+
+ -- run it
+ os.execv(devenv, argv)
+
+ -- ok
+ return true
+end
+
-- run program with debugger
--
-- @param program the program name
@@ -229,6 +251,7 @@ function main(program, argv)
table.insert(debuggers, 1, {"ollydbg", _run_ollydbg})
table.insert(debuggers, 1, {"x64dbg", _run_x64dbg})
table.insert(debuggers, 1, {"vsjitdebugger", _run_vsjitdebugger})
+ table.insert(debuggers, 1, {"devenv", _run_devenv})
end
-- get debugger from the configure