|
| 1 | +function! Build(native) abort |
| 2 | + let python = (g:spacevim.os.windows ? 'python ' : './') |
| 3 | + call system(python.a:native.plugpath.'/src/bootstrap/configure.py '. |
| 4 | + \ '--prefix='.a:native.plugpath.'/install --bindir=bin --libdir=lib'. |
| 5 | + \ ' --sysconfdir=. --disable-docs') |
| 6 | + |
| 7 | + if filereadable('config.toml') |
| 8 | + " profile=user setting unsupported through configure.py interface |
| 9 | + execute ':tabnew +%s/\\V\#profile\ \=\ \<none\>/profile\ \=\ \"user\"/e|up config.toml' |
| 10 | + call spacevim#util#info('Edit config.toml rustc configuration if desired...') |
| 11 | + endif |
| 12 | + |
| 13 | + call execute('AsyncRun -cwd='.a:native.plugpath.'/build -mode=term '. |
| 14 | + \ '-pos=tab -post='. |
| 15 | + \ 'call\ spacevim\#vim\#plug\#PostBuild(code,\ ''rust'') @ '. |
| 16 | + \ python.'x.py build && '.python.'x.py install') |
| 17 | +endfunction |
| 18 | + |
| 19 | +function! PostBuild(native) abort |
| 20 | + "TODO: Comment? |
| 21 | + "call delete('library', 'rf') |
| 22 | + "call delete('Makefile') |
| 23 | + "call delete('src', 'rf') |
| 24 | + " Install rg and fd tools if not on system |
| 25 | + if executable('rg') != 1 |
| 26 | + call spacevim#vim#plug#post_update('', 'cargo install --locked ripgrep') |
| 27 | + endif |
| 28 | + if executable('fd') != 1 |
| 29 | + call spacevim#vim#plug#post_update('', 'cargo install --locked fd-find') |
| 30 | + endif |
| 31 | + if executable('delta') != 1 |
| 32 | + call spacevim#vim#plug#post_update('', 'cargo install --locked git-delta') |
| 33 | + endif |
| 34 | + if executable('bat') != 1 |
| 35 | + call spacevim#vim#plug#post_update('', 'cargo install --locked bat') |
| 36 | + endif |
| 37 | +endfunction |
| 38 | + |
| 39 | +let g:spacevim#vim#plug#native_dependency = get(g:, 'spacevim#vim#plug#native_dependency', {}) |
| 40 | +let g:spacevim#vim#plug#native_dependency['rust'] = { |
| 41 | + \ 'bin': 'rustc', |
| 42 | + \ 'override': '$RUSTC', |
| 43 | + \ 'repo': 'rust-lang/rust', |
| 44 | + \ 'vregex': '\Vrustc \(\[0-9]\+\).\(\[0-9]\+\).\(\[0-9]\+\)', |
| 45 | + \ 'v_req': [1, 56, 0], |
| 46 | + \ 'Build': function('Build'), |
| 47 | + \ 'PostBuild': function('PostBuild'), |
| 48 | +\ } |
0 commit comments