diff options
| author | ruki <[email protected]> | 2018-06-14 22:41:43 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2018-06-14 10:10:19 +0800 |
| commit | 9c7bf9033b146f2099331774a16606c3a9068db4 (patch) | |
| tree | dee692ea1d545faf4e610ded586bf664cba4c61f | |
| parent | ec8068f4d052e4c4536fd485f9c9eb815e451397 (diff) | |
improve load rules
| -rw-r--r-- | xmake/core/project/project.lua | 30 | ||||
| -rw-r--r-- | xmake/core/project/target.lua | 12 | ||||
| -rw-r--r-- | xmake/rules/qt/env/xmake.lua | 4 | ||||
| -rw-r--r-- | xmake/rules/qt/moc/xmake.lua | 4 | ||||
| -rw-r--r-- | xmake/rules/qt/qrc/xmake.lua | 4 | ||||
| -rw-r--r-- | xmake/rules/qt/ui/xmake.lua | 4 | ||||
| -rw-r--r-- | xmake/rules/qt/xmake.lua | 16 | ||||
| -rw-r--r-- | xmake/rules/wdk/env/xmake.lua | 16 | ||||
| -rw-r--r-- | xmake/rules/wdk/inf/xmake.lua | 4 | ||||
| -rw-r--r-- | xmake/rules/wdk/man/xmake.lua | 4 | ||||
| -rw-r--r-- | xmake/rules/wdk/mc/xmake.lua | 4 | ||||
| -rw-r--r-- | xmake/rules/wdk/mof/xmake.lua | 4 | ||||
| -rw-r--r-- | xmake/rules/wdk/sign/xmake.lua | 4 | ||||
| -rw-r--r-- | xmake/rules/wdk/tracewpp/xmake.lua | 4 | ||||
| -rw-r--r-- | xmake/rules/wdk/xmake.lua | 16 | ||||
| -rw-r--r-- | xmake/rules/winsdk/dotnet/xmake.lua | 4 | ||||
| -rw-r--r-- | xmake/rules/winsdk/xmake.lua | 4 |
17 files changed, 60 insertions, 78 deletions
diff --git a/xmake/core/project/project.lua b/xmake/core/project/project.lua index 1038d22e2..e68d1086e 100644 --- a/xmake/core/project/project.lua +++ b/xmake/core/project/project.lua @@ -396,37 +396,19 @@ function project._load_targets() -- enter toolchains environment environment.enter("toolchains") - -- on load for each target - local ok = true + -- do load for each target + local ok = false for _, t in pairs(targets) do - - -- do load for target - local on_load = t:script("load") - if on_load then - ok, errors = sandbox.load(on_load, t) - if not ok then - break - end - end - - -- do load with target rules - if ok then - for _, r in pairs(t:orderules()) do - ok, errors = t:_load_rule(r) - if not ok then - break - end - end - if not ok then - break - end + ok, errors = t:_load() + if not ok then + break end end -- leave toolchains environment environment.leave("toolchains") - -- on load failed? + -- do load failed? if not ok then return nil, errors end diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua index 98623895b..fae55d048 100644 --- a/xmake/core/project/target.lua +++ b/xmake/core/project/target.lua @@ -197,6 +197,12 @@ function target:_load() return false, errors end + -- do load with target rules + local ok, errors = self:_load_rules() + if not ok then + return false, errors + end + -- do load for target local on_load = self:script("load") if on_load then @@ -206,12 +212,6 @@ function target:_load() end end - -- do load with target rules - local ok, errors = self:_load_rules() - if not ok then - return false, errors - end - -- do after_load with target rules local ok, errors = self:_load_rules("after") if not ok then diff --git a/xmake/rules/qt/env/xmake.lua b/xmake/rules/qt/env/xmake.lua index 782aece2a..99bd81150 100644 --- a/xmake/rules/qt/env/xmake.lua +++ b/xmake/rules/qt/env/xmake.lua @@ -25,8 +25,8 @@ -- define rule: environment rule("qt.env") - -- on load - on_load(function (target) + -- before load + before_load(function (target) import("detect.sdks.find_qt") if not target:data("qt") then target:data_set("qt", assert(find_qt(nil, {verbose = true}), "Qt SDK not found!")) diff --git a/xmake/rules/qt/moc/xmake.lua b/xmake/rules/qt/moc/xmake.lua index aad6cab1c..afb6b1df2 100644 --- a/xmake/rules/qt/moc/xmake.lua +++ b/xmake/rules/qt/moc/xmake.lua @@ -31,8 +31,8 @@ rule("qt.moc") -- set extensions set_extensions(".h") - -- on load - on_load(function (target) + -- before load + before_load(function (target) -- get moc local moc = path.join(target:data("qt").bindir, is_host("windows") and "moc.exe" or "moc") diff --git a/xmake/rules/qt/qrc/xmake.lua b/xmake/rules/qt/qrc/xmake.lua index 03c17be4e..96ef8f2fd 100644 --- a/xmake/rules/qt/qrc/xmake.lua +++ b/xmake/rules/qt/qrc/xmake.lua @@ -31,8 +31,8 @@ rule("qt.qrc") -- set extensions set_extensions(".qrc") - -- on load - on_load(function (target) + -- before load + before_load(function (target) -- get rcc local rcc = path.join(target:data("qt").bindir, is_host("windows") and "rcc.exe" or "rcc") diff --git a/xmake/rules/qt/ui/xmake.lua b/xmake/rules/qt/ui/xmake.lua index b00ede129..a59ff3b9f 100644 --- a/xmake/rules/qt/ui/xmake.lua +++ b/xmake/rules/qt/ui/xmake.lua @@ -31,8 +31,8 @@ rule("qt.ui") -- set extensions set_extensions(".ui") - -- on load - on_load(function (target) + -- before load + before_load(function (target) -- get uic local uic = path.join(target:data("qt").bindir, is_host("windows") and "uic.exe" or "uic") diff --git a/xmake/rules/qt/xmake.lua b/xmake/rules/qt/xmake.lua index 8fb9ed36d..fe8a38d16 100644 --- a/xmake/rules/qt/xmake.lua +++ b/xmake/rules/qt/xmake.lua @@ -28,8 +28,8 @@ rule("qt.static") -- add rules add_deps("qt.qrc", "qt.ui", "qt.moc") - -- on load - on_load(function (target) + -- after load + after_load(function (target) import("load")(target, {kind = "static", frameworks = {"QtCore"}}) end) @@ -39,8 +39,8 @@ rule("qt.shared") -- add rules add_deps("qt.qrc", "qt.ui", "qt.moc") - -- on load - on_load(function (target) + -- after load + after_load(function (target) import("load")(target, {kind = "shared", frameworks = {"QtCore"}}) end) @@ -50,8 +50,8 @@ rule("qt.console") -- add rules add_deps("qt.qrc", "qt.ui", "qt.moc") - -- on load - on_load(function (target) + -- after load + after_load(function (target) import("load")(target, {kind = "binary", frameworks = {"QtCore"}}) end) @@ -61,8 +61,8 @@ rule("qt.application") -- add rules add_deps("qt.qrc", "qt.ui", "qt.moc") - -- on load - on_load(function (target) + -- after load + after_load(function (target) -- load common flags to target import("load")(target, {kind = "binary", frameworks = {"QtGui", "QtQml", "QtNetwork", "QtCore"}}) diff --git a/xmake/rules/wdk/env/xmake.lua b/xmake/rules/wdk/env/xmake.lua index c2b2642e1..b97e15d12 100644 --- a/xmake/rules/wdk/env/xmake.lua +++ b/xmake/rules/wdk/env/xmake.lua @@ -25,8 +25,8 @@ -- define rule: environment rule("wdk.env") - -- on load - on_load(function (target) + -- before load + before_load(function (target) -- imports import("detect.sdks.find_wdk") @@ -73,8 +73,8 @@ rule("wdk.env.umdf") -- add rules add_deps("wdk.env") - -- on load - on_load(function (target) + -- after load + after_load(function (target) import("load").umdf(target) end) @@ -84,8 +84,8 @@ rule("wdk.env.kmdf") -- add rules add_deps("wdk.env") - -- on load - on_load(function (target) + -- after load + after_load(function (target) import("load").kmdf(target) end) @@ -95,7 +95,7 @@ rule("wdk.env.wdm") -- add rules add_deps("wdk.env") - -- on load - on_load(function (target) + -- after load + after_load(function (target) import("load").wdm(target) end) diff --git a/xmake/rules/wdk/inf/xmake.lua b/xmake/rules/wdk/inf/xmake.lua index a06a21ce7..c01033cf0 100644 --- a/xmake/rules/wdk/inf/xmake.lua +++ b/xmake/rules/wdk/inf/xmake.lua @@ -31,8 +31,8 @@ rule("wdk.inf") -- set extensions set_extensions(".inf", ".inx") - -- on load - on_load(function (target) + -- before load + before_load(function (target) -- imports import("core.project.config") diff --git a/xmake/rules/wdk/man/xmake.lua b/xmake/rules/wdk/man/xmake.lua index 4bda72992..61b5ac86e 100644 --- a/xmake/rules/wdk/man/xmake.lua +++ b/xmake/rules/wdk/man/xmake.lua @@ -31,8 +31,8 @@ rule("wdk.man") -- set extensions set_extensions(".man") - -- on load - on_load(function (target) + -- before load + before_load(function (target) -- imports import("core.project.config") diff --git a/xmake/rules/wdk/mc/xmake.lua b/xmake/rules/wdk/mc/xmake.lua index 26426481f..12543bcfb 100644 --- a/xmake/rules/wdk/mc/xmake.lua +++ b/xmake/rules/wdk/mc/xmake.lua @@ -31,8 +31,8 @@ rule("wdk.mc") -- set extensions set_extensions(".mc") - -- on load - on_load(function (target) + -- before load + before_load(function (target) -- imports import("core.project.config") diff --git a/xmake/rules/wdk/mof/xmake.lua b/xmake/rules/wdk/mof/xmake.lua index 22ffe176c..6ad2c2991 100644 --- a/xmake/rules/wdk/mof/xmake.lua +++ b/xmake/rules/wdk/mof/xmake.lua @@ -31,8 +31,8 @@ rule("wdk.mof") -- set extensions set_extensions(".mof") - -- on load - on_load(function (target) + -- before load + before_load(function (target) -- imports import("core.project.config") diff --git a/xmake/rules/wdk/sign/xmake.lua b/xmake/rules/wdk/sign/xmake.lua index 1e388043e..f7cc22b80 100644 --- a/xmake/rules/wdk/sign/xmake.lua +++ b/xmake/rules/wdk/sign/xmake.lua @@ -37,8 +37,8 @@ rule("wdk.sign") -- add rule: wdk environment add_deps("wdk.env") - -- on load - on_load(function (target) + -- before load + before_load(function (target) -- imports import("core.project.config") diff --git a/xmake/rules/wdk/tracewpp/xmake.lua b/xmake/rules/wdk/tracewpp/xmake.lua index c732525bb..9a5587084 100644 --- a/xmake/rules/wdk/tracewpp/xmake.lua +++ b/xmake/rules/wdk/tracewpp/xmake.lua @@ -28,8 +28,8 @@ rule("wdk.tracewpp") -- add rule: wdk environment add_deps("wdk.env") - -- on load - on_load(function (target) + -- before load + before_load(function (target) -- imports import("core.project.config") diff --git a/xmake/rules/wdk/xmake.lua b/xmake/rules/wdk/xmake.lua index cc6bab715..8ac241572 100644 --- a/xmake/rules/wdk/xmake.lua +++ b/xmake/rules/wdk/xmake.lua @@ -28,8 +28,8 @@ rule("wdk.driver") -- add rules add_deps("wdk.inf", "wdk.man", "wdk.mc", "wdk.mof", "wdk.tracewpp", "wdk.sign", "wdk.package.cab") - -- on load - on_load(function (target) + -- after load + after_load(function (target) -- load environment if target:rule("wdk.env.umdf") then @@ -69,8 +69,8 @@ rule("wdk.binary") -- add rules add_deps("wdk.inf", "wdk.man", "wdk.mc", "wdk.mof", "wdk.tracewpp") - -- on load - on_load(function (target) + -- after load + after_load(function (target) -- set kind target:set("kind", "binary") @@ -86,8 +86,8 @@ rule("wdk.static") -- add rules add_deps("wdk.inf", "wdk.man", "wdk.mc", "wdk.mof", "wdk.tracewpp") - -- on load - on_load(function (target) + -- after load + after_load(function (target) -- set kind target:set("kind", "static") @@ -105,8 +105,8 @@ rule("wdk.shared") -- add rules add_deps("wdk.inf", "wdk.man", "wdk.mc", "wdk.mof", "wdk.tracewpp") - -- on load - on_load(function (target) + -- after load + after_load(function (target) -- set kind target:set("kind", "shared") diff --git a/xmake/rules/winsdk/dotnet/xmake.lua b/xmake/rules/winsdk/dotnet/xmake.lua index 31e5ff756..5fa1cf96f 100644 --- a/xmake/rules/winsdk/dotnet/xmake.lua +++ b/xmake/rules/winsdk/dotnet/xmake.lua @@ -25,8 +25,8 @@ -- define rule: dotnet rule("win.sdk.dotnet") - -- on load - on_load(function (target) + -- before load + before_load(function (target) -- imports import("core.project.config") diff --git a/xmake/rules/winsdk/xmake.lua b/xmake/rules/winsdk/xmake.lua index 20ce411de..5cb1a14b6 100644 --- a/xmake/rules/winsdk/xmake.lua +++ b/xmake/rules/winsdk/xmake.lua @@ -25,8 +25,8 @@ -- define rule: application rule("win.sdk.application") - -- on load - on_load(function (target) + -- after load + after_load(function (target) -- set kind: binary target:set("kind", "binary") |
