Our project has a standard version numbering system with major, minor and revision numbers. For this discussion, assume they have values 1, 2 and 3 respectively.
I'd like to define the major, minor and revision number components in a single place but with the following twist: the version number components must be accessible to the C compiler (likely defined by the pre-processor) so I can do something like this:
write_to_flash(make_version_number(VERS_MAJOR, VERS_MINOR, VERS_REVISION));
AND also accessible to KDS/Eclipse, so I can generate an output filename of the form:
myproj-1-2-3.sbin
I already have a pre-processor script, so I could clearly use it to take build variables and create a .h file from them, so I'd end up with:
#ifndef SOURCE_VERSION_H #define SOURCE_VERSION_H #define VERS_MAJOR 1 #define VERS_MINOR 2 #define VERS_REVISION 3 #endif
This way, I only have to define the version numbers (once) in the project's Build Variables. Is this the recommended way to do it? Or is there another preferred technique?
Update: Wait a minute! I thought I'd be able to insert Build Variables into the Debug Configurations dialog in order to control the C/C++ application that it looks for:
... but clearly that's not the case. Let me add a follow-on question: How do I tell the debugger to load the C/C++ application with the filename and version #? Is there a way to expand a Build Variable in the Debug Configurations dialog?
Hello Robert,
Sorry I don't really know your meaning , do you want to rename file with version number ?
If yes, how about the post-build commend:
- Add Build Variable"Newname":
- In Post-build, input command:
- Build , the new name with version number appeares:
Have a great day,
TIC
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------