-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Refine the helper function fo building Rust dep #202
Merged
+49
−19
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
bd0b9d9
Skip building python dynamic module if no +python3
liuchengxu 27655d9
Check Rust nightly
liuchengxu c68eff4
Skip building python dynamic module when calling build_all but Rust
liuchengxu 870832d
.
liuchengxu 89afa8a
.
liuchengxu 0fb0198
.
liuchengxu e9c8ab8
.
liuchengxu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,35 +102,61 @@ else | |
let s:rust_ext_cwd = fnamemodify(g:clap#autoload_dir, ':h').'/pythonx/clap' | ||
endif | ||
|
||
function! clap#helper#build_rust_ext() abort | ||
function! s:has_rust_nightly(show_warning) abort | ||
call system('cargo +nightly --help') | ||
if v:shell_error | ||
if a:show_warning | ||
call clap#helper#echo_warn('Rust nightly is required, try running `rustup toolchain install nightly` in the command line and then rerun this function.') | ||
else | ||
call clap#helper#echo_info('Rust nightly is required, skip building the Python dynamic module.') | ||
endif | ||
return v:false | ||
endif | ||
return v:true | ||
endfunction | ||
|
||
function! clap#helper#build_python_dynamic_module() abort | ||
if !has('python3') | ||
call clap#helper#echo_info('+python3 is required, skip building the Python dynamic module.') | ||
return | ||
endif | ||
|
||
if executable('cargo') | ||
call s:run_term(s:rust_ext_cmd, s:rust_ext_cwd, 'build Rust extension successfully') | ||
if !s:has_rust_nightly(v:true) | ||
return | ||
endif | ||
call s:run_term(s:rust_ext_cmd, s:rust_ext_cwd, 'build Python dynamic module successfully') | ||
else | ||
call clap#helper#echo_error('Can not build Rust extension in that cargo is not found.') | ||
call clap#helper#echo_error('Can not build Python dynamic module in that cargo is not found.') | ||
endif | ||
endfunction | ||
|
||
function! clap#helper#build_maple() abort | ||
if executable('cargo') | ||
let cmd = 'cargo build --release' | ||
let cwd = fnamemodify(g:clap#autoload_dir, ':h') | ||
call s:run_term(cmd, cwd, 'build maple successfully') | ||
call s:run_term(cmd, cwd, 'build maple binary successfully') | ||
else | ||
call clap#helper#echo_error('Can not build maple in that cargo is not found.') | ||
call clap#helper#echo_error('Can not build maple binary in that cargo is not found.') | ||
endif | ||
endfunction | ||
|
||
function! clap#helper#build_all(...) abort | ||
if executable('cargo') | ||
let cwd = fnamemodify(g:clap#autoload_dir, ':h') | ||
if has('win32') | ||
let cmd = printf('cargo build --release && cd /d %s && %s', s:rust_ext_cwd, s:rust_ext_cmd) | ||
" If Rust nightly and +python3 is unavailable, build the maple only. | ||
if has('python3') && s:has_rust_nightly(v:false) | ||
let cwd = fnamemodify(g:clap#autoload_dir, ':h') | ||
if has('win32') | ||
let cmd = printf('cargo build --release && cd /d %s && %s', s:rust_ext_cwd, s:rust_ext_cmd) | ||
else | ||
let cmd = 'make' | ||
endif | ||
call s:run_term(cmd, cwd, 'build maple binary and Python dynamic module successfully') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. built* |
||
else | ||
let cmd = 'make' | ||
call clap#helper#build_maple() | ||
endif | ||
call s:run_term(cmd, cwd, 'build maple and Rust extension successfully') | ||
else | ||
call clap#helper#echo_warn('cargo not found, skipped building maple and the Rust extension.') | ||
call clap#helper#echo_warn('cargo not found, skipped building maple binary and Python dynamic module.') | ||
endif | ||
endfunction | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
built*
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, will fix that later.