-
Notifications
You must be signed in to change notification settings - Fork 24
Better compatibility to Android IDE local packages installation #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,6 +54,9 @@ function! arduino#InitializeConfig() | |
if !exists('g:arduino_run_headless') | ||
let g:arduino_run_headless = executable('Xvfb') ? 1 : 0 | ||
endif | ||
if !exists('g:arduino_user_installation') | ||
let g:arduino_user_installation = 0 | ||
endif | ||
|
||
if !exists('g:arduino_serial_port_globs') | ||
let g:arduino_serial_port_globs = ['/dev/ttyACM*', | ||
|
@@ -118,19 +121,36 @@ endfunction | |
function! arduino#GetBoards() | ||
let arduino_dir = arduino#GetArduinoDir() | ||
let boards = [] | ||
for filename in split(globpath(arduino_dir . '/hardware', '**/boards.txt'), '\n') | ||
let pieces = split(filename, '/') | ||
let package = pieces[-3] | ||
let arch = pieces[-2] | ||
let lines = readfile(filename) | ||
for line in lines | ||
if line =~? '^[^.]*\.build\.board=.*$' | ||
let linesplit = split(line, '\.') | ||
let board = linesplit[0] | ||
call add(boards, package . ':' . arch . ':' . board) | ||
endif | ||
if arduino#GetArduinoUserInstallation() == 1 | ||
for filename in split(globpath(arduino_dir . '/packages', '**/boards.txt'), '\n') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the difference in logic here (searching There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes you got the point correct: I realized with your plugin, that all my hardware, etc. (installed by the arduino ide into the user dir) wasn't available. |
||
let pieces = split(filename, '/') | ||
let package = pieces[-5] | ||
let arch = pieces[-3] | ||
let package_version = pieces[-2] | ||
let lines = readfile(filename) | ||
for line in lines | ||
if line =~? '^[^.]*\.build\.board=.*$' | ||
let linesplit = split(line, '\.') | ||
let board = linesplit[0] | ||
call add(boards, package . ':' . arch . ':' . board . ':' . package_version) | ||
endif | ||
endfor | ||
endfor | ||
endfor | ||
else | ||
for filename in split(globpath(arduino_dir . '/hardware', '**/boards.txt'), '\n') | ||
let pieces = split(filename, '/') | ||
let package = pieces[-3] | ||
let arch = pieces[-2] | ||
let lines = readfile(filename) | ||
for line in lines | ||
if line =~? '^[^.]*\.build\.board=.*$' | ||
let linesplit = split(line, '\.') | ||
let board = linesplit[0] | ||
call add(boards, package . ':' . arch . ':' . board) | ||
endif | ||
endfor | ||
endfor | ||
endif | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you take the shared logic here and factor it out into a function? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
return boards | ||
endfunction | ||
|
||
|
@@ -139,6 +159,10 @@ function! arduino#GetBoardOptions(board) | |
let board_pieces = split(a:board, ':') | ||
let filename = arduino_dir . '/hardware/' . board_pieces[0] . | ||
\ '/' . board_pieces[1] . '/boards.txt' | ||
if !filereadable(filename) | ||
let filename = arduino_dir . '/packages/' . board_pieces[0] . | ||
\ '/hardware/' . board_pieces[1] . '/' . board_pieces[3] . '/boards.txt' | ||
endif | ||
let lines = readfile(filename) | ||
let pattern = '^' . board_pieces[2] . '\.menu\.\([^.]*\)\.\([^.]*\)=' | ||
let options = {} | ||
|
@@ -160,18 +184,33 @@ endfunction | |
function! arduino#GetProgrammers() | ||
let arduino_dir = arduino#GetArduinoDir() | ||
let programmers = [] | ||
for filename in split(globpath(arduino_dir . '/hardware', '**/programmers.txt'), '\n') | ||
let pieces = split(filename, '/') | ||
let package = pieces[-3] | ||
let lines = readfile(filename) | ||
for line in lines | ||
if line =~? '^[^.]*\.name=.*$' | ||
let linesplit = split(line, '\.') | ||
let programmer = linesplit[0] | ||
call add(programmers, package . ':' . programmer) | ||
endif | ||
if arduino#GetArduinoUserInstallation() == 1 | ||
for filename in split(globpath(arduino_dir . '/packages', '**/programmers.txt'), '\n') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same question about if this is specific to a user installation There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes it is. |
||
let pieces = split(filename, '/') | ||
let package = pieces[-5] | ||
let lines = readfile(filename) | ||
for line in lines | ||
if line =~? '^[^.]*\.name=.*$' | ||
let linesplit = split(line, '\.') | ||
let programmer = linesplit[0] | ||
call add(programmers, package . ':' . programmer) | ||
endif | ||
endfor | ||
endfor | ||
endfor | ||
else | ||
for filename in split(globpath(arduino_dir . '/hardware', '**/programmers.txt'), '\n') | ||
let pieces = split(filename, '/') | ||
let package = pieces[-3] | ||
let lines = readfile(filename) | ||
for line in lines | ||
if line =~? '^[^.]*\.name=.*$' | ||
let linesplit = split(line, '\.') | ||
let programmer = linesplit[0] | ||
call add(programmers, package . ':' . programmer) | ||
endif | ||
endfor | ||
endfor | ||
endif | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also looks like a lot of shared logic that could be factored out into a function There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
return sort(programmers) | ||
endfunction | ||
|
||
|
@@ -222,9 +261,15 @@ endfunction | |
" Callback from board selection. Sets the board and prompts for any options | ||
function! arduino#SelectBoard(board) | ||
let options = arduino#GetBoardOptions(a:board) | ||
call arduino#SetBoard(a:board) | ||
let board_pieces = split(a:board, ':') | ||
if len(board_pieces) == 4 | ||
let board = board_pieces[0] . ':' . board_pieces[1] . ':' . board_pieces[2] | ||
else | ||
let board = a:board | ||
endif | ||
call arduino#SetBoard(board) | ||
let s:callback_data = { | ||
\ 'board': a:board, | ||
\ 'board': board, | ||
\ 'available_opts': options, | ||
\ 'opts': {}, | ||
\ 'active_option': '', | ||
|
@@ -418,18 +463,31 @@ function! arduino#GetArduinoDir() | |
if exists('g:arduino_dir') | ||
return g:arduino_dir | ||
endif | ||
let executable = arduino#GetArduinoExecutable() | ||
let arduino_cmd = arduino#FindExecutable(executable) | ||
let arduino_dir = fnamemodify(arduino_cmd, ':h') | ||
if s:OS == 'Darwin' | ||
let arduino_dir = fnamemodify(arduino_dir, ':h') . '/Java' | ||
endif | ||
if !s:FileExists(arduino_dir . '/hardware/arduino/') | ||
throw "Could not find arduino directory. Please set g:arduino_dir" | ||
if arduino#GetArduinoUserInstallation() == 1 | ||
let arduino_dir = $HOME . '/.arduino15' | ||
if !s:FileExists(arduino_dir) | ||
throw "Could not find arduino directory. Please set g:arduino_dir" | ||
endif | ||
else | ||
let executable = arduino#GetArduinoExecutable() | ||
let arduino_cmd = arduino#FindExecutable(executable) | ||
let arduino_dir = fnamemodify(arduino_cmd, ':h') | ||
if s:OS == 'Darwin' | ||
let arduino_dir = fnamemodify(arduino_dir, ':h') . '/Java' | ||
endif | ||
if !s:FileExists(arduino_dir . '/hardware/arduino/') | ||
throw "Could not find arduino directory. Please set g:arduino_dir" | ||
endif | ||
endif | ||
return arduino_dir | ||
endfunction | ||
|
||
function! arduino#GetArduinoUserInstallation() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think you actually need this function. Since you do the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The user should be able to configure the directory, because it can be configured in the arduino ide as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps I'm misunderstanding, but at the top of the file you're doing if !exists('g:arduino_user_installation')
if s:FileExists(s:ARDUINO_USER_DIR)
let g:arduino_user_installation = 1
else
let g:arduino_user_installation = 0
endif
endif So by the time this method is called, the only way |
||
if exists('g:arduino_user_installation') | ||
return g:arduino_user_installation | ||
endif | ||
endfunction | ||
|
||
" Ctrlp extension {{{1 | ||
if exists('g:ctrlp_ext_vars') | ||
let g:arduino_ctrlp_enabled = 1 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,7 @@ Overview:~ | |
|arduino_serial_tmux|..........Tmux command to open serial debugger. | ||
|arduino_serial_port|..........Location of the serial port. | ||
|arduino_serial_port_globs|....Globs to auto-search for serial port. | ||
|arduino_user_installation|....Use user installation of arduino ide. | ||
|
||
------------------------------------------------------------------------------- | ||
Detailed descriptions and default values:~ | ||
|
@@ -110,6 +111,13 @@ Search these patterns to find a likely serial port to upload to. > | |
\'/dev/tty.usbserial*'] | ||
< | ||
|
||
*'g:arduino_user_installation'* | ||
Set this variable to 1 if you want to use the the arduino user folder normally | ||
located under ~/.arduino15. | ||
If you're using a non default path you also have to set 'g:arduino_dir'. > | ||
let g:arduino_user_installation = 0 | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe you'll want a closing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
=============================================================================== | ||
COMMANDS *arduino-commands* | ||
*:ArduinoChooseBoard* | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want, you could default this to 1 if
s:FileExists($HOME . ".arduino15")
. If you do, you should probably pull$HOME . ".arduino15"
out into a constant or a functionThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done :)