diff options
| author | ruki <[email protected]> | 2024-07-02 13:52:54 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-07-02 13:52:54 +0800 |
| commit | fa2e9d25eebe92dd603adfd4ac221b63e9aa994f (patch) | |
| tree | 0b4e431e93ad7a73aa031cfc48b561981f817bbd | |
| parent | 7b7d1ade7075b2a3673ae1cfccabba628c7f9f86 (diff) | |
| parent | c23cbda1060b73f0f24369253d0e051fafb2b318 (diff) | |
Merge pull request #5283 from xmake-io/intermediate
add build.intermediate_directory policy #5278
| -rw-r--r-- | xmake/core/project/policy.lua | 2 | ||||
| -rw-r--r-- | xmake/core/project/target.lua | 58 |
2 files changed, 29 insertions, 31 deletions
diff --git a/xmake/core/project/policy.lua b/xmake/core/project/policy.lua index 4e495e449..4b5ef9dae 100644 --- a/xmake/core/project/policy.lua +++ b/xmake/core/project/policy.lua @@ -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 diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua index 3b98e15f2..0ed7465d4 100644 --- a/xmake/core/project/target.lua +++ b/xmake/core/project/target.lua @@ -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 @@ -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 @@ -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 @@ -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 @@ -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" |
