Skip to content

Commit

Permalink
Updating Package Generator to prompt user for version number if one i…
Browse files Browse the repository at this point in the history
…s not provided on the command line.
  • Loading branch information
rlebeau committed Jul 11, 2024
1 parent e34573d commit 498cfcd
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 23 deletions.
69 changes: 52 additions & 17 deletions Builder/Package Generator/Package.pas
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ function iif(ATest: Boolean; const ATrue: Boolean; const AFalse: Boolean): Boole
IndyVersion_VersionInfo_FileVersion_Str: string = '';
IndyVersion_VersionInfo_FileVersion_Template: string = '';

procedure InitVersionNumbers;

implementation

uses
Expand Down Expand Up @@ -611,27 +613,52 @@ procedure TPackage.GenResourceScript;
procedure InitVersionNumbers;
var
LMajor, LMinor, LRelease, LBuild, LPos: Integer;
LParam: string;
LVerNum, LTemp: string;
begin
if not FindCmdLineSwitch('version', LParam) then
raise Exception.Create('Version parameter is missing');
if FindCmdLineSwitch('version', LVerNum) then
LVerNum := Trim(LVerNum);

if LVerNum = '' then begin
with TMemIniFile.Create(DM.DataPath + 'PkgGen.ini') do try
LVerNum := Trim(ReadString('Settings', 'LastVersion', ''));
finally
Free;
end;
WriteLn;
if LVerNum <> '' then begin
WriteLn('Please enter a version number in #.#.#.# format');
Write ('or leave blank to reuse last version (',LVerNum,'): ');
end else
begin
Write('Please enter a version number in #.#.#.# format: ');
end;
ReadLn(LTemp);
LTemp := Trim(LTemp);
if LTemp <> '' then begin
LVerNum := LTemp;
end
else if LVerNum = '' then begin
raise Exception.Create('Version number is missing');
end;
end;

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

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

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

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

Expand All @@ -648,9 +675,17 @@ procedure InitVersionNumbers;
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;
with TMemIniFile.Create(DM.DataPath + 'PkgGen.ini') do
try
WriteString('Settings', 'LastVersion', LVerNum);
UpdateFile;
finally
Free;
end;

WriteLn;
WriteLn('Version Number set to ',LMajor,'.',LMinor,'.',LRelease,'.',LBuild);
end;

end.
8 changes: 6 additions & 2 deletions Builder/Package Generator/PackageBuildRes.pas
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ interface

type
TBuildRes = class(TPackage)
private
procedure RunBuildRes;
public
constructor Create; override;
procedure Generate(ACompilers: TCompilers; const AFlags: TGenerateFlags); override;
procedure Run;
end;

implementation
Expand Down Expand Up @@ -95,9 +96,12 @@ procedure TBuildRes.Generate(ACompilers: TCompilers; const AFlags: TGenerateFlag
end;

WriteFile;

// TODO: run buildres.bat only if any .rc files were actually (re-)generated...
RunBuildRes;
end;

procedure TBuildRes.Run;
procedure TBuildRes.RunBuildRes;
var
LPathname: string;
LSubDir: string;
Expand Down
11 changes: 8 additions & 3 deletions Builder/Package Generator/PkgGen.dpr
Original file line number Diff line number Diff line change
Expand Up @@ -107,19 +107,25 @@ var
begin
DM := TDM.Create(nil); try
with DM do begin
WriteLn('INI Path: '+ Ini.FileName );
WriteLn('INI Path: ' + Ini.FileName );

if FindCmdLineSwitch('checkini') then begin
WriteLn('Checking for missing files to add to INI...');
CheckForMissingFiles;
Exit;
end;

InitVersionNumbers;

LDebugFlag := [];
if FindCmdLineSwitch('debugPkgs') then begin
Include(LDebugFlag, gfDebug);
WriteLn('Will Generate Debug Packages');
end else begin
WriteLn('Will Not Generate Debug Packages');
end;

WriteLn;
WriteLn('Generating Visual Studio Package...');

with TPackageVisualStudio.Create do try
Expand Down Expand Up @@ -258,8 +264,6 @@ begin
with TBuildRes.Create do try
// nothing to load from the database...
Generate(Delphi_Native);
// TODO: run buildres.bat only if any .rc files were actually (re-)generated...
Run;
finally Free; end;

WriteLn('Generating Clean.cmd scripts...');
Expand All @@ -286,6 +290,7 @@ begin
end;
end;

WriteLn;
WriteLn('Done! Press ENTER to exit...');
ReadLn;
end.
2 changes: 1 addition & 1 deletion Builder/Package Generator/PkgGen.dproj
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
<PropertyGroup Condition="'$(Cfg_2_Win32)'!=''">
<VerInfo_Keys>CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName)</VerInfo_Keys>
<DCC_ImportedDataReferences>false</DCC_ImportedDataReferences>
<Debugger_RunParams>-version:10.6.3.3 -debugPkgs</Debugger_RunParams>
<Debugger_RunParams>-debugPkgs</Debugger_RunParams>
<DCC_DebugDCUs>true</DCC_DebugDCUs>
</PropertyGroup>
<ItemGroup>
Expand Down

0 comments on commit 498cfcd

Please sign in to comment.