fprime-community / fprime-tutorial-arduino-blinker

https://fprime-community.github.io/fprime-tutorial-arduino-blinker/
Apache License 2.0
2 stars 8 forks source link

Build Fails Without Deployment #14

Open LeStarch opened 4 months ago

LeStarch commented 4 months ago

Following the steps, but building after "new project" and before "new deployment" causes a crash with "cannot find #include "

ethancheez commented 4 months ago

Did you run:

arduino-cli lib install Time

Instructions are here:

Library Dependencies

Required Dependencies:

arduino-cli lib install Time

If you will be using the TcpClient component, install:

arduino-cli lib install WiFi
LeStarch commented 4 months ago

I did. It works with building the deployment. Just not the raw project.

LeStarch commented 4 months ago

It might be that some of the hooks for libraries etc are done on deployments and not on the full project build.

ethancheez commented 4 months ago

Right. I see what's going on. Yes you are correct. When running fprime-util build when no deployment is present (i.e. if you want to build for the Led component itself), the arduino-cli wrapper doesn't seem to be importing all the arduino libraries correctly which result in dependency errors.

In the tutorial, I ended up putting the Add Arduino Deployment step near the beginning before running fprime-util build.

Edit: Seems that building the LED component with no deployment works now, but raw project does not work still.

ethancheez commented 4 months ago

FYI, this is not a TimeLib issue. I remember getting a similar error with the SPI and Wire.h libraries, they are also not linked properly when no component/deployment is present in the project. See below:

In file included from /home/ethan/work/fprime-projects/fprime-community/fprime-tutorial-arduino-blinker/fprime-arduino/Arduino/Drv/SpiDriver/SpiDriver.cpp:8:
/home/ethan/work/fprime-projects/fprime-community/fprime-tutorial-arduino-blinker/fprime-arduino/Arduino/Drv/SpiDriver/SpiDriver.hpp:11:10: fatal error: SPI.h: No such file or directory
   11 | #include <SPI.h>
      |          ^~~~~~~
compilation terminated.
gmake[2]: *** [Arduino/Drv/SpiDriver/CMakeFiles/Arduino_Drv_SpiDriver.dir/build.make:91: Arduino/Drv/SpiDriver/CMakeFiles/Arduino_Drv_SpiDriver.dir/SpiDriver.cpp.obj] Error 1
[ 75%] Linking CXX static library ../../../lib/rpipicow/libDrv_BlockDriver.a
[ 75%] Built target Drv_BlockDriver
gmake[2]: *** Waiting for unfinished jobs....
In file included from /home/ethan/work/fprime-projects/fprime-community/fprime-tutorial-arduino-blinker/fprime-arduino/Arduino/Drv/SpiDriver/SpiDriverArduino.cpp:8:
/home/ethan/work/fprime-projects/fprime-community/fprime-tutorial-arduino-blinker/fprime-arduino/Arduino/Drv/SpiDriver/SpiDriver.hpp:11:10: fatal error: SPI.h: No such file or directory
   11 | #include <SPI.h>
      |          ^~~~~~~
compilation terminated.
gmake[2]: *** [Arduino/Drv/SpiDriver/CMakeFiles/Arduino_Drv_SpiDriver.dir/build.make:105: Arduino/Drv/SpiDriver/CMakeFiles/Arduino_Drv_SpiDriver.dir/SpiDriverArduino.cpp.obj] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:4926: Arduino/Drv/SpiDriver/CMakeFiles/Arduino_Drv_SpiDriver.dir/all] Error 2
LeStarch commented 4 months ago

Yes, this call comes from the line: finalize_arduino_executable("${FPRIME_CURRENT_MODULE}") in the deployment CMake. This line fixes library usages...but isn't done at the project level.

For now, I am just tracking the issue.