ino build doesn't call "ino preproc" correctly. #60

Open
TLINDEN opened this Issue Jan 10, 2013 · 11 comments

Comments

Projects
None yet
3 participants
@TLINDEN

TLINDEN commented Jan 10, 2013

OS: FreeBSD 9.0
Ino Version: unknown (there's no -v switch), I installed today using easy_install
Arduino: 1.0.3

Just made a new empty project:

$ md inotest
$ cd inotest
$ ino build
Searching for Board description file (boards.txt) ... /usr/local/share/arduino/hardware/arduino/boards.txt
Searching for Arduino lib version file (version.txt) ... /usr/local/share/arduino/lib/version.txt
Detecting Arduino software version ... 1.0 (1.0.3)
Searching for Arduino core library ... /usr/local/share/arduino/hardware/arduino/cores/arduino
Searching for Arduino standard libraries ... /usr/local/share/arduino/libraries
Searching for Arduino variants directory ... /usr/local/share/arduino/hardware/arduino/variants
Searching for avr-gcc ... /usr/local/share/arduino/hardware/tools/avr/bin/avr-gcc
Searching for avr-g++ ... /usr/local/share/arduino/hardware/tools/avr/bin/avr-g++
Searching for avr-ar ... /usr/local/share/arduino/hardware/tools/avr/bin/avr-ar
Searching for avr-objcopy ... /usr/local/share/arduino/hardware/tools/avr/bin/avr-objcopy
src/sketch.ino
usage: ino preproc [-h] [-d PATH] [-o OUTPUT] sketch
ino preproc: error: too few arguments
*** Error code 2

Stop in /usr/home/mad/tmp/inotest.
Make failed with code 1

Also there's no verbose switch to see, what it did (or tried to do).

If I call preproc manually, it works:

$ ino preproc src/sketch.ino

include <Arduino.h>

void setup();
void loop();

line 1 "src/sketch.ino"

define LED_PIN 13

void setup()
{
pinMode(LED_PIN, OUTPUT);
}

void loop()
{
digitalWrite(LED_PIN, HIGH);
delay(100);
digitalWrite(LED_PIN, LOW);
delay(900);
}

It also didn't find the boards.txt file, while it was there, only somewhere else. That's FreeBSD which has other locations as linux. Since it is not possible to tell ino where to find boards.txt (config, switch, env, whatever), I had to create a symlink.

And - btw - a manpage would be nice :)

PS: ok, these are multiple issues. The one which is important is the preproc bug.

@mchughj

This comment has been minimized.

Show comment Hide comment
@mchughj

mchughj Feb 17, 2013

I'm unable to reproduce the problem that you are describing. Are you calling "ino init" after you change into the 'inotest' directory that you describe above? For me

mkdir inotest
cd inotest
ino init
ino build

Works fine.

mchughj commented Feb 17, 2013

I'm unable to reproduce the problem that you are describing. Are you calling "ino init" after you change into the 'inotest' directory that you describe above? For me

mkdir inotest
cd inotest
ino init
ino build

Works fine.

@TLINDEN

This comment has been minimized.

Show comment Hide comment
@TLINDEN

TLINDEN Feb 17, 2013

Of course I did. Just in case, I made a record of the session: http://ascii.io/a/2124

TLINDEN commented Feb 17, 2013

Of course I did. Just in case, I made a record of the session: http://ascii.io/a/2124

@TLINDEN

This comment has been minimized.

Show comment Hide comment
@TLINDEN

TLINDEN Feb 17, 2013

One more thing: The problem is, that preproc is being called without the -d parameter. I just added the following line to make/Makefile.sketch.jinja:

@echo "ARDUINO DIST DIR: {{ e['arduino_dist_dir'] }}"

The output during "ino build" is:

$ ino build
Searching for Board description file (boards.txt) ... /usr/local/share/arduino/hardware/arduino/boards.txt
Searching for Arduino lib version file (version.txt) ... /usr/local/share/arduino/lib/version.txt
Detecting Arduino software version ... 1.0 (1.0.3)
Searching for Arduino core library ... /usr/local/share/arduino/hardware/arduino/cores/arduino
Searching for Arduino standard libraries ... /usr/local/share/arduino/libraries
Searching for Arduino variants directory ... /usr/local/share/arduino/hardware/arduino/variants
Searching for avr-gcc ... /usr/local/share/arduino/hardware/tools/avr/bin/avr-gcc
Searching for avr-g++ ... /usr/local/share/arduino/hardware/tools/avr/bin/avr-g++
Searching for avr-ar ... /usr/local/share/arduino/hardware/tools/avr/bin/avr-ar
Searching for avr-objcopy ... /usr/local/share/arduino/hardware/tools/avr/bin/avr-objcopy
src/sketch.ino
ARDUINO DIST DIR: None
usage: ino preproc [-h] [-d PATH] [-o OUTPUT] sketch
ino preproc: error: too few arguments
*** Error code 2

