Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arduino CI seems to not handle dependencies between imported Arduino Libraries #192

Closed
cherbel opened this issue Nov 2, 2020 · 11 comments · Fixed by #223
Closed

Arduino CI seems to not handle dependencies between imported Arduino Libraries #192

cherbel opened this issue Nov 2, 2020 · 11 comments · Fixed by #223
Labels
bug Something isn't working unittest libs The assert / assure / unittest reporting apparatus is affected

Comments

@cherbel
Copy link

cherbel commented Nov 2, 2020

I am writing tests for a library A (TankControllerLib), and it imports library B (MAX31865) that has a dependance on library C (BusIO). When I wrote tests for library B, I included library C in .arduino-ci.yml, and it was able to find and use my modified library C. Now, I've included B and C as prerequisites for library A, and when library B is compiled, the header for library C is not found.

In file included from /Users/c/Desktop/Fall 2020/CPTR 450 Software Engineering/Projects/TankControllerLib/src/Devices/TempProbe_TC.cpp:5:
In file included from /Users/c/Documents/Arduino/libraries/Adafruit_MAX31865/src/Adafruit_MAX31865_CI.h:2:
/Users/c/Documents/Arduino/libraries/Adafruit_MAX31865/src/Adafruit_MAX31865.h:63:10: fatal error: 'Adafruit_SPIDevice.h' file not found
#include <Adafruit_SPIDevice.h>
         ^~~~~~~~~~~~~~~~~~~~~~
1 error generated.

Here is my .arduino_ci.yml for the TankControllerLib:

unittest:
    platforms:
        - mega2560
    libraries:
      - "LiquidCrystal"
      - "Adafruit BusIO"
      - "Adafruit_MAX31865"

Here is my .arduino_ci.yml for MAX31865:

unittest:
  platforms:
    - mega2560
  testfiles:
    reject:
      - "Common.cpp"
  libraries:
    - "Adafruit BusIO"

Issue report prepared with @jgfoster

@ianfixes
Copy link
Collaborator

ianfixes commented Nov 4, 2020

This might be fixed by my #183 branch, I added some recursive logic that leverages the library.properties spec. Can you try the instructions in the PR description for how to test that out, and let me know if that works?

@ianfixes ianfixes added bug Something isn't working unittest libs The assert / assure / unittest reporting apparatus is affected labels Nov 4, 2020
@Kavikick
Copy link

Kavikick commented Nov 4, 2020

I'm having the same problem with a different library, and the branch "2020-10-16_suggestions" does not seem to fix it. What library.properties would this involve?

@ianfixes
Copy link
Collaborator

ianfixes commented Nov 4, 2020

I should have linked to the library.properties spec. And from you, it would be helpful to see the compiler invocation that produced the error -- it should be printed to the console above that error output.

Broadly speaking, the problem is that I need to come up with a compiler invocation that matches what the Arduino IDE might use. Perhaps theirs is a brute-force inclusion of all Arduino libraries in the Libraries directory; I'm not familiar with what they do. In any case, their system used to function by delegating all the dependency management to the end user -- you'd bring in the dependencies, and then bring in any dependencies of those dependencies, and so on. This is what is now referred to as the "1.0 library spec".

To enable automatic dependency resolution, a "1.5 library spec" was released that includes a metadata file called library.properties. But now you have two problems: you can walk the dependency list recursively and install missing packages on demand, but you will also have to contend with the fact that not all libraries meet the 1.5 specification! I wrote Arduino CI when this was the case the majority of the time. So my solution was to have all dependencies listed manually in the config.

However, there were bugs in my implementation: I didn't include directories in a spec-conformant way, and there was no recursion. (This kind of thing would have been a complex feature when I was still building out a proof of concept for simple libraries.) I am attempting to fix those in #183

What we'll have to hone in on here is whether this is failing due to having 1.0-spec libraries in the mix (in which case it should be solvable by adding entries to the .arduino-ci.yml file), or further bugs in the way I parse dependencies and include libraries.

It could also be that my branch is not automatically downloading all the necessary dependencies.

@cherbel cherbel closed this as completed Nov 4, 2020
@cherbel cherbel reopened this Nov 4, 2020
@cherbel
Copy link
Author

cherbel commented Nov 4, 2020

This might be fixed by my #183 branch, I added some recursive logic that leverages the library.properties spec. Can you try the instructions in the PR description for how to test that out, and let me know if that works?

I didn't mean to close the issue, but I tried the instructions form #183 and I seem to be having the same issue.
Here is the compiler message if that's useful:

