diff options
| author | ruki <[email protected]> | 2018-04-12 22:33:44 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2018-04-12 09:22:27 +0800 |
| commit | afcbad58716d9b766d77a70827f45695c9819099 (patch) | |
| tree | 3fbf510bd3a60ada43d915edb56a0fa396a0b3ca | |
| parent | 67bfa73b2ae4ddfa3f5c001685bdb063a0454ec1 (diff) | |
remove some rule interfaces
| -rw-r--r-- | tests/apis/rules/xmake.lua | 1 | ||||
| -rw-r--r-- | xmake/core/project/project.lua | 9 | ||||
| -rw-r--r-- | xmake/core/project/rule.lua | 135 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/import/core/project/rule.lua | 98 |
4 files changed, 6 insertions, 237 deletions
diff --git a/tests/apis/rules/xmake.lua b/tests/apis/rules/xmake.lua index cb5179982..7afddab29 100644 --- a/tests/apis/rules/xmake.lua +++ b/tests/apis/rules/xmake.lua @@ -13,7 +13,6 @@ rule("man") for _, sourcefile in ipairs(sourcefiles) do print("generating man: %s", sourcefile) end - rule.build_files("markdown", target, sourcefiles) end) -- define rule: c code diff --git a/xmake/core/project/project.lua b/xmake/core/project/project.lua index 5e9fe6895..5a070fe80 100644 --- a/xmake/core/project/project.lua +++ b/xmake/core/project/project.lua @@ -452,9 +452,12 @@ function project._load_targets() -- do load with target rules if ok then for _, r in pairs(t:orderules()) do - ok, errors = r:do_load(t) - if not ok then - break + local on_load = r:script("load") + if on_load then + ok, errors = sandbox.load(on_load, t) + if not ok then + break + end end end if not ok then diff --git a/xmake/core/project/rule.lua b/xmake/core/project/rule.lua index ab9fd09ec..6648ec73e 100644 --- a/xmake/core/project/rule.lua +++ b/xmake/core/project/rule.lua @@ -243,141 +243,6 @@ function rule:orderdeps() return self._ORDERDEPS end --- do load -function rule:do_load(target) - - -- on_load? - local on_load = self:script("load") - if on_load then - return sandbox.load(on_load, target) - end - - -- ok - return true -end - --- do build source files -function rule:do_build_files(target, sourcefiles) - - -- on_build_files? - local on_build_files = self:script("build_files") - if on_build_files then - return sandbox.load(on_build_files, target, sourcefiles) - else - local on_build_file = self:script("build_file") - if not on_build_file then - return false, string.format("rule(%s): on_build_file() script not found!", self:name()) - end - for _, sourcefile in ipairs(table.wrap(sourcefiles)) do - local ok, errors = sandbox.load(on_build_file, target, sourcefile) - if not ok then - return false, errors - end - end - end - - -- ok - return true -end - --- clean files -function rule:clean(target, sourcefiles) - ---[[ - -- clean all? - local clean_all = self:script("clean_all") - if clean_all then - return sandbox.load(clean_all, target, sourcefiles) - else - local clean = self:script("clean") - if clean then - for _, sourcefile in ipairs(table.wrap(sourcefiles)) do - local ok, errors = sandbox.load(clean, target, sourcefile) - if not ok then - return false, errors - end - end - end - end -]] - -- ok - return true -end - --- install files -function rule:install(target, sourcefiles) - ---[[ - -- install all? - local install_all = self:script("install_all") - if install_all then - return sandbox.load(install_all, target, sourcefiles) - else - local install = self:script("install") - if install then - for _, sourcefile in ipairs(table.wrap(sourcefiles)) do - local ok, errors = sandbox.load(install, target, sourcefile) - if not ok then - return false, errors - end - end - end - end - ]] - - -- ok - return true -end - --- uninstall files -function rule:uninstall(target, sourcefiles) - ---[[ - -- uninstall all? - local uninstall_all = self:script("uninstall_all") - if uninstall_all then - return sandbox.load(uninstall_all, target, sourcefiles) - else - local uninstall = self:script("uninstall") - if uninstall then - for _, sourcefile in ipairs(table.wrap(sourcefiles)) do - local ok, errors = sandbox.load(uninstall, target, sourcefile) - if not ok then - return false, errors - end - end - end - end - ]] - - -- ok - return true -end - --- package files -function rule:package(target, sourcefiles) - ---[[ - -- package all? - local package_all = self:script("package_all") - if package_all then - return sandbox.load(package_all, target, sourcefiles) - else - local package = self:script("package") - if package then - for _, sourcefile in ipairs(table.wrap(sourcefiles)) do - local ok, errors = sandbox.load(package, target, sourcefile) - if not ok then - return false, errors - end - end - end - end]] - - -- ok - return true -end - -- get xxx_script function rule:script(name, generic) diff --git a/xmake/core/sandbox/modules/import/core/project/rule.lua b/xmake/core/sandbox/modules/import/core/project/rule.lua index 6cb5c72a2..07db95f6e 100644 --- a/xmake/core/sandbox/modules/import/core/project/rule.lua +++ b/xmake/core/sandbox/modules/import/core/project/rule.lua @@ -42,103 +42,5 @@ function sandbox_core_project_rule.rules() return rule.rules() end --- build source files -function sandbox_core_project_rule.build_files(rulename, target, sourcefiles) - - -- get rule - local rule = project.rule(rulename) or rule.rule(rulename) - if not rule then - raise("unknown rule: %s", rulename) - end - - -- do build - local ok, errors = rule:do_build_files(target, sourcefiles) - if not ok then - raise(errors) - end -end - ---[[ --- build source files -function sandbox_core_project_rule.build(rulename, target, sourcefiles) - - -- get rule - local rule = project.rule(rulename) - if not rule then - raise("unknown rule: %s", rulename) - end - - -- do build - local ok, errors = rule:build(target, sourcefiles) - if not ok then - raise(errors) - end -end - --- clean files -function sandbox_core_project_rule.clean(rulename, target, sourcefiles) - - -- get rule - local rule = project.rule(rulename) - if not rule then - raise("unknown rule: %s", rulename) - end - - -- do clean - local ok, errors = rule:clean(target, sourcefiles) - if not ok then - raise(errors) - end -end - --- install files -function sandbox_core_project_rule.install(rulename, target, sourcefiles) - - -- get rule - local rule = project.rule(rulename) - if not rule then - raise("unknown rule: %s", rulename) - end - - -- do install - local ok, errors = rule:install(target, sourcefiles) - if not ok then - raise(errors) - end -end - --- uninstall files -function sandbox_core_project_rule.uninstall(rulename, target, sourcefiles) - - -- get rule - local rule = project.rule(rulename) - if not rule then - raise("unknown rule: %s", rulename) - end - - -- do uninstall - local ok, errors = rule:uninstall(target, sourcefiles) - if not ok then - raise(errors) - end -end - --- package files -function sandbox_core_project_rule.package(rulename, target, sourcefiles) - - -- get rule - local rule = project.rule(rulename) - if not rule then - raise("unknown rule: %s", rulename) - end - - -- do package - local ok, errors = rule:package(target, sourcefiles) - if not ok then - raise(errors) - end -end -]] - -- return module return sandbox_core_project_rule |
