summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2021-10-18 21:02:26 +0800
committerruki <[email protected]>2021-10-18 21:02:26 +0800
commit4e3967d123432b2352b450ed892fcb1b8f3b37d2 (patch)
tree6fbd34ee82aff8e57cb779784a44de030dfa9c3e
parent69ddff2a27199172659c9c823dabde8c4b004ae3 (diff)
rename to unity build
-rw-r--r--tests/projects/c/unit_build/xmake.lua8
-rw-r--r--tests/projects/c/unity_build/src/bar/test4.c (renamed from tests/projects/c/unit_build/src/bar/test4.c)0
-rw-r--r--tests/projects/c/unity_build/src/bar/test5.c (renamed from tests/projects/c/unit_build/src/bar/test5.c)0
-rw-r--r--tests/projects/c/unity_build/src/foo/test1.c (renamed from tests/projects/c/unit_build/src/foo/test1.c)0
-rw-r--r--tests/projects/c/unity_build/src/foo/test2.c (renamed from tests/projects/c/unit_build/src/foo/test2.c)0
-rw-r--r--tests/projects/c/unity_build/src/header.h (renamed from tests/projects/c/unit_build/src/header.h)0
-rw-r--r--tests/projects/c/unity_build/src/main.c (renamed from tests/projects/c/unit_build/src/main.c)0
-rw-r--r--tests/projects/c/unity_build/src/test.cpp (renamed from tests/projects/c/unit_build/src/test.cpp)0
-rw-r--r--tests/projects/c/unity_build/src/test2.c (renamed from tests/projects/c/unit_build/src/test2.c)0
-rw-r--r--tests/projects/c/unity_build/src/test6.c (renamed from tests/projects/c/unit_build/src/test6.c)0
-rw-r--r--tests/projects/c/unity_build/src/test7.c (renamed from tests/projects/c/unit_build/src/test7.c)0
-rw-r--r--tests/projects/c/unity_build/src/test8.c (renamed from tests/projects/c/unit_build/src/test8.c)0
-rw-r--r--tests/projects/c/unity_build/test.lua (renamed from tests/projects/c/unit_build/test.lua)0
-rw-r--r--tests/projects/c/unity_build/xmake.lua8
-rw-r--r--xmake/rules/c++/unity_build/unity_build.lua (renamed from xmake/rules/c++/unit_build/unit_build.lua)70
-rw-r--r--xmake/rules/c++/unity_build/xmake.lua (renamed from xmake/rules/c++/unit_build/xmake.lua)10
16 files changed, 48 insertions, 48 deletions
diff --git a/tests/projects/c/unit_build/xmake.lua b/tests/projects/c/unit_build/xmake.lua
deleted file mode 100644
index 1df67c0ec..000000000
--- a/tests/projects/c/unit_build/xmake.lua
+++ /dev/null
@@ -1,8 +0,0 @@
-target("test")
- set_kind("binary")
- add_includedirs("src")
- add_rules("c++.unit_build", {batchsize = 2})
- add_files("src/*.c", "src/*.cpp")
- add_files("src/foo/*.c", {unit_group = "foo"})
- add_files("src/bar/*.c", {unit_group = "bar"})
-
diff --git a/tests/projects/c/unit_build/src/bar/test4.c b/tests/projects/c/unity_build/src/bar/test4.c
index a92803eb7..a92803eb7 100644
--- a/tests/projects/c/unit_build/src/bar/test4.c
+++ b/tests/projects/c/unity_build/src/bar/test4.c
diff --git a/tests/projects/c/unit_build/src/bar/test5.c b/tests/projects/c/unity_build/src/bar/test5.c
index 2a3e7066c..2a3e7066c 100644
--- a/tests/projects/c/unit_build/src/bar/test5.c
+++ b/tests/projects/c/unity_build/src/bar/test5.c
diff --git a/tests/projects/c/unit_build/src/foo/test1.c b/tests/projects/c/unity_build/src/foo/test1.c
index e9d6c83d9..e9d6c83d9 100644
--- a/tests/projects/c/unit_build/src/foo/test1.c
+++ b/tests/projects/c/unity_build/src/foo/test1.c
diff --git a/tests/projects/c/unit_build/src/foo/test2.c b/tests/projects/c/unity_build/src/foo/test2.c
index b4ce69b0f..b4ce69b0f 100644
--- a/tests/projects/c/unit_build/src/foo/test2.c
+++ b/tests/projects/c/unity_build/src/foo/test2.c
diff --git a/tests/projects/c/unit_build/src/header.h b/tests/projects/c/unity_build/src/header.h
index 29bfc5870..29bfc5870 100644
--- a/tests/projects/c/unit_build/src/header.h
+++ b/tests/projects/c/unity_build/src/header.h
diff --git a/tests/projects/c/unit_build/src/main.c b/tests/projects/c/unity_build/src/main.c
index f0408cdf8..f0408cdf8 100644
--- a/tests/projects/c/unit_build/src/main.c
+++ b/tests/projects/c/unity_build/src/main.c
diff --git a/tests/projects/c/unit_build/src/test.cpp b/tests/projects/c/unity_build/src/test.cpp
index 1cedddad9..1cedddad9 100644
--- a/tests/projects/c/unit_build/src/test.cpp
+++ b/tests/projects/c/unity_build/src/test.cpp
diff --git a/tests/projects/c/unit_build/src/test2.c b/tests/projects/c/unity_build/src/test2.c
index 596359cd2..596359cd2 100644
--- a/tests/projects/c/unit_build/src/test2.c
+++ b/tests/projects/c/unity_build/src/test2.c
diff --git a/tests/projects/c/unit_build/src/test6.c b/tests/projects/c/unity_build/src/test6.c
index efbd7c6c1..efbd7c6c1 100644
--- a/tests/projects/c/unit_build/src/test6.c
+++ b/tests/projects/c/unity_build/src/test6.c
diff --git a/tests/projects/c/unit_build/src/test7.c b/tests/projects/c/unity_build/src/test7.c
index 24aeff619..24aeff619 100644
--- a/tests/projects/c/unit_build/src/test7.c
+++ b/tests/projects/c/unity_build/src/test7.c
diff --git a/tests/projects/c/unit_build/src/test8.c b/tests/projects/c/unity_build/src/test8.c
index 6ad5680a6..6ad5680a6 100644
--- a/tests/projects/c/unit_build/src/test8.c
+++ b/tests/projects/c/unity_build/src/test8.c
diff --git a/tests/projects/c/unit_build/test.lua b/tests/projects/c/unity_build/test.lua
index b76241be2..b76241be2 100644
--- a/tests/projects/c/unit_build/test.lua
+++ b/tests/projects/c/unity_build/test.lua
diff --git a/tests/projects/c/unity_build/xmake.lua b/tests/projects/c/unity_build/xmake.lua
new file mode 100644
index 000000000..447960db5
--- /dev/null
+++ b/tests/projects/c/unity_build/xmake.lua
@@ -0,0 +1,8 @@
+target("test")
+ set_kind("binary")
+ add_includedirs("src")
+ add_rules("c++.unity_build", {batchsize = 2})
+ add_files("src/*.c", "src/*.cpp")
+ add_files("src/foo/*.c", {unity_group = "foo"})
+ add_files("src/bar/*.c", {unity_group = "bar"})
+
diff --git a/xmake/rules/c++/unit_build/unit_build.lua b/xmake/rules/c++/unity_build/unity_build.lua
index 7fd50b596..57bff99a0 100644
--- a/xmake/rules/c++/unit_build/unit_build.lua
+++ b/xmake/rules/c++/unity_build/unity_build.lua
@@ -15,75 +15,75 @@
-- Copyright (C) 2015-present, TBOOX Open Source Group.
--
-- @author ruki
--- @file unit_build.lua
+-- @file unity_build.lua
--
-- imports
import("core.project.depend")
-function _merge_unitfile(target, sourcefile_unit, sourcefiles, opt)
- local dependfile = target:dependfile(sourcefile_unit)
+function _merge_unityfile(target, sourcefile_unity, sourcefiles, opt)
+ local dependfile = target:dependfile(sourcefile_unity)
depend.on_changed(function ()
-- trace
- vprint("generating.unitfile %s", sourcefile_unit)
+ vprint("generating.unityfile %s", sourcefile_unity)
-- do merge
- local unitfile = io.open(sourcefile_unit, "w")
+ local unityfile = io.open(sourcefile_unity, "w")
for _, sourcefile in ipairs(sourcefiles) do
sourcefile = path.absolute(sourcefile)
- sourcefile_unit = path.absolute(sourcefile_unit)
- sourcefile = path.relative(sourcefile, path.directory(sourcefile_unit))
- unitfile:print("#include \"%s\"", sourcefile)
+ sourcefile_unity = path.absolute(sourcefile_unity)
+ sourcefile = path.relative(sourcefile, path.directory(sourcefile_unity))
+ unityfile:print("#include \"%s\"", sourcefile)
end
- unitfile:close()
+ unityfile:close()
end, {dependfile = dependfile, files = sourcefiles})
end
-function generate_unitfiles(target, sourcebatch, opt)
- local unitbatch = target:data("unit_build.unitbatch." .. sourcebatch.rulename)
- if unitbatch then
- for _, sourcefile_unit in ipairs(sourcebatch.sourcefiles) do
- local sourceinfo = unitbatch[sourcefile_unit]
+function generate_unityfiles(target, sourcebatch, opt)
+ local unity_batch = target:data("unity_build.unity_batch." .. sourcebatch.rulename)
+ if unity_batch then
+ for _, sourcefile_unity in ipairs(sourcebatch.sourcefiles) do
+ local sourceinfo = unity_batch[sourcefile_unity]
if sourceinfo then
local sourcefiles = sourceinfo.sourcefiles
if sourcefiles then
- _merge_unitfile(target, sourcefile_unit, sourcefiles, opt)
+ _merge_unityfile(target, sourcefile_unity, sourcefiles, opt)
end
end
end
end
end
--- use unit build
+-- use unity build
--
-- e.g.
--- add_rules("c++.unit_build", {batchsize = 2})
--- add_files("src/*.c", "src/*.cpp", {unit_ignored = true})
--- add_files("src/foo/*.c", {unit_group = "foo"})
--- add_files("src/bar/*.c", {unit_group = "bar"})
+-- add_rules("c++.unity_build", {batchsize = 2})
+-- add_files("src/*.c", "src/*.cpp", {unity_ignored = true})
+-- add_files("src/foo/*.c", {unity_group = "foo"})
+-- add_files("src/bar/*.c", {unity_group = "bar"})
--
function main(target, sourcebatch)
-- get unit batch sources
- local extraconf = target:extraconf("rules", "c++.unit_build")
+ local extraconf = target:extraconf("rules", "c++.unity_build")
local batchsize = extraconf and extraconf.batchsize
local id = 1
local count = 0
- local unitbatch = {}
+ local unity_batch = {}
local sourcefiles = {}
local objectfiles = {}
local dependfiles = {}
- local sourcedir = path.join(target:autogendir({root = true}), "unit_build")
+ local sourcedir = path.join(target:autogendir({root = true}), "unity_build")
for idx, sourcefile in pairs(sourcebatch.sourcefiles) do
- local sourcefile_unit
+ local sourcefile_unity
local objectfile = sourcebatch.objectfiles[idx]
local dependfile = sourcebatch.dependfiles[idx]
local fileconfig = target:fileconfig(sourcefile)
- if fileconfig and fileconfig.unit_group then
- sourcefile_unit = path.join(sourcedir, "unit_" .. fileconfig.unit_group .. path.extension(sourcefile))
- elseif fileconfig and fileconfig.unit_ignored then
+ if fileconfig and fileconfig.unity_group then
+ sourcefile_unity = path.join(sourcedir, "unity_" .. fileconfig.unity_group .. path.extension(sourcefile))
+ elseif fileconfig and fileconfig.unity_ignored then
-- we do not add these files to unit file
table.insert(sourcefiles, sourcefile)
table.insert(objectfiles, objectfile)
@@ -92,16 +92,16 @@ function main(target, sourcebatch)
if batchsize and count > batchsize then
id = id + 1
end
- sourcefile_unit = path.join(sourcedir, "unit_" .. hash.uuid(tostring(id)):split("-", {plain = true})[1] .. path.extension(sourcefile))
+ sourcefile_unity = path.join(sourcedir, "unity_" .. hash.uuid(tostring(id)):split("-", {plain = true})[1] .. path.extension(sourcefile))
count = count + 1
end
- if sourcefile_unit then
- local sourceinfo = unitbatch[sourcefile_unit]
+ if sourcefile_unity then
+ local sourceinfo = unity_batch[sourcefile_unity]
if not sourceinfo then
sourceinfo = {}
- sourceinfo.objectfile = target:objectfile(sourcefile_unit)
+ sourceinfo.objectfile = target:objectfile(sourcefile_unity)
sourceinfo.dependfile = target:dependfile(sourceinfo.objectfile)
- unitbatch[sourcefile_unit] = sourceinfo
+ unity_batch[sourcefile_unity] = sourceinfo
end
sourceinfo.sourcefiles = sourceinfo.sourcefiles or {}
table.insert(sourceinfo.sourcefiles, sourcefile)
@@ -109,8 +109,8 @@ function main(target, sourcebatch)
end
-- use unit batch
- for sourcefile_unit, sourceinfo in pairs(unitbatch) do
- table.insert(sourcefiles, sourcefile_unit)
+ for sourcefile_unity, sourceinfo in pairs(unity_batch) do
+ table.insert(sourcefiles, sourcefile_unity)
table.insert(objectfiles, sourceinfo.objectfile)
table.insert(dependfiles, sourceinfo.dependfile)
end
@@ -119,5 +119,5 @@ function main(target, sourcebatch)
sourcebatch.dependfiles = dependfiles
-- save unit batch
- target:data_set("unit_build.unitbatch." .. sourcebatch.rulename, unitbatch)
+ target:data_set("unity_build.unity_batch." .. sourcebatch.rulename, unity_batch)
end
diff --git a/xmake/rules/c++/unit_build/xmake.lua b/xmake/rules/c++/unity_build/xmake.lua
index b0eb7b39a..838f8a097 100644
--- a/xmake/rules/c++/unit_build/xmake.lua
+++ b/xmake/rules/c++/unity_build/xmake.lua
@@ -18,27 +18,27 @@
-- @file xmake.lua
--
-rule("c++.unit_build")
+rule("c++.unity_build")
after_load(function (target)
- import("unit_build")
+ import("unity_build")
local sourcebatches = target:sourcebatches()
if sourcebatches then
for _, rulename in ipairs({"c.build", "c++.build"}) do
local sourcebatch = sourcebatches[rulename]
if sourcebatch then
- unit_build(target, sourcebatch)
+ unity_build(target, sourcebatch)
end
end
end
end)
before_build(function (target, opt)
- import("unit_build")
+ import("unity_build")
local sourcebatches = target:sourcebatches()
if sourcebatches then
for _, rulename in ipairs({"c.build", "c++.build"}) do
local sourcebatch = sourcebatches[rulename]
if sourcebatch then
- unit_build.generate_unitfiles(target, sourcebatch, opt)
+ unity_build.generate_unitfiles(target, sourcebatch, opt)
end
end
end