summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2023-02-08 22:55:20 +0800
committerruki <[email protected]>2023-02-08 22:55:20 +0800
commitf38629bf5c5748719a02fae9afebd7ce83a64d0a (patch)
tree305136458ff6a803889c2900f284cd528ea6e75a
parent9d8d0b6b038d831be197dea90271ae4bd1b7ea55 (diff)
add external workdir
-rw-r--r--xmake/actions/config/main.lua13
-rw-r--r--xmake/core/main.lua4
-rw-r--r--xmake/core/project/config.lua7
3 files changed, 17 insertions, 7 deletions
diff --git a/xmake/actions/config/main.lua b/xmake/actions/config/main.lua
index 110c50c62..1a392d33f 100644
--- a/xmake/actions/config/main.lua
+++ b/xmake/actions/config/main.lua
@@ -485,6 +485,19 @@ force to build in current directory via run `xmake -P .`]], os.projectdir())
_export_configs()
end
+ -- we need save it and enable external working mode
+ -- if we configure the given project directory
+ --
+ -- @see https://github.com/xmake-io/xmake/issues/3342
+ --
+ local projectdir = option.get("project")
+ local projectfile = option.get("file")
+ if projectdir or projectfile then
+ localcache.set("project", "projectdir", projectdir)
+ localcache.set("project", "projectfile", projectfile)
+ localcache.save("project")
+ end
+
-- save options and config cache
localcache.set("config", "recheck", false)
localcache.set("config", "mtimes", project.mtimes())
diff --git a/xmake/core/main.lua b/xmake/core/main.lua
index 4e061f45d..e6c3fbfd5 100644
--- a/xmake/core/main.lua
+++ b/xmake/core/main.lua
@@ -139,7 +139,7 @@ function main._init()
local opt_projectdir, opt_projectfile = options.project, options.file
-- init the project directory
- local projectdir = opt_projectdir or xmake._PROJECT_DIR
+ local projectdir = opt_projectdir or localcache.get("project", "projectdir") or xmake._PROJECT_DIR
if projectdir and not path.is_absolute(projectdir) then
projectdir = path.absolute(projectdir)
elseif projectdir then
@@ -149,7 +149,7 @@ function main._init()
assert(projectdir)
-- init the xmake.lua file path
- local projectfile = opt_projectfile or xmake._PROJECT_FILE
+ local projectfile = opt_projectfile or localcache.get("project", "projectfile") or xmake._PROJECT_FILE
if projectfile and not path.is_absolute(projectfile) then
projectfile = path.absolute(projectfile, projectdir)
end
diff --git a/xmake/core/project/config.lua b/xmake/core/project/config.lua
index bf68e93a8..3f9f02341 100644
--- a/xmake/core/project/config.lua
+++ b/xmake/core/project/config.lua
@@ -129,12 +129,9 @@ end
function config.directory()
if config._DIRECTORY == nil then
local rootdir = os.getenv("XMAKE_CONFIGDIR")
- if not rootdir and os.isdir(path.join(os.workingdir(), ".xmake")) then
- -- we switch to independent working directory @see https://github.com/xmake-io/xmake/issues/820
- rootdir = os.workingdir()
- end
if not rootdir then
- rootdir = os.projectdir()
+ -- @see https://github.com/xmake-io/xmake/issues/3342
+ rootdir = os.workingdir()
end
config._DIRECTORY = path.join(rootdir, "." .. xmake._NAME, os.host(), os.arch())
end