So, there's something fishy...

btw, the generated file .build/environment.pickle doesn't contain this variable as well.

TLINDEN commented Feb 17, 2013

One more thing: The problem is, that preproc is being called without the -d parameter. I just added the following line to make/Makefile.sketch.jinja:

@echo "ARDUINO DIST DIR: {{ e['arduino_dist_dir'] }}"

The output during "ino build" is:

$ ino build
Searching for Board description file (boards.txt) ... /usr/local/share/arduino/hardware/arduino/boards.txt
Searching for Arduino lib version file (version.txt) ... /usr/local/share/arduino/lib/version.txt
Detecting Arduino software version ... 1.0 (1.0.3)
Searching for Arduino core library ... /usr/local/share/arduino/hardware/arduino/cores/arduino
Searching for Arduino standard libraries ... /usr/local/share/arduino/libraries
Searching for Arduino variants directory ... /usr/local/share/arduino/hardware/arduino/variants
Searching for avr-gcc ... /usr/local/share/arduino/hardware/tools/avr/bin/avr-gcc
Searching for avr-g++ ... /usr/local/share/arduino/hardware/tools/avr/bin/avr-g++
Searching for avr-ar ... /usr/local/share/arduino/hardware/tools/avr/bin/avr-ar
Searching for avr-objcopy ... /usr/local/share/arduino/hardware/tools/avr/bin/avr-objcopy
src/sketch.ino
ARDUINO DIST DIR: None
usage: ino preproc [-h] [-d PATH] [-o OUTPUT] sketch
ino preproc: error: too few arguments
*** Error code 2

So, there's something fishy...

btw, the generated file .build/environment.pickle doesn't contain this variable as well.

@TLINDEN

This comment has been minimized.

Show comment Hide comment
@TLINDEN

TLINDEN Feb 18, 2013

Now I just edited the Makefile something more and added the path manually:

{{v}}{{ e.ino }} preproc -d /usr/local/share/arduino -o $@ $^

Still the same error. Then I stumbled upon this {{v}} sentence and tried to add -v, and there it is, verbose output. Didn't I mention this earlier? Why didn't you tell me about this?

However, the output if I run "ino build" with this is:

$ ino build -v
src/sketch.ino
/usr/local/bin/ino preproc -d /usr/local/share/arduino -o .build/uno/src/sketch.cpp
usage: ino preproc [-h] [-d PATH] [-o OUTPUT] sketch
ino preproc: error: too few arguments
*** Error code 2

Stop in /usr/home/scip/devel/inotest.
Make failed with code 1

Obviously the last parameter is missing, in the Makefile this is $^, which either is not a valid make variable or is not fed into the pipeline. So, while I was at it, I just appended the sketch file:

{{v}}{{ e.ino }} preproc -d /usr/local/share/arduino -o $@ sketch.ino

The output with this is now:
$ ino build -v
/usr/local/share/arduino/hardware/tools/avr/bin/avr-gcc -mmcu=atmega328p -ffunction-sections -fdata-sections -g -Os -w -DF_CPU=16000000L -DARDUINO=100 -I/usr/local/share/arduino/hardware/arduino/cores/arduino -I/usr/local/share/arduino/hardware/arduino/variants/standard -I/usr/local/share/arduino/hardware/arduino/cores/arduino -I/usr/local/share/arduino/libraries/LiquidCrystal -I/usr/local/share/arduino/libraries/Wire -I/usr/local/share/arduino/libraries/Wire/utility -I/usr/local/share/arduino/libraries/Stepper -I/usr/local/share/arduino/libraries/WiFi -I/usr/local/share/arduino/libraries/WiFi/utility -I/usr/local/share/arduino/libraries/Ethernet -I/usr/local/share/arduino/libraries/Ethernet/utility -I/usr/local/share/arduino/libraries/SoftwareSerial -I/usr/local/share/arduino/libraries/Firmata -I/usr/local/share/arduino/libraries/Servo -I/usr/local/share/arduino/libraries/Esplora -I/usr/local/share/arduino/libraries/SPI -I/usr/local/share/arduino/libraries/SD -I/usr/local/share/arduino/libraries/SD/utility -I/usr/local/share/arduino/libraries/EEPROM -iquote src -MM > .build/uno/src/sketch.d
avr-gcc: no input files
*** Error code 1

Stop in /usr/home/scip/devel/inotest.
Make failed with code 1

I also tried src/sketch.ino - same output.

So I'm not sure what to say about this, but it looks like either incomplete software or untested at all, which is a pity as the idea sounds really great and there is a lot of code written for the tool.

TLINDEN commented Feb 18, 2013

Now I just edited the Makefile something more and added the path manually:

{{v}}{{ e.ino }} preproc -d /usr/local/share/arduino -o $@ $^

Still the same error. Then I stumbled upon this {{v}} sentence and tried to add -v, and there it is, verbose output. Didn't I mention this earlier? Why didn't you tell me about this?

However, the output if I run "ino build" with this is:

$ ino build -v
src/sketch.ino
/usr/local/bin/ino preproc -d /usr/local/share/arduino -o .build/uno/src/sketch.cpp
usage: ino preproc [-h] [-d PATH] [-o OUTPUT] sketch
ino preproc: error: too few arguments
*** Error code 2

Stop in /usr/home/scip/devel/inotest.
Make failed with code 1

Obviously the last parameter is missing, in the Makefile this is $^, which either is not a valid make variable or is not fed into the pipeline. So, while I was at it, I just appended the sketch file:

{{v}}{{ e.ino }} preproc -d /usr/local/share/arduino -o $@ sketch.ino

The output with this is now:
$ ino build -v
/usr/local/share/arduino/hardware/tools/avr/bin/avr-gcc -mmcu=atmega328p -ffunction-sections -fdata-sections -g -Os -w -DF_CPU=16000000L -DARDUINO=100 -I/usr/local/share/arduino/hardware/arduino/cores/arduino -I/usr/local/share/arduino/hardware/arduino/variants/standard -I/usr/local/share/arduino/hardware/arduino/cores/arduino -I/usr/local/share/arduino/libraries/LiquidCrystal -I/usr/local/share/arduino/libraries/Wire -I/usr/local/share/arduino/libraries/Wire/utility -I/usr/local/share/arduino/libraries/Stepper -I/usr/local/share/arduino/libraries/WiFi -I/usr/local/share/arduino/libraries/WiFi/utility -I/usr/local/share/arduino/libraries/Ethernet -I/usr/local/share/arduino/libraries/Ethernet/utility -I/usr/local/share/arduino/libraries/SoftwareSerial -I/usr/local/share/arduino/libraries/Firmata -I/usr/local/share/arduino/libraries/Servo -I/usr/local/share/arduino/libraries/Esplora -I/usr/local/share/arduino/libraries/SPI -I/usr/local/share/arduino/libraries/SD -I/usr/local/share/arduino/libraries/SD/utility -I/usr/local/share/arduino/libraries/EEPROM -iquote src -MM > .build/uno/src/sketch.d
avr-gcc: no input files
*** Error code 1

Stop in /usr/home/scip/devel/inotest.
Make failed with code 1

I also tried src/sketch.ino - same output.

So I'm not sure what to say about this, but it looks like either incomplete software or untested at all, which is a pity as the idea sounds really great and there is a lot of code written for the tool.

@mchughj

This comment has been minimized.

Show comment Hide comment
@mchughj

mchughj Feb 19, 2013

I don't think I would characterize the software the same way. It worked flawlessly for me - and apparently others - out of the gate. I don't doubt that you are having a problem - clearly there is something different with your experience.

Things you could consider checking:

1/ Do you have the latest version? Checked in at

https://github.com/amperka/ino/blob/master/ino/make/Makefile.sketch.jinjahttps://github.com/amperka/ino/blob/master/ino/make/Makefile.sketch.jinja

line 9 reads:
{{v}}{{ e.ino }} preproc {% if 'arduino_dist_dir' in e %}-d {{ e['arduino_dist_dir'] }}{% endif %} -o $@ $^

Does your file look the same?

This line contains the arduino distribution directory so there should be no need to manually add in "-d /usr/local/share/arduino".

2/ If the code is the same then confirm that during the initial 'ino build' step that all of the requirements that are searched for are found appropriately. http://inotool.org/quickstart has a great little walkthrough.

I hope this helps.

Jason

mchughj commented Feb 19, 2013

I don't think I would characterize the software the same way. It worked flawlessly for me - and apparently others - out of the gate. I don't doubt that you are having a problem - clearly there is something different with your experience.

Things you could consider checking:

1/ Do you have the latest version? Checked in at

https://github.com/amperka/ino/blob/master/ino/make/Makefile.sketch.jinjahttps://github.com/amperka/ino/blob/master/ino/make/Makefile.sketch.jinja

line 9 reads:
{{v}}{{ e.ino }} preproc {% if 'arduino_dist_dir' in e %}-d {{ e['arduino_dist_dir'] }}{% endif %} -o $@ $^

Does your file look the same?

This line contains the arduino distribution directory so there should be no need to manually add in "-d /usr/local/share/arduino".

2/ If the code is the same then confirm that during the initial 'ino build' step that all of the requirements that are searched for are found appropriately. http://inotool.org/quickstart has a great little walkthrough.

I hope this helps.

Jason

@TLINDEN

This comment has been minimized.

Show comment Hide comment
@TLINDEN

TLINDEN Feb 19, 2013

  1. yes the file looks exactly like this. But the variable arduino_dist_dir is not set internally, which leads to the error (the first one of them).

  2. of course I followed the quickstart. Doesn't work anyway. If I set the variable arduino-dist in my .inorc, then at least the first error of the preproc call without -d being set vanishes, but the second one remains, $^ is still not set:

$ ino build -v
src/sketch.ino
/usr/local/bin/ino preproc -d /usr/local/share/arduino -o .build/uno-5a7bf3ac/src/sketch.cpp
usage: ino preproc [-h] [-d PATH] [-o OUTPUT] sketch
ino preproc: error: too few arguments
*** Error code 2

Stop in /usr/home/scip/tmp/inotest.
Make failed with code 1

However, after another time digging though the code, I found the problem with $^, it's in line 138 in commands/build.py:

ret = subprocess.call(['make', '-f', makefile, 'all'])

But according that variable and the way you're calling it, the script assumes GNU Make. But as I already said, I'm using FreeBSD, which has its own make command (BSD Make), which is mostly incompatible to the GNU flavour. If I want to use the GNU version, I'll have to use "gmake" instead of "make". So, I just changed line 138 to call gmake and now it works.

You should add a config file variable for this, so the user can specify which command to call for GNU Make.

Oh, and the -d preproc issue is also resolved this way.

TLINDEN commented Feb 19, 2013

  1. yes the file looks exactly like this. But the variable arduino_dist_dir is not set internally, which leads to the error (the first one of them).

  2. of course I followed the quickstart. Doesn't work anyway. If I set the variable arduino-dist in my .inorc, then at least the first error of the preproc call without -d being set vanishes, but the second one remains, $^ is still not set:

$ ino build -v
src/sketch.ino
/usr/local/bin/ino preproc -d /usr/local/share/arduino -o .build/uno-5a7bf3ac/src/sketch.cpp
usage: ino preproc [-h] [-d PATH] [-o OUTPUT] sketch
ino preproc: error: too few arguments
*** Error code 2

Stop in /usr/home/scip/tmp/inotest.
Make failed with code 1

However, after another time digging though the code, I found the problem with $^, it's in line 138 in commands/build.py:

ret = subprocess.call(['make', '-f', makefile, 'all'])

But according that variable and the way you're calling it, the script assumes GNU Make. But as I already said, I'm using FreeBSD, which has its own make command (BSD Make), which is mostly incompatible to the GNU flavour. If I want to use the GNU version, I'll have to use "gmake" instead of "make". So, I just changed line 138 to call gmake and now it works.

You should add a config file variable for this, so the user can specify which command to call for GNU Make.

Oh, and the -d preproc issue is also resolved this way.

@TLINDEN

This comment has been minimized.

Show comment Hide comment
@TLINDEN

TLINDEN Feb 19, 2013

PS: so, sorry for the harsh comment earlier, it was unfair. Now that I've got ino running, I've got to admit, that I love it.

TLINDEN commented Feb 19, 2013

PS: so, sorry for the harsh comment earlier, it was unfair. Now that I've got ino running, I've got to admit, that I love it.

@Kernald

This comment has been minimized.

Show comment Hide comment
@Kernald

Kernald Feb 19, 2013

I'll try to write a patch to make the make command configurable. I'll tell here if I get something working or not, never really digged into ino code, and rarely code in Python. But I'll try :-)

Kernald commented Feb 19, 2013

I'll try to write a patch to make the make command configurable. I'll tell here if I get something working or not, never really digged into ino code, and rarely code in Python. But I'll try :-)

@Kernald

This comment has been minimized.

Show comment Hide comment
@Kernald

Kernald Feb 19, 2013

@TLINDEN: can you try with the branch I commited within (https://github.com/Kernald/ino/tree/make-command-option)? You'll have two ways to fix your issue: use the -c gmake switch, or in your inorc, make-command = gmake.

Kernald commented Feb 19, 2013

@TLINDEN: can you try with the branch I commited within (https://github.com/Kernald/ino/tree/make-command-option)? You'll have two ways to fix your issue: use the -c gmake switch, or in your inorc, make-command = gmake.

@TLINDEN

This comment has been minimized.

Show comment Hide comment
@TLINDEN

TLINDEN Feb 21, 2013

@Kernald: works like a charm.

TLINDEN commented Feb 21, 2013

@Kernald: works like a charm.

@mchughj

This comment has been minimized.

Show comment Hide comment
@mchughj

mchughj Feb 22, 2013

Very cool. @TLINDEN - glad it is working well for you now! I'm a huge fan of the command line build and the overall approach that the author has taken with Ino. Good stuff! :)

mchughj commented Feb 22, 2013

Very cool. @TLINDEN - glad it is working well for you now! I'm a huge fan of the command line build and the overall approach that the author has taken with Ino. Good stuff! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment