Visual Studio Ide for Arduino
https://www.visualmicro.com/forums/YaBB.pl
Other >> Ideas and Suggestions >> Versioning the bin file and copying it to the required directory
https://www.visualmicro.com/forums/YaBB.pl?num=1548592163

Message started by Acuario on Jan 27th, 2019 at 12:29pm

Title: Versioning the bin file and copying it to the required directory
Post by Acuario on Jan 27th, 2019 at 12:29pm
I needed to put a version number on my compiled bin file and then copy it to a specific directory (for ftp upload to a server for subsequent download). Using a combination of the versioning code I previously wrote here: Automatic build version in built code combined with the following batch file and addition to the local Board.txt I achieved my objective.

Create a new batch file, copyme.bat in your project and mark it as exclude from project:

Code (]
@echo off
setlocal EnableDelayedExpansion
set file=%1

for /F "tokens=1-3 delims=N " %%a in (%file%) do (
   for %%A in (%%a %%b %%c) do set "i=%%A"
)

set from=%2
set dest=%3

copy %from% %dest%%i%.ino.bin
[/code):

Then add the following line in Board.txt
[code]
recipe.objcopy.hex.pattern.1.pattern=cmd.exe /c "{build.project_path}\copyme.bat {build.project_path}\version.h {vm.runtime.build.intermediate_output_path}{build.project_name}.bin {build.project_path}\php\bin\"


Replace the {build.project_path}\php\bin\ for the directory where you want to copy the bin file.

The batch file will get run after the .bin file has been created, and will rename it to [current version].ino.bin

Hope this is of use to someone.

Title: Re: Versioning the bin file and copying it to the required directory
Post by Acuario on Jan 27th, 2019 at 6:04pm
If you want to do the same for the SPIFFS file then the following works:

Add the following to the copyme.bat file

Code (]
set mkspiffs=%4
set spiffsdir=%5
%mkspiffs%\0.1.2\mkspiffs -c %spiffsdir% -s 1004000 -p 256 -b 8192 %dest%%i%.spiffs.bin
[/code):

Note: You may need to modify the path for your mkspiffs.exe file (the \0.1.2\mkspiffs bit)

Change the line in Board.txt for the following line:
[code]
recipe.objcopy.hex.pattern.1.pattern=cmd.exe /c "{build.project_path}\copyme.bat {build.project_path}\version.h {vm.runtime.build.intermediate_output_path}{build.project_name}.bin {build.project_path}\php\bin\ {tools.mkspiffs.path} {build.project_path}\data"


The result will be 2 files, [version].ino.bin and [version].spiffs.bin

Title: Re: Versioning the bin file and copying it to the required directory
Post by Acuario on Jun 10th, 2019 at 8:52am
The latest VM build breaks the auto copy. The fix is the same as for the auto version increment (as described in another post).

Removing the quotes from the command string (after the cmd.exe /c ".....") fixes the problem.

Visual Studio Ide for Arduino » Powered by YaBB 2.5.2!
YaBB Forum Software © 2000-2019. All Rights Reserved.