diff options
| author | ruki <[email protected]> | 2023-05-12 23:03:28 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-05-12 12:21:33 +0800 |
| commit | e3a661a2eafc2fc32bd77125978dd64c6b7b9a1f (patch) | |
| tree | 55fe9d36b3f83eb5edc69537b23e6e76a12b52cb | |
| parent | 643719b7e52a0a2bf458853d2b0381e416bdf433 (diff) | |
improve tools.xmake to install package #3720
| -rw-r--r-- | xmake/modules/package/tools/xmake.lua | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/xmake/modules/package/tools/xmake.lua b/xmake/modules/package/tools/xmake.lua index 4ad87605b..eaf30c941 100644 --- a/xmake/modules/package/tools/xmake.lua +++ b/xmake/modules/package/tools/xmake.lua @@ -154,13 +154,26 @@ function _get_configs(package, configs, opt) return configs end +-- maybe in project? +-- @see https://github.com/xmake-io/xmake/issues/3720 +function _maybe_in_project(package) + local dir = package:sourcedir() or package:cachedir() + local parentdir = path.directory(dir) + while parentdir and os.isdir(parentdir) do + if os.isfile(path.join(parentdir, "xmake.lua")) then + print("parentdir", parentdir) + return true + end + parentdir = path.directory(parentdir) + end +end + -- set some builtin global options from the parent xmake function _set_builtin_argv(package, argv) -- if the package cache directory is modified, -- we need to force the project directory to be specified to avoid interference by the upper level xmake.lua. -- and we also need to put `-P` in the first argument to avoid option.parse() parsing errors - local maybe_in_project = os.getenv("XMAKE_PKG_CACHEDIR") or global.get("pkg_cachedir") or package:sourcedir() - if maybe_in_project then + if _maybe_in_project(package) then table.insert(argv, "-P") table.insert(argv, os.curdir()) end |
