Skip to content

Commit

Permalink
presets: no expand build dir
Browse files Browse the repository at this point in the history
  • Loading branch information
Civitasv committed Jun 11, 2024
1 parent 56b448e commit 09bd614
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions lua/cmake-tools/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ function Config:has_build_directory()
return self.build_directory and self.build_directory:exists()
end

---comment
---The reason for storing no expand build directory is to make cwd selecting easier
function Config:no_expand_build_directory_path()
return self.base_settings.build_dir
end
Expand Down
4 changes: 2 additions & 2 deletions lua/cmake-tools/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ function cmake.generate(opt, callback)
if presets_file and config.configure_preset then
-- if exsist preset file and set configure preset, then
-- set build directory to the `binaryDir` option of `configurePresets`
local build_directory = presets.get_build_dir(
local build_directory, no_expand_build_directory = presets.get_build_dir(
presets.get_preset_by_name(config.configure_preset, "configurePresets", config.cwd),
config.cwd
)
if build_directory ~= "" then
config:update_build_dir(build_directory, build_directory)
config:update_build_dir(build_directory, no_expand_build_directory)
end
config:generate_build_directory()

Expand Down
3 changes: 2 additions & 1 deletion lua/cmake-tools/presets.lua
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ function presets.get_build_dir(preset, cwd)
end

local build_dir = helper(preset)
local no_expand_build_dir = build_dir

-- macro expansion
local source_path = Path:new(cwd)
Expand All @@ -245,7 +246,7 @@ function presets.get_build_dir(preset, cwd)

build_dir = vim.fn.fnamemodify(build_dir, ":.")

return build_dir
return build_dir, no_expand_build_dir
end

return presets

0 comments on commit 09bd614

Please sign in to comment.