Skip to content

Commit 6f259b5

Browse files
committed
Merge branch 'master' into feature-add-kit-scanner
2 parents b71824b + 49f717d commit 6f259b5

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
@@ -352,6 +352,7 @@ function cmake.build(opt, callback)
352352
end
353353

354354
local presets_exists = config.base_settings.use_preset and Presets.exists(config.cwd)
355+
local use_build_preset = false
355356
if presets_exists then
356357
local presets = Presets:parse(config.cwd)
357358
if not config.build_preset then
@@ -371,9 +372,10 @@ function cmake.build(opt, callback)
371372
end
372373
if config.build_preset then
373374
local build_preset = presets:get_build_preset(config.build_preset)
374-
if build_preset then
375+
if build_preset and build_preset:is_valid() then
375376
config:update_build_target()
376377
config:update_build_type()
378+
use_build_preset = true
377379
end
378380
end
379381
end
@@ -391,7 +393,7 @@ function cmake.build(opt, callback)
391393

392394
local args
393395

394-
if presets_exists and config.build_preset then
396+
if use_build_preset then
395397
args = { "--build", "--preset", config.build_preset } -- preset don't need define build dir.
396398
else
397399
args = {
@@ -895,32 +897,29 @@ function cmake.select_build_preset(callback)
895897
callback(Result:new_error(Types.NOT_SELECT_PRESET, "No build preset selected"))
896898
return
897899
end
900+
898901
if config.build_preset ~= choice then
902+
config.build_preset = choice
903+
899904
local build_preset = presets:get_build_preset(choice)
900-
if build_preset:is_valid() then
901-
config.build_preset = choice
902905

903-
if build_preset then
904-
config:update_build_target()
906+
if build_preset and build_preset:is_valid() then
907+
config:update_build_target()
908+
909+
local associated_configure_preset =
910+
presets:get_configure_preset(build_preset.configurePreset, { include_hidden = true })
911+
local associated_configure_preset_name = associated_configure_preset
912+
and associated_configure_preset.name
913+
or nil
914+
915+
if
916+
associated_configure_preset_name
917+
and config.configure_preset ~= associated_configure_preset_name
918+
then
919+
config.configure_preset = associated_configure_preset_name
905920
end
906921
end
907922
end
908-
local associated_configure_preset = presets:get_configure_preset(
909-
presets:get_build_preset(choice).configurePreset,
910-
{ include_hidden = true }
911-
)
912-
local associated_configure_preset_name = associated_configure_preset
913-
and associated_configure_preset.name
914-
or nil
915-
local configure_preset_updated = false
916-
917-
if
918-
associated_configure_preset_name
919-
and config.configure_preset ~= associated_configure_preset_name
920-
then
921-
config.configure_preset = associated_configure_preset_name
922-
configure_preset_updated = true
923-
end
924923

925924
callback(Result:new(Types.SUCCESS, nil, nil))
926925
end)
@@ -1211,7 +1210,7 @@ function cmake.run_test(opt, callback)
12111210
return
12121211
end
12131212
if idx == 1 then
1214-
ctest.run(const.ctest_command, "'.*'", config:build_directory_path(), env, config, opt)
1213+
ctest.run(const.ctest_command, nil, config:build_directory_path(), env, config, opt)
12151214
else
12161215
ctest.run(
12171216
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)