Automated Versioning

Started by stevengraff, January 28, 2014, 12:48:25 PM

Previous topic - Next topic

stevengraff

I've created an application that consists of about a dozen executables.  I've been neglectful of applying any versioning or maintaining a change log for the myriad quick-fixes and even major feature changes I've been applying. Is there any easy or semi-automatic way I can apply some kind of version number to each mod? Maybe even the compile date, or last mod date of the wil file would be OK. I'm supposing I'll need to display said number in the title bars for simplicity.

Lots of changes happen very quickly, just because they can. But now I'm starting to get real customers, who'll be wanting to report a bug against a particular version or release.

I'm running on empty re creativity on this topic; anyone have a good method of doing this they'd be willing to share? Obviously I want to spend my time coding, not clerically appending version numbers.

Deana

Often software developers use MajorVer.MinorVer.Patch format, and increment the:
1. MajorVer version when making incompatible changes,
2. MinorVer version when adding functionality in a backwards-compatible manner
3. Patch version when you make backwards-compatible bug fixes.

The previous version numbers are stored in the .CMP ( created when you compile)  that can be queried and incremented, then used at compile time.

Or maybe consider using the date versioning scheme like this "MyCode 20140128". (reference: http://en.wikipedia.org/wiki/Software_versioning#Date)
Deana F.
Technical Support
Wilson WindowWare Inc.

stevengraff

Is there any way the wil file can pick up the date/time of the compile, so it could be displayed in the title bar of the exe?

Deana

Yes FileVersionInfo can be useful.

Code (winbatch) Select
WbtPgm = IntControl(1004,0,0,0,0)
If RtStatus() == 1 ;Compiled Exe
   Lang = "";'0asdasf'
   FileVersion = FileVerInfo(WbtPgm, Lang, "FileVersion" )
   ProductVersion = FileVerInfo(WbtPgm, Lang, "ProductVersion" )
   Comments = FileVerInfo(WbtPgm, Lang, "Comments" )
   LegalCopyright = FileVerInfo(WbtPgm, Lang, "LegalCopyright" )
   CompanyName = FileVerInfo(WbtPgm, Lang, "CompanyName" )
   LegalTrademarks = FileVerInfo(WbtPgm, Lang, "LegalTrademarks" )
   FileDescription = FileVerInfo(WbtPgm, Lang, "FileDescription" )
   OriginalFilename = FileVerInfo(WbtPgm, Lang, "OriginalFilename" )
   ProductName = FileVerInfo(WbtPgm, Lang, "ProductName" )
   InternalName = FileVerInfo(WbtPgm, Lang, "InternalName" )
   Msg = "FileVersion: ":FileVersion:@LF:"ProductVersion: ":ProductVersion:@LF:"Comments: ":Comments:@LF:"LegalCopyright: ":LegalCopyright:@LF:"CompanyName: ":CompanyName:@LF:"LegalTrademarks: ":LegalTrademarks:@LF:"FileDescription: ":FileDescription:@LF:"OriginalFilename: ":OriginalFilename:@LF:"ProductName: ":ProductName:@LF:"InternalName: ":InternalName
   Pause( "Resource Strings", Msg )

   nFileVersion = FileVerInfo(WbtPgm, Lang, "#FileVersion" )
   nProductVersion = FileVerInfo(WbtPgm, Lang, "#ProductVersion" )
   nFileFlagsMask = FileVerInfo(WbtPgm, Lang, "#FileFlagsMask" )
   nFileFlags = FileVerInfo(WbtPgm, Lang, "#FileFlags" )
   nFileOS = FileVerInfo(WbtPgm, Lang, "#FileOS" )
   nFileType = FileVerInfo(WbtPgm, Lang, "#FileType" )
   nFileSubtype = FileVerInfo(WbtPgm, Lang, "#FileSubtype" )
   Msg = "#FileVersion: ":nFileVersion:@LF:"#ProductVersion: ":nProductVersion:@LF:"#FileFlagsMask: ":nFileFlagsMask:@LF:"#FileFlags: ":nFileFlags:@LF:"#FileOS: ":nFileOS:@LF:"#FileType: ":nFileType:@LF:"#FileSubtype: ":nFileSubtype
   Pause( WbtPgm, Msg )

   Compiletime = FileVerInfo(WbtPgm, Lang, "CompileTime" )            ; Special to WinBatch Compiled EXE
   ToolsetBuildInfo = FileVerInfo(WbtPgm, Lang, "ToolsetBuildInfo" )  ; Special to WinBatch Compiled EXE
   ToolsetCopyright  = FileVerInfo(WbtPgm, Lang, "ToolsetCopyright" ) ; Special to WinBatch Compiled EXE
   Msg = "CompileTime: ":CompileTime:@LF:"ToolsetBuildInfo: ":ToolsetBuildInfo:@LF:"ToolsetCopyright: ":ToolsetCopyright
   Pause( WbtPgm, Msg )

Else
   Message( WbtPgm, "Sorry this script must be compiled into an EXE")
EndIf
Exit


Reference: http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/tsleft.web+WinBatch/Compiler+Determine~Version~of~Compiler~Used~to~Compile~an~EXE.txt
Deana F.
Technical Support
Wilson WindowWare Inc.

JTaylor

The version info and such things for the compiled exe are set in an INI so if you have preprocessor script that bundles things you could set that before compiling and then extract it with your script and display it wherever you want.

Jim

DAG_P6

Quote from: Deana on January 28, 2014, 02:11:01 PM
Yes FileVersionInfo can be useful.

It even thoughtfully includes a plug for the developer whose license was used to compile it.
David A. Gray
You are more important than any technology.

stevengraff

Really cool stuff, thanks.

Now, I have the feeling the answer to this will be to easy in retrospect, but I'm not there yet, so I'll ask anyway: Is there a way of auto-incrementing the version number (say in the hundredths) each time I compile?

I know the date is a simple form of auto-incrementer, but maybe a version number is more "sophisticated." i.e. version 1.01.217 vs. 140129


Deana

Your compiler settings including version numbers are all stored in a .CMP file with the same name as the source code (.WBT) file. The internal format of the .CMP file is the same as .INI files; you can use all of the WinBatch IniXXXPvt() functions to manage these files. For more about that format of the CMP files see: http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/tsleft.web+WinBatch/Compiler+Saved~Compiler~Settings.txt

If dealing with the Majorver.MinorVer.Patch version, just treat it like a string and use ItemExtract to read out each integer between the dots. Then you can increment the value by simply adding 1. Rebuild the string using string concatenation.

For example if you want to increment the MinorVer in a version string formatted like this Majorver.MinorVer.Patch, the code would look something like this:

Code (winbatch) Select

; Increment the MinorVer in a version string formatted like this Majorver.MinorVer.Patch
cmpfile = 'C:\TEMP\a.cmp'
productver = IniReadPvt(  'Version Info', 'ProductVersion', '', cmpfile ) ; value 1.01.01
majorver = ItemExtract( 1, productver, '.' )
minorver = ItemExtract( 2, productver, '.' )
patch = ItemExtract( 3, productver, '.' )

If majorver == '' || minorver == '' || patch == ''
    Pause('Notice','Expecting the version format of Majorver.MinorVer.Patch for the product version in the .CMP file!')
    Exit
Endif

;GoSub AddMajorVer
GoSub AddMinorVer
;GoSub AddPatch

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; Display result (Replace with IniWritePvt to update your .CMP)
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
newproductver = majorver : '.' :minorver : '.' : patch
Pause('Updated version numer', newproductver)

Exit

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; Subroutines
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:AddMajorVer
majorver =  majorver+1
return

:AddMinorVer
minorver = StrFixLeft( minorver+1, 0, 2 ) ; pad to 2 characters
return

:AddPatch
patch = StrFixLeft( patch+1, 0, 2 ) ; pad to 2 characters
return




Deana F.
Technical Support
Wilson WindowWare Inc.

stevengraff

In your example I would still need to use iniWritePvt to update the .cmp file, right?

But the updating of the version number... how can I trigger that by the act of doing a new compile?

Deana

Quote from: stevengraff on January 29, 2014, 08:37:39 AM
In your example I would still need to use iniWritePvt to update the .cmp file, right?

But the updating of the version number... how can I trigger that by the act of doing a new compile?

Yes you would need to add the code to write the data back to your CMP. The code posted was written as a starting point.

WinBatch+Compiler Command line
A command like this runs the WinBatch+Compiler from a command line or an icon:
"C:\Program Files\WinBatch\System\WBCompiler.exe" "{.wbt}"
*OR*
"C:\Program Files\WinBatch\System\WBCompiler.exe" "{.cmp}"


A command like this runs the WinBatch+Compiler in Batch compile mode from a command line or an icon:
"C:\Program Files\WInBatch\System\WBCompiler.exe" "{.cmplist}"


For more information see the following topics in the Consolidated WIL help file:
"Command Line Parameters"
"Batch Compile"

Deana F.
Technical Support
Wilson WindowWare Inc.

stevengraff

So I might actually launch the compiler via another WinBatch program that would read the current cmp file and bump the version (writing it back to the cmp), prior to issuing the command to compile?

JTaylor


Deana

Quote from: stevengraff on January 29, 2014, 09:19:37 AM
So I might actually launch the compiler via another WinBatch program that would read the current cmp file and bump the version (writing it back to the cmp), prior to issuing the command to compile?

Yes you could create a build.wbt script to handle the version roll and build.
Deana F.
Technical Support
Wilson WindowWare Inc.

stevengraff


If RtStatus() <> 1 then param1 = "goldsms"
inifile = param1
inifile = dirget() : param1 : ".cmp"
wilfile = dirget() : param1 : ".wil"

curVersion = iniReadPvt(  "Version Info", "ProductVersion", "", inifile )
if itemCount( curversion, "." ) <> 3 then curversion = "1.10.030"
majorver = ItemExtract( 1, curVersion, '.' )
minorver = ItemExtract( 2, curVersion, '.' )
patch = ItemExtract( 3, curVersion, '.' )

gosub doincrement
newVersion = majorver : "." : minorver : "."  : patch
iniWritePvt( "Version Info", "ProductVersion", newVersion, iniFile )

RunShell("C:\Program Files (x86)\WinBatch\System\WBCompiler.exe", wilfile, dirget() ,@normal,@nowait)

Exit


The above does the trick, thanks! btw, its final act is to present me with the compiler UI. All I have to do then is hit the Enter key on the keyboard. Any way to program that last step in, also? Maybe just use a sendKeysTo?

Deana

Yes. Again... to batch compile you should be passing the compiler the .CMP file.

In your example it should look like:
Code (winbatch) Select

RunShell("C:\Program Files (x86)\WinBatch\System\WBCompiler.exe", inifile, dirget() ,@normal,@nowait)


For more information see the following topic in the Consolidated WIL help file: "Batch Compile"

You might also want to add code to check if the .CMP file doesn't already exist.
Deana F.
Technical Support
Wilson WindowWare Inc.

stevengraff

Well, that's what I thought at first, but it failed. Somehow it updates the source in the cmp file to be the cmp file itself, and of course fails.

http://screencast.com/t/0FN9BtVm

Deana

I forgot to mention the creation of the .CMPLIST file for a Batch compile. Here is the text from the [Batch Compile] topic, that I have been referring to:

Quote
WinBatch+Compiler supports the following command line for ââ,¬Ëœbatch compilation' of WinBatch scripts:

32-bit
"C:\Program Files (x86)\WinBatch\System\WBCompiler.exe" "C:\WBProjects\Test.cmplist"

64-bit
"C:\Program Files\WinBatch\System\WBCompiler.exe" "C:\WBProjects\Test.cmplist"

A batch compile does require a little setup in order to work. 

First you must have .CMP file for each script you want to compile. A .CMP file is a configuration file that contains all the compile options used.  A .CMP file automatically gets generated each time you successfully compile any script.  The .WBT source file must be located in the same directory as the .CMP file.

The format of the .CMP file is as follows:
[Main]
Type=1
Src=test1.wbt
Targ=C:\WBProjects\test1.exe
Icon=
CmpVersion=4
[Options]
TechWebPage=
UACManifestSelection=highestAvailable
UACManifestUI=false
CodeSign=0
CodeSignDetails=
RunHidden=0
LargeExtractDest=0
PreventAutoExtract=0

[Version Info]
Comments=
CompanyName= Sample Inc
FileDescription=test3
FileVersion=1.0
InternalName=test3.exe
LegalCopyright=Sample Inc
LegalTrademarks=
OriginalFilename=test3.exe
ProductName=test3
ProductVersion=1.0

[Other Files]
Count = 2
File001 = C:\sample1.txt
File002 = C:\sample2.txt

[Extenders]
Count =  2
File001 = wwctl44i.dll
File002 =  wwwnt34i.dll

Note: You could feasibly create a .CMP file on the fly. The internal format of the .CMP file is the same as .INI files. You can use all of the WinBatch IniXXXPvt() functions to manage these files.

[MAIN]
Type = [REQUIRED] Compile option. ( 1 = Large, 2 = Small )
Source = [REQUIRED] Name of the source code file (.WBT or .WIL) to compile.
Target = [REQUIRED] Name of the exe file to create.
Icon = Path to icon filename.
CmpVersion = Version of CMP file. ( Subject to change in future versions of WinBatch. )

[OPTIONS]
TechWebPage = URL to be displayed in WinBatch error messages. ( http://www.example.com )
UACManifestSelection = Requested Execution Level. ( "highestAvailable", "asInvoker", "requireAdministrator" )
UACManifestUI = Manifest uiAccess. ( "true" or "false" )
CodeSign = Code sign settings. ( 1 = true , 0 = false )
CodeSignDetails = Code signing certificates friendly-name. ( WWWTEST )
RunHidden = Hides the EXEs icon on the task bar. ( 1 = "true" , 0 = "false" )
LargeExtractDest = Force the EXE to extract the files to the removable drive. ( 1 = true, 0 = false )
PreventAutoExtract = Prevent extract of Extender and Other files. ( 1 = true, 0 = false )

[Version Info]
Comments = Any Comments about the EXE ( "My Test EXE")
CompanyName = Company name. ( "Wilson WindowWare Inc" )
FileDescription = Description of EXE. ( test1 )
FileVersion = File version number of the EXE ( 1.0 )
InternalName = Name of the EXE file. ( test1.exe )
LegalCopyright = Copyright info. ( "Wilson WindowWare Inc" )
LegalTrademarks = Trademark info. ( "WinBatch is a registered trademark of Wilson WindowWare Inc" )
OriginalFilename = Name of the EXE file. ( test1.exe )
ProductName = Product name of the EXE file. ( test1 )
ProductVersion = Product version of the EXE file. ( 1.0 )

[Other Files]
Count = total number of other files included. ( 2 )
File001 = Path of the 'Other file' to include in the compile. ( C:\sample1.txt )
File002 = Path of the 'Other file' to include in the compile. ( C:\sample2.txt )
Etcââ,¬Â¦

[Extenders]
Count = total number of Extender files included. ( 2 )
File001 = 'Extender' file to include in the compile. ( wwctl44i.dll )
File002 = "Extender' file to include in the compile. ( wwwnt34i.dll )
Etcââ,¬Â¦

You will then need to create a specially formatted file with the file extension of .CMPLIST.

For Example:
C:\WBProjects\Test.cmplist

The .CMPLIST file must include a single line that contains the full path to the .CMP ( configuration ) files for *each* script you would like to batch compile.

For Example:
C:\WBProjects\test1.cmp
C:\WBProjects\test2.cmp
C:\WBProjects\test3.cmp

Notes:
You *must* specify a full file path to each .CMP file in the .CMPLIST file.
Ideally you should put all these .CMP files into a single ââ,¬ËœProjectââ,¬â,,¢ directory. However you can specify paths to all the various .CMP files regardless of the directory.
Now that you have successfully created a .CMP file for each script and also created a .CMPLIST file, you can create your ââ,¬ËœBatch Compileââ,¬â,,¢ script. 

For Example:
;BatchCompile.wbt
wbcompiler = ââ,¬ËœC:\Program Files (x86)\WinBatch\System\WBCompiler.exeââ,¬â,,¢
cmplistfile = ââ,¬ËœC:\WBProjects\Test.cmplistââ,¬â,,¢
Run( wbcompiler, cmplistfile )
exit

IMPORTANT:
The .CMP files information must be correct or this compile process will fail.
The .WBT source file must be located in the same directory as the .CMP file.
The .CMPLIST files information must be correct or this compile process will fail.



Deana F.
Technical Support
Wilson WindowWare Inc.

stevengraff

I think I don't have such a comprehensive reference in my (older) version, so this is helpful.

If I read it right, I need to have a cmplist file listing all the cmp's... this would appear to be true even if I only want to compile a single cmp?

Deana

Quote from: stevengraff on January 30, 2014, 10:46:35 AM
I think I don't have such a comprehensive reference in my (older) version, so this is helpful.

If I read it right, I need to have a cmplist file listing all the cmp's... this would appear to be true even if I only want to compile a single cmp?

That is correct. You might consider updating to the latest version to get all the latest functionality. Here is a link to what new functionality has been added since your version: http://www.winbatch.com/whatsnew.html
Deana F.
Technical Support
Wilson WindowWare Inc.