Skip to content

Commit

Permalink
Updating Package Generator to accept the target Indy version number a…
Browse files Browse the repository at this point in the history
…s a command line parameter.
  • Loading branch information
rlebeau committed May 15, 2024
1 parent 8762b62 commit 9dbc947
Show file tree
Hide file tree
Showing 4 changed files with 1,110 additions and 49 deletions.
94 changes: 69 additions & 25 deletions Builder/Package Generator/Package.pas
Original file line number Diff line number Diff line change
Expand Up @@ -219,20 +219,24 @@ TPackage = class
'', // .NET
''); // Kylix

//Fetch Defaults
IdFetchDelimDefault = ' '; {Do not Localize}
IdFetchDeleteDefault = True;
IdFetchCaseSensitiveDefault = True;

function iif(ATest: Boolean; const ATrue: Integer; const AFalse: Integer): Integer; overload;
function iif(ATest: Boolean; const ATrue: string; const AFalse: string): string; overload;
function iif(ATest: Boolean; const ATrue: Boolean; const AFalse: Boolean): Boolean; overload;

const
IndyVersion_Major = 10;
IndyVersion_Minor = 6;
IndyVersion_Release = 3;
IndyVersion_Build = 2;
var
IndyVersion_Major_Str: string = '';
IndyVersion_Minor_Str: string = '';
IndyVersion_Release_Str: string = '';
IndyVersion_Build_Str: string = '';
IndyVersion_Build_Template: string = '';

IndyVersion_ProductVersion_Str: string = '';
IndyVersion_FileVersion_Str: string = '';
IndyVersion_FileVersion_Template: string = '';

IndyVersion_VersionInfo_ProductVersion_Str: string = '';
IndyVersion_VersionInfo_FileVersion_Str: string = '';
IndyVersion_VersionInfo_FileVersion_Template: string = '';

implementation

Expand Down Expand Up @@ -293,7 +297,7 @@ constructor TPackage.Create;
begin
FContainsClause := 'contains';
FExt := '.dpk';
FVersion := IntToStr(IndyVersion_Major);
FVersion := IndyVersion_Major_Str;
FCode := TStringList.Create;
FDirs := TStringList.Create;
FUnits := TStringList.Create;
Expand Down Expand Up @@ -557,31 +561,26 @@ procedure TPackage.GenPreContains;

procedure TPackage.GenResourceScript;
var
ProductVersion: string;
FileVersion : string;
BuildStr: String;
begin
//We don't call many of the inherited Protected methods because
//those are for Packages while I'm making a unit.

if FTemplate then
BuildStr := '$WCREV$'
else
BuildStr := IntToStr(IndyVersion_Build);

FileVersion := Format('%d,%d,%d,%s', [IndyVersion_Major, IndyVersion_Minor, IndyVersion_Release, BuildStr]);
ProductVersion := FileVersion;
FileVersion := iif(FTemplate,
IndyVersion_VersionInfo_FileVersion_Template,
IndyVersion_VersionInfo_FileVersion_Str);

Code('1 VERSIONINFO ');
Code('FILEVERSION ' + FileVersion);
Code('PRODUCTVERSION ' + ProductVersion);
Code('PRODUCTVERSION ' + FileVersion);
Code('FILEFLAGSMASK 0x3FL');
Code('FILEFLAGS 0x00L');
Code('FILEOS 0x40004L');
Code('FILETYPE 0x1L');

ProductVersion := Format('%d.%d.%d', [IndyVersion_Major, IndyVersion_Minor, IndyVersion_Release]);
FileVersion := ProductVersion + '.' + BuildStr;
FileVersion := iif(FTemplate,
IndyVersion_FileVersion_Template,
IndyVersion_FileVersion_Str);

Code('FILESUBTYPE 0x0L');
Code('{');
Expand All @@ -590,13 +589,13 @@ procedure TPackage.GenResourceScript;
Code(' BLOCK "000104E4"');
Code(' {');
Code(' VALUE "CompanyName", "Chad Z. Hower a.k.a Kudzu and the Indy Pit Crew\0"');
Code(' VALUE "FileDescription", "Internet Direct (Indy) ' + ProductVersion + ' - ' + FDesc + ' Package\0"');
Code(' VALUE "FileDescription", "Internet Direct (Indy) ' + IndyVersion_ProductVersion_Str + ' - ' + FDesc + ' Package\0"');
Code(' VALUE "FileVersion", "' + FileVersion + '\0"');
Code(' VALUE "InternalName", "' + FName + '\0"');
Code(' VALUE "LegalCopyright", "Copyright © 1993 - ' + IntToStr(DateUtils.YearOf(Date)) + ' Chad Z. Hower a.k.a Kudzu and the Indy Pit Crew\0"');
Code(' VALUE "OriginalFilename", "' + FName + '.bpl\0"');
Code(' VALUE "ProductName", "Indy\0"');
Code(' VALUE "ProductVersion", "' + ProductVersion + '\0"');
Code(' VALUE "ProductVersion", "' + IndyVersion_ProductVersion_Str + '\0"');
Code(' }');
Code('');
Code(' }');
Expand All @@ -609,4 +608,49 @@ procedure TPackage.GenResourceScript;
Code('}');
end;

procedure InitVersionNumbers;
var
LMajor, LMinor, LRelease, LBuild, LPos: Integer;
LParam: string;
begin
if not FindCmdLineSwitch('version', LParam) then
raise Exception.Create('Version parameter is missing');

try
LPos := Pos('.', LParam);
LMajor := StrToInt(Copy(LParam, 1, LPos-1));
Delete(LParam, 1, LPos);

LPos := Pos('.', LParam);
LMinor := StrToInt(Copy(LParam, 1, LPos-1));
Delete(LParam, 1, LPos);

LPos := Pos('.', LParam);
LRelease := StrToInt(Copy(LParam, 1, LPos-1));
Delete(LParam, 1, LPos);

LBuild := StrToInt(LParam);
except
Exception.RaiseOuterException(Exception.Create('Version parameter value is invalid'));
Exit;
end;

IndyVersion_Major_Str := IntToStr(LMajor);
IndyVersion_Minor_Str := IntToStr(LMinor);
IndyVersion_Release_Str := IntToStr(LRelease);
IndyVersion_Build_Str := IntToStr(LBuild);
IndyVersion_Build_Template := '$WCREV$';

IndyVersion_ProductVersion_Str := Format('%d.%d.%d', [LMajor, LMinor, LRelease]);
IndyVersion_FileVersion_Str := Format('%d.%d.%d.%d', [LMajor, LMinor, LRelease, LBuild]);
IndyVersion_FileVersion_Template := Format('%d.%d.%d.%s', [LMajor, LMinor, LRelease, IndyVersion_Build_Template]);

IndyVersion_VersionInfo_ProductVersion_Str := Format('%d,%d,%d', [LMajor, LMinor, LRelease]);
IndyVersion_VersionInfo_FileVersion_Str := Format('%d,%d,%d,%d', [LMajor, LMinor, LRelease, LBuild]);
IndyVersion_VersionInfo_FileVersion_Template := Format('%d,%d,%d,%s', [LMajor, LMinor, LRelease, IndyVersion_Build_Template]);
end;

initialization
InitVersionNumbers;

end.
42 changes: 18 additions & 24 deletions Builder/Package Generator/PackageVersInc.pas
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ interface
type
TVersInc = class(TPackage)
private
FProductVersion: string;
procedure GenIdVers;
procedure GenAsmVers;
procedure GenAsmInfo;
Expand All @@ -49,7 +48,6 @@ constructor TVersInc.Create;
begin
inherited;
FExt := '.inc';
FProductVersion := Format('%d.%d.%d', [IndyVersion_Major, IndyVersion_Minor, IndyVersion_Release]);
end;

procedure TVersInc.Generate(ACompiler: TCompiler; const AFlags: TGenerateFlags);
Expand Down Expand Up @@ -143,55 +141,51 @@ procedure TVersInc.Generate(ACompiler: TCompiler; const AFlags: TGenerateFlags);

procedure TVersInc.GenIdVers;
var
FileVersion : string;
MajorStr, MinorStr, ReleaseStr, BuildStr: String;
FileVersion, BuildStr: String;
begin
FCode.Clear;

MajorStr := IntToStr(IndyVersion_Major);
MinorStr := IntToStr(IndyVersion_Minor);
ReleaseStr := IntToStr(IndyVersion_Release);
BuildStr := iif(FTemplate,
IndyVersion_Build_Template,
IndyVersion_Build_Str);

if FTemplate then
BuildStr := '$WCREV$'
else
BuildStr := IntToStr(IndyVersion_Build);
FileVersion := iif(FTemplate,
IndyVersion_FileVersion_Template,
IndyVersion_FileVersion_Str);

FileVersion := FProductVersion + '.' + BuildStr;

