Compare commits

...

4 Commits

Author SHA1 Message Date
ff496a6a7f Update flog 2025-03-19 09:15:13 +01:00
f9946dc806 rename Make -> Invoke 2025-03-19 09:14:50 +01:00
ab7c371331 Reorder toptica.vim 2025-03-10 10:12:15 +01:00
0b46c3a932 toptica.vim 2025-02-24 09:57:20 +01:00
2 changed files with 97 additions and 149 deletions

@ -1 +1 @@
Subproject commit 6289ab2e237ceeefdbcc7eb584b63d144bf88d94 Subproject commit 77c86cb5db8960d224f2a866120893e61d62f5e8

View File

@ -18,91 +18,87 @@ command -nargs=? -complete=dir DeCoF call s:ProjectSet('decof', '<args>')
command DeviceFirmwareUpdate call s:DeviceFirmwareUpdate() command DeviceFirmwareUpdate call s:DeviceFirmwareUpdate()
command -nargs=? -complete=file JenkinsLinter call s:Jenkins_linter('<args>') command -nargs=? -complete=file JenkinsLinter call s:Jenkins_linter('<args>')
set titlestring= " set titlestring=
function! s:ProjectSet(project_type, project_base_dir) " Get titlestring for DLCpro
execute "DirenvExport" function! g:Title_string()
let g:project_type = a:project_type
let g:jenkins_url = 'http://jenkins.toptica.com'
" directories let titlestring = ''
if a:project_base_dir != '' if exists('g:project_type')
if (isdirectory(fnamemodify(a:project_base_dir, ':p:h:h').'/src')) let titlestring .= ' project: '.g:project_type
let s:ProjectBaseDir = fnamemodify(a:project_base_dir, ':p:h:h') endif
elseif (isdirectory(fnamemodify(a:project_base_dir, ':p:h').'/src'))
let s:ProjectBaseDir = fnamemodify(a:project_base_dir, ':p:h') if exists('g:ProjectBuildDir')
else let cmakefile = g:ProjectBuildDir . '/CMakeCache.txt'
let s:ProjectBaseDir = fnamemodify(a:project_base_dir, ':p') if filereadable(cmakefile)
endif let titlestring .= ' compiler: '
else for line in readfile(cmakefile)
" defaults if match(line, 'NEW_COMPILER:BOOL=OFF') >= 0
if (g:project_type == 'dlcpro-new') let titlestring .= 'old'
let s:ProjectBaseDir = '/home/stefan/dlcpro/firmware' elseif match(line, 'NEW_COMPILER:BOOL=ON') >= 0
elseif (g:project_type == 'dlcpro') let titlestring .= 'new'
let s:ProjectBaseDir = '/home/stefan/dlcpro/firmware' endif
elseif (g:project_type == 'dlcpro-tui') endfor
let s:ProjectBaseDir = '/home/stefan/dlcpro/firmware'
elseif (g:project_type == 'dlcpro-tui-simulator')
let s:ProjectBaseDir = '/home/stefan/dlcpro/firmware.tui-simulator'
elseif (g:project_type == 'dlcpro-can')
let s:ProjectBaseDir = '/home/stefan/dlcpro/firmware'
elseif (g:project_type == 'shg')
let s:ProjectBaseDir = '/home/stefan/dlcpro/shg-firmware'
elseif (g:project_type == 'dlcpro-gui')
let s:ProjectBaseDir = '/home/stefan/dlcpro/pc-gui'
elseif (g:project_type == 'topmode')
let s:ProjectBaseDir = '/home/stefan/topmode/firmware'
elseif (g:project_type == 'topmode-gui')
let s:ProjectBaseDir = '/home/stefan/topmode/pc-gui'
elseif (g:project_type == 'digifalc')
let s:ProjectBaseDir = '/home/stefan/dlcpro/falc/firmware'
elseif (g:project_type == 'servoboard')
let s:ProjectBaseDir = '/home/stefan/dlcpro/mta/firmware'
elseif (g:project_type == 'dl-motor')
let s:ProjectBaseDir = '/home/stefan/dlcpro/dl-motor'
elseif (g:project_type == 'pfd')
let s:ProjectBaseDir = '/home/stefan/dlcpro/pfd/firmware'
else
echo "no project"
endif endif
endif endif
let g:ProjectSrcDirRel = 'src' return titlestring
let s:ProjectSrcDir = s:ProjectBaseDir.'/'.g:ProjectSrcDirRel endfunction
function! s:ProjectSet(project_type, project_base_dir)
set spell spelllang=en,de
set expandtab
set cinoptions=l1,g2,h2,N-2,t0,+0,(0,w1,Ws,m1,)100,*100
set textwidth=120
let $QT_FONT_DPI=96 " Size for qt-application in debugger
let g:project_type = a:project_type
let g:jenkins_url = 'http://jenkins.toptica.com'
let s:ProjectBaseDir = fnamemodify(a:project_base_dir, ":p")
" Direnv " Direnv
execute "DirenvExport"
let $DIRENV_DIR = s:ProjectBaseDir let $DIRENV_DIR = s:ProjectBaseDir
" vim path " vim path
execute 'cd '.s:ProjectSrcDir execute 'cd '.s:ProjectBaseDir
execute 'set path-=./**' execute 'set path-=./**'
execute 'set path+=' . s:ProjectSrcDir.'/**' execute 'set path+='.s:ProjectBaseDir.'**'
" Settings for invoke development " Settings for invoke
let s:invoke = 'invoke' let s:invoke = 'invoke'
let s:tasks_file_dev = '/home/stefan/tools/invoke/'.g:project_type.'/tasks.py' let s:tasks_file_dev = '~/tools/invoke/'.g:project_type.'/tasks.py'
if filereadable(s:tasks_file_dev) command! TasksLoad call system('cp '.s:tasks_file_dev.' tasks.py') " copy development version to project
call system('cp '.s:tasks_file_dev.' tasks.py') " copy development version to project command! TasksSave call system('cp tasks.py '.s:tasks_file_dev) " copy project version to development
elseif filereadable('tasks.py') " Tab-completion for invoke is done with plugin vim-bash-completion
" do nothing let $BASH_COMPLETION_DIR = '/home/liebl/.invoke'
else let invoke_completion_file = $BASH_COMPLETION_DIR.'/bash_completion'
echoerr 'tasks.py not found' if !filereadable(invoke_completion_file)
call system('invoke --print-completion-script bash > '.invoke_completion_file)
endif endif
" python tags
" execute "set tags+=" . s:ProjectBaseDir . '/tags'
" ==== " configure quickfix window for asyncrun
" Make augroup QuickfixStatus
" ==== autocmd BufWinEnter quickfix setlocal
\ statusline=%t\ [%{g:asyncrun_status}]\ %{exists('w:quickfix_title')?\ '\ '.w:quickfix_title\ :\ ''}\ %=%-15(%l,%c%V%)\ %P
augroup END
function! s:getDefaultforOption(option_name) " ======
" Invoke
" ======
compiler gcc
let g:BuildType = 'Debug'
function! s:getDefaultValueForOption(option_name)
if a:option_name == '--project' if a:option_name == '--project'
return g:project_type return g:project_type
elseif a:option_name == '--device-ip' elseif a:option_name == '--device-ip'
return g:DeviceIP return g:DeviceIP
elseif a:option_name == '--build-type' elseif a:option_name == '--build-type'
return g:BuildType return g:BuildType
elseif a:option_name == '--version-file'
return g:ProjectBuildDir.'/artifacts/VERSION'
elseif a:option_name == '--laser1-type' elseif a:option_name == '--laser1-type'
return g:DeviceType return g:DeviceType
elseif a:option_name == '--powerswitch-ip' elseif a:option_name == '--powerswitch-ip'
@ -114,8 +110,8 @@ function! s:ProjectSet(project_type, project_base_dir)
endif endif
endfunction endfunction
" Add default value for all given options, if not already set " Add default value for all available options, if not already set
function! s:SetDefaults(commandline) function! s:SetDefaultsForAllOptions(commandline)
let commandline = a:commandline let commandline = a:commandline
let task = split(commandline)[0] let task = split(commandline)[0]
@ -124,7 +120,7 @@ function! s:ProjectSet(project_type, project_base_dir)
if l:tasks =~ task if l:tasks =~ task
let l:options_allowed = system(s:invoke.' --complete -- '.task.' -') let l:options_allowed = system(s:invoke.' --complete -- '.task.' -')
for option in split(l:options_allowed) for option in split(l:options_allowed)
let value = s:getDefaultforOption(option) let value = s:getDefaultValueForOption(option)
if value != '' && commandline !~ option if value != '' && commandline !~ option
let commandline .= ' '.option.'='.value let commandline .= ' '.option.'='.value
endif endif
@ -134,9 +130,18 @@ function! s:ProjectSet(project_type, project_base_dir)
return commandline return commandline
endfunction endfunction
function! s:Make(args, async_mode) " Tab completion for Invoke is done by bash-completion
function! GetAllInvokeCompletions(ArgLead, CmdLine, CursorPos)
let l:words = split(a:CmdLine)
let l:words[0] = 'invoke'
let l:command = join(l:words)
return bash#complete(l:command)
endfunction
command! -complete=customlist,GetAllInvokeCompletions -nargs=* Invoke call s:Invoke('<args>', 'async')
function! s:Invoke(args, async_mode)
" Add defaults for options " Add defaults for options
let l:options = s:SetDefaults(a:args) let l:options = s:SetDefaultsForAllOptions(a:args)
if (a:async_mode == 'sync') if (a:async_mode == 'sync')
" Synchronous execution with returned output " Synchronous execution with returned output
@ -150,49 +155,43 @@ function! s:ProjectSet(project_type, project_base_dir)
" Asynchronous execution in background " Asynchronous execution in background
call system(s:invoke.' -e '.l:options.'&') call system(s:invoke.' -e '.l:options.'&')
else else
" Asynchronous execution with AsyncRun
call asyncrun#quickfix_toggle(10, 1) call asyncrun#quickfix_toggle(10, 1)
let &makeprg = s:invoke.' -e' let &makeprg = s:invoke.' -e'
execute 'AsyncRun -mode='.a:async_mode.' -save=2 -program=make @ '.l:options execute 'AsyncRun -mode='.a:async_mode.' -save=2 -program=make @ '.l:options
endif endif
endfunction endfunction
" Tab-completion is done with plugin vim-bash-completion
let $BASH_COMPLETION_DIR = '/home/stefan/.invoke'
let invoke_completion_file = $BASH_COMPLETION_DIR.'/bash_completion'
if !filereadable(invoke_completion_file)
call system('invoke --print-completion-script bash > '.invoke_completion_file)
endif
function! GetAllMakeCompletions(ArgLead, CmdLine, CursorPos)
let l:words = split(a:CmdLine)
let l:words[0] = 'invoke'
let l:command = join(l:words)
return bash#complete(l:command)
endfunction
" Get some configurations from the project " Get some configurations from the project
" ---------------------------------------- " ----------------------------------------
let l:tasks = s:Make('--list', 'sync') let l:tasks = s:Invoke('--list', 'sync')
let g:DebugRemote = l:targets =~ 'gdb-server' let g:DebugRemote = (l:tasks =~ 'gdb-server')
let g:ProjectBuildDir = s:Make('build-dir', 'sync') let g:ProjectBuildDir = s:Invoke('get-build-dir', 'sync')
let g:Elffile = s:Make('elf-file', 'sync') " Fallback
if g:ProjectBuildDir == ''
let g:ProjectBuildDir = s:ProjectBaseDir.'.build/'.g:project_type
endif
let g:Elffile = s:Invoke('get-elf-file', 'sync')
let l:is_arm = s:Make('is-arm', 'sync') let l:is_arm = s:Invoke('is-arm', 'sync')
let g:termdebug_config = {} let g:termdebug_config = {}
if l:is_arm =~ 'True' if l:is_arm =~ 'True'
if g:project_type == 'topmode' if g:project_type == 'topmode' || g:project_type == 'dlcpro'
" Old topmode needs old gdb " Old dlcpro and topmode need old gdb
let g:termdebug_config['command'] = '/opt/OSELAS.Toolchain-2020.08.0/arm-v7a-linux-gnueabihf/gcc-10.2.1-clang-10.0.1-glibc-2.32-binutils-2.35-kernel-5.8-sanitized/bin/arm-v7a-linux-gnueabihf-gdb' let g:termdebug_config['command'] = '/opt/OSELAS.Toolchain-2020.08.0/arm-v7a-linux-gnueabihf/gcc-10.2.1-clang-10.0.1-glibc-2.32-binutils-2.35-kernel-5.8-sanitized/bin/arm-v7a-linux-gnueabihf-gdb'
else else
let g:termdebug_config['command'] = 'arm-none-eabi-gdb' let g:termdebug_config['command'] = 'arm-none-eabi-gdb'
endif
else else
let g:termdebug_config['command'] = 'gdb' let g:termdebug_config['command'] = ['gdb']
" let g:termdebug_config['command'] = ['ssh', 'localhost', 'gdb']
endif endif
if (count(['dlcpro', 'dlcpro-new'], g:project_type) > 0) if (count(['dlcpro', 'dlcpro-new'], g:project_type) > 0)
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')})%=project:\ %{g:project_type}\ \ \ \ compiler:\ %{g:Compiler_version()} set titlestring=%<%t\ (%{expand('%:p:h')})%{g:Title_string()}
let g:DeviceIP = 'dlc_pro__040083' let g:DeviceIP = 'dlc_pro__040083'
let g:DeviceType = 'TApro' let g:DeviceType = 'TApro'
let g:PowerswitchIP = 'elab-stefan' let g:PowerswitchIP = 'elab-stefan'
@ -222,70 +221,22 @@ function! s:ProjectSet(project_type, project_base_dir)
" let g:DebugRemote = v:true " let g:DebugRemote = v:true
" let g:GdbPort = '6666' " let g:GdbPort = '6666'
" let g:SshOpts = '-o ForwardAgent=yes -o ProxyCommand="ssh -o RemoteCommand=none -q -W shg:22 root@%h" -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR' " let g:SshOpts = '-o ForwardAgent=yes -o ProxyCommand="ssh -o RemoteCommand=none -q -W shg:22 root@%h" -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR'
" let g:SshOpts2 = "-L localhost:1998:localhost:1998 -L localhost:1999:localhost:1999" " let g:SshOpts2 = '-L localhost:1998:localhost:1998 -L localhost:1999:localhost:1999'
elseif (g:project_type == 'dlcpro-gui')
command! DlcProGuiStart execute("!~/dlcpro/pc-gui/start-gui&")
elseif (g:project_type == 'topmode') elseif (g:project_type == 'topmode')
let g:DeviceIP = 'topmode_stefan' let g:DeviceIP = 'topmode_stefan'
let g:PowerswitchIP = 'elab-stefan' let g:PowerswitchIP = 'elab-stefan'
let g:Powerplug = '3' let g:Powerplug = '3'
command! TopmodeGuiStart execute("!~/topmode/pc-gui/start-gui&") command! TopmodeGuiStart execute("!~/topmode/pc-gui/start-gui&")
elseif (g:project_type == 'topmode-gui')
command! TopmodeGuiStart execute("!~/topmode/pc-gui/start-gui&")
elseif (g:project_type == 'operation-panel-f1') elseif (g:project_type == 'operation-panel-f1')
let g:stm32_target = 'STM32F10X' let g:stm32_target = 'STM32F10X'
elseif (g:project_type == 'operation-panel-f4') elseif (g:project_type == 'operation-panel-f4')
let g:stm32_target = 'STM32F4XX' let g:stm32_target = 'STM32F4XX'
endif endif
" python tags
execute "set tags+=" . s:ProjectBaseDir . '/tags'
" compiler
" if exists("s:Program")
" " let g:Program = g:ProjectBuildDir.s:Program
" let g:Elffile = g:ProjectBuildDir.s:Elffile
" endif
" =============
" Some settings
" =============
set spell spelllang=en,de
set expandtab
set cinoptions=l1,g2,h2,N-2,t0,+0,(0,w1,Ws,m1,)100,*100
set textwidth=120
let $QT_FONT_DPI=96 " Size for qt-application in debugger
let g:BuildType = 'Default'
compiler gcc
command! -complete=customlist,GetAllMakeCompletions -nargs=* MakeCmd call s:Make('<args>', 'async')
" Get compiler-version for DLCpro
function! g:Compiler_version()
if exists('g:ProjectBuildDir')
let cmakefile = g:ProjectBuildDir . '/CMakeCache.txt'
if filereadable(cmakefile)
for line in readfile(cmakefile)
if match(line, 'NEW_COMPILER:BOOL=OFF') >= 0
return 'old'
elseif match(line, 'NEW_COMPILER:BOOL=ON') >= 0
return 'new'
endif
endfor
endif
endif
return 0
endfunction
" configure quickfix window for asyncrun
augroup QuickfixStatus
autocmd BufWinEnter quickfix setlocal
\ statusline=%t\ [%{g:asyncrun_status}]\ %{exists('w:quickfix_title')?\ '\ '.w:quickfix_title\ :\ ''}\ %=%-15(%l,%c%V%)\ %P
augroup END
function! s:DeviceFirmwareUpdate() function! s:DeviceFirmwareUpdate()
call s:Make('kill', 'bang') call s:Invoke('kill', 'bang')
call s:Make('flash', 'bang') call s:Invoke('flash', 'bang')
call s:Make('run', 'bang') call s:Invoke('run', 'bang')
endfunction endfunction
function! g:JLinkSWOviewer() function! g:JLinkSWOviewer()
@ -311,20 +262,17 @@ function! s:ProjectSet(project_type, project_base_dir)
command! DeviceDebugAttach call s:DeviceDebug(1) command! DeviceDebugAttach call s:DeviceDebug(1)
function! s:DeviceDebug(attach) function! s:DeviceDebug(attach)
if g:DebugRemote if g:DebugRemote
call s:Make('kill', 'bang') call s:Invoke('kill', 'bang')
" Close quickfix window " Close quickfix window
execute 'cclose' execute 'cclose'
autocmd! User TermdebugStartPre autocmd! User TermdebugStartPre
autocmd! User TermdebugStartPost autocmd! User TermdebugStartPost
autocmd! User TermdebugStopPost autocmd! User TermdebugStopPost
call s:Make('gdb-server', 'background') call s:Invoke('gdb-server', 'background')
sleep 2 sleep 2
let s:gdb_connect_script = g:ProjectBuildDir.'/gdbinit' let s:gdb_connect_script = g:ProjectBuildDir.'/gdbinit'
if file_readable(s:gdb_connect_script) if file_readable(s:gdb_connect_script)
echom 'Liebl1'
autocmd User TermdebugStartPost call term_sendkeys('',"source ".s:gdb_connect_script."\n") autocmd User TermdebugStartPost call term_sendkeys('',"source ".s:gdb_connect_script."\n")
else
echom 'Liebl2'
endif endif
Termdebug Termdebug
call s:SendToDebugger('set confirm off') call s:SendToDebugger('set confirm off')
@ -333,8 +281,8 @@ function! s:ProjectSet(project_type, project_base_dir)
else else
call s:StartDebugger(g:Elffile, a:attach) call s:StartDebugger(g:Elffile, a:attach)
call s:SendToDebugger('file '.g:Elffile) call s:SendToDebugger('file '.g:Elffile)
call s:SendToDebugger('break main') " call s:SendToDebugger('break main')
call s:SendToDebugger('run') " call s:SendToDebugger('run')
endif endif
endfunction endfunction