diff options
| author | ruki <[email protected]> | 2023-02-08 23:04:27 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-02-08 23:04:27 +0800 |
| commit | 13c187a5bf48fa0470e153ae863c2c2931f5a576 (patch) | |
| tree | c57f4a10a28114641ec14d9d6136fb5544b19563 /xmake/core/project/config.lua | |
| parent | f38629bf5c5748719a02fae9afebd7ce83a64d0a (diff) | |
improve to load projectdir
Diffstat (limited to 'xmake/core/project/config.lua')
| -rw-r--r-- | xmake/core/project/config.lua | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/xmake/core/project/config.lua b/xmake/core/project/config.lua index 3f9f02341..1220fbc79 100644 --- a/xmake/core/project/config.lua +++ b/xmake/core/project/config.lua @@ -96,8 +96,14 @@ function config.buildir(opt) -- get the absolute path first opt = opt or {} local rootdir - if os.isdir(path.join(os.workingdir(), ".xmake")) then - -- we switch to independent working directory @see https://github.com/xmake-io/xmake/issues/820 + -- we always switch to independent working directory if `-P/-F` is set + -- @see https://github.com/xmake-io/xmake/issues/3342 + if not rootdir and (option.get("project") or option.get("projectfile")) then + rootdir = os.workingdir() + end + -- we switch to independent working directory if .xmake exists + -- @see https://github.com/xmake-io/xmake/issues/820 + if not rootdir and os.isdir(path.join(os.workingdir(), "." .. xmake._NAME)) then rootdir = os.workingdir() end if not rootdir then @@ -129,10 +135,19 @@ end function config.directory() if config._DIRECTORY == nil then local rootdir = os.getenv("XMAKE_CONFIGDIR") - if not rootdir then - -- @see https://github.com/xmake-io/xmake/issues/3342 + -- we always switch to independent working directory if `-P/-F` is set + -- @see https://github.com/xmake-io/xmake/issues/3342 + if not rootdir and (option.get("project") or option.get("projectfile")) then rootdir = os.workingdir() end + -- we switch to independent working directory if .xmake exists + -- @see https://github.com/xmake-io/xmake/issues/820 + if not rootdir and os.isdir(path.join(os.workingdir(), "." .. xmake._NAME)) then + rootdir = os.workingdir() + end + if not rootdir then + rootdir = os.projectdir() + end config._DIRECTORY = path.join(rootdir, "." .. xmake._NAME, os.host(), os.arch()) end return config._DIRECTORY |
