DpkGen is a small command line utility which allows you to generate Delphi package files (DPK) based on the given template file.
[jp-insert-adsense-main]
[jp-insert-prog-spec-table]
[jp-insert-download-block]
DpkGen is a very small command line utility which allows you to generate Delphi package files (DPK) based on the given template file.
[jp-insert-donation-button]
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
This program was made for my private use, but it may also be useful to someone.
When once again I had to copy a dozen DPK files and manually correct the descriptions and lib suffixes in them, I said: “enough!” and I wrote this program.
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.
-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.
-h
, --help
Show help.
-V
, --version
Show application version.
--home
Opens program homepage in the default browser.
Value | Description |
---|---|
0 | OK – no errors |
2 | Syntax error |
1 | Other error |
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.
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.
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
[jp-insert-uninstall-info-zip]
[jp-insert-license-info-total-free]
Pazera Free MP4 Video Converter is a free program that allows you to convert almost…
Small utility that allows you to quickly change the display resolution
A simple text files analyzer. The program counts the lines of text in the given…
Free WebM to MP3 Converter is an absolutely free program that converts videos downloaded from…