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

electron
Tags: #<Tag:0x00007f0390dcbde8>

#1

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?


#2

Bump


#3

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?


#4

using po-util and particle os v0.6.1


#5

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.


#6

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


#7

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:

meta-build()
{
./generate
po photon build-beta
}

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

meta-build

#8

You are a god

:doge: