diff options
| author | Dan Engelbrecht <[email protected]> | 2026-03-18 16:46:27 +0100 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2026-03-18 16:46:27 +0100 |
| commit | a4ead902944658a6ae95ed06de7766c21dd0456d (patch) | |
| tree | 1489661a5548a17c822faf7e9c1ed74c2472076d /xmake.lua | |
| parent | Allow pre-commit without it being in the PATH (#861) (diff) | |
| download | zen-a4ead902944658a6ae95ed06de7766c21dd0456d.tar.xz zen-a4ead902944658a6ae95ed06de7766c21dd0456d.zip | |
add kind positional argument to xmake sln (#857)
- Improvement: `xmake sln` now accepts an optional positional argument to select the IDE target (e.g. `xmake sln vs2026`); defaults to `vs2022` on Windows, `xcode` on macOS, `vscode` on Linux
Diffstat (limited to 'xmake.lua')
| -rw-r--r-- | xmake.lua | 44 |
1 files changed, 30 insertions, 14 deletions
@@ -576,34 +576,50 @@ task("precommit") task("sln") set_menu { - usage = "xmake sln [--open] [--vscode]", - description = "Generate IDE project files", + usage = "xmake sln [--open] [vsXXXX|xcode|vscode]", + description = "Generate IDE project files (default: vs2022 on Windows, xcode on macOS, vscode on Linux)", options = { {'o', "open", "k", nil, "Open the generated project in the IDE after generation"}, - {nil, "vscode", "k", nil, "Generate compile_commands.json for VS Code / clangd"}, + {nil, "kind", "v", nil, "IDE kind: vsXXXX (e.g. vs2022, vs2026), xcode, or vscode"}, } } on_run(function () import("core.base.option") - if option.get("vscode") then + local kind = option.get("kind") + if not kind then + if os.is_host("windows") then + kind = "vs2022" + elseif os.is_host("macosx") then + kind = "xcode" + else + kind = "vscode" + end + end + + if kind == "vscode" then os.exec("xmake project --yes --kind=compile_commands --lsp=clangd") printf("generated compile_commands.json\n") - return - end - if is_os("windows") then - os.exec("xmake project --yes --kind=vsxmake2022 -m release,debug -a x64") - if option.get("open") then - local sln = path.join(os.projectdir(), "vsxmake2022", path.filename(os.projectdir()) .. ".sln") - printf("opening %s\n", sln) - try { function() os.execv("explorer", {sln}) end, catch { function() end } } - end - elseif is_os("macosx") then + elseif kind == "xcode" then os.exec("xmake project --yes --kind=xcode -m release,debug -a x64,arm64") if option.get("open") then local xcproj = path.join(os.projectdir(), path.filename(os.projectdir()) .. ".xcodeproj") printf("opening %s\n", xcproj) os.exec("open \"%s\"", xcproj) end + elseif kind:startswith("vs") then + local vs_ver = kind:sub(3) + if vs_ver == "" then + raise("'vs' requires a version, e.g. vs2022") + end + local xmake_kind = "vsxmake" .. vs_ver + os.exec("xmake project --yes --kind=" .. xmake_kind .. " -m release,debug -a x64") + if option.get("open") then + local sln = path.join(os.projectdir(), xmake_kind, path.filename(os.projectdir()) .. ".sln") + printf("opening %s\n", sln) + try { function() os.execv("explorer", {sln}) end, catch { function() end } } + end + else + raise("Unknown kind '%s'. Expected vsXXXX (e.g. vs2022), xcode, or vscode.", kind) end end) |