Skip to content

Commit 49f717d

Browse files
authored
Merge pull request #1 from Civitasv/master
Backmerge Main
2 parents 88e07c6 + 16dfb08 commit 49f717d

5 files changed

Lines changed: 38 additions & 28 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ require("cmake-tools").setup {
159159
start_insert = false, -- If you want to enter terminal with :startinsert upon using :CMakeRun
160160
focus = false, -- Focus on terminal when cmake task is launched.
161161
do_not_add_newline = false, -- Do not hit enter on the command inserted when using :CMakeRun, allowing a chance to review or modify the command before hitting enter.
162+
use_shell_alias = false, -- Hide the verbose command wrapper by using a shell alias, showing only the program's output (currently not supported on Windows)
162163
},
163164
},
164165
},

lua/cmake-tools/init.lua

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ function cmake.build(opt, callback)
348348
end
349349

350350
local presets_exists = config.base_settings.use_preset and Presets.exists(config.cwd)
351+
local use_build_preset = false
351352
if presets_exists then
352353
local presets = Presets:parse(config.cwd)
353354
if not config.build_preset then
@@ -367,9 +368,10 @@ function cmake.build(opt, callback)
367368
end
368369
if config.build_preset then
369370
local build_preset = presets:get_build_preset(config.build_preset)
370-
if build_preset then
371+
if build_preset and build_preset:is_valid() then
371372
config:update_build_target()
372373
config:update_build_type()
374+
use_build_preset = true
373375
end
374376
end
375377
end
@@ -387,7 +389,7 @@ function cmake.build(opt, callback)
387389

388390
local args
389391

390-
if presets_exists and config.build_preset then
392+
if use_build_preset then
391393
args = { "--build", "--preset", config.build_preset } -- preset don't need define build dir.
392394
else
393395
args = {
@@ -868,32 +870,29 @@ function cmake.select_build_preset(callback)
868870
callback(Result:new_error(Types.NOT_SELECT_PRESET, "No build preset selected"))
869871
return
870872
end
873+
871874
if config.build_preset ~= choice then
875+
config.build_preset = choice
876+
872877
local build_preset = presets:get_build_preset(choice)
873-
if build_preset:is_valid() then
874-
config.build_preset = choice
875878

876-
if build_preset then
877-
config:update_build_target()
879+
if build_preset and build_preset:is_valid() then
880+
config:update_build_target()
881+
882+
local associated_configure_preset =
883+
presets:get_configure_preset(build_preset.configurePreset, { include_hidden = true })
884+
local associated_configure_preset_name = associated_configure_preset
885+
and associated_configure_preset.name
886+
or nil
887+
888+
if
889+
associated_configure_preset_name
890+
and config.configure_preset ~= associated_configure_preset_name
891+
then
892+
config.configure_preset = associated_configure_preset_name
878893
end
879894
end
880895
end
881-
local associated_configure_preset = presets:get_configure_preset(
882-
presets:get_build_preset(choice).configurePreset,
883-
{ include_hidden = true }
884-
)
885-
local associated_configure_preset_name = associated_configure_preset
886-
and associated_configure_preset.name
887-
or nil
888-
local configure_preset_updated = false
889-
890-
if
891-
associated_configure_preset_name
892-
and config.configure_preset ~= associated_configure_preset_name
893-
then
894-
config.configure_preset = associated_configure_preset_name
895-
configure_preset_updated = true
896-
end
897896

898897
callback(Result:new(Types.SUCCESS, nil, nil))
899898
end)
@@ -1184,7 +1183,7 @@ function cmake.run_test(opt, callback)
11841183
return
11851184
end
11861185
if idx == 1 then
1187-
ctest.run(const.ctest_command, "'.*'", config:build_directory_path(), env, config, opt)
1186+
ctest.run(const.ctest_command, nil, config:build_directory_path(), env, config, opt)
11881187
else
11891188
ctest.run(
11901189
const.ctest_command,

lua/cmake-tools/presets.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ function Presets:parse(cwd)
125125
preset = createPreset(preset)
126126
end
127127

128-
for _, build_preset in ipairs(instance.buildPresets or {}) do
128+
instance.buildPresets = instance.buildPresets or {}
129+
for _, build_preset in ipairs(instance.buildPresets) do
129130
build_preset = createBuildPreset(build_preset)
130131
end
131132

lua/cmake-tools/test/ctest.lua

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,14 @@ function ctest.run(ctest_command, test_name, build_dir, env, config, opt)
3838
local cmd = ctest_command
3939
opt = opt or {}
4040

41-
local args = { "--test-dir", utils.transform_path(build_dir), "-R", test_name, opt.args }
41+
local args = { "--test-dir", utils.transform_path(build_dir) }
42+
if test_name then
43+
table.insert(args, "-R")
44+
table.insert(args, test_name)
45+
end
46+
if opt.args then
47+
table.insert(args, opt.args)
48+
end
4249
utils.run(cmd, config.env_script, env, args, config.cwd, config.runner, nil)
4350
end
4451

lua/cmake-tools/vimux.lua

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
local terminal = require("cmake-tools.terminal")
21
local osys = require("cmake-tools.osys")
32
local utils = require("cmake-tools.utils")
4-
---@class vimux : terminal
3+
4+
---@class vimux : executor, runner
55
local _vimux = {
66
id = nil,
77
}
@@ -17,7 +17,9 @@ end
1717
function _vimux.run(cmd, env_script, env, args, cwd, opts, on_exit, on_output)
1818
local full_cmd = _vimux.prepare_cmd_for_run(cmd, env, args, cwd)
1919
vim.fn.VimuxRunCommand(full_cmd)
20-
terminal.handle_exit(opts, on_exit, opts.close_on_exit)
20+
if type(on_exit) == "function" then
21+
on_exit(0) -- vimux does not provide exit codes, assume success
22+
end
2123
end
2224

2325
function _vimux.has_active_job(opts)

0 commit comments

Comments
 (0)