Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: Shlaklava on August 25, 2007, 08:04:33 am

Title: Creating Version Info
Post by: Shlaklava on August 25, 2007, 08:04:33 am
When compiling my project in other IDEs such as Bloodshed DevC++ I was able to attach version info to the executable description. Is there any way to do that in Code::Blocks?
Title: Re: Creating Version Info
Post by: MortenMacFly on August 25, 2007, 01:00:32 pm
Is there any way to do that in Code::Blocks?
Sure. You only need to the version info part to your RC file (assuming you already have one, for icons or similar). If not: Create a new RC file and add the part. C::B will compile and link it for you if you just add the RC file to your project. There is VersionInfo plugin for C::B that might help you to fill the resource content automatically... but I never tried that -> but it sounds interesting though...
With regards, Morten.
Title: Re: Creating Version Info
Post by: Shlaklava on August 25, 2007, 04:38:02 pm
Thank you very much. Now it will be much easier to my Beta Testers what version they have.
Title: Re: Creating Version Info
Post by: PsYhLo on August 25, 2007, 05:51:02 pm
http://forums.codeblocks.org/index.php/topic,6294.0.html
Title: Re: Creating Version Info
Post by: JGM on August 25, 2007, 06:09:36 pm
The autoversioning plugin that I did may help you with that, it generate a version.h with various variable declarations and two defines to use on rc files. I haven't tested it with rc files but it should be something like this:

Code
#include "version.h" //File generated by the plugin with the 
//AutoVersion::RC_FILEVERSION and
//AutoVersion::RC_FILEVERSION_STRING
//defines.

aaaa ICON "app.ico"


1 VERSIONINFO
FILEVERSION AutoVersion::RC_FILEVERSION
PRODUCTVERSION AutoVersion::RC_FILEVERSION

FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
  FILEFLAGS 0x1L
#else
  FILEFLAGS 0x0L
#endif

FILEOS 0x4L
FILETYPE 0x1L    // 0x1L = EXE, 0x2L = DLL
FILESUBTYPE 0x0L

BEGIN
   BLOCK "StringFileInfo"
   BEGIN

      BLOCK "040904e4"
      BEGIN
         VALUE "CompanyName", "My Company"
         VALUE "LegalCopyright", "(c) 2007 My Copyrights"
         VALUE "FileDescription", "Blah"
         VALUE "FileVersion", AutoVersion::RC_FILEVERSION_STRING
         VALUE "InternalName", "AppName"
         VALUE "OriginalFilename", "app.exe"
         VALUE "ProductName", "Appname blahh"
         VALUE "ProductVersion", AutoVersion::RC_FILEVERSION_STRING
         VALUE "Comments", "This is a beta app"
      END
   END

   BLOCK "VarFileInfo"
   BEGIN
      VALUE "Translation", 0x409, 1252
   END

END

If you want to test it follow the links on my signature for mor info on the forum and downloads. I have created also a berlios account for it. If something goes wrong or goes fine I will appreciate if you report it :D. I think that the plugin should also generate an rc file under windows, that should be a feature maybe. :roll:
Title: Re: Creating Version Info
Post by: MortenMacFly on August 25, 2007, 07:30:45 pm
I think that the plugin should also generate an rc file under windows, that should be a feature maybe. :roll:
Definitely. In fact the version info I use is even more detailed than the one you have just shown. Here is how it looks like:
Code
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US

VS_VERSION_INFO    VERSIONINFO
  FILEVERSION      1,0,0,1
  PRODUCTVERSION   1,0,0,1
  FILEFLAGSMASK    0x3fL // VS_FFI_FILEFLAGSMASK
#ifdef _DEBUG
  FILEFLAGS        0x1L  // VS_FF_DEBUG|VS_FF_PRIVATEBUILD|VS_FF_PRERELEASE
#else
  FILEFLAGS        0x0L  // final version
#endif
  FILEOS           VOS_NT_WINDOWS32
  FILETYPE         VFT_APP
  FILESUBTYPE      VFT2_UNKNOWN // not used
{
  BLOCK "StringFileInfo"
  {
    BLOCK "040904E4" // Lang=US English, CharSet=Windows Multilingual
    {
      VALUE "Build",            "August 2007\0"
      VALUE "Comments",         "Free for personal use only.\0"
      VALUE "CompanyName",      "Fake Company\0"
      VALUE "Developer",        "The Developer\0"
      VALUE "FileDescription",  "Application implementing something\0"
      VALUE "FileVersion",      "1.0.000\0"
      VALUE "InternalName",     "AppInternalName\0"
      VALUE "LegalCopyright",   "Copyright (C) 2007 Fake Company\0"
      VALUE "LegalTrademarks",  "All rights reserved.\0"
      VALUE "OriginalFilename", "TheEXE.exe\0"
      VALUE "PrivateBuild",     "\0"
      VALUE "ProductName",      "The EXE\0"
      VALUE "ProductVersion",   "1.0.000\0"
      VALUE "SpecialBuild",     "\0"
      VALUE "Support",          "TheEXE at fake-domain.com\0"
      VALUE "Users",            "Unlimited.\0"
    } // BLOCK "040904E4"
  } // BLOCK "StringFileInfo"
  BLOCK "VarFileInfo"
  {
    VALUE "Translation", 0x409, 1252 // 1252 = 0x04E4
  } // BLOCK "VarFileInfo"
}
As you can see - a file version plugin (windows only) should offer a lot more than you describe. And a lot of it has nothing to do with versioning. So honestly: I think it's better to handle these things in another plugin (for Windows only). Hence this one *might* use the macros of the autoversioning plugin... (IMHO).
With regards, Morten.
Title: Re: Creating Version Info
Post by: JGM on August 25, 2007, 07:47:35 pm
I think it's better to handle these things in another plugin (for Windows only). Hence this one *might* use the macros of the autoversioning plugin... (IMHO).
With regards, Morten.

Ok I will do the plugin, as I will benefit from it also :) I will also follow your opinion of using the autoversioning plugin when available for the macros.

What name you think it should be for the plugin? I doesn't have any idea :?.
Title: Re: Creating Version Info
Post by: MortenMacFly on August 25, 2007, 07:59:53 pm
Ok I will do the plugin, as I will benefit from it also :)
I honestly didn't mean to push you to that step - but I'm looking forward to it... ;-)

What name you think it should be for the plugin?
VersionInfo plugin? ;-)
Title: Re: Creating Version Info
Post by: JGM on August 25, 2007, 08:31:18 pm
I honestly didn't mean to push you to that step - but I'm looking forward to it... ;-)

Thats okay :)

VersionInfo plugin? ;-)

OK, now I'm going to work on my car to change the oil, filter and sparks. When I finish that and the every day tasks of the home, I will start on it. Is good to improve my programming skills and exercise my mind. :D

THe plugin should be something easy.
Title: Re: Creating Version Info
Post by: raph on August 25, 2007, 09:19:20 pm
One step further would mean to build some kind of ResourceBuilder plugin.
It would be able to
- customize application executable icon
- add icons, bitmaps, binary files to executable
- add version info
- add menus, string tables, accelerators
thus creating the .rc file automatically.
Title: Re: Creating Version Info
Post by: JGM on August 25, 2007, 10:53:10 pm
I finished my daily tasks. :D

One step further would mean to build some kind of ResourceBuilder plugin.
It would be able to
- .. bitmaps, binary files to executable
- add menus, string tables, accelerators
thus creating the .rc file automatically.

Whooo!! I will have to read some documentation of microsoft rc files and create some small parser for all that (may be regular explressions) :idea:.

Well, and create some GUI with a data grid to edit all that resources by type. This is not so easy now for a novice like me jeje, but is a good idea and good for learning. :)

raph:

Could you point me to good documentation of rc files, because I have never used:
- menus,
- string tables,
- accelerators,
- binary files
- And I don't remember if Bitmaps
inside rc files.

I will start this when I get a bath, I smell to oil  :shock:
Title: Re: Creating Version Info
Post by: raph on August 25, 2007, 11:22:36 pm
You really want to do this? cool :)

You will get all you want from the msdn here (http://msdn2.microsoft.com/en-us/library/aa380599.aspx).
I don't know whether windres (mingw resource compiler) does have the very same syntax like Microsoft's rc.
Quick reference about windres syntax (http://www.cygwin.com/cygwin-ug-net/windres.html).
A very nice and comfortable way to understand the windows resource system is to play around with ResourceHacker (http://www.angusj.com/resourcehacker/) (or change some existing application interfaces you don't like  :D).
Title: Re: Creating Version Info
Post by: JGM on August 26, 2007, 05:53:41 am
Does it exist some equivalent for linux?
Title: Re: Creating Version Info
Post by: Biplab on August 26, 2007, 06:18:21 am
Does it exist some equivalent for linux?

No. On Linux, RC files are not necessary.
Title: Re: Creating Version Info
Post by: MortenMacFly on August 26, 2007, 09:57:08 am
One step further would mean to build some kind of ResourceBuilder plugin.
It would be able to
- customize application executable icon
- add icons, bitmaps, binary files to executable
- add version info
- add menus, string tables, accelerators
thus creating the .rc file automatically.
Wait, wait... I don't think this is an easy tasks. A complete resource editor is far more complex than just a file version plugin. JGM: Watch out! In addition I think it's not even necessary. There are *very* good free resource editors around (e.g. ResEd) which you can easily connect to *.RC files within C::B as external tool. So why make another resource editor? I don't see a good reason for it. In addition C::B is a cross-platform tool and there is no "RC" under Linux. There are other cross-platform requirements around that are more important than Windows-only tasks IMHO.
With regards, Morten.
Title: Re: Creating Version Info
Post by: raph on August 26, 2007, 10:52:32 am
You're definetly right Morten
JGM: If you still want to develop this you could e.g. limit to version info, icons, bitmaps, cursors and binary data (allowing to include a xp manifest file) thus the easy things.
Title: Re: Creating Version Info
Post by: JGM on August 26, 2007, 03:38:21 pm
There are *very* good free resource editors around (e.g. ResEd) which you can easily connect to *.RC files within C::B as external tool.

Yep, I saw that tool and it is really complex. I was thinking of only adding bitmaps, icons, pointers, but not windows controls or dialogs :shock: Anyway I will keep it simple just a version info plugin for windows rc with a section marked like this:

//{Version Info
...
//}

That will be the only area on the file changing and the other rest free to be managed by a third party tool of choice.

There are other cross-platform requirements around that are more important than Windows-only tasks IMHO.
With regards, Morten.

I'm curious, what other things need to be done for both plataforms? I will like to help :)
Title: Re: Creating Version Info
Post by: JGM on October 07, 2007, 05:10:40 pm
I forgot about this, but people on the autoversioning at plugin forums are asking for it. So I just remembered to create the plug in. but it will only generate a version.rc, that you can include into your actual rc file. And only the info that posted Morten here http://forums.codeblocks.org/index.php/topic,6775.msg51955.html#msg51955. I guess I will have to create some dialog to edit all that properties. I will make some parser with regular expressions only for the options pointed at the above url.