$ g++ -std=c++0x -o /Users/c/Desktop/Fall 2020/CPTR 450 Software Engineering/Projects/TankControllerLib/unittest_TempProbe_TC_Test.cpp.bin -DARDUINO=100 -D__AVR__ -g -O1 -fno-omit-frame-pointer -fno-optimize-sibling-calls -fsanitize=address -D__AVR_ATmega2560__ -DARDUINO_CI -D__AVR__ -I/Users/c/Desktop/Fall 2020/CPTR 450 Software Engineering/Projects/TankControllerLib/vendor/bundle/ruby/2.6.0/bundler/gems/arduino_ci-334b7aa377c8/cpp/arduino -I/Users/c/Desktop/Fall 2020/CPTR 450 Software Engineering/Projects/TankControllerLib/vendor/bundle/ruby/2.6.0/bundler/gems/arduino_ci-334b7aa377c8/cpp/unittest -I/Users/c/Desktop/Fall 2020/CPTR 450 Software Engineering/Projects/TankControllerLib/src -I/Users/c/Desktop/Fall 2020/CPTR 450 Software Engineering/Projects/TankControllerLib/src/Devices -I/Users/c/Desktop/Fall 2020/CPTR 450 Software Engineering/Projects/TankControllerLib/src/UIState -I/Users/cl/Desktop/Fall 2020/CPTR 450 Software Engineering/Projects/LiquidCrystal/src -I/Users/c/Documents/Arduino/libraries/Adafruit_MAX31865/src /Users/c/Desktop/Fall 2020/CPTR 450 Software Engineering/Projects/TankControllerLib/vendor/bundle/ruby/2.6.0/bundler/gems/arduino_ci-334b7aa377c8/cpp/arduino/Arduino.cpp /Users/c/Desktop/Fall 2020/CPTR 450 Software Engineering/Projects/TankControllerLib/vendor/bundle/ruby/2.6.0/bundler/gems/arduino_ci-334b7aa377c8/cpp/arduino/Godmode.cpp /Users/c/Desktop/Fall 2020/CPTR 450 Software Engineering/Projects/TankControllerLib/vendor/bundle/ruby/2.6.0/bundler/gems/arduino_ci-334b7aa377c8/cpp/arduino/stdlib.cpp /Users/c/Desktop/Fall 2020/CPTR 450 Software Engineering/Projects/TankControllerLib/vendor/bundle/ruby/2.6.0/bundler/gems/arduino_ci-334b7aa377c8/cpp/unittest/ArduinoUnitTests.cpp /Users/c/Desktop/Fall 2020/CPTR 450 Software Engineering/Projects/TankControllerLib/src/TankControllerLib.cpp /Users/c/Desktop/Fall 2020/CPTR 450 Software Engineering/Projects/TankControllerLib/src/Devices/LiquidCrystal_TC.cpp /Users/c/Desktop/Fall 2020/CPTR 450 Software Engineering/Projects/TankControllerLib/src/UIState/MainMenu.cpp /Users/c/Desktop/Fall 2020/CPTR 450 Software Engineering/Projects/LiquidCrystal/src/LiquidCrystal.cpp /Users/c/Desktop/Fall 2020/CPTR 450 Software Engineering/Projects/LiquidCrystal/src/LiquidCrystal_CI.cpp /Users/c/Documents/Arduino/libraries/Adafruit_MAX31865/src/Adafruit_MAX31865.cpp /Users/c/Documents/Arduino/libraries/Adafruit_MAX31865/src/Adafruit_MAX31865_CI.cpp /Users/c/Desktop/Fall 2020/CPTR 450 Software Engineering/Projects/TankControllerLib/test/TempProbe_TC_Test.cpp

@ianfixes
Copy link
Collaborator

ianfixes commented Nov 4, 2020

I'm parsing that as

$ g++ -std=c++0x -o /PROJECTS_DIR/TankControllerLib/unittest_TempProbe_TC_Test.cpp.bin \
-DARDUINO=100 -D__AVR__ -g -O1 -fno-omit-frame-pointer -fno-optimize-sibling-calls -fsanitize=address \
-D__AVR_ATmega2560__ -DARDUINO_CI -D__AVR__ \
 -I/PROJECTS_DIR/TankControllerLib/vendor/bundle/ruby/2.6.0/bundler/gems/arduino_ci-334b7aa377c8/cpp/arduino \
 -I/PROJECTS_DIR/TankControllerLib/vendor/bundle/ruby/2.6.0/bundler/gems/arduino_ci-334b7aa377c8/cpp/unittest \
 -I/PROJECTS_DIR/TankControllerLib/src \
 -I/PROJECTS_DIR/TankControllerLib/src/Devices \
 -I/PROJECTS_DIR/TankControllerLib/src/UIState \
 -I/Users/cl/Desktop/Fall 2020/CPTR 450 Software Engineering/Projects/LiquidCrystal/src \
 -I/Users/c/Documents/Arduino/libraries/Adafruit_MAX31865/src \
 /PROJECTS_DIR/TankControllerLib/vendor/bundle/ruby/2.6.0/bundler/gems/arduino_ci-334b7aa377c8/cpp/arduino/Arduino.cpp \
 /PROJECTS_DIR/TankControllerLib/vendor/bundle/ruby/2.6.0/bundler/gems/arduino_ci-334b7aa377c8/cpp/arduino/Godmode.cpp \
 /PROJECTS_DIR/TankControllerLib/vendor/bundle/ruby/2.6.0/bundler/gems/arduino_ci-334b7aa377c8/cpp/arduino/stdlib.cpp \
 /PROJECTS_DIR/TankControllerLib/vendor/bundle/ruby/2.6.0/bundler/gems/arduino_ci-334b7aa377c8/cpp/unittest/ArduinoUnitTests.cpp \
 /PROJECTS_DIR/TankControllerLib/src/TankControllerLib.cpp \
 /PROJECTS_DIR/TankControllerLib/src/Devices/LiquidCrystal_TC.cpp \
 /PROJECTS_DIR/TankControllerLib/src/UIState/MainMenu.cpp \
 /PROJECTS_DIR/LiquidCrystal/src/LiquidCrystal.cpp \
 /PROJECTS_DIR/LiquidCrystal/src/LiquidCrystal_CI.cpp \
 /Users/c/Documents/Arduino/libraries/Adafruit_MAX31865/src/Adafruit_MAX31865.cpp \
 /Users/c/Documents/Arduino/libraries/Adafruit_MAX31865/src/Adafruit_MAX31865_CI.cpp \
 /PROJECTS_DIR/TankControllerLib/test/TempProbe_TC_Test.cpp

So in that context, your error:

In file included from /Users/c/Desktop/Fall 2020/CPTR 450 Software Engineering/Projects/TankControllerLib/src/Devices/TempProbe_TC.cpp:5:
In file included from /Users/c/Documents/Arduino/libraries/Adafruit_MAX31865/src/Adafruit_MAX31865_CI.h:2:
/Users/c/Documents/Arduino/libraries/Adafruit_MAX31865/src/Adafruit_MAX31865.h:63:10: fatal error: 'Adafruit_SPIDevice.h' file not found
#include <Adafruit_SPIDevice.h>
         ^~~~~~~~~~~~~~~~~~~~~~
1 error generated.

That looks like this file
https://github.com/adafruit/Adafruit_MAX31865/blob/master/Adafruit_MAX31865.h#L55

This repo does have library.properties, but as mentioned in #168 (comment) it lacks a src/ folder so will be treated as a 1.0 library. That said, it does refer to the BusIO library as a dependency (which contains https://github.com/adafruit/Adafruit_BusIO/blob/master/Adafruit_SPIDevice.h) and I don't see BusIO getting pulled in to the compiler command. Let me check on that.

@ianfixes
Copy link
Collaborator

ianfixes commented Nov 4, 2020

is your project on GitHub somewhere that I could try it out locally?

@jgfoster
Copy link
Member

jgfoster commented Nov 4, 2020

Yes, see TempProbe.

@ianfixes
Copy link
Collaborator

I apologize for the delay on this, but it's on my radar

@jgfoster
Copy link
Member

One thing at a time! I'm somewhat curious to know if the library problem is similar to #180 (another case where a library was not found).

@ianfixes
Copy link
Collaborator

The problem with #180 is that (for the Ethernet library) the library manager breaks my assumption... although it will download the library, it won't go into the Libraries folder with the others.

jgfoster pushed a commit to jgfoster/arduino_ci that referenced this issue Nov 15, 2020
ianfixes added a commit that referenced this issue Nov 16, 2020
Add test for #192: fatal error: 'Adafruit_SPIDevice.h' file not found
@ianfixes
Copy link
Collaborator

ianfixes commented Nov 20, 2020

The error is a regression on my part in the way libraries with spaces in their names are handled. I incorrectly removed this line
v0.2.0...v0.2.1#diff-2af4cf9f84ef0b95eeda4f611a7f3d1d8e749e8717e06093be22f6664a35a9eaR225

I'm tracking this with #222 since it's going to be a bigger issue than just for this.

Note that I get other errors when I fix this

/Users/me/Documents/Arduino/libraries/Adafruit_BusIO/Adafruit_I2CDevice.cpp:160:24: error: call to member function 'requestFrom' is ambiguous
  size_t recv = _wire->requestFrom((uint8_t)_addr, (uint8_t)len, (uint8_t)stop);
                ~~~~~~~^~~~~~~~~~~
/Users/me/Development/arduino_ci/cpp/arduino/Wire.h:119:11: note: candidate function
  uint8_t requestFrom(uint8_t address, size_t quantity, bool stop) {
          ^
/Users/me/Development/arduino_ci/cpp/arduino/Wire.h:137:11: note: candidate function
  uint8_t requestFrom(int address, int quantity, int stop) {
          ^
/Users/me/Development/arduino_ci/cpp/arduino/Wire.h:134:11: note: candidate function not viable: requires 2 arguments, but 3 were provided
  uint8_t requestFrom(int address, int quantity) {
          ^
1 error generated.
In file included from /Users/me/Development/arduino_ci/SampleProjects/BusIO/test/test.cpp:9:
/Users/me/Development/arduino_ci/SampleProjects/BusIO/src/BusIO.h:9:2: error: expected ';' after class
}
 ^
 ;
/Users/me/Development/arduino_ci/SampleProjects/BusIO/test/test.cpp:14:34: error: expected ';' after do/while statement
  assertEqual(42, busIO.answer()));
                                 ^
                                 ;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working unittest libs The assert / assure / unittest reporting apparatus is affected
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants