summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xmake/core/project/project.lua4
-rw-r--r--xmake/core/project/rule.lua13
-rw-r--r--xmake/core/project/target.lua13
3 files changed, 25 insertions, 5 deletions
diff --git a/xmake/core/project/project.lua b/xmake/core/project/project.lua
index 62f1f2398..989dc0302 100644
--- a/xmake/core/project/project.lua
+++ b/xmake/core/project/project.lua
@@ -50,8 +50,10 @@ local language = require("language/language")
local sandbox_os = require("sandbox/modules/os")
local sandbox_module = require("sandbox/modules/import/core/sandbox/module")
--- register project to platform
+-- register project to platform, rule and target
platform._PROJECT = project
+target._PROJECT = project
+rule._PROJECT = project
-- the current os is belong to the given os?
function project._api_is_os(interp, ...)
diff --git a/xmake/core/project/rule.lua b/xmake/core/project/rule.lua
index d0fbfb93d..c3403a197 100644
--- a/xmake/core/project/rule.lua
+++ b/xmake/core/project/rule.lua
@@ -29,6 +29,7 @@ local utils = require("base/utils")
local table = require("base/table")
local global = require("base/global")
local interpreter = require("base/interpreter")
+local instance_deps = require("base/private/instance_deps")
local config = require("project/config")
local sandbox = require("sandbox/sandbox")
local sandbox_os = require("sandbox/modules/os")
@@ -44,6 +45,13 @@ end
-- build deps
function _instance:_build_deps()
+ local instances = rule.rules()
+ if rule._project() then
+ instances = table.join(rule.rules(), rule._project().rules())
+ end
+ self._DEPS = self._DEPS or {}
+ self._ORDERDEPS = self._ORDERDEPS or {}
+ instance_deps.load_deps(self, instances, self._DEPS, self._ORDERDEPS, {self:name()})
end
-- clone rule
@@ -236,6 +244,11 @@ function rule._interpreter()
return interp
end
+-- get project
+function rule._project()
+ return rule._PROJECT
+end
+
-- load rule
function rule._load(filepath)
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua
index a568fb15b..4e5f150be 100644
--- a/xmake/core/project/target.lua
+++ b/xmake/core/project/target.lua
@@ -859,7 +859,7 @@ function _instance:orderpkgs(opt)
local packages = self:_memcache():get(cachekey)
if not packages then
packages = {}
- local requires = self._PROJECT.required_packages()
+ local requires = target._project().required_packages()
if requires then
for _, packagename in ipairs(table.wrap(self:get("packages", opt))) do
local pkg = requires[packagename]
@@ -1220,7 +1220,7 @@ function _instance:filerules(sourcefile)
if filerules then
override = filerules.override
for _, rulename in ipairs(table.wrap(filerules)) do
- local r = self._PROJECT.rule(rulename) or rule.rule(rulename)
+ local r = target._project().rule(rulename) or rule.rule(rulename)
if r then
table.insert(rules, r)
end
@@ -2062,8 +2062,8 @@ function _instance:toolchains()
toolchain_opt.plat = self:plat()
local toolchain_inst, errors = toolchain.load(name, toolchain_opt)
-- attempt to load toolchain from project
- if not toolchain_inst and self._PROJECT then
- toolchain_inst = self._PROJECT.toolchain(name, toolchain_opt)
+ if not toolchain_inst and target._project() then
+ toolchain_inst = target._project().toolchain(name, toolchain_opt)
end
if not toolchain_inst then
os.raise(errors)
@@ -2160,6 +2160,11 @@ function _instance:has_tool(toolkind, ...)
end
end
+-- get project
+function target._project()
+ return target._PROJECT
+end
+
-- get target apis
function target.apis()