File: nvcc.vim

package info (click to toggle)
vim-syntastic 3.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,064 kB
  • ctags: 888
  • sloc: erlang: 52; sh: 41; python: 8; makefile: 2
file content (78 lines) | stat: -rw-r--r-- 2,696 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
"============================================================================
"File:        cuda.vim
"Description: Syntax checking plugin for syntastic.vim
"
"Author:      Hannes Schulz <schulz at ais dot uni-bonn dot de>
"
"============================================================================

" in order to also check header files add this to your .vimrc:
" (this creates an empty .syntastic_dummy.cu file in your source directory)
"
"   let g:syntastic_cuda_check_header = 1

" By default, nvcc and thus syntastic, defaults to the most basic architecture.
" This can produce false errors if the developer intends to compile for newer
" hardware and use newer features, eg. double precision numbers. To pass a
" specific target arch to nvcc, e.g. add the following to your .vimrc:
"
"   let g:syntastic_cuda_arch = "sm_20"

if exists("g:loaded_syntastic_cuda_nvcc_checker")
    finish
endif
let g:loaded_syntastic_cuda_nvcc_checker = 1

let s:save_cpo = &cpo
set cpo&vim

function! SyntaxCheckers_cuda_nvcc_GetLocList() dict
    if exists('g:syntastic_cuda_arch')
        let arch_flag = '-arch=' . g:syntastic_cuda_arch
    else
        let arch_flag = ''
    endif
    let makeprg =
        \ self.getExecEscaped() . ' ' . arch_flag .
        \ ' --cuda -O0 -I . -Xcompiler -fsyntax-only ' .
        \ syntastic#util#shexpand('%') . ' ' . syntastic#c#NullOutput()

    let errorformat =
        \ '%*[^"]"%f"%*\D%l: %m,'.
        \ '"%f"%*\D%l: %m,'.
        \ '%-G%f:%l: (Each undeclared identifier is reported only once,'.
        \ '%-G%f:%l: for each function it appears in.),'.
        \ '%f:%l:%c:%m,'.
        \ '%f(%l):%m,'.
        \ '%f:%l:%m,'.
        \ '"%f"\, line %l%*\D%c%*[^ ] %m,'.
        \ '%D%*\a[%*\d]: Entering directory `%f'','.
        \ '%X%*\a[%*\d]: Leaving directory `%f'','.
        \ '%D%*\a: Entering directory `%f'','.
        \ '%X%*\a: Leaving directory `%f'','.
        \ '%DMaking %*\a in %f,'.
        \ '%f|%l| %m'

    if expand('%') =~? '\m\%(.h\|.hpp\|.cuh\)$'
        if exists('g:syntastic_cuda_check_header')
            let makeprg =
                \ 'echo > .syntastic_dummy.cu ; ' .
                \ self.getExecEscaped() . ' ' . arch_flag .
                \ ' --cuda -O0 -I . .syntastic_dummy.cu -Xcompiler -fsyntax-only -include ' .
                \ syntastic#util#shexpand('%') . ' ' . syntastic#c#NullOutput()
        else
            return []
        endif
    endif

    return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
endfunction

call g:SyntasticRegistry.CreateAndRegisterChecker({
    \ 'filetype': 'cuda',
    \ 'name': 'nvcc'})

let &cpo = s:save_cpo
unlet s:save_cpo

" vim: set et sts=4 sw=4: