feat: added build pristine, build configuration, erase and recover
This commit is contained in:
1 parent
80a2c4d56f
commit
5b1d640d4b
11 files changed
+636
-80
No files matched your search
+74
-16
@@ -1,32 +1,90 @@
|
||||
local M = {}
|
||||
|
||||
function M.build(opts, pristine)
|
||||
local a = { "build", "-d", opts.build_dir, vim.fn.getcwd(), "--board", opts.board }
|
||||
if opts.sysbuild then
|
||||
table.insert(a, "--sysbuild")
|
||||
--- Config del formulario -> argumentos de `west build`.
|
||||
local function config_args(cfg)
|
||||
local a = {}
|
||||
if cfg.board then
|
||||
vim.list_extend(a, { "--board", cfg.board })
|
||||
end
|
||||
|
||||
if cfg.sysbuild == "yes" then
|
||||
table.insert(a, "--sysbuild")
|
||||
elseif cfg.sysbuild == "no" then
|
||||
table.insert(a, "--no-sysbuild") -- verificar nombre exacto en tu west
|
||||
end
|
||||
|
||||
table.insert(a, "--")
|
||||
table.insert(a, "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON")
|
||||
|
||||
local function multi(flag, list)
|
||||
if list and #list > 0 then
|
||||
table.insert(a, flag .. "=" .. table.concat(list, ";"))
|
||||
end
|
||||
end
|
||||
multi("-DCONF_FILE", cfg.conf_files)
|
||||
multi("-DEXTRA_CONF_FILE", cfg.extra_conf_files)
|
||||
multi("-DDTC_OVERLAY_FILE", cfg.overlays)
|
||||
multi("-DEXTRA_DTC_OVERLAY_FILE", cfg.extra_overlays)
|
||||
multi("-DSNIPPET", cfg.snippets)
|
||||
|
||||
if cfg.optimization == "size" then
|
||||
table.insert(a, "-DCONFIG_SIZE_OPTIMIZATIONS=y")
|
||||
elseif cfg.optimization == "speed" then
|
||||
table.insert(a, "-DCONFIG_SPEED_OPTIMIZATIONS=y")
|
||||
elseif cfg.optimization == "debug" then
|
||||
table.insert(a, "-DCONFIG_DEBUG_OPTIMIZATIONS=y")
|
||||
end
|
||||
|
||||
if cfg.debug_thread_info then
|
||||
table.insert(a, "-DCONFIG_DEBUG_THREAD_INFO=y")
|
||||
end
|
||||
|
||||
for _, e in ipairs(cfg.extra_cmake or {}) do
|
||||
table.insert(a, e)
|
||||
end
|
||||
return a
|
||||
end
|
||||
|
||||
--- Config del spec del plugin (one-liner) -> config del formulario.
|
||||
local function from_opts(opts)
|
||||
return {
|
||||
board = opts.board,
|
||||
conf_files = opts.conf_file and { opts.conf_file } or {},
|
||||
overlays = opts.overlays or {},
|
||||
extra_cmake = opts.extra_cmake or {},
|
||||
build_dir = opts.build_dir or "build",
|
||||
sysbuild = (opts.sysbuild == false) and "no" or "default",
|
||||
}
|
||||
end
|
||||
|
||||
function M.build(opts, pristine, cfg)
|
||||
cfg = cfg or from_opts(opts)
|
||||
|
||||
if cfg.generate_only then
|
||||
vim.notify("[hego] 'Generate only' todavía no está cableado (pendiente de verificar)", vim.log.levels.WARN)
|
||||
end
|
||||
|
||||
local a = {
|
||||
"build",
|
||||
"-d",
|
||||
cfg.build_dir or opts.build_dir,
|
||||
vim.fn.getcwd(),
|
||||
}
|
||||
if pristine then
|
||||
table.insert(a, "--pristine")
|
||||
end
|
||||
table.insert(a, "--")
|
||||
table.insert(a, "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON")
|
||||
if opts.conf_file then
|
||||
table.insert(a, "-DCONF_FILE=" .. opts.conf_file)
|
||||
end
|
||||
if #opts.overlays > 0 then
|
||||
table.insert(a, "-DDTC_OVERLAY_FILE=" .. table.concat(opts.overlays, ";"))
|
||||
end
|
||||
for _, e in ipairs(opts.extra_cmake or {}) do
|
||||
table.insert(a, e)
|
||||
end
|
||||
vim.list_extend(a, config_args(cfg))
|
||||
|
||||
local exec = require("hego.exec")
|
||||
local cmd = exec.ncs(opts, vim.list_extend({ "west" }, a))
|
||||
|
||||
return exec.run_async(cmd, {
|
||||
title = "hego://build",
|
||||
cwd = vim.fn.getcwd(),
|
||||
env = exec.zephyr_env(opts),
|
||||
on_exit = function(obj)
|
||||
if obj.code == 0 then
|
||||
require("hego.lsp").link(opts)
|
||||
require("hego.lsp").link(cfg)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user