Build number?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Build number?

754 Views
mattgeerts
Contributor II

How can I auto-generate a build number at compile time? I want to use this number to report firmware version via uart or display.

Also, how can I have my build automatically name the output file with the build number, or any other macro?

 

So far I'm using __DATE__ and __TIME__. However, I hate this because the date is not ISO standard! I also don't know how to get this into the file name automagically.

 

Thanks!

Labels (1)
0 Kudos
3 Replies

574 Views
DavidS
NXP Employee
NXP Employee

Hi Matt,

I have a static method to do this but hopefully someone else has dynamic version too.

In the Properties you can do a Define symbol in the Preprocessor as shown below:

ScreenHunter_164 Jul. 24 11.30.gif

In your "C" file do the following for declaration:

static const unsigned int BUILD_NUMBER = __BUILD_NUMBER;//DES added as a Pre-Processor Define constant

Then in code you can printf it.

    PRINTF("\r\nBUILD_NUMBER = 0x%X", BUILD_NUMBER);//DES added

I used the hello_world_frdmk64f as my test project in KSDK_1.2..

My terminal output looked like:

Hello World!

BUILD_NUMBER = 0x12345670

Regards,

David

0 Kudos

574 Views
mattgeerts
Contributor II

Thanks David,

The goal is really to do this in a way that doesn't require manually updating the number.

For years in Metroworks Codewarrior I would just keep a version.c in my project that contained either strings or chars to define the current project release, but i've never tracked per-build.

Can we have KDS run a batch file on compile or something? Then I could just have a batch file read a C file with a number in it, then delete the number and incriment a new number in its place. Dirty, but it would work.

0 Kudos

574 Views
Carlos_Musich
NXP Employee
NXP Employee

Hi Matt,

You can use the Build Steps properties tab to customize the selected build configuration, in this case you can call a batch file immediately after building.

Go to menu Project > Properties > C/C++ Build > Settings > Build Steps.

Hope it helps.

Regards,

Carlos

0 Kudos