summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-09-22 15:21:46 +0800
committerGitHub <[email protected]>2022-09-22 15:21:46 +0800
commit95744e90280781b105de7846367156fb61d4f318 (patch)
tree5029ef2a829aebae73da01e702d1139e11e5fc61
parentc1b7687cf86b5af65cbc7bff51979e8868d31f74 (diff)
parente41a407b7a412679d31c5ecf59771cbc405ea197 (diff)
Merge pull request #2856 from xmake-io/debug
Improve to debug package using the debug source directory
-rw-r--r--CHANGELOG.md2
-rw-r--r--xmake/actions/require/xmake.lua1
-rw-r--r--xmake/modules/private/action/require/impl/actions/download.lua8
-rw-r--r--xmake/modules/private/xrepo/action/install.lua15
4 files changed, 23 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 85ffc7e1f..321961be4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,6 +9,7 @@
* [#2810](https://github.com/xmake-io/xmake/pull/2810): Support os.execv to run shell script file
* [#2817](https://github.com/xmake-io/xmake/pull/2817): Improve rule to support dependence order
* [#2824](https://github.com/xmake-io/xmake/pull/2824): Pass cross-file to meson.install and trybuild
+* [#2856](https://github.com/xmake-io/xmake/pull/2856): Improve to debug package using the debug source directory
### Changes
@@ -1401,6 +1402,7 @@
* [#2810](https://github.com/xmake-io/xmake/pull/2810): 支持 os.execv 去执行 shell 脚本文件
* [#2817](https://github.com/xmake-io/xmake/pull/2817): 改进规则支持依赖顺序执行
* [#2824](https://github.com/xmake-io/xmake/pull/2824): 传递 cross-file 交叉编译环境给 meson.install 和 trybuild
+* [#2856](https://github.com/xmake-io/xmake/pull/2856): xrepo 支持从当前指定源码目录调试程序
### 改进
diff --git a/xmake/actions/require/xmake.lua b/xmake/actions/require/xmake.lua
index 3ffd17fe3..150bba51f 100644
--- a/xmake/actions/require/xmake.lua
+++ b/xmake/actions/require/xmake.lua
@@ -91,6 +91,7 @@ task("require")
" $ xmake require --import --packagedir=packagesdir zlib",
" $ xmake require --import --extra=\"{debug=true}\" tbox" }
, {nil, "packagedir", "kv", "packages","Set the packages directory for exporting and importing." }
+ , {nil, "debugdir", "kv", nil, "Set the source directory of the current package for debugging." }
, {nil, "extra", "kv", nil, "Set the extra info of packages." }
, { }
, {nil, "requires", "vs", nil, "The package requires.",
diff --git a/xmake/modules/private/action/require/impl/actions/download.lua b/xmake/modules/private/action/require/impl/actions/download.lua
index 7d0666c4e..a70b712fc 100644
--- a/xmake/modules/private/action/require/impl/actions/download.lua
+++ b/xmake/modules/private/action/require/impl/actions/download.lua
@@ -258,6 +258,14 @@ function main(package)
{
function ()
+ -- use debug source directory directly?
+ local debugdir = package:is_toplevel() and option.get("debugdir") or nil
+ if debugdir then
+ package:set("sourcedir", debugdir)
+ tty.erase_line_to_start().cr()
+ return true
+ end
+
-- download package
local sourcedir = "source"
local script = package:script("download")
diff --git a/xmake/modules/private/xrepo/action/install.lua b/xmake/modules/private/xrepo/action/install.lua
index bd77e7b00..19d594178 100644
--- a/xmake/modules/private/xrepo/action/install.lua
+++ b/xmake/modules/private/xrepo/action/install.lua
@@ -65,6 +65,8 @@ function menu_options()
{nil, "xcode_sdkver", "kv", nil, "The SDK Version for Xcode" },
{nil, "target_minver", "kv", nil, "The Target Minimal Version" },
{nil, "appledev", "kv", nil, "The Apple Device Type" },
+ {category = "Debug Configuration" },
+ {'d', "debugdir", "kv", nil, "The source directory of the current package for debugging. It will enable --force/--shallow by default."},
{category = "Other Configuration" },
{nil, "force", "k", nil, "Force to reinstall all package dependencies."},
{nil, "shallow", "k", nil, "Does not install dependent packages."},
@@ -124,6 +126,7 @@ function _install_packages(packages)
if packagefile then
subdir = subdir .. "-" .. hash.uuid(packagefile):split('-')[1]
end
+ local origindir = os.curdir()
local workdir = path.join(os.tmpdir(), "xrepo", subdir)
if not os.isdir(workdir) then
os.mkdir(workdir)
@@ -228,13 +231,19 @@ function _install_packages(packages)
if option.get("linkjobs") then
table.insert(require_argv, "--linkjobs=" .. option.get("linkjobs"))
end
- if option.get("force") then
+ local is_debug = false
+ local sourcedir = option.get("debugdir")
+ if sourcedir then
+ is_debug = true
+ table.insert(require_argv, "--debugdir=" .. path.absolute(sourcedir, origindir))
+ end
+ if option.get("force") or is_debug then
table.insert(require_argv, "--force")
end
- if option.get("shallow") then
+ if option.get("shallow") or is_debug then
table.insert(require_argv, "--shallow")
end
- if option.get("build") then
+ if option.get("build") or is_debug then
table.insert(require_argv, "--build")
end
local extra = {system = false}