summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-02-17 22:41:01 +0800
committerruki <[email protected]>2022-02-17 22:41:01 +0800
commit54efc65b6ed2dfc86c28ba7cc3f40a6084785026 (patch)
treefebf2f4fcc2b80a5e8fb8c372f52742fad3dcd87
parentfe5673d0291653137c3ecc53c2abba5c162a6779 (diff)
...
-rw-r--r--tests/projects/c++/modules/hello/xmake.lua2
-rw-r--r--xmake/core/base/interpreter.lua8
-rw-r--r--xmake/core/base/scopeinfo.lua8
-rw-r--r--xmake/core/base/table.lua18
-rw-r--r--xmake/core/tool/builder.lua6
-rw-r--r--xmake/rules/c++/modules/build_modules/msvc.lua6
6 files changed, 40 insertions, 8 deletions
diff --git a/tests/projects/c++/modules/hello/xmake.lua b/tests/projects/c++/modules/hello/xmake.lua
index 2315cf287..6a69ce121 100644
--- a/tests/projects/c++/modules/hello/xmake.lua
+++ b/tests/projects/c++/modules/hello/xmake.lua
@@ -1,4 +1,4 @@
set_languages("c++20")
-target("hello")
+target("A hello")
set_kind("binary")
add_files("src/*.cpp", "src/*.mpp")
diff --git a/xmake/core/base/interpreter.lua b/xmake/core/base/interpreter.lua
index 6f5f0360b..506d8cdad 100644
--- a/xmake/core/base/interpreter.lua
+++ b/xmake/core/base/interpreter.lua
@@ -1060,7 +1060,9 @@ function interpreter:api_register_set_values(scope_kind, ...)
end
-- expand values
- values = table.join(table.unpack(values))
+ if not extra_config or extra_config.expand ~= false then
+ values = table.join(table.unpack(values))
+ end
-- save values
if #values > 0 then
@@ -1100,7 +1102,9 @@ function interpreter:api_register_add_values(scope_kind, ...)
end
-- expand values
- values = table.join(table.unpack(values))
+ if not extra_config or extra_config.expand ~= false then
+ values = table.join(table.unpack(values))
+ end
-- save values
scope[name] = table.join2(scope[name] or {}, values)
diff --git a/xmake/core/base/scopeinfo.lua b/xmake/core/base/scopeinfo.lua
index 26be325eb..8a69a9299 100644
--- a/xmake/core/base/scopeinfo.lua
+++ b/xmake/core/base/scopeinfo.lua
@@ -114,7 +114,9 @@ function _instance:_api_set_values(name, ...)
end
-- expand values
- values = table.join(table.unpack(values))
+ if not extra_config or extra_config.expand ~= false then
+ values = table.join(table.unpack(values))
+ end
-- handle values
local handled_values = self:_api_handle(name, values)
@@ -153,7 +155,9 @@ function _instance:_api_add_values(name, ...)
end
-- expand values
- values = table.join(table.unpack(values))
+ if not extra_config or extra_config.expand ~= false then
+ values = table.join(table.unpack(values))
+ end
-- save values
scope[name] = self:_api_handle(name, table.join2(table.wrap(scope[name]), values))
diff --git a/xmake/core/base/table.lua b/xmake/core/base/table.lua
index 2bf776151..9868c93d5 100644
--- a/xmake/core/base/table.lua
+++ b/xmake/core/base/table.lua
@@ -120,6 +120,24 @@ function table.join2(self, ...)
return self
end
+-- shallow join all objects, it will not expand all table values
+function table.shallow_join(...)
+ local result = {}
+ for _, t in ipairs({...}) do
+ table.insert(result, t)
+ end
+ return result
+end
+
+
+-- shallow join all objects, it will not expand all table values
+function table.shallow_join2(self, ...)
+ for _, t in ipairs({...}) do
+ table.insert(self, t)
+ end
+ return self
+end
+
-- swap items in array
function table.swap(array, i, j)
local val = array[i]
diff --git a/xmake/core/tool/builder.lua b/xmake/core/tool/builder.lua
index 343eec0ae..8685c34b7 100644
--- a/xmake/core/tool/builder.lua
+++ b/xmake/core/tool/builder.lua
@@ -136,12 +136,16 @@ function builder:_add_flags_from_flagkind(flags, target, flagkind, opt)
local flagconf = extraconf[flag]
if flagconf and flagconf.force then
table.join2(flags, flag)
+ print("111")
else
table.join2(flags, self:_mapflags(flag, flagkind, target))
+ print("222")
+ utils.dump(self:_mapflags(flag, flagkind, target))
end
end
else
table.join2(flags, self:_mapflags(targetflags, flagkind, target))
+ print("xxxx")
end
end
@@ -213,11 +217,13 @@ function builder:_add_flags_from_target(flags, target)
self:_inherit_flags_from_targetdeps(targetflags, target)
end
+ utils.dump(targetflags)
-- add the target flags
for _, flagkind in ipairs(self:_flagkinds()) do
self:_add_flags_from_flagkind(targetflags, target, flagkind)
end
cache[key] = targetflags
+ utils.dump(targetflags)
end
table.join2(flags, targetflags)
end
diff --git a/xmake/rules/c++/modules/build_modules/msvc.lua b/xmake/rules/c++/modules/build_modules/msvc.lua
index 1dc04618f..2b227e354 100644
--- a/xmake/rules/c++/modules/build_modules/msvc.lua
+++ b/xmake/rules/c++/modules/build_modules/msvc.lua
@@ -43,7 +43,7 @@ function load_parent(target, opt)
local sourcebatches = dep:sourcebatches()
if sourcebatches and sourcebatches["c++.build.modules"] then
local cachedir = path.join(dep:autogendir(), "rules", "modules", "cache")
- target:add("cxxflags", "/ifcSearchDir " .. os.args(cachedir), {force = true})
+ target:add("cxxflags", {"/ifcSearchDir", cachedir}, {force = true, expand = false})
end
end
end
@@ -129,7 +129,7 @@ function build_with_batchjobs(target, batchjobs, sourcebatch, opt)
local moduledep = assert(moduledeps_files[sourcefile], "moduledep(%s) not found!", sourcefile)
moduledep.job = batchjobs:newjob(sourcefile, function (index, total)
local opt2 = table.join(opt, {configs = {force = {cxxflags = {interfaceflag,
- outputflag .. " " .. os.args(modulefiles[i]), "/TP"}}}})
+ {outputflag, modulefiles[i]}, "/TP"}}}})
opt2.progress = (index * 100) / total
opt2.objectfile = sourcebatch.objectfiles[i]
opt2.dependfile = sourcebatch.dependfiles[i]
@@ -149,7 +149,7 @@ function build_with_batchjobs(target, batchjobs, sourcebatch, opt)
-- add module flags
target:add("cxxflags", modulesflag)
if cachedir then
- target:add("cxxflags", "/ifcSearchDir " .. os.args(cachedir))
+ target:add("cxxflags", {"/ifcSearchDir", cachedir}, {expand = false})
end
if stdifcdirflag then
for _, toolchain_inst in ipairs(target:toolchains()) do