invoke for toptica

This commit is contained in:
Stefan Liebl 2024-07-15 16:13:16 +02:00
parent 28916c67c5
commit d773bced94

View File

@ -143,14 +143,14 @@ function! s:ProjectSet(project_type, project_base_dir)
let s:use_invoke = v:true let s:use_invoke = v:true
set wildignore-=**/firmware/src/device-control/** set wildignore-=**/firmware/src/device-control/**
set wildignore+=**/shg-firmware/** set wildignore+=**/shg-firmware/**
" set titlestring=%<%t\ (%{expand('%:p:h')})%=compiler:\ %{Compiler_version()} set titlestring=%<%t\ (%{expand('%:p:h')})%=project:\ %{g:project_type}\ \ \ \ compiler:\ %{Compiler_version()}
let g:DeviceIP = 'dlc_pro__040083' let g:DeviceIP = 'dlc_pro__040083'
call s:set_oselas_gcc() call s:set_oselas_gcc()
let g:termdebugger = '/opt/OSELAS.Toolchain-2022.10.2/arm-v7a-linux-gnueabihf/gcc-12.3.1-glibc-2.33-binutils-2.39-kernel-5.4-sanitized/bin/arm-v7a-linux-gnueabihf-gdb' let g:termdebugger = '/opt/OSELAS.Toolchain-2022.10.2/arm-v7a-linux-gnueabihf/gcc-12.3.1-glibc-2.33-binutils-2.39-kernel-5.4-sanitized/bin/arm-v7a-linux-gnueabihf-gdb'
let g:DebugRemote = v:true let g:DebugRemote = v:true
command DlcproEmissionOn call s:DlcproEmission('1') command! DlcproEmissionOn call s:DlcproEmission('1')
command DlcproEmissionOff call s:DlcproEmission('0') command! DlcproEmissionOff call s:DlcproEmission('0')
command DlcproShutup call s:DlcproShutup() command! DlcproShutup call s:DlcproShutup()
elseif (g:project_type == 'dlcpro-old') elseif (g:project_type == 'dlcpro-old')
let s:Program = '/device-control/device-control' let s:Program = '/device-control/device-control'
let s:Elffile = s:Program let s:Elffile = s:Program
@ -166,9 +166,9 @@ function! s:ProjectSet(project_type, project_base_dir)
let g:SshOpts = "" let g:SshOpts = ""
let g:SshOpts2 = "" let g:SshOpts2 = ""
call s:set_oselas_gcc() call s:set_oselas_gcc()
command DlcproEmissionOn call s:DlcproEmission('1') command! DlcproEmissionOn call s:DlcproEmission('1')
command DlcproEmissionOff call s:DlcproEmission('0') command! DlcproEmissionOff call s:DlcproEmission('0')
command DlcproShutup call s:DlcproShutup() command! DlcproShutup call s:DlcproShutup()
elseif ((g:project_type == 'dlcpro-tui') || (g:project_type == 'dlcpro-tui-simulator')) elseif ((g:project_type == 'dlcpro-tui') || (g:project_type == 'dlcpro-tui-simulator'))
let s:Program = '/user-interface/src/user-interface' let s:Program = '/user-interface/src/user-interface'
let s:Elffile = s:Program let s:Elffile = s:Program
@ -184,7 +184,7 @@ function! s:ProjectSet(project_type, project_base_dir)
let g:SshOpts2 = "" let g:SshOpts2 = ""
call s:set_oselas_gcc4() call s:set_oselas_gcc4()
" command DlcproTuiStart execute('!cd user-interface/src && ../../../build/user-interface/src/user-interface&') " command DlcproTuiStart execute('!cd user-interface/src && ../../../build/user-interface/src/user-interface&')
command DlcProTuiStart call s:DlcproTuiStart() command! DlcProTuiStart call s:DlcproTuiStart()
elseif (g:project_type == 'dlcpro-can') elseif (g:project_type == 'dlcpro-can')
let s:Program = '/canopen/can-updater' let s:Program = '/canopen/can-updater'
let s:Elffile = s:Program let s:Elffile = s:Program
@ -353,7 +353,7 @@ function! s:ProjectSet(project_type, project_base_dir)
let g:Program = g:ProjectBuildDir.s:Program let g:Program = g:ProjectBuildDir.s:Program
let g:Elffile = g:ProjectBuildDir.s:Elffile let g:Elffile = g:ProjectBuildDir.s:Elffile
endif endif
command! -complete=custom,GetAllMakeCompletions -nargs=* MakeCmd call s:Make('<args>', 0) command! -complete=customlist,GetAllMakeCompletions -nargs=* MakeCmd call s:Make('<args>', 0)
command! MakeTestBuild call s:MakeTestBuild() command! MakeTestBuild call s:MakeTestBuild()
command! -nargs=* Ctest call s:Ctest('<args>', 0) command! -nargs=* Ctest call s:Ctest('<args>', 0)
command! -nargs=* Ctest1 call s:Ctest1('<args>', 0) command! -nargs=* Ctest1 call s:Ctest1('<args>', 0)
@ -382,7 +382,11 @@ function! s:ProjectSet(project_type, project_base_dir)
function! s:DeviceFirmwareUpdate() function! s:DeviceFirmwareUpdate()
if s:use_invoke if s:use_invoke
execute "!invoke -e flash-and-run --target-ip ".g:DeviceIP let l:options = ' --project=dlcpro'
if g:new_compiler
let l:options .= ' --new-compiler'
endif
execute "!invoke -e flash-and-run --target-ip ".g:DeviceIP.l:options
elseif (g:project_type == 'dlcpro-can') elseif (g:project_type == 'dlcpro-can')
call s:DeviceUpdateProgramLinux() call s:DeviceUpdateProgramLinux()
elseif ((g:project_type == 'digifalc') || (g:project_type == 'servoboard') || (g:project_type == 'dl-motor') || (g:project_type == 'pfd')) elseif ((g:project_type == 'digifalc') || (g:project_type == 'servoboard') || (g:project_type == 'dl-motor') || (g:project_type == 'pfd'))
@ -421,9 +425,40 @@ endfunction
" ==== " ====
function! GetAllMakeCompletions(ArgLead, CmdLine, CursorPos) function! GetAllMakeCompletions(ArgLead, CmdLine, CursorPos)
if s:use_invoke if s:use_invoke
let l:makegoals = split(system('invoke targets')) let CmdList = split(a:CmdLine)
let l:invoke_targets = ['--target'] let makegoals = []
return join(l:makegoals + l:invoke_targets + glob(a:ArgLead.'*', 1, 1), "\n") let makegoals += split(system('invoke -c ~/tools/invoke/'.g:project_type.'/tasks --complete --'))
if len(CmdList) > 1
let last_goal = CmdList[-1]
if a:ArgLead[0] == '-' || a:ArgLead == '' && last_goal[0] == '-'
let last_goal = CmdList[-2]
let last_opt = CmdList[-1]
elseif a:ArgLead != '' && a:ArgLead[0] != '-' && len(CmdList) > 2
let last_goal = CmdList[-3]
let last_opt = CmdList[-2]
endif
" Expand option
if count(makegoals, last_goal) > 0
let makegoals += split(system('invoke -c ~/tools/invoke/'.g:project_type.'/tasks --complete -- '.last_goal.' -'))
endif
if exists('last_opt')
" Expand values of option
let helptext = systemlist('invoke -c ~/tools/invoke/'.g:project_type.'/tasks '.last_goal.' --help')
let i = match(helptext, last_opt)
if i > 0
let values = []
call substitute(helptext[i], '"\([^"]\+\)"', '\=add(values, submatch(1))', 'g')
if len(values) > 0
let makegoals += values
endif
endif
endif
endif
if a:ArgLead != ''
" Filter option if started to type
call filter(makegoals, 'v:val =~ "^'. a:ArgLead .'"')
endif
return makegoals
else else
return join(s:makegoals + s:makeopts + glob(a:ArgLead.'*', 1, 1), "\n") return join(s:makegoals + s:makeopts + glob(a:ArgLead.'*', 1, 1), "\n")
endif endif
@ -433,7 +468,7 @@ function! s:Make(args, async_mode)
call asyncrun#quickfix_toggle(10, 1) call asyncrun#quickfix_toggle(10, 1)
if s:use_invoke if s:use_invoke
" let l:makeprg = 'invoke -e build --project '.g:project_type " let l:makeprg = 'invoke -e build --project '.g:project_type
let l:makeprg = 'invoke -e build' let l:makeprg = 'invoke -c ~/tools/invoke/'.g:project_type.'/tasks -e build'
if g:new_compiler if g:new_compiler
let l:makeprg .= ' --new-compiler' let l:makeprg .= ' --new-compiler'
endif endif
@ -477,7 +512,7 @@ function! s:Cmake(options, async_mode)
let l:options .= ' --no-new-compiler' let l:options .= ' --no-new-compiler'
endif endif
execute '!echo "invoke cmake '.l:options.'"' execute '!echo "invoke cmake '.l:options.'"'
execute 'AsyncRun -mode='.a:async_mode.' -save=2 @ invoke -e cmake '.l:options execute 'AsyncRun -mode='.a:async_mode.' -save=2 @ invoke -c ~/tools/invoke/'.g:project_type.'/tasks -e cmake '.l:options
else else
if !isdirectory(g:ProjectBuildDir) if !isdirectory(g:ProjectBuildDir)
call mkdir(g:ProjectBuildDir) call mkdir(g:ProjectBuildDir)
@ -630,7 +665,7 @@ endfunction
function! s:DeviceStartGdbServer() function! s:DeviceStartGdbServer()
if (g:project_type == 'pfd') if (g:project_type == 'pfd')
call system('killall --quiet JLinkGDBServer') call system('killall --quiet JLinkGDBServer')
call s:Call_and_log('invoke -e jlink&') call s:Call_and_log('invoke -c ~/tools/invoke/'.g:project_type.'/tasks -e jlink&')
autocmd User TermdebugStopPost call system('killall --quiet JLinkGDBServer') autocmd User TermdebugStopPost call system('killall --quiet JLinkGDBServer')
sleep 1 sleep 1
elseif ((g:project_type == 'digifalc') || (g:project_type == 'servoboard') || (g:project_type == 'dl-motor')) elseif ((g:project_type == 'digifalc') || (g:project_type == 'servoboard') || (g:project_type == 'dl-motor'))
@ -690,14 +725,17 @@ endfunction
let g:DlcproBasePath = "/jenkins/workspace/pro--firmware_release_1.9.0-DCESJ5C5R577IG5QFEWTML22UFDDZCJDGFLMDA4DCD3V2ZAGVEJA/source/" let g:DlcproBasePath = "/jenkins/workspace/pro--firmware_release_1.9.0-DCESJ5C5R577IG5QFEWTML22UFDDZCJDGFLMDA4DCD3V2ZAGVEJA/source/"
function! s:DeviceDebug(attach) function! s:DeviceDebug(attach)
if s:use_invoke if s:use_invoke
if v:DebugRemote if g:DebugRemote
execute "!invoke -e gdb-server --target-ip=".g:DeviceIP execute "!invoke -c ~/tools/invoke/'.g:project_type.'/tasks -e gdb-server --target-ip=".g:DeviceIP
autocmd! User TermdebugStartPre
autocmd! User TermdebugStartPost autocmd! User TermdebugStartPost
autocmd! User TermdebugStopPost autocmd! User TermdebugStopPost
autocmd User TermdebugStartPost call term_sendkeys('',"source gdb-connect.txt\n") autocmd User TermdebugStartPost call term_sendkeys('',"cd .build/dlcpro-new\nsource ../../gdb-connect.txt\n")
autocmd User TermdebugStopPost call system('pkill --full gdbserver') autocmd User TermdebugStopPost call system('pkill --full gdbserver')
endif endif
Termdebug Termdebug
" Close Program window
execute '2hide'
else else
if (a:attach == 0) if (a:attach == 0)
" let r = s:DeviceFirmwareUpdate() " let r = s:DeviceFirmwareUpdate()