[SOLVED] Accessing git meta data in using c preprocessor directives and/or makefile

Does the build process for Particle OS devices include support for pre-processor macros that allow you to include Git meta-data in sourcecode.

For example, I would like to do something like:

Particle.publish("git-branch-name", __GITBRANCH__, 60, PRIVATE);

and have that publish the branch name of the repository that I am using to build my app.

If Git meta data isn’t supported by the build process, then what are the pre-processor macros/keywords available to me for tracking versions of my app?


I’d imagine you could make a shell script to generate a header file with the definitions you need and source the header file in your application.

How are you building?

using po-util and particle os v0.6.1

Check out this demo I’ve made. It includes a script to generate the git metadata so it can be included in the application code.


This is awesome! No I just have to figure out how to have this script called automagically by po util!

You could make an alias or bash function to go in your ~/.bashrc to run the script and your po build command.

Example Bash function:

po photon build-beta

You could run the function whenever you’d normally build:


You are a god


1 Like