VS Arduino | |
Visual Micro >> Ideas, Suggestions and Related Tools >> Automatic build version in built code
https://www.visualmicro.com/forums/YaBB.pl?num=1545471409 Message started by Acuario on Dec 22nd, 2018 at 9:36am |
Title: Automatic build version in built code Post by Acuario on Dec 22nd, 2018 at 9:36am
Hi,
it would be a nice feature to be able to automatically include a build number in built bin files that can then be used in the Sketch. For example: A file 'BuildVersion.h' included in the project that contains: #define VERSION 3.1 Each time the project is built this number gets automatically (if desired by a setting) incremented The version can then be used as desired in the sketch. I guess this could be implemented using a pre or post build script. Acuario |
Title: RE: Automatic build version in built code (SOLUTION) Post by Acuario on Dec 23rd, 2018 at 7:42am
For anyone who wants this feature, here is a way to achieve at least a basic way of doing it.
1. Create a file in your project called version.h 2. Put the following in version.h Code (]#define VERSION 1[/code):
5. Add the following to your Board.txt Code (]# Increment version before build recipe.hooks.sketch.prebuild.1.pattern=cmd.exe /c "{build.project_path}\version.bat {build.project_path}\version.h" [/code):
Acuario |
Title: Re: Automatic build version in built code Post by Visual Micro on Dec 24th, 2018 at 3:32pm
Excellent thank you!
|
Title: Re: Automatic build version in built code Post by Acuario on Jun 10th, 2019 at 7:48am
I just upgraded to the latest version of VS and it broke my auto update.
It appears something has changed in the build process and now the quotes on the command string are no longer required. To fix this change the code in step 5 from this: Code (]# Increment version before build recipe.hooks.sketch.prebuild.1.pattern=cmd.exe /c "{build.project_path}\version.bat {build.project_path}\version.h"[/code):
The version increment then works correctly. |
Title: Re: Automatic build version in built code Post by Visual Micro on Jun 10th, 2019 at 1:00pm
Thanks, sadly, the quotes cause an issue with some platforms. Sorry forgot to add to the release notes.
|
VS Arduino » Powered by YaBB 2.6.12! YaBB Forum Software © 2000-2024. All Rights Reserved. |