Robot-Will / Stino

A Sublime Text Plugin for Arduino
Other
1.58k stars 250 forks source link

Failed to build projects with multiple *.ino files. #10

Closed Smartype closed 11 years ago

Smartype commented 11 years ago

With the Arduino IDE, if will merge all ino files to create a cpp file and build that one. But with this plug in , it will try to build every one instead.

Robot-Will commented 11 years ago

Thanks a lot. Actually, I do not know what Arduino IDE does for multiple ino files. I just treat them as c++ source files and compile them separately. Would you give me more information about this topic? If I have more detailed information, I will make this plugin acting more like Arduino IDE.

Smartype commented 11 years ago

This file is created from all the .ino, .cpp, .h, .c files in the project directory:

Erics-MacBook-Pro:MultiWii eric$ ls -l total 12736 -rw-r--r-- 1 eric staff 24885 Mar 25 11:13 Alarms.ino -rw-r--r--@ 1 eric staff 1521686 Jan 18 14:38 Buzzer battery monitor.png -rw-r--r--@ 1 eric staff 162420 Mar 22 10:52 Dashboard.png -rw-r--r-- 1 eric staff 7385 Mar 25 11:11 EEPROM.ino -rw-r--r--@ 1 eric staff 82537 Mar 23 17:12 Fly to.png -rw-r--r-- 1 eric staff 54094 Mar 25 13:16 GPS.ino -rw-r--r-- 1 eric staff 15598 Mar 25 13:19 IMU.ino -rw-r--r-- 1 eric staff 96615 Mar 25 11:21 LCD.ino -rw-r--r-- 1 eric staff 3533 Jan 2 15:20 LED.ino -rw-r--r--@ 1 eric staff 949202 Mar 23 17:11 Map.png -rw-r--r--@ 1 eric staff 174984 Mar 23 17:11 Menu.png -rw-r--r--@ 1 eric staff 2840740 Jan 13 13:33 MultiWii board.png -rw-r--r-- 1 eric staff 79669 Mar 25 18:59 MultiWii.ino -rwxr-xr-x@ 1 eric staff 57111 Mar 25 11:24 Output.ino -rw-r--r--@ 1 eric staff 71940 Mar 23 17:08 PID.png -rw-r--r-- 1 eric staff 353 Mar 19 09:02 README.md -rw-r--r-- 1 eric staff 35468 Mar 25 11:25 RX.ino -rw-r--r-- 1 eric staff 86036 Mar 25 13:06 Sensors.ino -rw-r--r-- 1 eric staff 32173 Mar 25 13:31 Serial.ino -rwxr-xr-x 1 eric staff 113 Mar 25 12:35 build.sh -rw-r--r-- 1 eric staff 72879 Mar 25 18:18 config.h -rw-r--r-- 1 eric staff 1523 Mar 22 23:39 config.mwi -rw-r--r-- 1 eric staff 77012 Mar 25 10:32 def.h -rw-r--r-- 1 eric staff 6918 Jan 2 15:20 digitalWriteFast.h -rw-r--r-- 1 eric staff 15755 Mar 25 12:35 makefile -rw-r--r-- 1 eric staff 1262 Jan 2 15:20 tinygps.h

