Compare commits

...

2 Commits

Author SHA1 Message Date
409da47ad9 Get project settings from invoke 2025-02-13 10:01:21 +01:00
5dc7e1713d Improve options for make 2025-02-10 15:03:10 +01:00

View File

@ -5,7 +5,6 @@ command -nargs=? -complete=dir DlcProGui call s:ProjectSet('dlcpro-gui', '<args>
command -nargs=? -complete=dir DlcProTui call s:ProjectSet('dlcpro-tui', '<args>') command -nargs=? -complete=dir DlcProTui call s:ProjectSet('dlcpro-tui', '<args>')
command -nargs=? -complete=dir DlcProTuiSimulator call s:ProjectSet('dlcpro-tui-simulator', '<args>') command -nargs=? -complete=dir DlcProTuiSimulator call s:ProjectSet('dlcpro-tui-simulator', '<args>')
command -nargs=? -complete=dir DlcProCan call s:ProjectSet('dlcpro-can', '<args>') command -nargs=? -complete=dir DlcProCan call s:ProjectSet('dlcpro-can', '<args>')
command -nargs=? -complete=dir DlcProSpecalyser call s:ProjectSet('dlcpro-specalyser', '<args>')
command -nargs=? -complete=dir Topmode call s:ProjectSet('topmode', '<args>') command -nargs=? -complete=dir Topmode call s:ProjectSet('topmode', '<args>')
command -nargs=? -complete=dir TopmodeGui call s:ProjectSet('topmode-gui', '<args>') command -nargs=? -complete=dir TopmodeGui call s:ProjectSet('topmode-gui', '<args>')
command -nargs=? -complete=dir DigiFalc call s:ProjectSet('digifalc', '<args>') command -nargs=? -complete=dir DigiFalc call s:ProjectSet('digifalc', '<args>')
@ -19,7 +18,6 @@ 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>')
let s:path_orig = $PATH
set titlestring= set titlestring=
function! s:ProjectSet(project_type, project_base_dir) function! s:ProjectSet(project_type, project_base_dir)
@ -48,8 +46,6 @@ function! s:ProjectSet(project_type, project_base_dir)
let s:ProjectBaseDir = '/home/stefan/dlcpro/firmware.tui-simulator' let s:ProjectBaseDir = '/home/stefan/dlcpro/firmware.tui-simulator'
elseif (g:project_type == 'dlcpro-can') elseif (g:project_type == 'dlcpro-can')
let s:ProjectBaseDir = '/home/stefan/dlcpro/firmware' let s:ProjectBaseDir = '/home/stefan/dlcpro/firmware'
elseif (g:project_type == 'dlcpro-specalyser')
let s:ProjectBaseDir = '/home/stefan/dlcpro/firmware'
elseif (g:project_type == 'shg') elseif (g:project_type == 'shg')
let s:ProjectBaseDir = '/home/stefan/dlcpro/shg-firmware' let s:ProjectBaseDir = '/home/stefan/dlcpro/shg-firmware'
elseif (g:project_type == 'dlcpro-gui') elseif (g:project_type == 'dlcpro-gui')
@ -77,145 +73,11 @@ function! s:ProjectSet(project_type, project_base_dir)
" Direnv " Direnv
let $DIRENV_DIR = s:ProjectBaseDir let $DIRENV_DIR = s:ProjectBaseDir
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
" vim path " vim path
execute 'cd '.s:ProjectSrcDir execute 'cd '.s:ProjectSrcDir
execute 'set path-=./**' execute 'set path-=./**'
execute 'set path+=' . s:ProjectSrcDir.'/**' execute 'set path+=' . s:ProjectSrcDir.'/**'
if (count(['pfd', 'tiny'], g:project_type) > 0)
let g:ProjectBuildDir = s:ProjectSrcDir.'/.build/target/firmware/Debug'
let g:DebugRemote = v:true
let g:termdebugger = 'arm-none-eabi-gdb'
let s:gdb_connect_script = g:ProjectBuildDir.'/gdbinit'
elseif (count(['dlcpro', 'dlcpro-new'], g:project_type) > 0)
set wildignore-=**/firmware/src/device-control/**
set wildignore+=**/shg-firmware/**
set titlestring=%<%t\ (%{expand('%:p:h')})%=project:\ %{g:project_type}\ \ \ \ compiler:\ %{g:Compiler_version()}
let g:DeviceIP = 'dlc_pro__040083'
let g:DebugRemote = v:true
let g:ProjectBuildDir = s:ProjectSrcDir.'/.build/'.g:project_type
if (g:project_type == 'dlcpro-new')
let s:firware_file_name = 'DLCpro-archive-SSW7.fw'
else
let s:firware_file_name = 'DLCpro-archive.fw'
endif
let s:firmware_file = g:ProjectBuildDir.'/artifacts/'.s:firware_file_name
let g:DeviceType = 'TApro'
let g:PowerswitchIP = 'elab-stefan'
let g:Powerplug = '1'
let g:termdebugger = 'arm-none-eabi-gdb'
let s:gdb_connect_script = g:ProjectBuildDir.'/gdbinit'
command! DlcProGuiStart execute("!~/dlcpro/pc-gui/start-gui&")
elseif ((g:project_type == 'dlcpro-tui') || (g:project_type == 'dlcpro-tui-simulator'))
let s:Program = '/user-interface/src/user-interface'
let s:Elffile = s:Program
let g:ProgramRemote = '/opt/app/bin/user-interface'
set wildignore-=**/firmware/src/device-control/**
set wildignore+=**/shg-firmware/**
let g:DeviceIP = 'dlc_pro__040083'
let g:DebugRemote = v:true
elseif (g:project_type == 'dlcpro-can')
let s:Program = '/canopen/can-updater'
let s:Elffile = s:Program
let g:ProgramRemote = '/opt/app/bin/can-updater'
set wildignore-=**/firmware/src/device-control/**
set wildignore+=**/shg-firmware/**
let g:DeviceIP = 'dlc_pro__040083'
let g:DebugRemote = v:true
elseif (g:project_type == 'dlcpro-specalyser')
let s:Program = '/specalyser/specalyser'
let s:Elffile = s:Program
let g:ProgramRemote = '/opt/app/bin/specalyser'
set wildignore-=**/firmware/src/device-control/**
set wildignore+=**/shg-firmware/**
let g:DeviceIP = 'dlc_pro__040083'
let g:DebugRemote = v:true
elseif (g:project_type == 'shg')
let s:Program = '/shg-firmware/device-control/device-control-shg'
let s:Elffile = s:Program
let g:ProgramRemote = '/opt/app/bin/device-control-shg'
set wildignore-=**/shg-firmware/**
set wildignore+=**/firmware/src/device-control/**
let g:DeviceIP = 'dlc_pro__040083'
let g:DebugRemote = v:true
" 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:SshOpts2 = "-L localhost:1998:localhost:1998 -L localhost:1999:localhost:1999"
elseif (g:project_type == 'dlcpro-gui')
let g:ProjectBuildDir = s:ProjectSrcDir.'/.build' " FIXME (for DeviceDebug)
let s:Program = '/TOPAS_DLC_pro'
let s:Elffile = s:Program
let g:termdebugger = 'gdb'
let g:DebugRemote = v:false
command! DlcProGuiStart execute("!~/dlcpro/pc-gui/start-gui&")
elseif (g:project_type == 'topmode')
let g:ProjectBuildDir = s:ProjectSrcDir.'/.build/'
let g:DeviceIP = 'topmode_stefan'
let g:DebugRemote = v:true
let g:termdebugger = 'arm-none-eabi-gdb'
let s:gdb_connect_script = g:ProjectBuildDir.'/gdbinit'
let s:firware_file_name = 'TopMode-CHARM-Control-1.5.4-dev.fw'
let s:firmware_file = g:ProjectBuildDir.'/artifacts/'.s:firware_file_name
command! TopmodeGuiStart execute("!~/topmode/pc-gui/start-gui&")
elseif (g:project_type == 'topmode-gui')
let g:DebugRemote = v:false
command! TopmodeGuiStart execute("!~/topmode/pc-gui/start-gui&")
elseif (g:project_type == 'digifalc')
let s:Program = '/digifalc-image.bin'
let s:Elffile = '/application/digifalc.elf'
let g:DebugRemote = v:true
let g:termdebugger = 'arm-none-eabi-gdb'
elseif (g:project_type == 'servoboard')
let s:Program = '/servo-board-image.bin'
let s:Elffile = '/application/servo-board.elf'
let g:DebugRemote = v:true
let g:termdebugger = 'arm-none-eabi-gdb'
elseif (g:project_type == 'dl-motor')
let s:Program = '/dl-motor-image.bin'
let s:Elffile = '/application/dl-motor.elf'
let g:DebugRemote = v:true
let g:termdebugger = 'arm-none-eabi-gdb'
elseif (g:project_type == 'operation-panel-f1')
let g:stm32_target = 'STM32F10X'
let s:Program = '/firmware/operation_panel_'.g:stm32_target.'.bin'
let s:Elffile = '/firmware/operation_panel_'.g:stm32_target.'.elf'
" let s:makegoals = ['artifacts']
let g:DebugRemote = v:true
" let g:GdbPort = '3333'
let g:termdebugger = 'arm-none-eabi-gdb'
" let s:stm_cfg = 'stm32f1x'
elseif (g:project_type == 'operation-panel-f4')
let g:stm32_target = 'STM32F4XX'
let s:Program = '/firmware/operation_panel_'.g:stm32_target.'.bin'
let s:Elffile = '/firmware/operation_panel_'.g:stm32_target.'.elf'
" let s:makegoals = ['artifacts']
let g:DebugRemote = v:true
" let g:GdbPort = '3333'
let g:termdebugger = 'arm-none-eabi-gdb'
" let s:stm_cfg = 'stm32f4x'
elseif (g:project_type == 'decof')
" let s:makegoals = ['all']
let g:DebugRemote = v:false
else
echo "no project"
endif
" Settings for invoke development " Settings for invoke development
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 = '/home/stefan/tools/invoke/'.g:project_type.'/tasks.py'
@ -227,72 +89,65 @@ function! s:ProjectSet(project_type, project_base_dir)
echoerr 'tasks.py not found' echoerr 'tasks.py not found'
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
endfunction
" =============
" 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')
" 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
" ==== " ====
" Make " Make
" ==== " ====
" Add default value for all given options, if not already set function! s:getDefaultforOption(option_name)
function! s:SetDefaults(commandline, option_defaults) if a:option_name == '--project'
return g:project_type
elseif a:option_name == '--device-ip'
return g:DeviceIP
elseif a:option_name == '--build-type'
return g:BuildType
elseif a:option_name == '--version-file'
return g:ProjectBuildDir.'/artifacts/VERSION'
elseif a:option_name == '--laser1-type'
return g:DeviceType
elseif a:option_name == '--powerswitch-ip'
return g:PowerswitchIP
elseif a:option_name == '--powerplug'
return g:Powerplug
else
return ""
endif
endfunction
let g:option_defaults = [ " Add default value for all given options, if not already set
\ {'name': '--project', 'value': g:project_type}, function! s:SetDefaults(commandline)
\ {'name': '--device-ip', 'value': g:DeviceIP},
\ {'name': '--build-type', 'value': g:BuildType},
\ {'name': '--firmware-file', 'value': s:firmware_file},
\ {'name': '--version-file', 'value': g:ProjectBuildDir.'/artifacts/VERSION'},
\ {'name': '--laser1-type', 'value': g:DeviceType},
\ {'name': '--powerswitch-ip', 'value': g:PowerswitchIP},
\ {'name': '--powerplug', 'value': g:Powerplug},
\ {'name': '--firmware-file', 'value': s:firmware_file},
\ ]
let commandline = a:commandline let commandline = a:commandline
let task = split(commandline)[0] let task = split(commandline)[0]
let options_allowed = system(s:invoke.' --complete -- '.task.' -') let l:tasks = system(s:invoke.' --list')
for option_default in a:option_defaults
let option = option_default['name'] if l:tasks =~ task
let value = option_default['value'] let l:options_allowed = system(s:invoke.' --complete -- '.task.' -')
if options_allowed =~ option && commandline !~ option for option in split(l:options_allowed)
let value = s:getDefaultforOption(option)
if value != '' && commandline !~ option
let commandline .= ' '.option.'='.value let commandline .= ' '.option.'='.value
endif endif
endfor endfor
endif
return commandline return commandline
endfunction endfunction
function! s:Make(args, async_mode) function! s:Make(args, async_mode)
" Add defaults for options " Add defaults for options
let l:options = s:SetDefaults(a:args, g:option_defaults) let l:options = s:SetDefaults(a:args)
if (a:async_mode == 'background') if (a:async_mode == 'sync')
" Synchronous execution with returned output
let l:output = trim(system(s:invoke.' -e '.l:options))
if l:output =~ 'No idea'
return ''
else
return l:output
endif
elseif (a:async_mode == 'background')
" Asynchronous execution in background
call system(s:invoke.' -e '.l:options.'&') call system(s:invoke.' -e '.l:options.'&')
else else
call asyncrun#quickfix_toggle(10, 1) call asyncrun#quickfix_toggle(10, 1)
@ -314,6 +169,119 @@ function! GetAllMakeCompletions(ArgLead, CmdLine, CursorPos)
return bash#complete(l:command) return bash#complete(l:command)
endfunction endfunction
" Get some configurations from the project
" ----------------------------------------
let l:tasks = s:Make('--list', 'sync')
let g:DebugRemote = l:targets =~ 'gdb-server'
let g:ProjectBuildDir = s:Make('build-dir', 'sync')
let g:Elffile = s:Make('elf-file', 'sync')
let l:is_arm = s:Make('is-arm', 'sync')
let g:termdebug_config = {}
if l:is_arm =~ 'True'
if g:project_type == 'topmode'
" Old topmode needs 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'
else
let g:termdebug_config['command'] = 'arm-none-eabi-gdb'
else
let g:termdebug_config['command'] = 'gdb'
endif
if (count(['dlcpro', 'dlcpro-new'], g:project_type) > 0)
set wildignore-=**/firmware/src/device-control/**
set wildignore+=**/shg-firmware/**
set titlestring=%<%t\ (%{expand('%:p:h')})%=project:\ %{g:project_type}\ \ \ \ compiler:\ %{g:Compiler_version()}
let g:DeviceIP = 'dlc_pro__040083'
let g:DeviceType = 'TApro'
let g:PowerswitchIP = 'elab-stefan'
let g:Powerplug = '1'
command! DlcProGuiStart execute("!~/dlcpro/pc-gui/start-gui&")
elseif ((g:project_type == 'dlcpro-tui') || (g:project_type == 'dlcpro-tui-simulator'))
" let s:Program = '/user-interface/src/user-interface'
" let s:Elffile = s:Program
" let g:ProgramRemote = '/opt/app/bin/user-interface'
set wildignore-=**/firmware/src/device-control/**
set wildignore+=**/shg-firmware/**
let g:DeviceIP = 'dlc_pro__040083'
elseif (g:project_type == 'dlcpro-can')
" let s:Program = '/canopen/can-updater'
" let s:Elffile = s:Program
" let g:ProgramRemote = '/opt/app/bin/can-updater'
set wildignore-=**/firmware/src/device-control/**
set wildignore+=**/shg-firmware/**
let g:DeviceIP = 'dlc_pro__040083'
elseif (g:project_type == 'shg')
" let s:Program = '/shg-firmware/device-control/device-control-shg'
" let s:Elffile = s:Program
" let g:ProgramRemote = '/opt/app/bin/device-control-shg'
set wildignore-=**/shg-firmware/**
set wildignore+=**/firmware/src/device-control/**
let g:DeviceIP = 'dlc_pro__040083'
" let g:DebugRemote = v:true
" 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: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')
let g:DeviceIP = 'topmode_stefan'
let g:PowerswitchIP = 'elab-stefan'
let g:Powerplug = '3'
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')
let g:stm32_target = 'STM32F10X'
elseif (g:project_type == 'operation-panel-f4')
let g:stm32_target = 'STM32F4XX'
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:Make('kill', 'bang')
call s:Make('flash', 'bang') call s:Make('flash', 'bang')
@ -351,8 +319,12 @@ function! s:DeviceDebug(attach)
autocmd! User TermdebugStopPost autocmd! User TermdebugStopPost
call s:Make('gdb-server', 'background') call s:Make('gdb-server', 'background')
sleep 2 sleep 2
if exists('s:gdb_connect_script') let s:gdb_connect_script = g:ProjectBuildDir.'/gdbinit'
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')
@ -369,7 +341,7 @@ endfunction
" ------ " ------
" Pandoc " Pandoc
" ------ " ------
command TopticaBeamer execute('!pandoc -s -t beamer -H toptica-style.tex -o %:r.pdf %') command! TopticaBeamer execute('!pandoc -s -t beamer -H toptica-style.tex -o %:r.pdf %')
" ----------------- " -----------------
" Jenkins validator " Jenkins validator
@ -403,3 +375,4 @@ function! s:Jenkins_linter(jenkinsfile)
endif endif
echo l:out echo l:out
endfunction endfunction
endfunction