Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add build.intermediate_directory policy #5278 #5283

Merged
merged 4 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions xmake/core/project/policy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ function policy.policies()
["check.auto_map_flags"] = {description = "Enable map gcc flags to the current compiler and linker automatically.", default = true, type = "boolean"},
-- We will check the compatibility of target and package licenses
["check.target_package_licenses"] = {description = "Enable check the compatibility of target and package licenses.", default = true, type = "boolean"},
-- Generate intermediate build directory
["build.intermediate_directory"] = {description = "Generate intermediate build directory.", default = true, type = "boolean"},
-- Provide a way to block all targets build that depends on self
["build.fence"] = {description = "Block all targets build that depends on self.", default = false, type = "boolean"},
-- We can compile the source files for each target in parallel
Expand Down
58 changes: 27 additions & 31 deletions xmake/core/project/target.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1374,24 +1374,21 @@ function _instance:objectdir(opt)
objectdir = path.join(objectdir, self:name())

-- get root directory of target
if opt and opt.root then
local intermediate_directory = self:policy("build.intermediate_directory")
if (opt and opt.root) or intermediate_directory == false then
return objectdir
end

-- append plat sub-directory
-- generate intermediate directory
local plat = self:plat()
if plat then
objectdir = path.join(objectdir, plat)
end

-- append arch sub-directory
local arch = self:arch()
if arch then
objectdir = path.join(objectdir, arch)
end

-- append mode sub-directory
local mode = config.get("mode")
local mode = config.mode()
if mode then
objectdir = path.join(objectdir, mode)
end
Expand All @@ -1409,24 +1406,21 @@ function _instance:dependir(opt)
dependir = path.join(dependir, self:name())

-- get root directory of target
if opt and opt.root then
local intermediate_directory = self:policy("build.intermediate_directory")
if (opt and opt.root) or intermediate_directory == false then
return dependir
end

-- append plat sub-directory
-- generate intermediate directory
local plat = self:plat()
if plat then
dependir = path.join(dependir, plat)
end

-- append arch sub-directory
local arch = self:arch()
if arch then
dependir = path.join(dependir, arch)
end

-- append mode sub-directory
local mode = config.get("mode")
local mode = config.mode()
if mode then
dependir = path.join(dependir, mode)
end
Expand All @@ -1436,28 +1430,29 @@ end
-- get the autogen files directory
function _instance:autogendir(opt)

-- the autogen directory
local autogendir = path.join(config.buildir(), ".gens", self:name())
-- init the autogen directory
local autogendir = self:get("autogendir")
if not autogendir then
autogendir = path.join(config.buildir(), ".gens")
end
autogendir = path.join(autogendir, self:name())

-- get root directory of target
if opt and opt.root then
local intermediate_directory = self:policy("build.intermediate_directory")
if (opt and opt.root) or intermediate_directory == false then
return autogendir
end

-- append plat sub-directory
-- generate intermediate directory
local plat = self:plat()
if plat then
autogendir = path.join(autogendir, plat)
end

-- append arch sub-directory
local arch = self:arch()
if arch then
autogendir = path.join(autogendir, arch)
end

-- append mode sub-directory
local mode = config.get("mode")
local mode = config.mode()
if mode then
autogendir = path.join(autogendir, mode)
end
Expand Down Expand Up @@ -1517,24 +1512,24 @@ function _instance:targetdir()
-- the target directory
local targetdir = self:get("targetdir")
if not targetdir then

-- get build directory
targetdir = config.buildir()

-- append plat sub-directory
-- get root directory of target
local intermediate_directory = self:policy("build.intermediate_directory")
if intermediate_directory == false then
return targetdir
end

-- generate intermediate directory
local plat = self:plat()
if plat then
targetdir = path.join(targetdir, plat)
end

-- append arch sub-directory
local arch = self:arch()
if arch then
targetdir = path.join(targetdir, arch)
end

-- append mode sub-directory
local mode = config.get("mode")
local mode = config.mode()
if mode then
targetdir = path.join(targetdir, mode)
end
Expand Down Expand Up @@ -2771,6 +2766,7 @@ function target.apis()
"target.set_targetdir"
, "target.set_objectdir"
, "target.set_dependir"
, "target.set_autogendir"
, "target.set_configdir"
, "target.set_installdir"
, "target.set_rundir"
Expand Down
Loading