diff options
| author | ruki <[email protected]> | 2019-06-10 21:00:49 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-06-10 00:04:59 +0800 |
| commit | e368bcfdb1e8326579a2ffb56e57ec6b316a29f0 (patch) | |
| tree | db1712ec42a9136a1cac93744ec6ae559fb3dec7 | |
| parent | 60ddb4c5a6725d11a7821d691dfd53c23df282bc (diff) | |
patch rules for deprecated cuda link mode
| -rw-r--r-- | xmake/core/project/deprecated/project.lua | 33 | ||||
| -rw-r--r-- | xmake/core/project/project.lua | 1 |
2 files changed, 34 insertions, 0 deletions
diff --git a/xmake/core/project/deprecated/project.lua b/xmake/core/project/deprecated/project.lua index b55970c86..a7b285381 100644 --- a/xmake/core/project/deprecated/project.lua +++ b/xmake/core/project/deprecated/project.lua @@ -27,6 +27,7 @@ local path = require("base/path") local utils = require("base/utils") local table = require("base/table") local string = require("base/string") +local rule = require("project/rule") local config = require("project/config") local platform = require("platform/platform") local deprecated = require("base/deprecated") @@ -263,6 +264,38 @@ function deprecated_project._api_is_option(interp, ...) return config.has(...) end +-- patch target rules +function deprecated_project._patch_target_rules(target) + + -- TODO patch rules for the deprecated cuda link mode + -- we will remove this code in the future + local files = target:get("files") + if files and not target:rule("cuda.device_link") then + for _, sourcefile in ipairs(table.wrap(files)) do + if sourcefile:lower():endswith(".cu") then + local rules = {binary = "cuda.console", shared = "cuda.shared", static = "cuda.static"} + local rulename = rules[target:targetkind()] + if rulename then + local r = rule.rule(rulename) + if r then + target._RULES[rulename] = r + for _, deprule in ipairs(r:orderdeps()) do + local name = deprule:name() + if not target._RULES[name] then + target._RULES[name] = deprule + table.insert(target._ORDERULES, deprule) + end + end + table.insert(target._ORDERULES, r) + deprecated.add("add_rules(\"" .. rulename .. "\")", "set_kind(\"" .. target:targetkind() .. "\") for cuda") + end + end + break + end + end + end +end + -- register api function deprecated_project.api_register(interp) diff --git a/xmake/core/project/project.lua b/xmake/core/project/project.lua index 07fb6792f..ed9b87bb3 100644 --- a/xmake/core/project/project.lua +++ b/xmake/core/project/project.lua @@ -523,6 +523,7 @@ function project._load_targets() table.insert(t._ORDERULES, r) end end + deprecated_project._patch_target_rules(t) -- laod packages t._PACKAGES = t._PACKAGES or {} |
