summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOpportunity <[email protected]>2020-06-30 12:08:46 +0800
committerOpportunity <[email protected]>2020-06-30 12:08:46 +0800
commit6dd3577da0219a388ea2b3331cb9956c1e915dcd (patch)
tree5ea901dd29d0610f0fafe0f2c3bf6b85ff64dd4d
parent58c8e709cc4677ec6fb5fdfcec1958fab6743709 (diff)
set defaults for buildir
-rw-r--r--xmake/core/project/config.lua35
-rw-r--r--xmake/core/project/target.lua19
2 files changed, 22 insertions, 32 deletions
diff --git a/xmake/core/project/config.lua b/xmake/core/project/config.lua
index 837e45faf..90e4656a8 100644
--- a/xmake/core/project/config.lua
+++ b/xmake/core/project/config.lua
@@ -122,28 +122,27 @@ function config.options()
return configs
end
--- get the buildir
+-- get the buildir
function config.buildir()
-
- -- get it
- local buildir = config.get("buildir")
- if buildir then
- -- get the absolute path first
- if not path.is_absolute(buildir) then
- 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
- rootdir = os.workingdir()
- else
- rootdir = os.projectdir()
- end
- buildir = path.absolute(buildir, rootdir)
- end
+ -- get it
+ local buildir = config.get("buildir") or "build"
- -- adjust path for the current directory
- buildir = path.relative(buildir, os.curdir())
+ -- get the absolute path first
+ if not path.is_absolute(buildir) then
+ 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
+ rootdir = os.workingdir()
+ else
+ rootdir = os.projectdir()
+ end
+ buildir = path.absolute(buildir, rootdir)
end
+
+ -- adjust path for the current directory
+ buildir = path.relative(buildir, os.curdir())
+
return buildir
end
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua
index d7f44c4af..fc73acd25 100644
--- a/xmake/core/project/target.lua
+++ b/xmake/core/project/target.lua
@@ -875,17 +875,8 @@ end
-- get the target directory
function _instance:targetdir()
- -- the target directory
- local targetdir = self:get("targetdir")
- if not targetdir then
-
- -- get build directory
- targetdir = config.buildir()
- end
-
- if not targetdir then
- return nil
- end
+ -- the target directory or build directory
+ local targetdir = self:get("targetdir") or config.buildir()
-- append plat sub-directory
local plat = self:plat()
@@ -909,7 +900,7 @@ function _instance:targetdir()
return targetdir
end
--- get the target file
+-- get the target file
function _instance:targetfile()
-- the target directory
@@ -920,7 +911,7 @@ function _instance:targetfile()
-- only compile objects? no target file
if targetkind == "object" then
- return
+ return
end
-- make the target file name and attempt to use the format of linker first
@@ -935,7 +926,7 @@ end
function _instance:symbolfile()
-- the target directory
- local targetdir = self:targetdir() or config.buildir()
+ local targetdir = self:targetdir()
assert(targetdir and type(targetdir) == "string")
-- the symbol file name