/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=103 -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/variants/standard /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/MultiWii.cpp -o /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/MultiWii.cpp.o MultiWii.ino:57: warning: only initialized variables can be placed into program memory area MultiWii.ino:129: warning: only initialized variables can be placed into program memory area MultiWii.ino:186: warning: only initialized variables can be placed into program memory area MultiWii.ino:472: warning: 'typedef' was ignored in this declaration MultiWii.ino: In function 'void loop()': MultiWii.ino:1747: warning: suggest parentheses around && within || MultiWii.ino:1347: warning: unused variable 'timestamp_fixated' GPS.ino: In function 'void GPS_NewData()': GPS.ino:329: warning: unused variable 'axis' IMU.ino: In function 'uint8_t getEstimatedAltitude()': IMU.ino:365: warning: unused variable 'deadLine' RX.ino: In function 'void computeRC()': RX.ino:443: warning: unused variable 'rcData4Values' RX.ino:443: warning: unused variable 'rcDataMean' RX.ino:444: warning: unused variable 'rc4ValuesIndex' RX.ino:445: warning: unused variable 'chan' RX.ino:445: warning: unused variable 'a' Sensors.ino: In function 'void GYRO_Common()': Sensors.ino:288: warning: unused variable 'tilt' MultiWii.ino: At global scope: MultiWii.ino:50: warning: 'uint8_t led_flasher_on()' declared 'static' but never defined MultiWii.ino:82: warning: 'bool check_missed_wp()' declared 'static' but never defined MultiWii.ino:85: warning: 'void GPS_calc_velocity()' declared 'static' but never defined MultiWii.ino:86: warning: 'void GPS_calc_location_error(int32t, int32t, int32t, int32t)' declared 'static' but never defined MultiWii.ino:87: warning: 'void GPS_calc_poshold()' declared 'static' but never defined MultiWii.ino:88: warning: 'void GPS_calc_nav_rate(uint16_t)' declared 'static' but never defined MultiWii.ino:89: warning: 'void GPS_update_crosstrack()' declared 'static' but never defined MultiWii.ino:90: warning: 'uint16_t GPS_calc_desired_speed(uint16_t, bool)' declared 'static' but never defined MultiWii.ino:382: warning: 'uint8_t debugmsg_available()' declared 'static' but never defined MultiWii.ino:383: warning: 'void debugmsg_serialize(uint8_t)' declared 'static' but never defined MultiWii.ino:562: warning: 'GPS_Present' defined but not used MultiWii.ino:659: warning: 'AltVario' defined but not used RX.ino:28: warning: 'PCInt_RX_Pins' defined but not used Using previously compiled: /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/WInterrupts.c.o Using previously compiled: /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/wiring.c.o Using previously compiled: /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/wiring_analog.c.o Using previously compiled: /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/wiring_digital.c.o Using previously compiled: /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/wiring_pulse.c.o Using previously compiled: /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/wiring_shift.c.o Using previously compiled: /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/CDC.cpp.o Using previously compiled: /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/HardwareSerial.cpp.o Using previously compiled: /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/HID.cpp.o Using previously compiled: /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/IPAddress.cpp.o Using previously compiled: /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/main.cpp.o Using previously compiled: /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/new.cpp.o Using previously compiled: /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/Print.cpp.o Using previously compiled: /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/Stream.cpp.o Using previously compiled: /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/Tone.cpp.o Using previously compiled: /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/USBCore.cpp.o Using previously compiled: /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/WMath.cpp.o Using previously compiled: /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/WString.cpp.o /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-ar rcs /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/core.a /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/WInterrupts.c.o /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-ar rcs /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/core.a /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/wiring.c.o /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-ar rcs /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/core.a /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/wiring_analog.c.o /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-ar rcs /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/core.a /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/wiring_digital.c.o /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-ar rcs /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/core.a /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/wiring_pulse.c.o /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-ar rcs /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/core.a /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/wiring_shift.c.o /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-ar rcs /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/core.a /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/CDC.cpp.o /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-ar rcs /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/core.a /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/HardwareSerial.cpp.o /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-ar rcs /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/core.a /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/HID.cpp.o /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-ar rcs /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/core.a /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/IPAddress.cpp.o /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-ar rcs /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/core.a /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/main.cpp.o /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-ar rcs /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/core.a /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/new.cpp.o /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-ar rcs /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/core.a /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/Print.cpp.o /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-ar rcs /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/core.a /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/Stream.cpp.o /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-ar rcs /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/core.a /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/Tone.cpp.o /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-ar rcs /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/core.a /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/USBCore.cpp.o /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-ar rcs /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/core.a /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/WMath.cpp.o /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-ar rcs /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/core.a /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/WString.cpp.o /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-gcc -Os -Wl,--gc-sections -mmcu=atmega328p -o /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/MultiWii.cpp.elf /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/MultiWii.cpp.o /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/core.a -L/var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp -lm /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-objcopy -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/MultiWii.cpp.elf /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/MultiWii.cpp.eep /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-objcopy -O ihex -R .eeprom /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/MultiWii.cpp.elf /var/folders/b7/_w2dyg3j6sx9zf61hz03l4hw0000gn/T/build8640577125137740608.tmp/MultiWii.cpp.hex Binary sketch size: 29,790 bytes (of a 30,720 byte maximum)

Robot-Will commented 11 years ago

I download your codes and try to compile them, but I failed. You made a great job, and your code are very complex. It's a challenge to me, and I will write codes to parse it in right way.

blezalex commented 11 years ago

you can try a smaller project, two ino files is enough. Make second file call something like " OCR1A =" and you'll get compilation error - error: 'OCR1A' was not declared in this scope.

Thank you for quick response and the plugin, once you find a way to fix this one, i can start using it.

Robot-Will commented 11 years ago

You are right, no declaration error will give.

I think Arduino IDE is for beginners, so it needn't users writing complete source codes, just writing function definitions, and the IDE will combine all source code into one file, then compile the combination. Before compilation, the IDE creates a declaration list and adds the list to the top of the combination file. So Arduino IDE will not give declaration error. I do not read the source code of Arduino IDE, and do not know how it creates the declaration list, but it does a good job.

I did not learn the course of Compilation Principle, so I have no idea how to analyze a complex C++ source code, and current plugin just gives a simple resolution to create declaration lists. So it maybe give error messages when compiling.

However, I think it is not a good habit for programming that just writing function definitions. I read the book "C++ How to program" 8th edition (Paul Deitel and Harvey Deitel), and this book taught me how to write good C++ codes. Write your declarations in header (.h, .hpp) files. When you use the functions, just include the corresponding header files. In your main source code, which includes setup() and loop() functions, do not write extra function definitions, just include header files. That is, you function definition files will be a library, and you can copy these files to SKETCHBOOK FOLDER/libraries/LIB_NAME, you can repeat using this functions just writing #include <HEADER.h>.

Or you can see this issue and start to use this plugin https://github.com/Robot-Will/Stino/issues/3