Menu Close

DpkGen

Version:
1.0
Release date:
2019.05.31
Language:
English
License:
Freeware, Open Source
System:
Windows XP, Vista, 7, 8, 10
Downloads:
8,173

Download

Description

DpkGen is a very small command line utility which allows you to generate Delphi package files (DPK) based on the given template file.

The program is intended mainly for Delphi programmers managing package/component collections.

If you want to compile the program yourself, here you will find source files and compilation instructions: https://github.com/jackdp/DpkGen

Usage

Usage: DpkGen.exe -t=FILE -o=FILE [-d=STR] [-p=STR] [-s=STR] [-v=STR] [-h] [-V] [--home]

Mandatory arguments to long options are mandatory for short options too.
Options are case-sensitive. Options in square brackets are optional. Equality characters (=) are also optional.

Input / Output options

-t--template-file=FILE
Template DPK file.

-o--output-file=FILE
The output DPK file.

-d--description=STR
Package description. All instances of the text <DESCRIPTION> in the template file will be replaced by the string specified in this option.

-p--lib-prefix=STR
Library prefix. All instances of the text <LIBPREFIX> in the template file will be replaced by the string specified in this option.

-s--lib-suffix=STR
Library suffix. All instances of the text <LIBSUFFIX> in the template file will be replaced by the string specified in this option.

-v--lib-version=STR
Library version. All instances of the text <LIBVERSION> in the template file will be replaced by the string specified in this option.

Information

-h--help
Show help.

-V--version
Show application version.

--home
Opens program homepage in the default browser.

Exit codes

ValueDescription
0OK – no errors
2Syntax error
1Other error

Hint

You can use relative paths when specifying an input template file and an output DPK file. If the output directory does not exist, it will be created automatically.

Template files

The template file should be a regular DPK package, with one exception – the following strings (placeholders) in the DPK file will be replaced by values passed from the command line to the DpkGen program:

DPK string (placeholder)cmd-line option with sample value
<description>-d "SomeLib - Runtime package"
<libprefix>-p dcl
<libsuffix>-s XE4
<libversion>-v 1.1.0
package SomeLib;
{$R *.res}
{$IFDEF IMPLICITBUILDING This IFDEF should not be used by users}
{$ALIGN 8}
{.....}
{$ENDIF IMPLICITBUILDING}
{$DESCRIPTION '<description>'}
{$LIBPREFIX '<libprefix>'}
{$LIBSUFFIX '<libsuffix>'}
{$LIBVERSION '<libversion>'}
{$RUNONLY}
requires
  rtl;
contains
  Unit1 in '..\..\Source\Unit1.pas';
end.

After launching the DpkGen with the parameters as in the above table, we will get:

package SomeLib;
{$R *.res}
{$IFDEF IMPLICITBUILDING This IFDEF should not be used by users}
{$ALIGN 8}
{.....}
{$ENDIF IMPLICITBUILDING}
{$DESCRIPTION 'SomeLib - Runtime package'}
{$LIBPREFIX 'dcl'}
{$LIBSUFFIX 'XE4'}
{$LIBVERSION '1.1.0'}
{$RUNONLY}
requires
  rtl;
contains
  Unit1 in '..\..\Source\Unit1.pas';
end.

When you manage a collection of packages for many versions of Delphi, thanks to DpkGen, you can create one general template and quickly generate all necessary packages. You can use, for example, a batch file from the example below.

As you can see, the program is very simple (just ordinary StringReplace), but if you manage multiple packages from many libraries, DpkGen can save you a lot of time.

The program has a built-in advanced command line option parser, has a flexible structure and can be easily expanded with additional functions: simply register the command line option in the RegisterOptions procedure, read / check the option value in the ProcessOptions and perform the appropriate actions in the CreateDpkFile.

Of course, similar functionality can be achieved using more complex scripts or grep-like applications. Just choose the solution that you prefer.

Example

This example shows how to generate DPK files for the Delphi version from XE2 to 10.3 Rio using the DpkGen program launched from a batch file:

@echo off

set Template=JPLib_TEMPLATE.dpk
set Desc="JPLib Runtime Package"
set BaseOutDir=..\Delphi
set ShortDpkName=JPLib.dpk

for %%x in (XE2,XE3,XE4,XE5,XE6,XE7,XE8) do (
  DpkGen -t %Template% -d %Desc% -o %BaseOutDir%_%%x\%ShortDpkName% -s %%x
)

DpkGen -t %Template% -d %Desc% -o %BaseOutDir%_10.0_Seattle\%ShortDpkName% -s Seattle
DpkGen -t %Template% -d %Desc% -o %BaseOutDir%_10.1_Berlin\%ShortDpkName% -s Berlin
DpkGen -t %Template% -d %Desc% -o %BaseOutDir%_10.2_Tokyo\%ShortDpkName% -s Tokyo
DpkGen -t %Template% -d %Desc% -o %BaseOutDir%_10.3_Rio\%ShortDpkName% -s Rio

How to uninstall?

DpkGen application is distributed in the form of archive and does not require any special uninstall process. To uninstall it, just delete files previously extracted from the archive.

End User License Agreement

This program is completely free. You can use it without any restrictions, also for commercial purposes.