pixelmatix / aurora

Aurora runs on SmartMatrix, a beautiful music visualizer, dynamic art display, video game art display.
http://kck.st/1RUlTfb
Other
162 stars 44 forks source link

Make project compile in Eclipse and using arm-none-eabi-g++ #8

Closed kigster closed 9 years ago

kigster commented 9 years ago

Turns out it is not necessary to break every file in to .h and .cpp. All that is needed is to declare some of the variables used in each class as extern, so that compiler can resolve them later.

I also had to create a header file for the main .ino file so that functions used there could be called from other classes. Finally I updated .gitignore with lots of Mac/Eclipse specific ignores.

The project now gloriously compiles in Eclipse, as well as in Arduino 1.0.6 (updated to be used with Teensy).

There are quite a few warnings that can be fixed, but that's a separate issue.

I would love for someone to test this out on Windows and/or other environments and make sure this does not break anything for the conventional Arduino IDE users.

kigster commented 9 years ago

Here is the command that Eclipse generates the following command ($MY_ARDUINO_HOME is what I put in instead of my private arduino dir:

$MY_ARDUINO_HOME/hardware/teensy/tools/mac/arm-none-eabi/bin/arm-none-eabi-g++ \
      -c -g -Os -ffunction-sections -fdata-sections -nostdlib -fno-rtti -fno-exceptions \
      -mcpu=cortex-m4 -DF_CPU=96000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -MMD \
      -DARDUINO=158  -mthumb  -D__MK20DX256__  -felide-constructors \
      -std=gnu++0x -DTEENSYDUINO=120 \
      -I"$MY_ARDUINO_HOME/hardware/teensy/all/cores/teensy3" \
      -I"$MY_ARDUINO_HOME/hardware/teensy/all/libraries/DS1307RTC" \
      -I"$MY_ARDUINO_HOME/hardware/teensy/all/libraries/FastLED"  \
      -I"$MY_ARDUINO_HOME/hardware/teensy/all/libraries/IRremote" \
      -I"$MY_ARDUINO_HOME/hardware/teensy/all/libraries/SD" \
      -I"$MY_ARDUINO_HOME/hardware/teensy/all/libraries/SD/utility" \
      -I"$MY_ARDUINO_HOME/hardware/teensy/all/libraries/SPI" \
      -I"$MY_ARDUINO_HOME/hardware/teensy/all/libraries/Time" \
      -I"$MY_ARDUINO_HOME/hardware/teensy/all/libraries/Wire" \
      -I"$MY_ARDUINO_HOME/hardware/teensy/all/libraries/Wire/utility" \
      -I"$MY_ARDUINO_HOME/libraries/aJson" \
      -I"$MY_ARDUINO_HOME/libraries/aJson/utility" \
      -I"$MY_ARDUINO_HOME/libraries/SmartMatrix_32x32" \
      -MMD -MP -MF".ino.cpp.d" -MT".ino.cpp.d" -D__IN_ECLIPSE__=1 \
      -x c++ ".ino.cpp"  \
      -o  ".ino.cpp.o"   -Wall
kigster commented 9 years ago

This PR fixes #7

kigster commented 9 years ago

Anything else remaining to do before this is merged?

jasoncoon commented 9 years ago

Only a little more time to review the changes. :) I've only done a quick test to make sure most functions work. I'm not planning to merge this pull request directly to pixelmatix/aurora/master. I merged from your fork to the eclipse branch (https://github.com/pixelmatix/aurora/tree/eclipse). I plan to merge the eclipse branch to master for the next release. I'm trying to keep master fairly stable and well tested.

kigster commented 9 years ago

Got it, thanks! I think the changes are pretty safe, but I totally understand the caution.

jasoncoon commented 9 years ago

OK, sorry for the delay, against my better judgment I had a lot of changes that I was sitting on. I've created a new branch that contains all of our changes merged together: https://github.com/pixelmatix/aurora/tree/Aurora1.3

Would you mind checking it out and testing in Eclipse for me? I'm fairly certain the new files I've introduced are going to cause you more problems, sorry. I still have not gotten Eclipse set up so I can test locally, and I'm honestly not sure I want to. Do you mind being the designated Eclipse tester? :)

kigster commented 9 years ago

I do not mind at all being the Eclipse tester! It's very easy, I already have a project checked out and working under Eclipse.

Just tested it and it compiles without any problems. Here is the last few lines of output:

Starting combiner
"/Users/kig/arduino/hardware/teensy/tools/mac/arm-none-eabi/bin/arm-none-eabi-gcc"  -Os -Wl,--gc-sections -mcpu=cortex-m4 -mthumb "-T/Users/kig/arduino/hardware/teensy/all/cores/teensy3/mk20dx256.ld" -o "/Users/kig/projects/eclipse/aurora/Release/aurora.elf"    ./.ino.cpp.o  ./arduino/AudioStream.cpp.o ./arduino/DMAChannel.cpp.o ./arduino/HardwareSerial1.cpp.o ./arduino/HardwareSerial2.cpp.o ./arduino/HardwareSerial3.cpp.o ./arduino/IPAddress.cpp.o ./arduino/IntervalTimer.cpp.o ./arduino/Print.cpp.o ./arduino/Stream.cpp.o ./arduino/Tone.cpp.o ./arduino/WMath.cpp.o ./arduino/WString.cpp.o ./arduino/analog.c.o ./arduino/avr_emulation.cpp.o ./arduino/eeprom.c.o ./arduino/keylayouts.c.o ./arduino/main.cpp.o ./arduino/math_helper.c.o ./arduino/mk20dx128.c.o ./arduino/new.cpp.o ./arduino/nonstd.c.o ./arduino/pins_teensy.c.o ./arduino/serial1.c.o ./arduino/serial2.c.o ./arduino/serial3.c.o ./arduino/touch.c.o ./arduino/usb_desc.c.o ./arduino/usb_dev.c.o ./arduino/usb_flightsim.cpp.o ./arduino/usb_inst.cpp.o ./arduino/usb_joystick.c.o ./arduino/usb_keyboard.c.o ./arduino/usb_mem.c.o ./arduino/usb_midi.c.o ./arduino/usb_mouse.c.o ./arduino/usb_rawhid.c.o ./arduino/usb_seremu.c.o ./arduino/usb_serial.c.o ./arduino/yield.cpp.o  ./Libraries/aJson/utility/stringbuffer.c.o  ./Libraries/aJson/aJSON.cpp.o  ./Libraries/Wire/utility/twi.c.o  ./Libraries/Wire/Wire.cpp.o  ./Libraries/Time/DateStrings.cpp.o ./Libraries/Time/Time.cpp.o  ./Libraries/SmartMatrix_32x32/CircularBuffer.cpp.o ./Libraries/SmartMatrix_32x32/Font_apple4x6_256.c.o ./Libraries/SmartMatrix_32x32/Font_apple5x7_256.c.o ./Libraries/SmartMatrix_32x32/Font_apple6x10.c.o ./Libraries/SmartMatrix_32x32/Font_apple8x13.c.o ./Libraries/SmartMatrix_32x32/Font_gohufont6x11.c.o ./Libraries/SmartMatrix_32x32/Font_gohufont6x11b.c.o ./Libraries/SmartMatrix_32x32/MatrixColor.cpp.o ./Libraries/SmartMatrix_32x32/MatrixConfiguration.cpp.o ./Libraries/SmartMatrix_32x32/MatrixFont.cpp.o ./Libraries/SmartMatrix_32x32/MatrixForeground.cpp.o ./Libraries/SmartMatrix_32x32/MatrixGraphics.cpp.o ./Libraries/SmartMatrix_32x32/SmartMatrix.cpp.o  ./Libraries/SPI/SPI.cpp.o  ./Libraries/SD/utility/Sd2Card.cpp.o ./Libraries/SD/utility/SdFile.cpp.o ./Libraries/SD/utility/SdVolume.cpp.o  ./Libraries/SD/File.cpp.o ./Libraries/SD/SD.cpp.o  ./Libraries/IRremote/IRremote.cpp.o  ./Libraries/FastLED/FastLED.cpp.o ./Libraries/FastLED/colorpalettes.cpp.o ./Libraries/FastLED/colorutils.cpp.o ./Libraries/FastLED/hsv2rgb.cpp.o ./Libraries/FastLED/lib8tion.cpp.o ./Libraries/FastLED/noise.cpp.o ./Libraries/FastLED/power_mgt.cpp.o  ./Libraries/DS1307RTC/DS1307RTC.cpp.o   /Users/kig/projects/eclipse/aurora/Release/teensy.ar   -L"/Users/kig/projects/eclipse/aurora/Release" -lm
Finished building: aurora.elf

Create eeprom image
"/Users/kig/arduino/hardware/teensy/tools/mac/arm-none-eabi/bin/arm-none-eabi-objcopy" -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 "/Users/kig/projects/eclipse/aurora/Release/aurora.elf" "/Users/kig/projects/eclipse/aurora/Release/aurora.eep"
Finished building: aurora.eep

Create Flash image (ihex format)
"/Users/kig/arduino/hardware/teensy/tools/mac/arm-none-eabi/bin/arm-none-eabi-objcopy" -O ihex -R .eeprom "/Users/kig/projects/eclipse/aurora/Release/aurora.elf" "/Users/kig/projects/eclipse/aurora/Release/aurora.hex"
Finished building: aurora.hex

Building target: aurora
Printing size:
"/Users/kig/arduino/hardware/teensy/tools/mac/arm-none-eabi/bin/arm-none-eabi-size" -A "/Users/kig/projects/eclipse/aurora/Release/aurora.elf"
/Users/kig/projects/eclipse/aurora/Release/aurora.elf  :
section                  size        addr
.text                  123640           0
.ARM.exidx                  8      123640
.usbdescriptortable       160   536838144
.dmabuffers              3968   536838656
.usbbuffers               864   536842624
.data                    1700   536843488
.bss                    45408   536845188
.ARM.attributes            49           0
.comment                   59           0
.debug_info            458703           0
.debug_abbrev           53018           0
.debug_loc             181597           0
.debug_aranges           9176           0
.debug_ranges           34720           0
.debug_line             71087           0
.debug_str              76543           0
.debug_frame            29768           0
Total                 1090468

Finished building target: aurora

jasoncoon commented 9 years ago

Thanks! Closing this pull request, as the changes have been merged to the Aurora1.3 branch, and will be merged to master after the next release.