diff options
| author | ruki <[email protected]> | 2020-05-14 23:09:34 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-05-14 12:57:29 +0800 |
| commit | 46abd569d127f5d77735cc2071018970d34bcd37 (patch) | |
| tree | 8592e9e8b2953c85b2f7cda939802c19fc2f9568 | |
| parent | 0648c5178d1fabbaa082db10aeb1fa6bf822bd6a (diff) | |
check policies name
| -rw-r--r-- | xmake/core/project/project.lua | 14 | ||||
| -rw-r--r-- | xmake/core/project/target.lua | 17 |
2 files changed, 28 insertions, 3 deletions
diff --git a/xmake/core/project/project.lua b/xmake/core/project/project.lua index 2f9fd629c..e900f394f 100644 --- a/xmake/core/project/project.lua +++ b/xmake/core/project/project.lua @@ -811,7 +811,19 @@ end -- get the project policy, the root policy of the target scope function project.policy(name) - local policies = project.get("target.policy") + local policies = project._POLICIES + if not policies then + policies = project.get("target.policy") + project._POLICIES = policies + if policies then + local defined_policies = policy.policies() + for name, _ in pairs(policies) do + if not defined_policies[name] then + utils.warning("unknown policy(%s), please run `xmake l core.project.policy.policies` if you want to all policies", name) + end + end + end + end return policy.check(name, policies and policies[name]) end diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua index ac1b45fbe..9a519cbed 100644 --- a/xmake/core/project/target.lua +++ b/xmake/core/project/target.lua @@ -241,9 +241,10 @@ function _instance:_visibility(opt) return visibility end --- invalidate the previous cache key +-- invalidate the previous cache function _instance:_invalidate(name) self._CACHEID = self._CACHEID + 1 + self._POLICIES = nil -- we need flush the source files cache if target/files are modified, e.g. `target:add("files", "xxx.c")` if name == "files" then self._SOURCEFILES = nil @@ -471,7 +472,19 @@ end -- get the target policy function _instance:policy(name) - local policies = self:get("policy") + local policies = self._POLICIES + if not policies then + policies = self:get("policy") + self._POLICIES = policies + if policies then + local defined_policies = policy.policies() + for name, _ in pairs(policies) do + if not defined_policies[name] then + utils.warning("unknown policy(%s), please run `xmake l core.project.policy.policies` if you want to all policies", name) + end + end + end + end return policy.check(name, policies and policies[name]) end |
