|
| 1 | +" Need to add libyaml/install/lib to LD_LIBRARY_PATH for ctags runtime |
| 2 | +" but dein doesn't manage plugpath once built, so look at state |
| 3 | +" For spacevim#vim#plug#LocateDependency in packages.vim and cache.vim |
| 4 | +let f = g:spacevim.state_base.'libyaml_state' |
| 5 | +if filereadable(f) |
| 6 | + let p = readfile(f) |
| 7 | + if len(p) > 0 |
| 8 | + if match($LD_LIBRARY_PATH, '\V'.p[0]) == -1 |
| 9 | + let $LD_LIBRARY_PATH .= (empty($LD_LIBRARY_PATH) ? '' : |
| 10 | + \ spacevim#util#PathEnvSep()).p[0] |
| 11 | + endif |
| 12 | + endif |
| 13 | +endif |
| 14 | + |
| 15 | +function! BuildCtags(native) abort |
| 16 | + if executable('rst2man') != 1 |
| 17 | + call spacevim#util#info('Unable to build ctags man pages unless '. |
| 18 | + \ 'rst2man in python3-docutils is installed.') |
| 19 | + endif |
| 20 | + |
| 21 | + if a:native.posix_compiler |
| 22 | + execute 'tcd' a:native.plugpath |
| 23 | + let autoconf_log = a:native.temppath.'/ctags_autoconf.log' |
| 24 | + call system('./autogen.sh > '.autoconf_log) |
| 25 | + call rename(autoconf_log, a:native.plugpath.'/autoconf.log') |
| 26 | + |
| 27 | + execute 'tcd build' |
| 28 | + let configure_log = a:native.temppath.'/ctags_configure.log' |
| 29 | + call system(a:native.plugpath.'/configure --enable-yaml --prefix='. |
| 30 | + \ a:native.plugpath.'/install > '.configure_log) |
| 31 | + call rename(configure_log, a:native.plugpath.'/configure.log') |
| 32 | + call execute('AsyncRun -cwd='.a:native.plugpath.'/build '. |
| 33 | + \ '-mode=term -pos=tab -program=make -post='. |
| 34 | + \ 'call\ spacevim\#vim\#plug\#PostBuild(code,\ ''ctags'') @ '. |
| 35 | + \ 'install'.a:native.jobs_flag) |
| 36 | + endif |
| 37 | +endfunction |
| 38 | + |
| 39 | +function! PostBuildCtags(native) abort |
| 40 | + call delete('autom4te.cache', 'rf') |
| 41 | + call delete('gnulib', 'rf') |
| 42 | + call delete('man', 'rf') |
| 43 | + call delete('aclocal.m4') |
| 44 | + call delete('config.guess') |
| 45 | + call delete('config.h.in') |
| 46 | + call delete('config.h.in~') |
| 47 | + call delete('config.sub') |
| 48 | + call delete('configure') |
| 49 | + call delete('depcomp') |
| 50 | + call delete('install-sh') |
| 51 | + call delete('last-aclocal.m4') |
| 52 | + call delete('Makefile.in') |
| 53 | + call delete('missing') |
| 54 | +endfunction |
| 55 | + |
| 56 | +function! BuildYaml(native) abort |
| 57 | + if executable('autoconf') != 1 |
| 58 | + call spacevim#util#info('Unable to build libyaml, requires'. |
| 59 | + \ ' autoconf. After rectifying try `:call '. |
| 60 | + \ 'dein#get(''libyaml'').hook_post_update()`') |
| 61 | + else |
| 62 | + if a:native.posix_compiler |
| 63 | + execute 'tcd' a:native.plugpath |
| 64 | + let autoconf_log = a:native.temppath.'/libyaml_autoconf.log' |
| 65 | + call system('./bootstrap > '.autoconf_log) |
| 66 | + call rename(autoconf_log, a:native.plugpath.'/autoconf.log') |
| 67 | + |
| 68 | + execute 'tcd build' |
| 69 | + let configure_log = a:native.temppath.'/libyaml_configure.log' |
| 70 | + call system(a:native.plugpath.'/configure --prefix='. |
| 71 | + \ a:native.plugpath.'/install > '.configure_log) |
| 72 | + call rename(configure_log, a:native.plugpath.'/configure.log') |
| 73 | + call execute('AsyncRun -cwd='.a:native.plugpath.'/build '. |
| 74 | + \ '-mode=term -pos=tab -program=make -post='. |
| 75 | + \ 'call\ spacevim\#vim\#plug\#PostBuild(code,\ ''libyaml'') @ '. |
| 76 | + \ 'install'.a:native.jobs_flag) |
| 77 | + endif |
| 78 | + endif |
| 79 | +endfunction |
| 80 | + |
| 81 | +function! PostBuildYaml(native) abort |
| 82 | + if a:native.posix_compiler |
| 83 | + " And PKG_CONFIG_PATH so that ctags configure can find libyaml |
| 84 | + " And LD_LIBRARY_PATH so that library can be found at runtime |
| 85 | + let ps = spacevim#util#PathSep() |
| 86 | + let eps = spacevim#util#PathEnvSep() |
| 87 | + let l = a:native.plugpath.ps.'install'.ps.'lib' |
| 88 | + let $PKG_CONFIG_PATH .= (empty($PKG_CONFIG_PATH) ? '' : eps).l.'/pkgconfig' |
| 89 | + let $LD_LIBRARY_PATH .= (empty($LD_LIBRARY_PATH) ? '' : eps).l |
| 90 | + " Put into a statefile so that it can be loaded before version check |
| 91 | + let f = g:spacevim.state_base.'libyaml_state' |
| 92 | + call writefile([l], f, 'S') |
| 93 | + endif |
| 94 | + call delete('autom4te.cache', 'rf') |
| 95 | + call delete('config', 'rf') |
| 96 | + call delete('include', 'rf') |
| 97 | + call delete('src', 'rf') |
| 98 | + call delete('tests', 'rf') |
| 99 | + call delete('aclocal.m4') |
| 100 | + call delete('configure') |
| 101 | + call delete('Makefile.in') |
| 102 | + " Can't rely on dein to wait for libyaml to build to then build ctags |
| 103 | + execute 'tcd' a:native.cwd |
| 104 | + call spacevim#vim#plug#Build('ctags') |
| 105 | +endfunction |
| 106 | + |
| 107 | +let g:spacevim#vim#plug#native_dependency = get(g:, |
| 108 | + \ 'spacevim#vim#plug#native_dependency', {}) |
| 109 | + " Unfortunately plugin built ctags doesn't include YYYYMMDD versioning |
| 110 | + "\ vregex: '\V\%(p\)\@<=\(\[0-9]\+\).\(\[0-9]\+\).\(\[0-9]\{4}\)'. |
| 111 | + " \ '\(\[0-9]\{2}\)\(\[0-9]\{2}\)', |
| 112 | + "\ v_req: [5, 9, 2022, 8, 7], |
| 113 | +let g:spacevim#vim#plug#native_dependency['ctags'] = { |
| 114 | + \ 'bin': 'ctags', |
| 115 | + \ 'repo': 'universal-ctags/ctags', |
| 116 | + \ 'vregex': '\V\^Universal Ctags \(\[0-9]\+\).\(\[0-9]\+\).\(\[0-9]\+\)(', |
| 117 | + \ 'v_req': [5, 9, 0], |
| 118 | + \ 'feature_req': ['--list-features', '\V\nyaml'], |
| 119 | + \ 'Build': function('BuildCtags'), |
| 120 | + \ 'PostBuild': function('PostBuildCtags'), |
| 121 | +\ } |
| 122 | +let g:spacevim#vim#plug#native_dependency['libyaml'] = { |
| 123 | + \ 'repo': 'yaml/libyaml', |
| 124 | + \ 'Build': function('BuildYaml'), |
| 125 | + \ 'PostBuild': function('PostBuildYaml'), |
| 126 | +\ } |
0 commit comments