amperka / ino

Command line toolkit for working with Arduino hardware
http://inotool.org
MIT License
1.08k stars 233 forks source link

Add support to specify an arbitrary directory to track external libraries #193

Open skraelings opened 9 years ago

skraelings commented 9 years ago

Currently there are two ways to add external dependecies, correct me if I am wrong:

it would be nice to specify a directory (ala 'sketchbook/libraries') for external dependencies as not to clutter the arduino_libraries and also not to copy-paste endlessly the same libraries across the projects I am working on.

translucide commented 9 years ago

I use a simple script I made that adds a symlink to the lib/ dir folder of my current project for the librairies i want to import to my project. That works and prevents copying same libs files in all projects.

joelbschwartz commented 9 years ago

@skraelings +1. Being able to reference external libraries, for example by defining a [lib] path within the 'ino.ini' file, would be awesome.

@translucide I haven't been able to get this to work. When I tried this, I kept 'lib' as a directory, and used symlinks for a sample header. In this case, replacing what was '/test-header/' (within 'lib') with a symlink to '~/Development/Sketchbook/Libraries/test-header'. Can you please give more detail on how this works for you?

translucide commented 9 years ago

@joelbschwartz I used a folder in my main librairies folder that has a foldername.h and a foldername.cpp in it. Then I symlink that "foldername" folder in the lib subfolder of my ino project, i.e. I have now myinoproject/lib/foldername as a symlink to my librairiesfolder/foldername... Scripting this for integration with any ide is pretty straight forwward... just have to pop up a dialog box that fetches a list of directories from my main librairies directory. On linux symlinks are the same as having the files in your myinoproject/libs directory, so first I suggest you try with a lib subfolder that works, then move it to your librairies main directory.... I do not see why it would not work. Let me know if you are not able to make it work with the info I provided, Ill be happy to help you and dig more into it if necessary.

translucide commented 9 years ago

@joelbschwartz However I do agree that having an .ini setting with additional librairies path would be really awesome !

translucide commented 9 years ago

Should anyone need this and understand PHP , here is my add library script that I use with Komodo IDE (of course, you can change the paths to the Librairies folder!) :

!/bin/php

<?php /**

$cwd = echo $1; $options = ''; if ($handle = opendir('../../Librairies')) { while (false !== ($entry = readdir($handle))) { if ($entry != "." && $entry != "..") { $options .= ' false "'.trim($entry).'"'; } } closedir($handle); } $libs = yad --title "Choose librairies to import in current project" --list --checklist --column "" --column "Library"$options; $libs = str_replace("TRUE|",'TRUE::',$libs); $libs = str_replace("FALSE|",'FALSE::',$libs); $libs = explode("|",trim($libs));

foreach($libs as $v){ $info = explode("::",trim($v)); if ($info[0] == 'TRUE' && $info[1] != '' && file_exists('../../Librairies/'.$info[1]) && is_dir('../../Librairies/'.$info[1]) && !file_exists('../lib/'.$info[1])) { echo "Importing \"".$info[1]."\" library to current project\r\n"; $file = $info[1]; ln -s "../../Librairies/$file" "../lib/$file"; }

} exit; ?>

translucide commented 9 years ago

oups... where there is gray bg below code, it is encloded in backticks but they do not appear.... damn...where do we upload files here ???

joelbschwartz commented 9 years ago

@translucide Sorry, I realized from your response I had a typo (corrected) when I described the symlink. Based on your description and code, it seems like we're doing the same thing now. Not sure why it doesn't work for me...

translucide commented 9 years ago

@joelbschwartz Could file permissions be an issue ?

translucide commented 9 years ago

Did you start with a sub inoproject/lib/ folder and moved it to your lib directory after seeing it working ? Does your librairies folder resides on the same partition as your ino project one ?... jsut stating the obvious... you know we have to eliminate the basics first...

translucide commented 9 years ago

@joelbschwartz and moved it to your lib --> not lib, but main librairies folder I meant... sorry...

translucide commented 9 years ago

screenshot from 2014-09-27 23 22 14

Here is a screenshot: on the left a general librairies folder (created one on purpose cause I am not on my main computer right now).... on the right my ino prject named "libtest" in the lib subfolder. The link there refers to the MCP9701 folder in the Librairies folder. I thought that leaves no place for miscommunication.... so there we can tackle the remaining of the problem if you still have one ! So lets get this fixed for you !

translucide commented 9 years ago

I forgot to mention the obvious, I have in Librairies/MCP9701 folder a file named MCP9701.cpp and .h too.... will not work if files names are not named as the foldername