Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: 1 Send TopicPrint
Locked Topic Prebuild hook excuted after build (Read 1835 times)
Astroscout
Junior Member
**
Offline


Posts: 10
Joined: Jul 31st, 2019
Prebuild hook excuted after build
May 7th, 2020 at 1:59pm
 
Hello,
we mange our programming projects using Git. To ensure that we always have the latest git hash (and other building information) available in the software on the microcontroller, we added the following entry to the board.txt: 
Code
Select All
recipe.hooks.sketch.prebuild.1.pattern=GitWCRev.exe "{ProjectDir}." "{ProjectDir}git_template.txt" "{ProjectDir}git.h" 



This line creates a git.h file containing all necessary git info, which is included in our software, from the given template.

Unfortunately, we have now discovered that this process is not executed before the build as expected, but afterwards. Consequently, the software always contains the Git data of the previous build.

Is there a way to do this BEFORE every build process?

We are using Visual Studio 2019 with Visual Micro 1912.28.2

Thank you!

  
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2174
Joined: Feb 13th, 2019
Re: Prebuild hook excuted after build
Reply #1 - May 7th, 2020 at 2:32pm
 
The hook are broken down for the different phases of the compilation (Arduino Hardware Spec).

To Execute some code before any actions are taken (before Library search and any compilation), the hook below will allow this to happen (though does not appear to be in the documentation).
Code
Select All
recipe.hooks.prebuild.1.pattern=GitWCRev.exe "{ProjectDir}." "{ProjectDir}git_template.txt" "{ProjectDir}git.h"  



Let us know if this resolves the issue or if something different is required.
  
Back to top
 
IP Logged
 
Astroscout
Junior Member
**
Offline


Posts: 10
Joined: Jul 31st, 2019
Re: Prebuild hook excuted after build
Reply #2 - May 7th, 2020 at 3:05pm
 
Many thanks for your quick response!

It works perfectly!
  
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2174
Joined: Feb 13th, 2019
Re: Prebuild hook excuted after build
Reply #3 - May 7th, 2020 at 3:37pm
 
No problem, and glad it achieves what you need for your project.
  
Back to top
 
IP Logged
 
Astroscout
Junior Member
**
Offline


Posts: 10
Joined: Jul 31st, 2019
Re: Prebuild hook excuted after build
Reply #4 - May 8th, 2020 at 6:50am
 
Unfortunately I noticed another problem. The git.h is now created/updated before compilation, but the compiler does not recognize that this file has been updated and does not recompile this part.  When using rebuild or clean/build the compiler unfortunately also uses the old git.h

Does anyone have an idea how to solve this problem?
  
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2174
Joined: Feb 13th, 2019
Re: Prebuild hook excuted after build
Reply #5 - May 8th, 2020 at 10:16am
 
The files are copied from the project directory, to the build folder for compilation, and as we are changing the project files here, we need to ensure it is deployed to the build folder before compilation begins.

Adding a hook after the git.h re-generation should work, and we will create an article for this approach as useful in multiple VC scenarios

Code
Select All
# Step 1: Update Source Code in Project Dir with Tortoise Git Header Information
recipe.hooks.prebuild.1.pattern=GitWCRev.exe "{ProjectDir}." "{ProjectDir}git_template.txt" "{ProjectDir}git.h"
# Step 2: Clone H File to Build folder for compilation
recipe.hooks.prebuild.2.pattern=cmd.exe /c copy /y "{ProjectDir}git.h" "{build.path}\git.h"
 

  
Back to top
 
IP Logged
 
Astroscout
Junior Member
**
Offline


Posts: 10
Joined: Jul 31st, 2019
Re: Prebuild hook excuted after build
Reply #6 - May 8th, 2020 at 12:56pm
 
Thank you very much for this solution.

It really works perfectly!
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Prebuild hook excuted after build
Reply #7 - Jul 10th, 2020 at 11:34am
 
Off-Topic replies have been moved to this Topic.
  
Back to top
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint