diff options
author | roel0 <roel.postelmans@altran.com> | 2018-03-19 21:55:59 +0100 |
---|---|---|
committer | roel0 <roel.postelmans@altran.com> | 2018-03-19 21:56:18 +0100 |
commit | c47b5fd4b8f9b7c08774e631dae60ca51c23e7c9 (patch) | |
tree | dc72fd5a25569679790d16cc0b471c203ac8ac0a /ale_linters/c | |
parent | 68b9399d4c4cdca8a29b5e6125d44779c52def81 (diff) | |
download | ale-c47b5fd4b8f9b7c08774e631dae60ca51c23e7c9.zip |
Automatically determine build flags by parsing 'make -n' output #1167
Diffstat (limited to 'ale_linters/c')
-rw-r--r-- | ale_linters/c/clang.vim | 11 | ||||
-rw-r--r-- | ale_linters/c/gcc.vim | 11 |
2 files changed, 18 insertions, 4 deletions
diff --git a/ale_linters/c/clang.vim b/ale_linters/c/clang.vim index 76803056..25d93715 100644 --- a/ale_linters/c/clang.vim +++ b/ale_linters/c/clang.vim @@ -3,20 +3,27 @@ call ale#Set('c_clang_executable', 'clang') call ale#Set('c_clang_options', '-std=c11 -Wall') +call ale#Set('c_gcc_parse_makefile', 0) function! ale_linters#c#clang#GetExecutable(buffer) abort return ale#Var(a:buffer, 'c_clang_executable') endfunction function! ale_linters#c#clang#GetCommand(buffer) abort - let l:paths = ale#c#FindLocalHeaderPaths(a:buffer) +let l:cflags = [] + if g:ale_c_parse_makefile + let l:cflags = join(ale#c#ParseMakefile(a:buffer), ' ') + endif + if empty(l:cflags) + let l:cflags = ale#c#IncludeOptions(ale#c#FindLocalHeaderPaths(a:buffer)) + endif " -iquote with the directory the file is in makes #include work for " headers in the same directory. return ale#Escape(ale_linters#c#clang#GetExecutable(a:buffer)) \ . ' -S -x c -fsyntax-only ' \ . '-iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) . ' ' - \ . ale#c#IncludeOptions(l:paths) + \ . l:cflags . ' ' \ . ale#Var(a:buffer, 'c_clang_options') . ' -' endfunction diff --git a/ale_linters/c/gcc.vim b/ale_linters/c/gcc.vim index 4b241e37..3ad243a3 100644 --- a/ale_linters/c/gcc.vim +++ b/ale_linters/c/gcc.vim @@ -3,20 +3,27 @@ call ale#Set('c_gcc_executable', 'gcc') call ale#Set('c_gcc_options', '-std=c11 -Wall') +call ale#Set('c_parse_makefile', 0) function! ale_linters#c#gcc#GetExecutable(buffer) abort return ale#Var(a:buffer, 'c_gcc_executable') endfunction function! ale_linters#c#gcc#GetCommand(buffer) abort - let l:paths = ale#c#FindLocalHeaderPaths(a:buffer) + let l:cflags = [] + if g:ale_c_parse_makefile + let l:cflags = join(ale#c#ParseMakefile(a:buffer), ' ') + endif + if empty(l:cflags) + let l:cflags = ale#c#IncludeOptions(ale#c#FindLocalHeaderPaths(a:buffer)) + endif " -iquote with the directory the file is in makes #include work for " headers in the same directory. return ale#Escape(ale_linters#c#gcc#GetExecutable(a:buffer)) \ . ' -S -x c -fsyntax-only ' \ . '-iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) . ' ' - \ . ale#c#IncludeOptions(l:paths) + \ . l:cflags . ' ' \ . ale#Var(a:buffer, 'c_gcc_options') . ' -' endfunction |