summaryrefslogtreecommitdiff
path: root/xmake
diff options
context:
space:
mode:
authorruki <[email protected]>2017-11-11 11:52:48 +0800
committerruki <[email protected]>2017-11-11 11:52:48 +0800
commitfc0ac813b07b28abdbd2b40c5ba78ee76dcc09d7 (patch)
tree1288d79e7b51615d7f4f9235496dd46b379d5d0a /xmake
parent47e6e15e84968c6b0f1ebf6c939157fb027a1c4f (diff)
build rule
Diffstat (limited to 'xmake')
-rw-r--r--xmake/actions/build/kinds/object.lua43
-rw-r--r--xmake/core/project/rule.lua18
-rw-r--r--xmake/core/sandbox/modules/import/core/project/rule.lua4
3 files changed, 15 insertions, 50 deletions
diff --git a/xmake/actions/build/kinds/object.lua b/xmake/actions/build/kinds/object.lua
index de99b1675..a6e8a9050 100644
--- a/xmake/actions/build/kinds/object.lua
+++ b/xmake/actions/build/kinds/object.lua
@@ -293,48 +293,31 @@ function _build_pcheaderfiles(target, buildinfo)
end
end
--- build each objects from the given source batch with the custom rule
-function _build_each_objects_with_rule(target, buildinfo, sourcebatch, jobs, rule)
- print("each", sourcebatch.rulename)
-end
+-- build source files with the custom rule
+function _build_rule(target, buildinfo, sourcebatch, jobs)
--- compile source files to single object at the same time with the custom rule
-function _build_single_object_with_rule(target, buildinfo, sourcebatch, jobs, rule)
+ -- get rule
+ local rule = project.rule(sourcebatch.rulename)
+ assert(rule, "unknown rule: %s", sourcebatch.rule)
-- the rule scripts
local scripts =
{
- rule:script("build_all_before")
- , rule:script("build_all")
- , rule:script("build_all_after")
+ rule:script("build_before")
+ , rule:script("build")
+ , rule:script("build_after")
}
-- run the rule scripts
for i = 1, 3 do
local script = scripts[i]
if script ~= nil then
- script(target, sourcebatch.sourcefiles)
+ script(target, table.unwrap(sourcebatch.sourcefiles))
end
end
-end
-
--- build objects with the custom rule
-function _build_objects_with_rule(target, buildinfo, sourcebatch, jobs)
-
- -- get rule
- local rule = project.rule(sourcebatch.rulename)
- assert(rule, "unknown rule: %s", sourcebatch.rule)
-
- -- build all source files at once
- if rule:get("build_all") then
-
- -- build single object
- _build_single_object_with_rule(target, buildinfo, sourcebatch, jobs, rule)
- else
- -- build each objects
- _build_each_objects_with_rule(target, buildinfo, sourcebatch, jobs, rule)
- end
+ -- update object index
+ _g.sourceindex = _g.sourceindex + #sourcebatch.sourcefiles
end
-- build objects for the given target
@@ -362,8 +345,8 @@ function build(target, buildinfo)
-- compile source files using the custom rule
if sourcebatch.rulename then
- -- build objects with the custom rule
- _build_objects_with_rule(target, buildinfo, sourcebatch, jobs)
+ -- build source files with the custom rule
+ _build_rule(target, buildinfo, sourcebatch, jobs)
-- compile source files to single object at once
elseif type(sourcebatch.objectfiles) == "string" then
diff --git a/xmake/core/project/rule.lua b/xmake/core/project/rule.lua
index 13ab82ac0..51df6a6c2 100644
--- a/xmake/core/project/rule.lua
+++ b/xmake/core/project/rule.lua
@@ -63,24 +63,6 @@ function rule.apis()
, "rule.after_package"
, "rule.after_install"
, "rule.after_uninstall"
- -- rule.on_xxx_all
- , "rule.on_build_all"
- , "rule.on_clean_all"
- , "rule.on_package_all"
- , "rule.on_install_all"
- , "rule.on_uninstall_all"
- -- rule.before_xxx_all
- , "rule.before_build_all"
- , "rule.before_clean_all"
- , "rule.before_package_all"
- , "rule.before_install_all"
- , "rule.before_uninstall_all"
- -- rule.after_xxx_all
- , "rule.after_build_all"
- , "rule.after_clean_all"
- , "rule.after_package_all"
- , "rule.after_install_all"
- , "rule.after_uninstall_all"
}
}
end
diff --git a/xmake/core/sandbox/modules/import/core/project/rule.lua b/xmake/core/sandbox/modules/import/core/project/rule.lua
index 81a8db412..32d5cac03 100644
--- a/xmake/core/sandbox/modules/import/core/project/rule.lua
+++ b/xmake/core/sandbox/modules/import/core/project/rule.lua
@@ -29,8 +29,8 @@ local sandbox_core_project_rule = sandbox_core_project_rule or {}
local rule = require("project/rule")
local raise = require("sandbox/modules/raise")
--- build all source files
-function sandbox_core_project_rule.build_all(rulename, target, sourcefiles)
+-- build source files
+function sandbox_core_project_rule.build(rulename, target, sourcefiles)
end