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
Hot Topic (More than 8 Replies) prebuild hooks behavior is not correct (update: is correct but tweak required) (Read 7793 times)
Red Baron
Member
***
Offline


Posts: 112
Location: Germany
Joined: Jul 29th, 2015
prebuild hooks behavior is not correct (update: is correct but tweak required)
Jul 29th, 2016 at 12:59pm
Print Post  
Hi,
I'm using Visual Micro 1.1606.17, VS 2015 Update 3.

In former versions recipe.hooks.sketch.prebuild.1.pattern was executed BEFORE the project files are copied to temp directory. In the current version the files are copied before executing the prebuild scripts. The result: prebuild scripts have no effect  Cry

Kind regards
Red Baron
« Last Edit: Aug 9th, 2016 at 10:44am by Tim@Visual Micro »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12163
Location: United Kingdom
Joined: Apr 10th, 2010
Re: prebuild hooks behavior is not correct
Reply #1 - Aug 1st, 2016 at 8:48pm
Print Post  
Hi,

Sorry for the delay. The pre-build has moved slightly but I didn't think it was previously happening prior to file copy.

I'll look into it over the next couple of day.

Thanks for the report.
  
Back to top
IP Logged
 
Red Baron
Member
***
Offline


Posts: 112
Location: Germany
Joined: Jul 29th, 2015
Re: prebuild hooks behavior is not correct
Reply #2 - Aug 2nd, 2016 at 3:59pm
Print Post  
Indeed this was the behavior in former versions. I used it to update a version info via an external program. I documented this behavior at 2016-04-23 on my hompage http://www.microsofttranslator.com/bv.aspx?from=&to=en&a=http%3A%2F%2Fbienonline... (translated version)
« Last Edit: Aug 2nd, 2016 at 3:59pm by Red Baron »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12163
Location: United Kingdom
Joined: Apr 10th, 2010
Re: prebuild hooks behavior is not correct
Reply #3 - Aug 2nd, 2016 at 6:35pm
Print Post  
Thanks that's great. I will look into it asap.

In the meantime not sure if this helps but you can make the change directly to the build folder instead (or additionally).

Code
Select All
recipe.hooks.sketch.prebuild.1.pattern=IncrementVersion.exe "{build.path}\appversion.h" -M 



ps: Visual Micro can also be used in Atmel Studio although that might confuse your clear guide Smiley
« Last Edit: Aug 2nd, 2016 at 6:38pm by Tim@Visual Micro »  
Back to top
IP Logged
 
Red Baron
Member
***
Offline


Posts: 112
Location: Germany
Joined: Jul 29th, 2015
Re: prebuild hooks behavior is not correct
Reply #4 - Aug 2nd, 2016 at 8:29pm
Print Post  
That was the first option I tried. But modifying a copied file will always give the same result. You modify always the same base file.

I checked the Arduino-IDE. It also copies the files first and than executes the prebuild hooks. So VM has the same behavier as the IDE. That is perfect Smiley, you should not change this. I withdraw my error message.

I successfully tried the following:
- modify the copy
- copy the modified file back to the {sketch_path} folder.

I developed a batch file for this that works with VM and the IDE. I will document it and post a link to this documentation.

The Arduino-IDE (v 16.10) does not support parameter '{sketh_path}'. But it executes the compiler with the sketch folder as current directory ('C:\<user>\documents\Arduino\<sketch name>').

VM executes in in the Arduino program folder ('C:\Program Files (x86)\Arduino'). For compatibility reasons, you should consider to change this behavior.

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


Posts: 12163
Location: United Kingdom
Joined: Apr 10th, 2010
Re: prebuild hooks behavior is not correct
Reply #5 - Aug 2nd, 2016 at 8:34pm
Print Post  
That's really great feedback thanks. Will do.
  
Back to top
IP Logged
 
Red Baron
Member
***
Offline


Posts: 112
Location: Germany
Joined: Jul 29th, 2015
Re: prebuild hooks behavior is not correct
Reply #6 - Aug 3rd, 2016 at 7:37am
Print Post  
This is my batch file. It works with Visual Micro and the Arduino IDE. First German instruction followed by an English one.

Code
Select All
@echo off
REM ArduinoPrebuild.cmd

REM ---------- Deutsche Anleitung ---
REM Dieses Batch-Programm dient dazu, eine Datei beim Build-Prozess vor dem Kompilieren dauerhaft zu modifizieren, zB. um eine Versionsnummer hochzuzählen.
REM Der Aufruf der Datei erfolgt durch recipe.hooks.sketch.prebuild.#.pattern in der Datei 'platform.txt'.
REM AppVersion.h ist die Datei, die modifiziert werden soll. Das Programm, das modifiziert ist 'IncrementVersion.exe'.

REM Beim Kompilieren setzt die Arduino-IDE die CurrentDirectory auf das Sketch-Verzeichnis, z.B. <user>\documents\Arduino.
REM Visual Micro steht im Arduino Programm-Verzeichnis, z.B. C:\Program Files (x86)\Arduino.

