Build.mk in library not picked up on local build

When I try to add a library that has some silly requirements on header paths (all files in the lib refer to sibling directories via an #include "foo.h"), the build predictably fails not being able to find foo.h.

So I read: https://github.com/kbowerma/particle/blob/master/photon_firmware/firmware/docs/build.md

Learned a lot, but I can not for the life of me get a build.mk file to be considered by a local build.

Tried:

appdir
  library.properties
  src
    build.mk
  lib
    lib_with_subdirs
      src
        a/
        b/
appdir
  library.properties
  src
  lib
    lib_with_subdirs
      build.mk
      src
        a/
        b/
appdir
  library.properties
  src
  lib
    lib_with_subdirs
      src
        build.mk
        a/
        b/
appdir
  library.properties
  src
  build.mk
  lib
    lib_with_subdirs
      src
        a/
        b/
build.mk
appdir
  library.properties
  src
  lib
    lib_with_subdirs
      src
        a/
        b/
  • Swearing also has not been effective. :relaxed:
  • In addition to these permutations I attempted moving all the headers into an inc dir as I’ve seen in a couple examples.

Setup:

  • Windows 10
  • MinGW
  • gcc-arm-none-eabi-5_3-2016q1-20160330-win32.exe as recommended
  • On branch release/stable

I’ve placed echos in the build.mk to see it getting considered, it does not print. In all cases I get an output d:/code/photon/application/lib/eve/src/FT_Esd_Framework/FT_Esd_Dl.c:2:25: fatal error: FT_Platform.h: No such file or directory. How do I get a makefile in my application source tree get used with a local build?

# From https://docs.particle.io/faq/particle-tools/local-build/photon/#including-additional-header-directories

# Standard behavior must be included here
INCLUDE_DIRS += $(SOURCE_PATH)/$(USRSRC)  # add user sources to include path
CPPSRC += $(call target_files,$(USRSRC_SLASH),*.cpp)
CSRC += $(call target_files,$(USRSRC_SLASH),*.c)

APPSOURCES=$(call target_files,$(USRSRC_SLASH),*.cpp)
APPSOURCES+=$(call target_files,$(USRSRC_SLASH),*.c)

# Custom stuff can be added here
INCLUDE_DIRS += $(SOURCE_PATH)/$(USRSRC)/FT_Eve_Hal

all:
	@echo "+++++++++++++Including dirs: $INCLUDE_DIRS"

I’ve tried using build.mk in the past and it has never lived up to my expectations. I have more success using a simpler structure when local building.

projectDir/
    firmware/
        main.cpp
        build.mk
        lib1/
            lib1.h
            lib1.cpp

I set APPDIR to firmware and I use #include "lib1/lib1.h" in main.cpp.

I can still use the build.mk instead if I want, so I can use #include "lib1.h"

I’ve never been able to have .cpp files accepted by build.mk, only .h files.

You could also change the includes inside of the library I think.


If you weren’t using Windows you could use po, which takes care of all this for you.

1 Like

Thanks for the input, @nrobinson2000. I’m setting up an ubuntu server build image on my local docker host server. Will see if po has any extra luck with this. :slight_smile:

The library I’m trying to consume is an export from EVE Screen Designer: http://www.ftdichip.com/Support/Utilities.htm#ESD4

I just made an empty project, exported it and attempted to put it in the source tree of a project I’d like to use it with (in case you’d like to try & see how to work with one of these projects and po!)

There are many files in that library that rely on #include "header_name.h" so I was expecting to need to add those directories to the search directory list. I have to confess I’m not deeply experienced with make so it’s entirely possible I’m barking up the wrong tree here.

2 Likes

We’re you ever able to resolve this?
I have a very custom project structure (it targets more platforms than just particle) and I cannot get the build to pickup my custom makefile either.

I’ve tried the USER_MAKEFILE directive, but particle just completely ignores it.
Is this a bug in the particle toolchain?

Thanks!

1 Like

I ended up implementing this stuff from scratch. The library is “neat” but bloated and as I’m doing it mostly for fun… the makefile stuff just felt like work. Would be very nice to figure it out, but realistically someone else will get to it before I do.

I finally got my custom makefile working.

It turns out the particle build mangles the build directories pretty badly.
I was able to get include files working by switching to system-mode includes #include <somefile.h> and using absolute file paths for INCLUDE_DIRS additions.

It’s not the best, but it works.
I still haven’t gotten adding .cpp source from outside build trees but I’m working on it.

1 Like

Very nice, thanks for the tips!