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
Normal Topic Force Compilation (Read 5533 times)
n
Junior Member
**
Offline


Posts: 52
Joined: Mar 29th, 2016
Force Compilation
Feb 2nd, 2017 at 1:35am
Print Post  
Hi Tim,

In my project I use the macro __TIME__ as a proxy for version number to keep track of when the binary was built. 

However unless I clean or rebuild the whole project, the .cpp file containing the __TIME__ macro is not recompiled and so the compile time is not updated. 

Is there any way in Visual Micro to force re-compile of a particular .ino or .cpp file without recompiling the whole project each time?

Thanks

n

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


Posts: 12208
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Force Compilation
Reply #1 - Feb 2nd, 2017 at 3:02pm
Print Post  
I'll have to give it some thought.

These things come to mind

1) Click save on the source code that contains _TIME_ so that the date/time stamp of the source is updated. This will cause the individual file to be recompiled but not much fun for you.

2) Add a definition of time to the project properties > extra defines and remove from code. This will make the property define available to every build command. I am not sure if this is a practical solution but worth investigating.

3) We could have an option to switch off compile cache for project sources but this will slow compile times down.

4) Which source file is the time macro defined in? Could it be defined in the .ino sources. If so then visual micro could have a switch that always re-compiles the .ino sources instead of the entire project.

5) If the only solution might be to specify an individual source is never cached we could add an option for that.

Does any of this make sense?
  
Back to top
IP Logged
 
n
Junior Member
**
Offline


Posts: 52
Joined: Mar 29th, 2016
Re: Force Compilation
Reply #2 - Feb 2nd, 2017 at 9:45pm
Print Post  
Hi Tim,

Thanks for the extensive reply - you have given me a few things to think about. This is probably not something worth making mods to Visual Micro for - so that leave me your 1 and 2... 

1) Certainly works when done manually. I have tried to automate this using the VS Prebuild Events to change the dates on the relevant file but it looks to me as if the prebuild events are not being fired. Do they work with Visual Micro? There is no sign of it in the verbose compile log.... I understand that they are only fired when there are changes to the build but even then it does not seem to fire...??

2) If I put the following into the extra project defines:

DefineCompileTime __TIME__

then how can I get the time into a char string? Is it something like this I need? I can't make it work.

#define TOSTRING( X ) #X
char CompileTime[] = TOSTRING(DefineCompileTime);

Don't spend too much time on this one Tim - I thought it might just have been a simple switch I was missing...!

Thanks

n


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


Posts: 12208
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Force Compilation
Reply #3 - Feb 3rd, 2017 at 12:44am
Print Post  
ok thanks. let me know if you come up with any bright ideas. 

Not actually sure if my suggestion to pass in compiler is practical or that it will be detected as a change by the compiler cache.

If you switch on verbose you should see the udb properties being passed as strings in the compiler output. I think surrounding entirely with quotes then escaping the quotes around the value is the way.

Have you switched on "vMicro>Compiler>Parellel Build"? It will make the rebuilds much faster
« Last Edit: Feb 3rd, 2017 at 12:45am by Tim@Visual Micro »  
Back to top
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12208
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Force Compilation
Reply #4 - Feb 5th, 2017 at 9:23pm
Print Post  
I think I have a solution

You can add an arduino pre-build hook (action) to a board.txt or platform.txt that runs a batch file to force update of a source file.

The actions are documented in the arduino 3rd party hardware spec and allow you to pass variables sch as build path etc. so the same hook could handle multiple projects if file "x.h" exists


« Last Edit: Feb 5th, 2017 at 9:24pm by Tim@Visual Micro »  
Back to top
IP Logged
 
n
Junior Member
**
Offline


Posts: 52
Joined: Mar 29th, 2016
Re: Force Compilation
Reply #5 - Feb 9th, 2017 at 7:33am
Print Post  
Hi Tim,

Thanks for the suggestion. It took me a while to figure it all out but now it ALMOST works - but not quite....

I have added the following hook at the end of platform.txt

Code
Select All
recipe.hooks.sketch.prebuild.0.pattern="D:\My Documents\Arduino\Scripts\FixDate.cmd" "{sketch_path}" 



FixDate.cmd is a simple script which updates the modified time stamp of the file in my sketch which contains the __TIME__ macro. The script works well and is definitely being called during the compile process but the file containing __TIME__ is still not compiled. 

I can only assume that VM is not checking the time stamps - perhaps it is looking at something else to determine if the file has changed. Perhaps some checksum??

Any suggestions??

Thanks

« Last Edit: Feb 9th, 2017 at 7:35am by n »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12208
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Force Compilation
Reply #6 - Feb 9th, 2017 at 8:02am
Print Post  
You have to look at one of the compiler patterns to see the build folder property. The. Use that instead of hard coded paths
  
Back to top
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12208
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Force Compilation
Reply #7 - Feb 12th, 2017 at 2:20pm
Print Post  
Sorry to be clear, you want to update a file stamp or header file in the build folder and not in the original source folder.

You will see the build properties you will find {build.path} which you can feed to your action//hook
  
Back to top
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint