Skip to content

Commit

Permalink
Added option for a build.path
Browse files Browse the repository at this point in the history
  • Loading branch information
jerdna-regeiz committed Jan 27, 2019
1 parent 17e2110 commit d516525
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
19 changes: 19 additions & 0 deletions autoload/arduino.vim
Expand Up @@ -42,6 +42,10 @@ function! arduino#InitializeConfig() abort
if !exists('g:arduino_serial_cmd')
let g:arduino_serial_cmd = 'screen {port} {baud}'
endif
if !exists('g:arduino_build_path')
let g:arduino_build_path = '{project_dir}/build'
endif

if !exists('g:arduino_serial_baud')
let g:arduino_serial_baud = 9600
endif
Expand Down Expand Up @@ -102,6 +106,17 @@ function! arduino#GetArduinoExecutable() abort
endif
endfunction

function! arduino#GetBuildPath() abort
if empty(g:arduino_build_path)
return ''
endif
let l:path = g:arduino_build_path
let l:path = substitute(l:path, '{file}', expand('%:p'), 'g')
let l:path = substitute(l:path, '{project_dir}', fnamemodify(expand('%:p'), ":h"), 'g')
return l:path
endfunction


function! arduino#GetArduinoCommand(cmd) abort
let arduino = arduino#GetArduinoExecutable()

Expand All @@ -117,6 +132,10 @@ function! arduino#GetArduinoCommand(cmd) abort
if !empty(g:arduino_programmer)
let cmd = cmd . " --pref programmer=" . g:arduino_programmer
endif
let l:build_path = arduino#GetBuildPath()
if !empty(l:build_path)
let cmd = cmd . " --pref build.path=" . l:build_path
endif
let cmd = cmd . " " . g:arduino_args . " " . expand('%:p')
return cmd
endfunction
Expand Down
13 changes: 13 additions & 0 deletions doc/arduino.txt
Expand Up @@ -26,6 +26,7 @@ Overview:~
|arduino_cmd|..................Path to the arduino executable
|arduino_dir|..................Path to the arduino install directory
|arduino_home_dir|.............Path to the arduino user install directory
|arduino_build_path|...........Path to use for building the sketch
|arduino_run_headless|.........Try to run inside Xvfb
|arduino_args|.................Additional args to pass to 'arduino' command.
|arduino_board|................The fully-qualified name of the board.
Expand Down Expand Up @@ -59,6 +60,18 @@ able to detect it, but if it cannot you can set the value manually. >
let g:arduino_home_dir = $HOME . ".arduino15"
<

*'g:arduino_build_path'*
The path where the sketch will be build and all intermediate object files will
be placed. The final binary (.bin) can be found after building/verification in
the folder.
For a dynamic path you can following substitutions:
- {file} is substituted with the current sketch file (.ino)
- {project_dir} is substituted with the folder the sketch resides in
Usage of a build path can be disabled with g:arduino_build_path = ''.
If disabled, arduino ide chooses a temporary path and will do a full rebuild. >
let g:arduino_build_path = "{project_dir}/build"
<

*'g:arduino_run_headless'*
Run the arduino command inside a Xvfb. Requires Xvfb to be installed and in the
PATH. >
Expand Down
1 change: 1 addition & 0 deletions doc/tags
Expand Up @@ -4,6 +4,7 @@
'g:arduino_cmd' arduino.txt /*'g:arduino_cmd'*
'g:arduino_dir' arduino.txt /*'g:arduino_dir'*
'g:arduino_home_dir' arduino.txt /*'g:arduino_home_dir'*
'g:arduino_build_path' arduino.txt /*'g:arduino_build_path'*
'g:arduino_programmer' arduino.txt /*'g:arduino_programmer'*
'g:arduino_run_headless' arduino.txt /*'g:arduino_run_headless'*
'g:arduino_serial_baud' arduino.txt /*'g:arduino_serial_baud'*
Expand Down

0 comments on commit d516525

Please sign in to comment.