diff options
| author | ruki <[email protected]> | 2026-08-11 23:57:56 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2026-08-11 23:57:56 +0800 |
| commit | 911febdde5f22a4e548f7c8e5380c31c51be2af0 (patch) | |
| tree | ecd3213472446231a9081ddf04810cc39eccf2c2 /xmake/core/project | |
| parent | 7e2b17bd3e82bfedc3aa5a94bcf4cad68eaba581 (diff) | |
improve to register addon
Diffstat (limited to 'xmake/core/project')
| -rw-r--r-- | xmake/core/project/rule.lua | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/xmake/core/project/rule.lua b/xmake/core/project/rule.lua index f4d2be491..dfc385f35 100644 --- a/xmake/core/project/rule.lua +++ b/xmake/core/project/rule.lua @@ -459,6 +459,19 @@ function rule.new(name, info, opt) return instance end +-- report the missing addon of the given rule reference, e.g. add_rules("@addon/esp32/flash") +-- +-- it's either not installed at all, or it's installed but does not provide this rule +-- +function rule._raise_addon_notfound(name) + local referenceinfo, errors = addon.resolve_reference(name, "/", "rules") + if errors then + os.raise(errors) + end + os.raise("rule(%s) not found!\nplease install the addon which provides it first: xmake addon --install %s", + name, referenceinfo and referenceinfo.addon or "<addon>") +end + -- get the given global rule -- -- @param name the rule name, the rules of the installed addons need the @@ -467,12 +480,7 @@ end function rule.rule(name) local instance = rule.rules()[name] if instance == nil and name:startswith("@addon/") then - local referenceinfo, errors = addon.resolve_reference(name, "/", "rules") - if errors then - os.raise(errors) - end - os.raise("rule(%s) not found!\nplease install the addon which provides it first: xmake addon --install %s", - name, referenceinfo and referenceinfo.addon or "<addon>") + rule._raise_addon_notfound(name) end return instance end |
