Local build including header files in sub-directories

Hello,

I am trying to set up offline compiling on my machine since Particle cloud compiling is not reliable for larger projects. (see this post for more info).

I have everything setup as per the guide here, and am successfully able to compile/flash test apps.

When I go to try and compile the big main project that I’ve been working on, I hit a plethora of compiler errors:

../../../build/module.mk:223: warning: overriding commands for target `/c/PARTICLE_LOCAL/JazaHub'
../../../build/module.mk:216: warning: ignoring old commands for target `/c/PARTICLE_LOCAL/JazaHub'
../../../build/module.mk:232: warning: overriding commands for target `/c/PARTICLE_LOCAL/JazaHub'
../../../build/module.mk:223: warning: ignoring old commands for target `/c/PARTICLE_LOCAL/JazaHub'
../../../build/module.mk:256: warning: overriding commands for target `/c/PARTICLE_LOCAL/JazaHub'
../../../build/module.mk:232: warning: ignoring old commands for target `/c/PARTICLE_LOCAL/JazaHub'
../../../build/module.mk:261: warning: overriding commands for target `/c/PARTICLE_LOCAL/JazaHub'
../../../build/module.mk:256: warning: ignoring old commands for target `/c/PARTICLE_LOCAL/JazaHub'
../../../build/module.mk:277: warning: overriding commands for target `/c/PARTICLE_LOCAL/JazaHub'
../../../build/module.mk:261: warning: ignoring old commands for target `/c/PARTICLE_LOCAL/JazaHub'
build.mk:63: *** "No sources found in ../../JazaHub Controller/mainMash/".  Stop.

_
_

My code is split up into several subdirectories as shown in the following screenshot:

_
_
I take it that local compiling doesn’t support subdirectories?

I tested this out by trying to compile the following test file structure:

_
_
Which succeeds as per:

Boompy@TOMS_TOWER /c/PARTICLE_LOCAL/firmware/main
$ make PLATFORM=electron APPDIR="../../TestFlatness" TARGET_DIR="../../TestFlatness" TARGET_FILE="TestFlatness" -s
   text    data     bss     dec     hex filename
  10828     112    1604   12544    3100 c:/PARTICLE_LOCAL/TestFlatness/TestFlatness.elf

_
_
However, if I change the #include statement in main.cpp to: #include "TestHeader.h" I get the following when I try to compile:

Boompy@TOMS_TOWER /c/PARTICLE_LOCAL/firmware/main
$ make PLATFORM=electron APPDIR="../../TestFlatness" TARGET_DIR="../../TestFlatness" TARGET_FILE="TestFlatness" -s
../../TestFlatness/main.cpp:2:24: fatal error: TestHeader.h: No such file or directory
 #include "TestHeader.h"
                        ^
compilation terminated.
make[2]: *** [../build/target/user/platform-10-m/TestFlatness/main.o] Error 1
make[1]: *** [user] Error 2
make: *** [modules/electron/user-part] Error 2

_
_
So, how do I get local compiling to flatten the file structure? I have tried adding particle.include file to the directory, but I don’t think that works with local compiling based on what I’ve seen. Do I need to make a custom make file? If so, what do I need to put into it?

1 Like

I am having the same issue, building on a mac as per: https://docs.particle.io/faq/particle-tools/local-build/electron/#selecting-a-source-directory

@SCM,

Have you tried po-util? It is a tool I made to expedite local building and have a nice local workflow using the Command Line and or Atom.

It installs all the dependencies for local building for you, creates project folders that are ready for sharing on GitHub set up to use Travis CI, manages libraries using git or Particle Libraries 2.0, automatically uploads firmware over dfu-util, can load examples into a project, builds projects within Atom using keyboard shortcuts and more…

On macOS, you can install po-util with Homebrew:

$ brew tap nrobinson2000/po
$ brew install po
$ po install

Here is a guide wrote on Hackster recently, and here it is in PDF form.

2 Likes

I’m running Windows 10, though I suppose I might be able to get it to work using a virtual machine environment.

1 Like

po-util looks real handy. I’ll give it a try, thanks @nrobinson2000

1 Like

po-util will successfully install on any Ubuntu (Debian), Fedora (RHEL), or Arch distribution, provided that you have curl installed and you are user with sudo access. I'd suggest going with Ubuntu or Mint (an Ubuntu based distribution) if you are less familiar with Linux, or you can also just install it on an Ubuntu Server VM for minimalism. (It's Linux so do whatever you want really.)

Here are the steps to install po-util on Linux.

You can do the following for the quickest installation of po-util:

$ bash <( curl -sL https://git.io/vX4cl ) install

This link is safe, I just shortened https://raw.githubusercontent.com/nrobinson2000/po-util/master/po-util.sh using https://git.io/

I'd like to try to build a docker image for po-util if possible so that people could use it on Windows.

I was going to suggest the Docker approach as well on Windows. It’s getting more first class treatment in Windows so seems like a good approach here.

2 Likes