Skip to content

Commit

Permalink
Clap install-binary: ensure compiling the binary using specified ru…
Browse files Browse the repository at this point in the history
…st version

Close #1111
  • Loading branch information
liuchengxu committed Jan 26, 2025
1 parent 1d1810e commit 662c963
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion autoload/clap/client.vim
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ endfunction
function! clap#client#notify(method, ...) abort
if clap#job#daemon#is_running()
if exists('s:enqueued_messages')
for [method, params] in items(s:enqueued_messages)
for [method, params] in s:enqueued_messages
call clap#rpc#notify(method, params)
endfor
unlet s:enqueued_messages
Expand Down
17 changes: 16 additions & 1 deletion autoload/clap/installer.vim
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,22 @@ endfunction

function! clap#installer#build_maple() abort
if executable('cargo')
let cmd = 'cargo build --release'
let rust_version = ''
for line in readfile(s:plugin_root_dir.'/rust-toolchain.toml')
" Extract the rust version from the channel line
if line =~ '^channel\s*=\s*".*"$'
let rust_version = matchstr(line, '"\zs.*\ze"')
break
endif
endfor

if empty(rust_version)
call clap#helper#echo_error('Could not determine Rust version from rust-toolchain.toml.')
return
endif

let cmd = printf('cargo +%s build --release', rust_version)

call s:run_term(cmd, s:plugin_root_dir, 'built maple binary successfully', {-> clap#helper#echo_warn('build maple failed')})
else
call clap#helper#echo_error('Can not build maple binary in that cargo is not found.')
Expand Down

0 comments on commit 662c963

Please sign in to comment.