Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delphi Version number central but other info decentral

Background

Upto RS10.3 I used to use Andreas Hausladen DDevExtensions to set my version number in my project sources to be the same for all modules (bpl's/exe), but unfortunately Andreas has stopped updating his tool for RS10.4 and later.

So I am looking for more comfortable ways to set a version number in my app modules than applying multi-file changes to all dproj files with NotePad++.

But... On the other side I do want to keep specific information (like file description etc) specific to the module file.

What I also would like but isnt really a requirement is to have my (c) notice, and other shared info to be centralized in a single file (preferably .rc) as well.

It is not a problem to drop the version info from the dproj files (which are a pain to maintain anyway) and have a specific .rc file for each module instead.

Another advantage would be that having one central version number and (c) file is also a lot better in svn change management since I don't have to commit each and every .dproj file because of the version/build number change.

Investigation

(To be updated as we go along) I Checked out

  • How to include Subversion revision number into Delphi project
  • Incrementing Delphi XE project version number from command line

But those solutions are not really what I am looking for; I am not looking for scripts but a source file/project file way to accomplish my task.

So here's the Q

How can I have one single .rc file containing my version number and use it in other .rc files containing specific version info

like image 716
H.Hasenack Avatar asked Jun 26 '20 09:06

H.Hasenack


1 Answers

Ah I didn't expect it to be this simple... I Created two .rc files, one with the shared info as #defines SharedVersionDefs.rc:

#define VER_MAJ 1
#define VER_MIN 2
#define VER_SUB 3
#define VER_BUILD 8

#define VER_FILEVERSION             VER_MAJ,VER_MIN,VER_SUB,VER_BUILD
#define VER_FILEVERSION_STR         ""VER_MAJ,VER_MIN,VER_SUB,VER_BUILD"\0"

// in my app file and product version are the same
#define VER_PRODUCTVERSION          VER_MAJ,VER_MIN,VER_SUB,VER_BUILD
#define VER_PRODUCTVERSION_STR      ""VER_MAJ,VER_MIN,VER_SUB,VER_BUILD"\0"

#define VER_COMPANYNAME_STR "MyCompany\0"
#define VER_LEGALCOPYRIGHT_STR "(c) 2020 "VER_COMPANYNAME_STR"\0"

And one specific file (which would re-appear for each module with different names and contents) SpecificVersion.rc:

/* Use the shared version info from a central file */
#include "SharedVersionDefs.rc"


#ifndef DEBUG
#define VER_DEBUG                   0
#else
#define VER_DEBUG                   VS_FF_DEBUG
#endif

VS_VERSION_INFO VERSIONINFO
FILEVERSION     VER_FILEVERSION
PRODUCTVERSION  VER_PRODUCTVERSION

BEGIN
    BLOCK "StringFileInfo"
    BEGIN
        BLOCK "040904E4"
        BEGIN
            VALUE "CompanyName",      VER_COMPANYNAME_STR
            VALUE "FileDescription",  "Specific file description"
            VALUE "FileVersion",      VER_FILEVERSION_STR
            VALUE "InternalName",     "Specific internal name"
            VALUE "LegalCopyright",   VER_LEGALCOPYRIGHT_STR
            VALUE "ProductName",      "LCCAMQM"
            VALUE "ProductVersion",   VER_PRODUCTVERSION_STR
        END
    END

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

Just had to create these 2 files, set version info in the delphi dproj file to OFF, and then add the specific .rc file to the module's dproj where I want it to appear, in this case a minor delphi project:

program VersionInfoTest;

{$R 'SpecificVersion.res' 'SpecificVersion.rc'}

uses
  Vcl.Forms,
  uMain in 'uMain.pas' {frmMain},
  uVerinfo in 'uVerinfo.pas';

{$R *.res}

begin
  Application.Initialize;
  Application.MainFormOnTaskbar := True;
  Application.CreateForm(TfrmMain, frmMain);
  Application.Run;
end.

And I verified this worked.

ATTENTION: Due to RSP-13486 you are required to add the .rc file to the .dproj file as well. Just drag-and-drop in in there using the IDE.

More info regarding the .rc files and examples can be found on MSDN

like image 187
H.Hasenack Avatar answered Nov 01 '22 03:11

H.Hasenack