DPT 0.2: Integrated Code Generation and Preprocessing #7
WladiD
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
I'm excited to announce the release of DPT (Delphi Processing Tools) Version 0.2! This release brings significant improvements to how we handle project builds, specifically by integrating the TmplCodeGen functionality directly into the DPT workflow.
The Vision: Delphi as a Scripting Alternative
My vision for this feature is to enable the use of Delphi almost like a scripting language, combining the performance and robustness of compiled executables with the flexibility of scripts. By reducing the overhead of compilation -rebuilding executables only when source files or configurations actually change- we get the best of both worlds.
I personally plan to use this extensively in CI/CD workflows. This allows me to leverage my existing Delphi skills for all kinds of automation tasks, rather than switching to Bash, PowerShell, or Python. The only requirement is having a Delphi installation available (e.g., in a VM or build agent).
Key Features
1. Integrated Preprocessing
DPT now acts as a smart wrapper for your build process. When you run a Build or BuildAndRun command on a file that is not a standard .dproj (e.g., a .dpr file), DPT automatically triggers its new internal preprocessor. This allows you to generate or modify your project files on-the-fly before compilation.
2. Embedded Configuration
You can now embed your TmplCodeGen configuration directly within your source code comments. This eliminates the need for separate JSON files for simple setups and keeps your configuration close to the code.
Example
HelloWorld.dpr:Call DPT on it:
DPT.exe D12 BuildAndRun HelloWorld.dpr --OnlyIfChangedor_DPT.BuildAndRun.bat D12 BuildAndRun HelloWorld.dpr --OnlyIfChangedDPT scans for the
(* ...-conf.json *)block and the// TmplCodeGeninstruction, generates theHelloWorld.dprojfrom the template, and then seamlessly proceeds to build it.3. Parameter Transition
The build process has become smarter. If the preprocessor generates a new project file (e.g., converts a template to a .dproj), DPT automatically uses this generated file as the target for the subsequent MSBuild execution.
4. Incremental Build Optimization (
--OnlyIfChanged)We've optimized the code generator to respect file timestamps. When using the
--OnlyIfChangedflag, DPT will now:5. Include Partials Support
You can also use the preprocessor to inject code blocks into files using the
include_partialscommand, which is now fully supported within the DPT comment syntax:// TmplCodeGen include_partials MyUnit.pasGetting Started
Simply clone this repo.
Check out the updated Projects/DPT/Readme.md for more details on usage and syntax.
Happy coding!
All reactions