joshmarinacci / ElectronIDE

New web based Arduino IDE
BSD 3-Clause "New" or "Revised" License
246 stars 50 forks source link

support spaces in file names during compile #40

Closed tallsam closed 10 years ago

tallsam commented 10 years ago

Hey Josh,

Under linux avr-g++ fails when passed a sketch with spaces in the name.

/home/sam/ElectronIDE/downloads/platforms/1.0.5/linux/hardware/tools/avr/bin/avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DARDUINO=105 -DUSB_VID=0x2341 -DUSB_PID=0x0043 -I/home/sam/ElectronIDE/downloads/platforms/1.0.5/linux/hardware/arduino/cores/arduino -I/home/sam/ElectronIDE/downloads/platforms/1.0.5/linux/hardware/arduino/variants/standard -I/home/sam/ownCloud/Electronics/sketchbook/Simple Onboard Blinker build/tmp/Simple Onboard Blinker.cpp -o build/out/Simple Onboard Blinker.cpp.o
avr-g++: Onboard: No such file or directory
avr-g++: Blinker: No such file or directory
avr-g++: build/tmp/Simple: No such file or directory
avr-g++: Onboard: No such file or directory
avr-g++: Blinker.cpp: No such file or directory
avr-g++: Onboard: No such file or directory
avr-g++: Blinker.cpp.o: No such file or directory
avr-g++: no input files

I had a shot at fixing this, i'm pretty new to Node though. Seems to work.

Cheers, Sam.

joshmarinacci commented 10 years ago

Your commit will fix the immediate problem but not the underlying problem. The problem with spaces happens because the code execs out to the shell which then calls the compiler. The shell is interpreting the spaces as splitting command line args. The solution is to not use the shell but invoke the compiler directly. We must switch from exec() to spawn(). On my todo list now. Thanks!

joshmarinacci commented 10 years ago

Fixed now. I switched from exec to execFile, which doesn't execute a subshell. It works with a sketch named 'foo bar'.