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
+76
-9
@@ -3,15 +3,27 @@ local M = {}
|
||||
M.defaults = {
|
||||
ncs_root = vim.fn.expand("~/ncs"),
|
||||
toolchains_root = vim.fn.expand("~/ncs/toolchains"),
|
||||
ncs_version = nil, -- nil = autodetectar (p.ej. "v3.4.0")
|
||||
toolchain_dir = nil, -- nil = autodetectar
|
||||
board = nil, -- nil = leer de build/CMakeCache.txt
|
||||
ncs_version = nil,
|
||||
toolchain_dir = nil,
|
||||
board = nil,
|
||||
build_dir = "build",
|
||||
conf_file = "prj.conf",
|
||||
sysbuild = true,
|
||||
overlays = {}, -- { "boards/nrf54l15dk_nrf54l15_cpuapp.overlay" }
|
||||
extra_cmake = {}, -- { "-DCONFIG_DEBUG_THREAD_INFO=y" }
|
||||
keys = { build = "<leader>nb", pristine = "<leader>np", flash = "<leader>nf" },
|
||||
overlays = {},
|
||||
extra_cmake = {},
|
||||
keys = {
|
||||
build = "<leader>nb",
|
||||
pristine = "<leader>np",
|
||||
flash = "<leader>nf",
|
||||
flash_erase = "<leader>nE",
|
||||
flash_recover = "<leader>nR",
|
||||
device_recover = "<leader>nD",
|
||||
kconfig = "<leader>nk",
|
||||
memory = "<leader>nm",
|
||||
config = "<leader>nc",
|
||||
build_config = "<leader>nB",
|
||||
monitor = "<leader>nt",
|
||||
},
|
||||
}
|
||||
|
||||
M.options = {}
|
||||
@@ -37,12 +49,67 @@ function M.setup(opts)
|
||||
return o
|
||||
end
|
||||
|
||||
-- API que consumen keymaps y comandos de usuario
|
||||
function M.build(pristine)
|
||||
return require("hego.west").build(M.options, pristine)
|
||||
end
|
||||
function M.flash()
|
||||
return require("hego.flash").run(M.options)
|
||||
|
||||
--- mode: nil/"flash" | "erase" | "recover"
|
||||
function M.flash(mode)
|
||||
return require("hego.flash").run(M.options, mode)
|
||||
end
|
||||
|
||||
function M.device_recover()
|
||||
return require("hego.flash").device_recover(M.options)
|
||||
end
|
||||
|
||||
function M.kconfig()
|
||||
return require("hego.targets").run(M.options, "menuconfig", "hego://menuconfig")
|
||||
end
|
||||
|
||||
function M.memory_report()
|
||||
return require("hego.targets").memory(M.options)
|
||||
end
|
||||
|
||||
function M.monitor()
|
||||
return require("hego.monitor").run(M.options)
|
||||
end
|
||||
|
||||
function M.edit_config()
|
||||
local Config = require("hego.config")
|
||||
|
||||
if vim.fn.filereadable(Config.path) == 0 then
|
||||
Config.save({
|
||||
version = 1,
|
||||
configs = { default = Config.seed(M.options) },
|
||||
})
|
||||
vim.notify("[hego] creado " .. Config.path .. " (sembrado desde tus opts)", vim.log.levels.INFO)
|
||||
end
|
||||
|
||||
vim.cmd.edit(vim.fn.fnamemodify(Config.path, ":p"))
|
||||
end
|
||||
|
||||
function M.build_from_config(pristine)
|
||||
local Config = require("hego.config")
|
||||
local data = Config.load()
|
||||
local names = vim.tbl_keys(data.configs)
|
||||
|
||||
if #names == 0 then
|
||||
vim.notify("[hego] no hay configs en " .. Config.path .. " (usa <leader>nc)", vim.log.levels.WARN)
|
||||
return
|
||||
end
|
||||
table.sort(names)
|
||||
|
||||
vim.ui.select(names, {
|
||||
prompt = "Construir con configuración",
|
||||
format_item = function(n)
|
||||
return n
|
||||
end,
|
||||
}, function(choice)
|
||||
if not choice then
|
||||
return
|
||||
end
|
||||
require("hego.west").build(M.options, pristine, Config.normalize(data.configs[choice]))
|
||||
end)
|
||||
end
|
||||
|
||||
return M
|
||||
Reference in new issue
Block a user