edward0429 / arduino

Automatically exported from code.google.com/p/arduino
0 stars 0 forks source link

Recursive compilation #529

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What change would like to see?
For big or complex project, is very comfortable move some home made 
classes/libraries in sub folder. But arduino IDE doesn't do that

Why?
Well arduino IDE support that, but in the Compiler.java class you'll see that 
cursiveness is activated only for internal classes, not for the libraries 
folder neither for sketch folder.

Solution?
Here my solution: change all "findFilesInFolder(libraryFolder, "S", false)" to 
"findFilesInFolder(libraryFolder, "S", true)" so it will be recursive.
Delete the code in the part "// 2. compile the libraries, outputting .o files 
to: <buildPath>/<library>/" that handle the utils folder. in particular remove:
includePaths.add(utilityFolder.getAbsolutePath()); 
[...]
outputFolder = new File(outputFolder, "utility");
     createFolder(outputFolder);
     objectFiles.addAll(
       compileFiles(avrBasePath, outputFolder.getAbsolutePath(), includePaths,
               findFilesInFolder(utilityFolder, "S", true),
               findFilesInFolder(utilityFolder, "c", true),
               findFilesInFolder(utilityFolder, "cpp", true),
               boardPreferences));
     // other libraries should not see this library's utility/ folder
     //includePaths.remove(includePaths.size() - 1);

Now we have to deal with the libraries that was using utils folder... only 
Wire, so in Wire.cpp change #include "twi.h" to #include "utility/twi.h"

Would this cause any incompatibilities with previous versions?  If so, how
can these be mitigated?
It potentially can create some incompatibility, if some code was using directly 
twi.h (but just update the path and everything should work)

Original issue reported on code.google.com by mombelli...@gmail.com on 29 Apr 2011 at 7:52

GoogleCodeExporter commented 9 years ago
Here as attach the corrected Compile.java, the change to Wire.cpp is so easy 
that I won't  upload it

Original comment by mombelli...@gmail.com on 29 Apr 2011 at 8:03

Attachments:

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Here I'm again.
The previous code solved the problem for the libraries folder, but not for the 
sketch folder.
To solve i've added 2 method at Base.java:
public static void updateLib(File sketchPath)
and
private static boolean addLib(File folder) throws IOException
This second one, is just public void rebuildImportMenu(JMenu importMenu) 
rewritten to look in sketch folder and will not update the menu.
Then in class Sketch.java, method:
public String preprocess(String buildPath, PdePreprocessor preprocessor) throws 
RunnerException
add the line
Base.updateLib(folder); 
just before 
for (String item : preprocessor.getExtraImports()) {

GOOD: you don't need to restart IDE if you add a new libraries in the paths 
(core, libraries in sketchbook, sketch folder)
BAD: menu aren't updated
all the file from libraries in sketchbook and sketch folder will loose their 
subfolder organization, due to recursive setted as true. This can be avoided 
modifying findFilesInFolder() in Compiler.java, this also means if you put two 
file with the same name in subfolder and one of it's recursive, the results are 
unknown.

As attach the code

Original comment by mombelli...@gmail.com on 1 May 2011 at 2:35

Attachments:

GoogleCodeExporter commented 9 years ago
Are there any issues related to picking up the example files in the libraries 
folder? 

Original comment by rick.rickanderson on 11 May 2011 at 7:51

GoogleCodeExporter commented 9 years ago
When you say menus aren't updated, what are you looking to see?

Original comment by rick.rickanderson on 11 May 2011 at 10:01

GoogleCodeExporter commented 9 years ago
"Are there any issues related to picking up the example files in the
libraries folder?"

no, example files doesn't have any problem

"When you say menus aren't updated, what are you looking to see?"

When arduino look for recursive libraries, it doesn't add them to the menu
Sketch -> "Import Library". probably this is a secondary problem, as
recursive will be used form advanced user, that should know how use import.

Another problem: in the import you doesn't have to add the relative path,
because in compilation time all recursive library is copied  in the same
temporary .pde's folder

Original comment by mombelli...@gmail.com on 12 May 2011 at 10:27

GoogleCodeExporter commented 9 years ago
Recursive compilation will be available in IDE 1.5.2 and will be triggered only 
for fat libraries

Original comment by federico...@gmail.com on 28 Jan 2013 at 10:07

GoogleCodeExporter commented 9 years ago

Original comment by federico...@gmail.com on 6 Feb 2013 at 11:04