plerup / makeEspArduino

A makefile for ESP8266 and ESP32 Arduino projects
GNU Lesser General Public License v2.1
513 stars 131 forks source link

Specifying multiple library directories and source files in LIBS seems not to work #178

Closed hamishcunningham closed 2 years ago

hamishcunningham commented 2 years ago

hi again :)

I tried to include both a directory tree and a specific file from another tree in LIBS, but the latter doesn't get included in the build for some reason. E.g.:

make -f .../makeEspArduino/makeEspArduino.mk ESP_ROOT=.../Arduino/hardware/espressif/esp32     BOARD=featheresp32 CHIP=esp32 LIBS="...unphone/lib .../unphone/lib/unPhone_Library/src/IOExpander.cpp" SKETCH=sketch/sketch.ino  run

This gets me undefined symbol errors and IOExpander.cpp isn't present in /tmp/mkESP

plerup commented 2 years ago

Why are there three dots in the path?

hamishcunningham commented 2 years ago

I just abbreviated them. Everything is in $HOME

plerup commented 2 years ago

Are you using the full path in the spec? Please also verify that the path is correct

plerup commented 2 years ago

Which sketch is this in the repo?

hamishcunningham commented 2 years ago

SdInfo; here's the full command:

make -f /home/hamish/the-internet-of-things/support/tooling/makeEspArduino/makeEspArduino.mk \
  ESP_ROOT=/home/hamish/the-internet-of-things/support/tooling/Arduino/hardware/espressif/esp32 \
  BOARD=featheresp32 CHIP=esp32 \
  LIBS="/home/hamish/unphone/lib /home/hamish/unphone/src/IOExpander.cpp" \
  SKETCH=/home/hamish/unphone/lib/SdFat/examples/SdInfo/SdInfo.ino  run
plerup commented 2 years ago

Strange, I pasted this very command and it built without any problems

... esp32-hal-bt.c HardwareSerial.cpp 1_IOExpander.cpp 1_WebServer.cpp 2_IOExpander.cpp 2_WebServer.cpp SdInfo.ino.cpp Creating core archive Creating object archive Linking /tmp/mkESP/SdInfo_featheresp32/SdInfo.bin Versions: 0cbe2d8-dirty, 2.0.2 esptool.py v3.1 Merged 2 ELF sections

Memory summary RAM: 17172 bytes Flash: 244925 bytes

hamishcunningham commented 2 years ago

Strange! Did you do a clean first? Apart from that I'm on 21.04, maybe it is some subtle difference in the OS. (I also see with a fresh install that erase_flash doesn't work until I link esptool.py to esptool; perhaps we've got different versions of the core?)

plerup commented 2 years ago

Well, this is a virtual machine in which I installed from scratch according to your instructions in the previous case. What is it actually that you want to do here? Is it to replace the IOExpander file or to use both of them?

hamishcunningham commented 2 years ago

We develop a device that requires a patched version of digitalWrite (so we can toggle chip select via an io expander), so I need to trigger compilation and linking of the various patched libraries and the expander code and the sketch.

hamishcunningham commented 2 years ago

PS if I copy in the expander code to the sketch directory the Arduino IDE will compile and link. I can't figure out how to achieve the same with makeEspArduino

plerup commented 2 years ago

Sorry but I still don't get it. By specifying:

LIBS="/home/hamish/unphone/lib /home/hamish/unphone/src/IOExpander.cpp"

you will get two files in the wildcard search: unphone/src/IOExpander.cpp unphone/lib/unPhone_Library/IOExpander.cpp

As far as I can see they are both identical.

However when it comes to patching, i.e. replacing a possible existing file(s) from the wildcard search, you need to use the variable EXCLUDE_DIRS, see more in the readme

hamishcunningham commented 2 years ago

I guess I don't understand how LIBS works. If I get a missing header error when compiling, for example, doing LIBS="path to parent directory of library" fixes it. The documentation also states that individual source files can be added to LIBS, but that doesn't seem to have any effect.

plerup commented 2 years ago

Is this a new case? I'm sorry but I can't test more than the example you provided

LIBS can contain either directories which means an implicit wildcard for all sub directories, explicit wildcards or specific full file paths. All source files found when evaluating this will be added to the build. When I build your case I get the following (via new logging I just added)

I can assure you that individual files get added when present i LIBS, that is something that I use extensively myself

hamishcunningham commented 2 years ago

I span up a 20:04 docker image and ran the command as root and it behaved differently to my local system. Will try to duplicate again tomorrow! Tnx, H