REM Der Parameter {sketch_path} wird von Visual Micro aufgelöst und zeigt auf das Sketch-Verzeichnis (ohne Backslash am Ende).
REM Die Arduino-IDE liefert den Text "{sketch_path}" zurück.

REM Der Parameter {build.path} zeigt bei Visual Micro direkt auf den Ordner mit den Source-Dateien(ohne Backslash am Ende).
REM VM kopiert alle Quellen dorthin.
REM Beispiel: <Temp>\VMicroBuilds\<project-name>\<board-name>

REM Der Parameter {build.path} zeigt bei der Arduino-IDE in einen Sammel-Ordner (mit Backslash am Ende).
REM Die Quellen befinden sich im Unterverzeichnis 'sketch'.
REM Beispiel: <Temp>\buildc8b6589afc1136b3b8ee8306c9cc9978.tmp\sketch

REM Syntax:recipe.hooks.sketch.prebuild.#.pattern = <path>ArduinoPrebuild {sketch_path} {build.path}\AppVersion.h
REM                                                               %0            %1               %2

REM Wenn %~1 den Text "{sketch_path}" enthält, erfolgt die Kompilierung durch die Arduino-IDE

REM ---------- English instructions ---
REM This batch program is used to modify a file permanently during the build process before compiling, e.g. a version number increment.
REM It is called by recipe.hooks.sketch.prebuild.#.pattern in the file 'platform.txt'.
REM AppVersion.h is the file that is to be modified. The modifying program is 'IncrementVersion.exe'.

REM Compiling with the Arduino IDE the CurrentDirectory is set to the directory of the sketch, e.g. <user>\documents\Arduino.
REM Visual Micros CurrentDirectory is the Arduini program directory, e.g. C:\Program Files (x86)\Arduino.

REM The {sketch_path} parameter is resolved by Visual Micro and points to the directory of the sketch (without a backslash at the end).
REM The Arduino IDE simply returns the text '{sketch_path}'.

REM of parameters {build.path} shows Visual micro directly to the folder with the source Dateien(ohne Backslash andem an Ende).
REM VM copies all sources there.
REM example: <Temp>\VMicroBuilds\<project-name>\<board-name>

REM The parameter {build.path} of the Arduino IDE points to a bulk folder (with backslash at the end).
REM The source files are located in the subdirectory 'sketch'.
REM Example: <temp>\buildc8b6589afc1136b3b8ee8306c9cc9978.tmp\sketch

REM Syntax: recipe.hooks.sketch.prebuild.#.pattern = <path>ArduinoPrebuild {sketch_path} {build.path}\AppVersion.h
REM                                                                %0           %1                 %2

REM If % ~ 1 contains the text '{sketch_path}', the compilation is done by the Arduino IDE


IF "%~1" == "{sketch_path}" GOTO Arduino

REM -- Visual Micro -------------------------------
ECHO ***** Executing Visual Micro
Set DEST=%~1
Set SOURCE=%~2
goto DoIt

REM -- Arduino-IDE --------------------------------
:Arduino
ECHO ***** Executing Arduino
Set DEST=.
REM % ~dp2 adds a backslash!
Set SOURCE=%~dp2sketch\%~nx2

REM -- Execution --------------------------------
:DoIt
echo SOURCE: %SOURCE%
echo DEST: %DEST%
IncrementVersion %SOURCE% -M
copy %SOURCE% %DEST%
 

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


Posts: 12163
Location: United Kingdom
Joined: Apr 10th, 2010
Re: prebuild hooks behavior is not correct
Reply #7 - Aug 3rd, 2016 at 10:07am
Print Post  
Thanks I will write that up onto a page on visualmicro.com

I am also hoping to implement the visual studio project custom build events and pre-build-copy hook as soon as normal work  is less pressured.
  
Back to top
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12163
Location: United Kingdom
Joined: Apr 10th, 2010
Re: prebuild hooks behavior is not correct
Reply #8 - Aug 3rd, 2016 at 10:12am
Print Post  
Have you got enough pro licences for all of your development pc's?

If not have you purchased a license key yet? If yes then please email it to me and I will add some licences, if not then email and let me know your required name and email address so I can issue some licences.

info[at]visualmicro.com

Tim
« Last Edit: Aug 3rd, 2016 at 10:15am by Tim@Visual Micro »  
Back to top
IP Logged
 
Red Baron
Member
***
Offline


Posts: 112
Location: Germany
Joined: Jul 29th, 2015
Re: prebuild hooks behavior is not correct
Reply #9 - Aug 3rd, 2016 at 6:29pm
Print Post  
Thank you, I have a single user hobby license and one pc. That seems to fit Smiley
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12163
Location: United Kingdom
Joined: Apr 10th, 2010
Re: prebuild hooks behavior is not correct
Reply #10 - Aug 3rd, 2016 at 7:22pm
Print Post  
Let me know via email anytime you need more.

Don't forget to say your forum name in the email because I never know who is who Smiley
« Last Edit: Aug 3rd, 2016 at 7:23pm by Tim@Visual Micro »  
Back to top
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint