From de26f7c44d8ea3605b46764197e1a8c99d323b60 Mon Sep 17 00:00:00 2001 From: Stefan Liebl Date: Thu, 16 May 2024 15:13:40 +0200 Subject: [PATCH] toptica updates --- vimfiles.stefan/plugin/toptica.vim | 118 ++++++++++++++++------------- vimfiles.stefan/vimrc | 2 +- 2 files changed, 67 insertions(+), 53 deletions(-) diff --git a/vimfiles.stefan/plugin/toptica.vim b/vimfiles.stefan/plugin/toptica.vim index 0751d7f..bd148f0 100644 --- a/vimfiles.stefan/plugin/toptica.vim +++ b/vimfiles.stefan/plugin/toptica.vim @@ -2,6 +2,7 @@ command -nargs=1 -complete=dir DlcPro call s:ProjectSet('dlcpro', '') command -nargs=1 -complete=dir DlcProShg call s:ProjectSet('shg', '') command -nargs=1 -complete=dir DlcProGui call s:ProjectSet('dlcpro-gui', '') command -nargs=1 -complete=dir DlcProTui call s:ProjectSet('dlcpro-tui', '') +command -nargs=1 -complete=dir DlcProTuiSimulator call s:ProjectSet('dlcpro-tui-simulator', '') command -nargs=1 -complete=dir DlcProCan call s:ProjectSet('dlcpro-can', '') command -nargs=1 -complete=dir DlcProSpecalyser call s:ProjectSet('dlcpro-specalyser', '') command -nargs=1 -complete=dir Topmode call s:ProjectSet('topmode', '') @@ -19,7 +20,7 @@ command SetOselasGcc11 call s:set_oselas_gcc() let s:path_orig = $PATH -function s:ProjectSet(project_type, project_base_dir) +function! s:ProjectSet(project_type, project_base_dir) let g:project_type = a:project_type let g:jenkins_url = 'http://jenkins.toptica.com' @@ -38,6 +39,8 @@ function s:ProjectSet(project_type, project_base_dir) let s:ProjectBaseDir = '/home/stefan/dlcpro/firmware' elseif (g:project_type == 'dlcpro-tui') 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 == 'dlcpro-specalyser') @@ -95,6 +98,18 @@ function s:ProjectSet(project_type, project_base_dir) let g:new_compiler = ' -DNEW_COMPILER=ON' endfunction + function! g:Compiler_version() + let cmakefile = g:ProjectBuildDir . '/CMakeCache.txt' + 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 + return 0 + endfunction + " vim path execute 'cd '.s:ProjectSrcDir execute 'set path-=./**' @@ -108,6 +123,7 @@ function s:ProjectSet(project_type, project_base_dir) let g:ProgramRemote = '/opt/app/bin/device-control' set wildignore-=**/firmware/src/device-control/** set wildignore+=**/shg-firmware/** + set titlestring=%<%t\ (%{expand('%:p:h')})%=compiler:\ %{Compiler_version()} let s:makegoals = ['artifacts-firmware', 'artifacts-docu', 'artifacts', 'device-control', 'user-interface', 'doxygen', 'fw-updates', 'shg-firmware', 'can-updater', 'specalyser', 'docu-ul0', 'code-generation', 'dependency-graphs', 'decof', 'decof-sdk', 'clean', 'distclean', 'help', 'jamplayer', 'dlcpro-slot'] let s:makeprg = 'make' let g:DeviceIP = 'dlc_pro__040083' @@ -119,7 +135,7 @@ function s:ProjectSet(project_type, project_base_dir) command DlcproEmissionOn call s:DlcproEmission('1') command DlcproEmissionOff call s:DlcproEmission('0') command DlcproShutup call s:DlcproShutup() - elseif (g:project_type == 'dlcpro-tui') + 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' @@ -345,18 +361,18 @@ endfunction " ==== " Make " ==== -function GetAllMakeCompletions(ArgLead, CmdLine, CursorPos) +function! GetAllMakeCompletions(ArgLead, CmdLine, CursorPos) return join(s:makegoals + s:makeopts + glob(a:ArgLead.'*', 1, 1), "\n") endfunction -function s:Make(args, async_mode) +function! s:Make(args, async_mode) let &makeprg = s:makeprg call asyncrun#quickfix_toggle(10, 1) " execute 'AsyncRun -mode='.a:async_mode.' -save=2 -program=make @ --directory='.g:ProjectBuildDir.' '.a:args execute 'AsyncRun -mode='.a:async_mode.' -save=2 -program=make -cwd='.g:ProjectBuildDir. ' @ '.a:args endfunction -function s:MakeTestBuild() +function! s:MakeTestBuild() let &makeprg = s:makeprg call s:BuildDirStash('save') call s:Cmake('-DCMAKE_BUILD_TYPE=Release', 1) @@ -365,7 +381,7 @@ function s:MakeTestBuild() call s:BuildDirUnStash('save') endfunction -function s:MakeCheck(filename, async_mode) +function! s:MakeCheck(filename, async_mode) let &makeprg = s:ProjectSrcDir.'/tools/static-check.py' call asyncrun#quickfix_toggle(10, 1) if a:filename != '' @@ -379,7 +395,7 @@ function s:MakeCheck(filename, async_mode) execute 'AsyncRun -mode='.a:async_mode.' -save=2 -program=make -cwd='.g:ProjectBuildDir. ' @ '.args endfunction -function s:Cmake(options, async_mode) +function! s:Cmake(options, async_mode) if !isdirectory(g:ProjectBuildDir) call mkdir(g:ProjectBuildDir) endif @@ -393,11 +409,11 @@ function s:Cmake(options, async_mode) let args .= " --graphviz=dependencies.dot" let args .= " ".a:options let args .= " -DCMAKE_EXPORT_COMPILE_COMMANDS=1" - if (g:project_type == 'dlcpro') + if ((g:project_type == 'dlcpro') || (g:project_type == 'dlcpro-tui')) let args .= " -DCMAKE_TOOLCHAIN_FILE=../".g:ProjectSrcDirRel."/Toolchain-target.cmake" let args .= " -DBUILD_TARGET=target" let args .= g:new_compiler - elseif (g:project_type == 'dlcpro-tui') + elseif (g:project_type == 'dlcpro-tui-simulator') let args .= " -DBUILD_TARGET=simulation" let args .= " -DQT5_INSTALL_PATH=/usr/lib/x86_64-linux-gnu/qt5" elseif (g:project_type == 'topmode') @@ -417,13 +433,13 @@ function s:Cmake(options, async_mode) execute 'AsyncRun -mode='.a:async_mode.' -save=2 -cwd='.g:ProjectBuildDir.' @ cmake '.args endfunction -function s:Ctest(args, async_mode) +function! s:Ctest(args, async_mode) let cmd = 'ctest --build-and-test ../src . --build-generator "Unix Makefiles" --build-target unit_tests --nocompress-output -T Test --build-options -DCMAKE_BUILD_TYPE=Debug --test-command ctest' call asyncrun#quickfix_toggle(10, 1) execute 'AsyncRun -mode='.a:async_mode.' -save=2 -cwd='.s:ProjectBaseDir.'/unit-tests @ ' . cmd .' '. a:args endfunction -function s:Ctestx(args, async_mode) +function! s:Ctestx(args, async_mode) let unit_test_dirname = 'unit-tests' let unit_test_dir = s:ProjectBaseDir . '/' . unit_test_dirname if !isdirectory('./unit-tests') @@ -438,7 +454,7 @@ function s:Ctestx(args, async_mode) execute 'AsyncRun -mode='.a:async_mode.' -save=2 -cwd='.unit_test_dir.' @ ' . ctest_cmd .' '. a:args endfunction -function s:Ctest1(args, async_mode) +function! s:Ctest1(args, async_mode) let unit_test_dirname = 'unit-tests' let unit_test_dir = s:ProjectBaseDir . '/' . unit_test_dirname if !isdirectory(unit_test_dir) @@ -450,7 +466,7 @@ function s:Ctest1(args, async_mode) execute 'AsyncRun -mode=1 -save=2 -cwd='.unit_test_dir.' @ ' . cmake_cmd endfunction -function s:Ctest2(args, async_mode) +function! s:Ctest2(args, async_mode) let unit_test_dirname = 'unit-tests' let unit_test_dir = s:ProjectBaseDir . '/' . unit_test_dirname let build_cmd = 'cmake --build . -j --target unit_tests ' . a:args @@ -458,7 +474,7 @@ function s:Ctest2(args, async_mode) execute 'AsyncRun -mode=1 -save=2 -cwd='.unit_test_dir.' @ ' . build_cmd endfunction -function s:Ctest3(args, async_mode) +function! s:Ctest3(args, async_mode) let unit_test_dirname = 'unit-tests' let unit_test_dir = s:ProjectBaseDir . '/' . unit_test_dirname let ctest_cmd = 'ctest --nocompress-output -T Test' @@ -466,7 +482,7 @@ function s:Ctest3(args, async_mode) execute 'AsyncRun -mode='.a:async_mode.' -save=2 -cwd='.unit_test_dir.' @ ' . ctest_cmd .' '. a:args endfunction -function s:Call_and_log(cmd) +function! s:Call_and_log(cmd) echom a:cmd let r = system(a:cmd) let e = v:shell_error @@ -476,14 +492,14 @@ function s:Call_and_log(cmd) return v:shell_error endfunction -function s:DlcproTuiStart() +function! s:DlcproTuiStart() let workdir = s:ProjectSrcDir . '/user-interface/src' let cmd = g:ProjectBuildDir . '/user-interface/src/user-interface' call asyncrun#quickfix_toggle(10, 1) execute 'AsyncRun -mode=async -save=2 -cwd='.workdir.' @ ' . cmd endfunction -"function s:CopyFirmware(command) +"function! s:CopyFirmware(command) " let command = 'bash '.s:GdbSlave.' -h '.g:DeviceIP.' '.a:command "" if a:command == 'update' || a:command == 'start-debug' " let command .= ' '.g:Program @@ -492,25 +508,25 @@ endfunction " call system(command) "endfunction -function s:DlcproEmission(state) +function! s:DlcproEmission(state) call s:Call_and_log('ssh -o RemoteCommand=none '.g:SshOpts.' root@'.g:DeviceIP.' "echo '.a:state.' > /sys/bus/i2c/devices/200-0028/emission_button_state"') endfunction -function s:DlcproShutup() +function! s:DlcproShutup() call s:Call_and_log('ssh -o RemoteCommand=none '.g:SshOpts.' root@'.g:DeviceIP.' "modprobe -r tam3517_buzzer"') endfunction -function s:JLinkFlashProgram() +function! s:JLinkFlashProgram() call term_start(s:ProjectSrcDir.'/flash_firmware.py -j '.s:jlink_path.'/JLinkExe -a 0x8000000 '.g:Program) endfunction -function g:JLinkSWOviewer() +function! g:JLinkSWOviewer() let cmd = s:jlink_path.'/JLinkSWOViewerCLExe -device STM32H743ZI -itmmask 0xffffffff -swofreq 450000' call asyncrun#quickfix_toggle(10, 1) execute 'AsyncRun -mode=async @ ' . cmd endfunction -function s:DeviceUpdateProgramLinux() +function! s:DeviceUpdateProgramLinux() call s:Call_and_log('ssh -o RemoteCommand=none '.g:SshOpts.' root@'.g:DeviceIP.' "killall -q gdbserver start-dc.sh '.fnamemodify(g:ProgramRemote, ':t').'"') sleep 2 " call s:Call_and_log('ssh -o RemoteCommand=none '.g:SshOpts.' root@'.g:DeviceIP.' "killall -q -9 gdbserver start-dc.sh '.g:ProgramRemote.'"') @@ -519,15 +535,15 @@ function s:DeviceUpdateProgramLinux() return r endfunction -function s:DeviceFirmwareUpdateStartLinux() +function! s:DeviceFirmwareUpdateStartLinux() let r = s:DeviceUpdateProgramLinux() if (r == 0) - let workdir = 'cd /opt/app &&' - call s:Call_and_log('ssh -o RemoteCommand=none '.g:SshOpts.' -f root@'.g:DeviceIP.' "{ '.workdir.' '.g:ProgramRemote.' 2>&1 | logger -t "'.g:ProgramRemote.'" -p user.err; } &"') + let cd_workdir = 'cd ' . fnamemodify(g:ProgramRemote, ":h") . ' && ' + call s:Call_and_log('ssh -o RemoteCommand=none '.g:SshOpts.' -f root@'.g:DeviceIP.' "{ '.cd_workdir.' '.g:ProgramRemote.' 2>&1 | logger -t "'.g:ProgramRemote.'" -p user.err; } &"') endif endfunction -function s:DeviceStartGdbServer() +function! s:DeviceStartGdbServer() if ((g:project_type == 'digifalc') || (g:project_type == 'servoboard') || (g:project_type == 'dl-motor')) call s:Call_and_log('pkill --full JLinkGDBServer') call s:Call_and_log(s:jlink_path.'/JLinkGDBServer -if SWD -device STM32H743ZI &') @@ -541,7 +557,7 @@ function s:DeviceStartGdbServer() endif endfunction -function s:DeviceStartGdbServerAttach() +function! s:DeviceStartGdbServerAttach() if ((g:project_type == 'digifalc') || (g:project_type == 'servoboard') || (g:project_type == 'dl-motor')) else call s:Call_and_log('pkill --full gdbserver') @@ -549,15 +565,15 @@ function s:DeviceStartGdbServerAttach() endif endfunction -function s:SendToTerm(command) +function! s:SendToTerm(command) call term_sendkeys('', a:command . "\n") endfunction -function s:SendToConque(command) +function! s:SendToConque(command) execute 'ConqueGdbCommand ' . a:command endfunction -function s:SendToDebugger(command) +function! s:SendToDebugger(command) if !exists("s:UseConqueGdb") call s:SendToTerm(a:command) else @@ -565,7 +581,7 @@ function s:SendToDebugger(command) endif endfunction -function s:StartDebugger(elffile, attach) +function! s:StartDebugger(elffile, attach) if !exists("s:UseConqueGdb") if (a:attach == 0) Termdebug @@ -583,7 +599,7 @@ function s:StartDebugger(elffile, attach) endfunction let g:DlcproBasePath = "/jenkins/workspace/pro--firmware_release_1.9.0-DCESJ5C5R577IG5QFEWTML22UFDDZCJDGFLMDA4DCD3V2ZAGVEJA/source/" -function s:DeviceDebug(attach) +function! s:DeviceDebug(attach) if (a:attach == 0) " let r = s:DeviceFirmwareUpdate() let r = 0 @@ -635,25 +651,25 @@ endfunction " ================ " Regression Tests " ================ -function g:DlcproRegtestCmd(arguments) +function! g:DlcproRegtestCmd(arguments) return s:DlcproRegtestCmd('', '', '0', '1', '', '--capture=no', a:arguments) endfunction -function g:DlcproRegtestDlProCmd(arguments) - return s:DlcproRegtestCmd('dlc_pro__040011', 'elab-dlcpro2', '2', '1', 'DLpro', '', a:arguments) +function! g:DlcproRegtestDlProCmd(arguments) + return s:DlcproRegtestCmd('dlc_pro_proto_050003', 'elab-dlcpro2', '2', '1', 'DLpro', '', a:arguments) endfunction -function g:DlcproRegtestTaProCmd(arguments) - return s:DlcproRegtestCmd('dlc_pro_020372', 'elab-dlcpro2', '3', '1', 'TApro', '-m "not usb and not usbstick"', a:arguments) +function! g:DlcproRegtestTaProCmd(arguments) + return s:DlcproRegtestCmd('dlc_pro_045396', 'elab-dlcpro2', '3', '1', 'TApro', '-m "not usb and not usbstick"', a:arguments) endfunction -function g:DlcproRegtestCtlCmd(arguments) +function! g:DlcproRegtestCtlCmd(arguments) return s:DlcproRegtestCmd('dlc_pro__040120', 'elab-dlcpro2', '1', '1', 'CTL', '-m "not usb and not usbstick"', a:arguments) endfunction -function g:DlcproRegtestDualDlCmd(arguments) +function! g:DlcproRegtestDualDlCmd(arguments) return s:DlcproRegtestCmd('dlc_pro_041299', 'elab-dlcpro2', '4', '2', 'DLpro', '-m "not usb and not usbstick"', a:arguments) endfunction -function g:DlcproRegtestDualDl1Cmd(arguments) +function! g:DlcproRegtestDualDl1Cmd(arguments) return s:DlcproRegtestCmd('dlc_pro_041299', 'elab-dlcpro2', '4', '1', 'DLpro', '-m "not usb and not usbstick"', a:arguments) endfunction -function g:DlcproRegtestShgProCmd(arguments) +function! g:DlcproRegtestShgProCmd(arguments) return s:DlcproRegtestCmd('dlc_pro_041355', 'elab-dlcpro2', '7', '1', 'TA-SHGpro', '-m "not usb and not usbstick"', a:arguments) endfunction @@ -666,12 +682,12 @@ command -nargs=1 -complete=file DlcproRegtestDualDl1 call s:DlcproRegtest(g:Dlcp command -nargs=1 -complete=file DlcproRegtestShgPro call s:DlcproRegtest(g:DlcproRegtestShgProCmd('')) let g:DlcproRegtest_fast_restart = 1 -"let g:DlcproRegtest_marks = '"-m (no_crash_without_mc_fpga and not usb and not usbstick and not si1 and not servo_control and not eom and not cavity and not cell_spectroscopy)"' -let g:DlcproRegtest_marks = "" +let g:DlcproRegtest_marks = '"-m (no_crash_without_mc_fpga and not usb and not usbstick and not si and not si1 and not servo_control and not eom and not cavity and not cell_spectroscopy and not falc and not pfd and not smc)"' +"let g:DlcproRegtest_marks = "" let g:DlcproRegtest_lasertype = "DLpro" let g:DlcproRegtest_powerswitch_ip = "" -function s:DlcproRegtestCmd(ip, powerswitch_ip, powerplug, laser_count, laser_type, opts, arguments) +function! s:DlcproRegtestCmd(ip, powerswitch_ip, powerplug, laser_count, laser_type, opts, arguments) if (a:ip == '') let ip = g:DeviceIP else @@ -711,8 +727,7 @@ function s:DlcproRegtestCmd(ip, powerswitch_ip, powerplug, laser_count, laser_ty \"--firmware_file=".archive_dir."/DLCpro-archive.fw ". \"--license_tool=".licensetool." ". \"--license_keyfile=".s:ProjectSrcDir."/license/libdlcprolicense/rsa-private.key ". - \"--skip_shutdown_after_test ". - \"--skip_fw_update ". + \"--log-cli-level=INFO " \"--log-file-level=DEBUG " \"" @@ -721,14 +736,13 @@ function s:DlcproRegtestCmd(ip, powerswitch_ip, powerplug, laser_count, laser_ty endif " hint: --collect-only - "--log-cli-level=DEBUG --log-file-level=DEBUG let test_cmd .= a:opts." ". g:DlcproRegtest_marks." ".a:arguments let @+ = test_cmd return test_cmd endfunction -function s:DlcproRegtest(test_cmd) +function! s:DlcproRegtest(test_cmd) execute "wa" " Build license tool @@ -779,7 +793,7 @@ endfunction " =============== " Stash / Unstash " =============== -function s:BuildDirStash(suffix) +function! s:BuildDirStash(suffix) if a:suffix != '' let suffix = a:suffix else @@ -799,7 +813,7 @@ function s:BuildDirStash(suffix) call execute('!cp '.target_dir.'/.project '.g:ProjectBuildDir, 'silent!') endfunction -function s:BuildDirUnStash(suffix) +function! s:BuildDirUnStash(suffix) if a:suffix != '' let suffix = a:suffix else @@ -817,7 +831,7 @@ function s:BuildDirUnStash(suffix) endif endfunction -function GetAllStashedBuildDirs(ArgLead, CmdLine, CursorPos) +function! GetAllStashedBuildDirs(ArgLead, CmdLine, CursorPos) return system('ls '.s:ProjectBaseDir.' | grep build.') endfunction @@ -841,7 +855,7 @@ command TopticaBeamer execute('!pandoc -s -t beamer -H toptica-style.tex -o %:r. " ----------------- " Jenkins validator " ----------------- -function s:Jenkins_linter(jenkinsfile) +function! s:Jenkins_linter(jenkinsfile) if a:jenkinsfile == '' let jenkinsfile = expand("%") else diff --git a/vimfiles.stefan/vimrc b/vimfiles.stefan/vimrc index 9161c11..432bdd1 100644 --- a/vimfiles.stefan/vimrc +++ b/vimfiles.stefan/vimrc @@ -320,7 +320,7 @@ let g:clang_format#enable_fallback_style = 0 " ------------- " YouCompleteMe " ------------- -let g:ycm_clangd_binary_path = exepath('clangd-13') +"let g:ycm_clangd_binary_path = exepath('clangd-13') let g:ycm_clangd_uses_ycmd_caching = 0 " Let clangd fully control code completion "let g:ycm_clangd_args = ['--all-scopes-completion', '--clang-tidy', '--header-insertion=iwyu', '--suggest-missing-includes', '--enable-config'] let g:ycm_clangd_args = ['--all-scopes-completion', '--header-insertion=iwyu', '--suggest-missing-includes', '--enable-config']