diff options
| author | ruki <[email protected]> | 2023-06-16 23:59:58 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-06-16 23:59:58 +0800 |
| commit | 4e1b39f0f2a4381997d0e73b071507cf399ce897 (patch) | |
| tree | 38b6c04453581bc352926e642508d17ebee9c68b | |
| parent | ff6d29ac8742fd494054d49ff049d35acd0e86f7 (diff) | |
improve pack and pch
| -rw-r--r-- | xmake/core/package/package.lua | 6 | ||||
| -rw-r--r-- | xmake/core/project/config.lua | 4 | ||||
| -rw-r--r-- | xmake/core/project/project.lua | 4 | ||||
| -rw-r--r-- | xmake/core/project/target.lua | 20 | ||||
| -rw-r--r-- | xmake/modules/private/action/build/object.lua | 10 |
5 files changed, 33 insertions, 11 deletions
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua index ab7d01b88..21842b51f 100644 --- a/xmake/core/package/package.lua +++ b/xmake/core/package/package.lua @@ -212,7 +212,7 @@ end -- the current platform is belong to the given platforms? function _instance:is_plat(...) local plat = self:plat() - for _, v in ipairs(table.join(...)) do + for _, v in ipairs(table.pack(...)) do if v and plat == v then return true end @@ -222,7 +222,7 @@ end -- the current architecture is belong to the given architectures? function _instance:is_arch(...) local arch = self:arch() - for _, v in ipairs(table.join(...)) do + for _, v in ipairs(table.pack(...)) do if v and arch:find("^" .. v:gsub("%-", "%%-") .. "$") then return true end @@ -247,7 +247,7 @@ end -- the current architecture is belong to the given target architectures? function _instance:is_targetarch(...) local targetarch = self:targetarch() - for _, v in ipairs(table.join(...)) do + for _, v in ipairs(table.pack(...)) do if v and targetarch:find("^" .. v:gsub("%-", "%%-") .. "$") then return true end diff --git a/xmake/core/project/config.lua b/xmake/core/project/config.lua index 57b016e13..a979ffa54 100644 --- a/xmake/core/project/config.lua +++ b/xmake/core/project/config.lua @@ -265,7 +265,7 @@ function config.is_value(name, ...) if not value then return false end -- exists this value? and escape '-' - for _, v in ipairs(table.join(...)) do + for _, v in ipairs(table.pack(...)) do if v and type(v) == "string" and value:find("^" .. v:gsub("%-", "%%-") .. "$") then return true end @@ -274,7 +274,7 @@ end -- has the given configs? function config.has(...) - for _, name in ipairs(table.join(...)) do + for _, name in ipairs(table.pack(...)) do if name and type(name) == "string" and config.get(name) then return true end diff --git a/xmake/core/project/project.lua b/xmake/core/project/project.lua index e2a9528c4..81181c72d 100644 --- a/xmake/core/project/project.lua +++ b/xmake/core/project/project.lua @@ -93,7 +93,7 @@ function project._api_is_kind(interp, ...) if not kind then return false end -- exists this kind? - for _, k in ipairs(table.join(...)) do + for _, k in ipairs(table.pack(...)) do if k and type(k) == "string" and k == kind then return true end @@ -115,7 +115,7 @@ function project._api_has_package(interp, ...) -- only for loading targets local requires = project._memcache():get("requires") if requires then - for _, name in ipairs(table.join(...)) do + for _, name in ipairs(table.pack(...)) do local pkg = requires[name] if pkg and pkg:enabled() then return true diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua index 182fabb14..befb589a2 100644 --- a/xmake/core/project/target.lua +++ b/xmake/core/project/target.lua @@ -593,7 +593,7 @@ end -- the current target is belong to the given platforms? function _instance:is_plat(...) local plat = self:plat() - for _, v in ipairs(table.join(...)) do + for _, v in ipairs(table.pack(...)) do if v and plat == v then return true end @@ -603,7 +603,7 @@ end -- the current target is belong to the given architectures? function _instance:is_arch(...) local arch = self:arch() - for _, v in ipairs(table.join(...)) do + for _, v in ipairs(table.pack(...)) do if v and arch:find("^" .. v:gsub("%-", "%%-") .. "$") then return true end @@ -2234,6 +2234,20 @@ function _instance:toolconfig(name) end}) end +-- has source files with the given source kind? +function _instance:has_sourcekind(...) + local sourcekinds_set = self._SOURCEKINDS_SET + if sourcekinds_set == nil then + sourcekinds_set = hashset.from(self:sourcekinds()) + self._SOURCEKINDS_SET = sourcekinds_set + end + for _, v in ipairs(table.pack(...)) do + if sourcekinds_set:has(v) then + return true + end + end +end + -- has the given tool for the current target? -- -- e.g. @@ -2244,7 +2258,7 @@ end function _instance:has_tool(toolkind, ...) local _, toolname = self:tool(toolkind) if toolname then - for _, v in ipairs(table.join(...)) do + for _, v in ipairs(table.pack(...)) do if v and toolname:find("^" .. v:gsub("%-", "%%-") .. "$") then return true end diff --git a/xmake/modules/private/action/build/object.lua b/xmake/modules/private/action/build/object.lua index 00493cf4d..479ef8add 100644 --- a/xmake/modules/private/action/build/object.lua +++ b/xmake/modules/private/action/build/object.lua @@ -92,7 +92,15 @@ function _do_build_file(target, sourcefile, opt) -- update files and values to the dependent file dependinfo.values = depvalues - table.join2(dependinfo.files, sourcefile, target:pcoutputfile("cxx") or {}, target:pcoutputfile("c")) + table.insert(dependinfo.files, sourcefile) + local pcoutputfile = target:pcoutputfile("cxx") + if target:has_sourcekind("cxx") and pcoutputfile then + table.insert(dependinfo.files, pcoutputfile) + end + local pcoutputfile = target:pcoutputfile("c") + if target:has_sourcekind("cc") and pcoutputfile then + table.insert(dependinfo.files, pcoutputfile) + end depend.save(dependinfo, dependfile) end end |