Code(' gsIdVersionMajor = ' + MajorStr + ';');
Code(' gsIdVersionMajor = ' + IndyVersion_Major_Str + ';');
Code(' {$NODEFINE gsIdVersionMajor}');
Code(' gsIdVersionMinor = ' + MinorStr + ';');
Code(' gsIdVersionMinor = ' + IndyVersion_Minor_Str + ';');
Code(' {$NODEFINE gsIdVersionMinor}');
Code(' gsIdVersionRelease = ' + ReleaseStr + ';');
Code(' gsIdVersionRelease = ' + IndyVersion_Release_Str + ';');
Code(' {$NODEFINE gsIdVersionRelease}');
Code(' gsIdVersionBuild = ' + BuildStr + ';');
Code(' {$NODEFINE gsIdVersionBuild}');
Code('');
Code(' (*$HPPEMIT ''#define gsIdVersionMajor ' + MajorStr + '''*)');
Code(' (*$HPPEMIT ''#define gsIdVersionMinor ' + MinorStr + '''*)');
Code(' (*$HPPEMIT ''#define gsIdVersionRelease ' + ReleaseStr + '''*)');
Code(' (*$HPPEMIT ''#define gsIdVersionMajor ' + IndyVersion_Major_Str + '''*)');
Code(' (*$HPPEMIT ''#define gsIdVersionMinor ' + IndyVersion_Minor_Str + '''*)');
Code(' (*$HPPEMIT ''#define gsIdVersionRelease ' + IndyVersion_Release_Str + '''*)');
Code(' (*$HPPEMIT ''#define gsIdVersionBuild ' + BuildStr + '''*)');
Code(' (*$HPPEMIT ''''*)');
Code('');
Code(' gsIdVersion = ''' + FileVersion + '''; {do not localize}');
Code(' gsIdProductName = ''Indy''; {do not localize}');
Code(' gsIdProductVersion = ''' + FProductVersion + '''; {do not localize}');
Code(' gsIdProductVersion = ''' + IndyVersion_ProductVersion_Str + '''; {do not localize}');
end;

procedure TVersInc.GenAsmVers;
begin
FCode.Clear;

Code('[assembly: AssemblyDescription(''Internet Direct (Indy) ' + FProductVersion + ' ' + FDesc + ' Package for Borland Developer Studio'')]');
Code('[assembly: AssemblyDescription(''Internet Direct (Indy) ' + IndyVersion_ProductVersion_Str + ' ' + FDesc + ' Package for Borland Developer Studio'')]');
Code('[assembly: AssemblyConfiguration('''')]');
Code('[assembly: AssemblyCompany(''Chad Z. Hower a.k.a Kudzu and the Indy Pit Crew'')]');
Code('[assembly: AssemblyProduct(''Indy for Microsoft .NET Framework'')]');
Code('[assembly: AssemblyCopyright(''Copyright © 1993 - ' + IntToStr(YearOf(Date)) + ' Chad Z. Hower a.k.a Kudzu and the Indy Pit Crew'')]');
Code('[assembly: AssemblyTrademark('''')]');
Code('[assembly: AssemblyCulture('''')]');
Code('[assembly: AssemblyTitle(''Indy .NET ' + FDesc + ' Package'')]');
Code('[assembly: AssemblyVersion(''' + FProductVersion + '.*'')]');
Code('[assembly: AssemblyVersion(''' + IndyVersion_ProductVersion_Str + '.*'')]');
Code('[assembly: AssemblyDelaySign(false)]');
Code('[assembly: AssemblyKeyFile('''')]');
Code('[assembly: AssemblyKeyName('''')]');
Expand Down Expand Up @@ -236,7 +230,7 @@ procedure TVersInc.GenAsmInfo;
Code('// associated with an assembly.');
Code('//');
Code('[assembly: AssemblyTitle(''Indy'')]');
Code('[assembly: AssemblyDescription(''Internet Direct (Indy) ' + FProductVersion +' for Visual Studio .NET'')]');
Code('[assembly: AssemblyDescription(''Internet Direct (Indy) ' + IndyVersion_ProductVersion_Str +' for Visual Studio .NET'')]');
Code('[assembly: AssemblyConfiguration('''')]');
Code('[assembly: AssemblyCompany(''Chad Z. Hower a.k.a Kudzu and the Indy Pit Crew'')]');
Code('[assembly: AssemblyProduct(''Indy for Microsoft .NET Framework'')]');
Expand All @@ -255,7 +249,7 @@ procedure TVersInc.GenAsmInfo;
Code('// You can specify all the values or you can default the Revision and Build Numbers');
Code('// by using the ''*'' as shown below:');
Code('');
Code('[assembly: AssemblyVersion(''' + FProductVersion + '.*'')]');
Code('[assembly: AssemblyVersion(''' + IndyVersion_ProductVersion_Str + '.*'')]');
Code('');
Code('//');
Code('// In order to sign your assembly you must specify a key to use. Refer to the');
Expand Down
Loading

0 comments on commit 9dbc947

Please sign in to comment.