pombreda / arscons

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

multi-file sketches not handled correctly #2

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Have a multi-file (.pde, .cpp, etc) sketch
2. Attempt to compile it
3. ?
4. Don't profit.

Your SConstruct file as-is only handles single-file (target.pde) sketches. 
Additionally, there's a small bug in the handling of libraries with utilities, 
causing the actual library not to be compiled, instead compiling only its 
utilities.

I've patched it to handle multi-file sketches and fix the library bug. Probably 
not perfect, but maybe it's of use to you. Patch attached.

Original issue reported on code.google.com by mwes...@gmail.com on 17 Oct 2010 at 2:34

Attachments:

GoogleCodeExporter commented 9 years ago
I don't recommend multi-file in sketch root dir.
but, use make a directoy(ex. my_libs/my_special_lib) under sketch root then use 
EXTRA_LIB var. to point it. (ex. scons EXTRA_LIB=my_libs )

multi-file in one dir is not common use case. (genuin arduino don't support it. 
isn't it?)

utility bug is fixed in rev. 21
thanks!

Original comment by ff4...@gmail.com on 19 Oct 2010 at 5:27

GoogleCodeExporter commented 9 years ago
Actually you can have a multi-file sketch also with arduino IDE, and it's 
common. Maybe generate all .* from cpp which has a different name from sketch 
name may be enough...

Original comment by enricoca...@gmail.com on 27 Dec 2010 at 10:46

GoogleCodeExporter commented 9 years ago
Hi, I' ve tried this patch (which I think is very useful as I use to have 
several files inside each project), but doesn't work.

When you add a new tab in ardino IDE, and you give a name with no extension, a 
file ending in .pde is created. But this file is not used to compile the 
project so it fails to compile. There should be no need for use an include in 
the main file...

Original comment by gsy...@gmail.com on 23 Jan 2011 at 1:37

GoogleCodeExporter commented 9 years ago
The problem seems to be related with the order of the included files in the 
proyect.cpp generated by the script. For my sample project I have the following 
generated pruebaarduino.cpp:

  1 #include <WProgram.h>
  2 
  3 int main(void)
  4 {
  5         init();
  6         setup();
  7         for (;;)
  8                 loop();
  9         return 0;
 10 }
 11 
 12 #line 1 "build/pruebaarduino.pde"^M
 13 void setup()
 14 {
 15     pinMode(13,OUTPUT);
 16 }
 17 
 18 void loop()
 19 {
 20   parpadea(50);
 21 }
 22 #line 1 "/home/syvic/Arduino/projects/pruebaarduino/a.pde"^M
 23 
 24 void parpadea(int time)
 25 {
 26     digitalWrite(13,HIGH);
 27     delay(time);
 28     digitalWrite(13,LOW);
 29     delay(time);
 30 }

which fails while doing:

avr-g++ -o build/pruebaarduino.o -c -ffunction-sections -fdata-sections 
-fno-exceptions -funsigned-char -funsigned-bitfields -fpack-struct 
-fshort-enums -Os -mmcu=atmega328p -DARDUINO=20 -DF_CPU=16000000L -Ibuild/core 
build/pruebaarduino.cpp

It is easily fixed by changing the function parpadea to be on top of setup() 
function.

Original comment by gsy...@gmail.com on 23 Jan 2011 at 2:25

GoogleCodeExporter commented 9 years ago
I think is fixed now. The following code for fnProcessing works fine:

129 def fnProcessing(target, source, env):
130     wp = open ('%s'%target[0], 'w')
131     wp.write(open(ARDUINO_SKEL).read())
132     for file in glob(os.path.realpath(os.curdir) + "/*.pde"):
133         print file, TARGET
134         if not os.path.samefile(file, TARGET+".pde"):
135             wp.write('#line 1 "%s"\r\n' % file)
136             wp.write(open(file).read())
137     # Add this preprocessor directive to localize the errors.
138     wp.write('#line 1 "%s"\r\n' % source[0])
139     wp.write(open('%s'%source[0]).read())
140     wp.close()
141     return None

(Assuming the patch of the first comment is applied)

Original comment by gsy...@gmail.com on 23 Jan 2011 at 2:36

GoogleCodeExporter commented 9 years ago
Hi,

when doing changes in other than main pde this is not rebuilt,
by deleting build/TARGET.{cpp,pde} this is regenerated on every build.

See: 
https://gitorious.org/arscons/arscons/commit/397774fdf6ab38c66f05819e2b67b17e7bb
e3a7d

- Gaute

Original comment by e...@gaute.vetsj.com on 9 Sep 2011 at 1:46

GoogleCodeExporter commented 9 years ago
I have come to a similar solution. It does not break anything else for me but 
the changes are somewhat extensive.
Support for multiple pde files would be a nice addition.

The diff file is to the latest version in git ... hope I got it right, I don't 
have experience with git

Original comment by petrisor...@gmail.com on 21 Sep 2011 at 3:19

Attachments:

GoogleCodeExporter commented 9 years ago
I Just pushed patch for multi-file sketch.

I don't use the multi-file convention in my projects.
And, don't know it's good enough.

So, Please try with it. Give me some feedback.

- Homin Lee

Original comment by ff4...@gmail.com on 31 Oct 2011 at 4:51