Tech /

VIM And IAR





edit SideBar

VIM And IAR

VIM snippets for using the IAR ARM compiler (Embedded Workbench).

  • Various bits were tested either with IAR ARM or IAR MSP430? compilers

Makefile

  • Call xmlstar from makefile to extract includes and sourcefile list
  • Alternatively, transform project file to makefile entirely

Extract source files from IAR project

  • xmlstarlet
  • outputs list of all .c and .cpp files included in the project

Bash version

  • Escaped for direct inclusion in BASH script.
  • $PROJECT_FILE is .ewp project file
  • IAR uses standard DOS path separator so use tr '\\' '/'
xml sel -t -m '/project/file|/project//group/file' -i "contains(name,'.c') or contains(name,'.cpp')" -v "concat(substring-after(name,'\$PROJ_DIR$\'),'
')" $PROJECT_FILE

DOS batch version

  • Escaped for direct inclusion in DOS batch file.
  • %PROJECT_FILE% is .ewp project file
xml sel -t -m "/project/file|/project//group/file" -i "contains(name,'.c') or contains(name,'.cpp')" -v "concat(substring-after(name,'$PROJ_DIR$\'),'
')" %PROJECT_FILE%

Extract include directories from IAR project

Environment Variables

  • PROJ_DIR
  • TOOLKIT_DIR

Extract with xmlstar

xml sel -t -m '/project/configuration' -i "contains(name,'Debug')" -m './settings' -i "contains(name,'ICC430')" -m "./data/option" -i "contains(name,'CCStdIncludePaths') or contains(name,'newCCIncludePaths')" -m "state" -v "concat('-I "',.,'" ')"  $PROJECT_FILE

Extract defines from IAR project

xml sel -t -m '/project/configuration' -i "contains(name,'Debug')" -m './settings' -i "contains(name,'ICC430')" -m "./data/option" -i "name='CCDefines'" -m "./state" -v "concat('-D',.,' ')" $PROJECT_FILE

VIM Compiler File

  • Install into .vimfiles/compiler/iar.vim
" ---- Beginning of ${vimfiles}/compiler/iar.vim ----
" Compiler:     IAR icc430
" Maintainer:   Mark Ferry <vim_NOSPAM_AT_markferry_DOT_net>
" Last Change:  2009 Jan 21

if exists("current_compiler")
  finish
endif
let current_compiler = "iar"

" errorformat matches errors like:
" ...
"      MyOneArgumentFunction();
"                            ^
""MyFile.c",666  Error[Pe165]: too few arguments in function call
"
" ...
" Warnings are matched similarly.
"
CompilerSet errorformat=%E%p^,%Z\"%f\"\\\,%l\ \ Error[Pe%n]:\ %m,%W%p^,%Z\"%f\"\\\,%l\ \ Warning[Pe%n]:\ %m

" ---- End of Vim compiler file ----

Configure VIM

Set your compiler

:compiler iar

vimrc project settings

set path=.,,**,C:\Program\\\ Files\IAR\\\ Systems\Embedded\\\ Workbench\\\ 5.4\430\inc,C:\Program\\\ Files\IAR\\\ Systems\Embedded\\\ Workbench\\\ 5.4\430\inc\dlib

ToDo?

  • more compiler configuration - C99 etc.
Recent Changes (All) | Edit SideBar Page last modified on 21 June 2017, at 02:39 PM UTC Edit Page | Page History
Powered by PmWiki