Page 1 of 1

Autoreate EXE with version numbers in filename?

Posted: Tue Jan 31, 2017 7:53 am
by Fangbeast
When I create an executable, instead of the compiler asking me for the filename, is there some way it could get that data from the constants in compile options?

Data such as Product name, product version, Compile count, build count etc so it would look something like this when compiled:

Muffins v2.00.6.1.exe

Instead of me having to remember and rename it manually. This way, I'd be issuing updates each time with the correct build data in the filename.

I've filled in all the detail under compiler options, now I just want to make i easier on myself:):)

Hmm, must be too hard:)

Re: Autoreate EXE with version numbers in filename?

Posted: Thu Feb 02, 2017 3:51 am
by Lunasole
Well that's possible to do by simple IDE tool. I.e. WILL be possible, if only IDE send some data about executable version to a tool (currently it doesn't).
So I'd rather require version info transfer through tool environment variables ^^

Code: Select all

EnableExplicit

; compile this and add to IDE tools with "After Create Executable" trigger
Define ExeFile$ = GetEnvironmentVariable("PB_TOOL_Executable")

; here it is possible to rename your executable as you wish
If FileSize(ExeFile$) >= 0
	RenameFile(ExeFile$, GetPathPart(ExeFile$) + "new_exe_name" + "." + GetExtensionPart(ExeFile$))
EndIf
Anyway, you can somehow else extract version data (by getting it from exe directly using WINAPI or some code to read PE header, for example), then use it for renaming like you described

Re: Autoreate EXE with version numbers in filename?

Posted: Thu Feb 02, 2017 5:04 am
by Fangbeast
WILL be possible, if only IDE send some data about executable version to a tool (currently it doesn't).
Pity, would be very useful to spit out properly named exe's.
Anyway, you can somehow else extract version data (by getting it from exe directly using WINAPI or some code to read PE header, for example), then use it for renaming like you described
Guess anything is possible but didn't know that things like compile count etc, would be stored in the header.

Will go searching.

Re: Autoreate EXE with version numbers in filename?

Posted: Thu Feb 02, 2017 5:36 am
by Fangbeast
Found something in DroopyLib but no compile count info. And there is some sort of error with a global that I don't follow so the ide would be better to return that info for a tool.

Re: Autoreate EXE with version numbers in filename?

Posted: Fri Feb 03, 2017 12:07 am
by Lunasole
Fangbeast wrote: Guess anything is possible but didn't know that things like compile count etc, would be stored in the header.
There is a token %COMPILECOUNT for 'version info' compiler settings, so generally possible read it all from header.
Alternatively maybe it is possible to read all that data from .pb / .pbp files directly.
Hope this helps somehow, I'd like to code such a tool, but not needing it myself and a bit busy recently to go with it deeper

Re: Autoreate EXE with version numbers in filename?

Posted: Fri Feb 03, 2017 1:52 am
by skywalk
If you don't mind a date based version system...?
I use these to autogenerate my versions at compile for simple tools.
Place this text at the bottom of your main source file if you store config data in source files?

For main apps, I use a resource file which I autofill the version data.

Code: Select all

; IDE Options = PureBasic 5.60 Beta 2 (Windows - x64)
; CursorPosition = 55
; FirstLine = 69
; Folding = ------------------------------------------------v-------------------9---------------
; EnableThread
; EnableXP
; UseIcon = C:\dev\my.ico
; Executable = ..\..\myapp.exe
; CurrentDirectory = C:\dev\myapp\
; CompileSourceDirectory
; EnablePurifier = 1,1,1,1
; IncludeVersionInfo
; VersionField0 = %yy,%mm,%dd,0
; VersionField1 = %yy,%mm,%dd,0
; VersionField2 = My Co
; VersionField3 = MyApp
; VersionField4 = %yy.%mm.%dd
; VersionField5 = %yy.%mm.%dd
; VersionField6 = What my app does.
; VersionField7 = My app
; VersionField9 = My co
; VersionField10 = My co
; VersionField13 = skywalk@myco.com
; VersionField14 = www.myco.com
; VersionField17 = 0409 English (United States)
; EnableUnicode