diff options
| author | ruki <[email protected]> | 2026-01-06 22:40:49 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2026-01-06 22:40:49 +0800 |
| commit | 54a212a965f2e921f9ad225df69086282ba511a7 (patch) | |
| tree | 44a672ba394637b3875e432e0f20065d12c29e4f | |
| parent | fa07b0ea604c59ff150ccfce374cbd04314bb0dd (diff) | |
improve to show modes
| -rw-r--r-- | xmake/plugins/show/lists/buildmodes.lua | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/xmake/plugins/show/lists/buildmodes.lua b/xmake/plugins/show/lists/buildmodes.lua index d810c0604..5ecc007af 100644 --- a/xmake/plugins/show/lists/buildmodes.lua +++ b/xmake/plugins/show/lists/buildmodes.lua @@ -20,6 +20,7 @@ -- imports import("core.project.config") +import("core.project.project") import("core.project.rule") import(".showlist") @@ -27,10 +28,21 @@ import(".showlist") function main() config.load() local modes = {} - for _, r in pairs(rule.rules()) do - local rulename = r:name() - if rulename:startswith("mode.") then - table.insert(modes, rulename) + + -- prioritize project modes + local project_modes = nil + if os.isfile(os.projectfile()) then + project_modes = project.modes() + end + if project_modes and #project_modes > 0 then + modes = project_modes + else + -- fallback to rule modes + for _, r in pairs(rule.rules()) do + local rulename = r:name() + if rulename:startswith("mode.") then + table.insert(modes, rulename:sub(6)) -- remove "mode." prefix + end end end showlist(modes) |
