menu
  Home  ==>  papers  ==>  colibri_utilities  ==>  dccil_bat_generator   

DCCIL .BAT generator - Felix John COLIBRI.

  • abstract : automatic creation of the batch file for Delphi command line compilation
  • key words : Delphi, command line compiler, DCCIL, .BAT, .Net, Delphi 7, Delphi 8, Delphi 2005, configuration file, .DOF, .BDSPROJ, .XML, scanner, parser
  • software used : Windows XP, Delphi 6
  • hardware used : Pentium 1.400Mhz, 256 M memory, 140 G hard disc
  • scope : Delphi 7, Delphi 8, Delphi 2005
  • level : Delphi developer
  • plan :


1 - Introduction

All our papers published on this site include the full source code .ZIP files. To automate the building of those .ZIP we use a bunch of utilities in order to:
  • group all the units directly or indirectly used by the project
  • check the correctness of the files by launching a command line compilation
  • create the .ZIP file
For the .NET versions of Delphi, the information of the pathes used by a project are nested inside of the .BDSPROJ configuration file. This file is in .XML format, and the companion paper delphi_net_bdsproj presented a Delphi unit which analyzes the .XML file.

We are going to use this .XML analyzer to generate the .BAT compilation file.




2 - The .BAT generator

2.1 - DCCIL quick tutorial

DCCIL is the Delphi for .Net command line compiler.

If you type DCCIL from a DOS window, the following help will be displayed:

 
Borland Delphi for .NET compiler version 17.0
Copyright (c) 1983,2004 Borland Software Corporation
.NET Framework v1.1.4322 loaded

Syntax: dccil [options] filename [options]

-A<unit>=<alias> = Set unit alias
-B = Build all units
-CC = Console target
-CG = GUI target
-D<syms> = Define conditionals
-E<path> = EXE output directory
-H = Output hint messages
-I<paths> = Include directories
-K<addr> = Set image base addr
-LU<packages> = Link to packages/assemblies
-M = Make modified units
-N<path> = unit output directory
-NS<namespaces> = Namespace search path
-Q = Quiet compile
-R<paths> = Resource directories
-U<paths> = Unit directories
-V = Debug information in EXE
-VR = Generate remote debug (RSM)
-W = Output warning messages
-X = set output filename
-Z = Output 'never build' DCPs
-$<dir> = Compiler directive
--help = Show this help screen
--version = Show name and version
--doc = output XML documentation
--clrversion=v1.1.4322 = compile to this .NET CLR version
--drc = output .drcil file
--unsafe[+|-] = allow / disallow use of unsafe code at link time
--default-namespace = set namespace
--depends = output unit dependency information
--platform:[x86|x64] = PE executable format (default x86)
Compiler switches: -$<letter><state> (defaults are shown below)
A- Aligned record fields
B- Full boolean Evaluation
C+ Evaluate assertions at runtime
D+ Debug information
I+ I/O checking
J- Writeable structured consts
L+ Local debug symbols
O+ Optimization
P+ Open string params
Q- Integer overflow checking
R- Range checking
T- Typed @ operator
V+ Strict var-strings
X+ Extended syntax
Y+ Symbol reference info



2.2 - An example of .BAT

Let's take the following project using Windows Forms as an example. This project simply displays some text in a TextEdit, using a tStrings display library u_c_display.

Our path organization is the following:

 
...
colibri_win_helpers\  
    win_classes\  
        u_c_win_basic_object.pas
        u_c_win_display.pas
        u_c_win_log.pas
    win_units\  
        u_win_exe.pas
        u_win_strings.pas
primer\  
    delphi_2005_windows_forms\  
        my_compilation.bat
        p_delphi_2005_windows_forms.bdsproj
        p_delphi_2005_windows_forms.dpr
        p_delphi_2005_windows_forms.res
        u_delphi_2005_windows_forms.pas
        u_delphi_2005_windows_forms.resx
    exe\  
        dcu\  
                log\  

The pathes which are required by DCCIL are the following:

  • the .EXE path
  • the .DCUIL path
  • the search pathes
  • the packages
Therefore the DCCIL should look like this (without returns and without blank lines):

 
dccil.exe
-LU"System.XML"
-LU"System.Windows.Forms"
-LU"System.Drawing"
-LU"System.Data"

-E"C:\programs\primer\exe"

-N"C:\programs\primer\exe\dcu"

-U"C:\programs\colibri_win_helpers\win_units" -U"C:\programs\colibri_win_helpers\win_classes"

p_delphi_2005_windows_forms.dpr



2.3 - The Delphi generator

In order to build the .BAT
  • we search the "Directories" tag
  • we extract the strings from the tags with "OutputDir", "UnitOutputDir", "SearchPath" and Packages" attribute values
  • we perform some housecleaning on the path strings (changing the relative into absolute etc)


The search for a tag is performed by an enumerator over the XML tree:

procedure find_directory_tags(p_c_xml_textc_xml_text);
  begin
    with p_c_xml_text do
      enumerate('Directories'_handle_directory_tag_call_back);
  end// find_directory_tags

and the call back checks the attribute value, and then extracts the semi-colon separated strings

procedure c_bds_project_option_analyzer._handle_directory_tag_call_back(p_c_xml_tagc_xml_tag);

  procedure analyze_path_list(p_textStringp_c_dof_stringlisttStringList);
    var l_indexl_lengthInteger;
        l_pathString;
    begin
      l_index:= 1;

      while l_index<= Length(p_textdo
      begin
        l_path:= f_string_extract_until_in(p_text, [';'k_return], l_index);
        p_c_dof_stringlist.Add(f_with_ending_slash(l_path));

        skip_characters_in(p_text, [';'k_returnk_line_feed], l_index);
      end;
    end// analyze_path_list

  procedure add_string_if_key_matches(p_valueStringvar pv_c_dof_stringstStringList);
    var l_c_strings_listtStringList;
    begin
      with p_c_xml_tag do
        if f_key_value('Name')= p_value
          then begin
              l_c_strings_list:= f_c_get_strings_list;

              // -- transfer the strings into the DOF lists
              // -- CAUTION: some string ended by RETURN, other with ";" separators
              analyze_path_list(l_c_strings_list.Textpv_c_dof_strings);

              l_c_strings_list.Free;
            end;
    end// add_string_if_key_matches

  begin // _handle_directory_tag_call_back
    with p_c_xml_tag do
    begin
      // -- there is some text between <xxx> and </xxx>
      if f_contains_string
        then begin
            add_string_if_key_matches('OutputDir'm_c_exe_path_stringlist);
            add_string_if_key_matches('UnitOutputDir'm_c_dcu_path_stringlist);
            add_string_if_key_matches('SearchPath'm_c_pas_path_stringlist);

            add_string_if_key_matches('Packages'm_c_packages_stringlist);
          end;
    end// with p_c_xml_tag
  end// _handle_directory_tag_call_back



The main project extracts the relevant pathes from .BDSPROJ, and then generates the .BAT, adding the directives (-E, -LU etc), the quotes, the DCCIL and the project name.



Here is a snapshot of the generation:



2.4 - Automation of the compilation

The .BAT is only a step in our .ZIP generation chain. We usually do NOT use the .BAT, but directly invoke DCCIL from a Windows Process, which allows automatic compilation of many .DPR in a row buy finding all the .DPR in a path.

We only resort to .BAT compilation for error diagnostic (the WinExec reports the error, but not the messages). This part has not been included in this utility, but is easy enough to implement.




3 - Download the Sources

Here are the source code files: The .ZIP file(s) contain:
  • the main program (.DPR, .DOF, .RES), the main form (.PAS, .DFM), and any other auxiliary form
  • any .TXT for parameters, samples, test data
  • all units (.PAS) for units
Those .ZIP
  • are self-contained: you will not need any other product (unless expressly mentioned).
  • for Delphi 6 projects, can be used from any folder (the pathes are RELATIVE)
  • will not modify your PC in any way beyond the path where you placed the .ZIP (no registry changes, no path creation etc).
To use the .ZIP:
  • create or select any folder of your choice
  • unzip the downloaded file
  • using Delphi, compile and execute
To remove the .ZIP simply delete the folder.

The Pascal code uses the Alsacian notation, which prefixes identifier by program area: K_onstant, T_ype, G_lobal, L_ocal, P_arametre, F_unction, C_lass etc. This notation is presented in the Alsacian Notation paper.



As usual:

  • please tell us at fcolibri@felix-colibri.com if you found some errors, mistakes, bugs, broken links or had some problem downloading the file. Resulting corrections will be helpful for other readers
  • we welcome any comment, criticism, enhancement, other sources or reference suggestion. Just send an e-mail to fcolibri@felix-colibri.com.
  • or more simply, enter your (anonymous or with your e-mail if you want an answer) comments below and clic the "send" button
    Name :
    E-mail :
    Comments * :
     

  • and if you liked this article, talk about this site to your fellow developpers, add a link to your links page ou mention our articles in your blog or newsgroup posts when relevant. That's the way we operate: the more traffic and Google references we get, the more articles we will write.



4 - Conclusion

We presented a tool generating the batch file which can be used to launch a command line compilation of Delphi for .Net projects.




5 - Other Papers with Source and Links

Database
database reverse engineering Extraction of the Database Schema by analyzing the content of the application's .DFMs
sql parser Parsing SQL requests in Delphi, starting from an EBNF grammar for SELECT, INSERT and UPDATE
ado net tutorial a complete Ado Net architectural presentation, and projects for creating the Database, creating Tables, adding, deleting and updating rows, displaying the data in controls and DataGrids, using in memory DataSets, handling Views, updating the Tables with a DataGrid
turbo delphi interbase tutorial develop database applications with Turbo Delphi and Interbase. Complete ADO Net architecture, and full projects to create the database, the Tables, fill the rows, display and update the values with DataGrids. Uses the BDP
bdp ado net blobs BDP and Blobs : reading and writing Blob fields using the BDP with Turbo Delphi
interbase stored procedure grammar Interbase Stored Procedure Grammar : The BNF Grammar of the Interbase Stored Procedure. This grammar can be used to build stored procedure utilities, like pretty printers, renaming tools, Sql Engine conversion or ports
using interbase system tables Using InterBase System Tables : The Interbase / FireBird System Tables: description of the main Tables, with their relationship and presents examples of how to extract information from the schema
eco tutorial Writing a simple ECO application: the UML model, the in memory objects and the GUI presentation. We also will show how to evaluate OCL expressions using the EcoHandles, and persist the data on disc
delphi dbx4 programming the new dbExpress 4 framework for RAD Studio 2007 : the configuration files, how to connect, read and write data, using tracing and pooling delegates and metadata handling
blackfishsql using the new BlackfishSql standalone database engine of RAD Studio 2007 (Win32 and .Net) : create the database, create / fill / read Tables, use Pascal User Defined Functions and Stored Procedures
rave pdf intraweb how to produce PDF reports using Rave, and have an Intraweb site generate and display .PDF pages, with multi-user access
embarcadero er studio Embarcadero ER Studio tutorial: how to use the Entity Relationship tool to create a new model, reverse engineer a database, create sub-models, generate reports, import metadata, switch to Dimensional Model
Web
sql to html converting SQL ascii request to HTML format
simple web server a simple HTTP web Server and the corresponding HTTP web Browser, using our Client Server Socket library
simple cgi web server a simple CGI Web Server which handles HTML <FORM> requests, mainly for debugging CGI Server extension purposes
cgi database browser a CGI extension in order to display and modify a Table using a Web Browser
whois a Whois Client who requests information about owners of IP adresses. Works in batch mode.
web downloader an HTTP tool enabling to save on a local folder an HTML page with its associated images (.GIF, .JPEG, .PNG or other) for archieving or later off-line reading
web spider a Web Spider allowing to download all pages from a site, with custom or GUI filtering and selection.
asp net log file a logging CLASS allowing to monitor the Asp.Net events, mainly used for undesrtanding, debugging and journaling Asp.Net Web applications
asp net viewstate viewer an ASP.NET utility displaying the content of the viewtate field which carries the request state between Internet Explorer and the IIS / CASSINI Servers
rss reader the RSS Reader lets you download and view the content of an .RSS feed (the entry point into somebody's blog) in a tMemo or a tTreeView. Comes complete with an .HTML downloader and an .XML parser
news message tree how to build a tree of the NNTP News Messages. The downloaded messages are displayed in tListBox by message thread (topic), and for each thread the messages are presented in a tTreeVi"ew
threaded indy news reader a NewsReader which presents the articles sorted by thread and in a logical hierarchical way. This is the basic Indy newsreader demo plus the tree organization of messages
delphi asp net portal programming presentation, architecture and programming of the Delphi Asp Net Portal. This is a Delphi version of the Microsoft ASP.NET Starter Kit Web Portal showcase. With detailed schemas and step by step presentation, the Sql scripts and binaries of the Database
delphi web designer a tiny Delphi "RAD Web Designer", which explains how the Delphi IDE can be used to generate .HTML pages using the Palette / Object Inspector / Form metaphor to layout the page content
intraweb architecture the architecture of the Intraweb web site building tool. Explains how Delphi "rad html generator" work, and presents the CLASS organization (UML Class diagrams)
ajax tutorial AJAX Tutorial : writing an AJAX web application. How AJAX works, using a JavaScript DOM parser, the Indy Web Server, requesting .XML data packets - Integrated development project
asp net master pages Asp.Net 2.0 Master Pages : the new Asp.Net 2.0 allow us to define the page structure in a hierarchical way using Master Pages and Content Pages, in a way similar to tForm inheritance
delphi asp net 20 databases Asp.Net 2.0 and Ado.Net 2.0 : displaying and writing InterBase and Blackfish Sql data using Dbx4, Ado.Net Db and AdoDbxClient. Handling of ListBox and GridView with DataSource components
asp net 20 users roles profiles Asp.Net 2.0 Security: Users, Roles and Profiles : Asp.Net 2.0 offers a vaslty improved support for handling security: new Login Controls, and services for managing Users, grouping Users in Roles, and storing User preferences in Profiles
bayesian spam filter Bayesian Spam Filter : presentation and implementation of a spam elimination tool which uses Bayesian Filtering techniques
TCP/IP
tcp ip sniffer project to capture and display the packets travelling on the Ethernet network of your PC.
sniffing interbase traffic capture and analysis of Interbase packets. Creation of a database and test table, and comparison of the BDE vs Interbase Express Delphi components
socket programming the simplest Client Server example of TCP / IP communication using Windows Sockets with Delphi
delphi socket architecture the organization of the ScktComp unit, with UML diagrams and a simple Client Server file transfer example using tClientSocket and tServerSocket
Object Oriented Programming Components
delphi virtual constructor VIRTUAL CONSTRUCTORS together with CLASS references and dynamic Packages allow the separation between a main project and modules compiled and linked in later. The starting point for Application Frameworks and Plugins
delphi generics tutorial Delphi Generics Tutorial : using Generics (parameterized types) in Delphi : the type parameter and the type argument, application of generics, constraints on INTERFACEs or CONSTRUCTORs
UML Patterns
the lexi editor delphi source code of the Gof Editor: Composite, Decorator, Iterator, Strategy, Visitor, Command, with UML diagrams
factory and bridge patterns presentation and Delphi sources for the Abstract Factory and Bridge patterns, used in the Lexi Document Editor case study from the GOF book
gof design patterns delphi source code of the 23 Gof (GAMMA and other) patterns: Composite, Decorator, Iterator, Strategy, Visitor, Command
Debug and Test
Graphic
delphi 3d designer build a 3d volume list, display it in perspective and move the camera, the screen or the volumes with the mouse.
writing a flash player build your own ShockWave Flash movie Player, with pause, custom back and forward steps, snapshots, resizing. Designed for analyzing .SWF demos.
Utilities
the coliget search engine a Full Text Search unit allowing to find the files in a directory satisfying a complex string request (UML AND Delphi OR Patters)
treeview html help viewer Treeview .HTML Help Viewer : the use of a Treeview along with a WebBrowser to display .HTML files alows both structuring and ordering of the help topics. This tool was used to browse the Delphi PRISM Wiki help.
Delphi utilities
delphi net bdsproj structure and analysis of the .BDSPROJ file with the help of a small Delphi .XML parser
dccil bat generator generation of the .BAT for the Delphi DCCIL command line compiler using the .BDSPROJ
dfm parser a Delphi Project analyzing the .DFM file and building a memory representation. This can be used for transformations of the form components
dfm binary to text a Delphi Project converting all .DFM file from a path from binary to ascii format
component to code generate the component creation and initialization code by analyzing the .DFM. Handy to avoid installing components on the Palette when examining new libraries
exe dll pe explorer presents and analyzes the content of .EXE and .DLL files. The starting point for extracting resources, spying .DLL function calls or injecting additional functionalities
dll and process viewer analyze and display the list of running processes, with their associated DLLs and Memory mapped files (Process Walker)
Controls
find memo a tMemo with "find first", "find next", "sort", "save" capabilities
Helper units
windows environment read and write Windows Environment strings
stdin stdout send and receive strings from a GUI application to a CONSOLE application




6 - The author

Felix John COLIBRI works at the Pascal Institute. Starting with Pascal in 1979, he then became involved with Object Oriented Programming, Delphi, Sql, Tcp/Ip, Html, UML. Currently, he is mainly active in the area of custom software development (new projects, maintenance, audits, BDE migration, Delphi Xe_n migrations, refactoring), Delphi Consulting and Delph training. His web site features tutorials, technical papers about programming with full downloadable source code, and the description and calendar of forthcoming Delphi, FireBird, Tcp/IP, Web Services, OOP  /  UML, Design Patterns, Unit Testing training sessions.
Created: nov-04. Last updated: jul-15 - 98 articles, 131 .ZIP sources, 1012 figures
Copyright © Felix J. Colibri   http://www.felix-colibri.com 2004 - 2015. All rigths reserved
Back:    Home  Papers  Training  Delphi developments  Links  Download
the Pascal Institute

Felix J COLIBRI

+ Home
  + articles_with_sources
    + database
    + web_internet_sockets
    + oop_components
    + uml_design_patterns
    + debug_and_test
    + graphic
    + controls
    + colibri_utilities
      – delphi_net_bdsproj
      – dccil_bat_generator
      – coliget_search_engine
      – dfm_parser
      – dfm_binary_to_text
      – component_to_code
      – exe_dll_pe_explorer
      – dll_process_viewer
      – the_alsacian_notation
      – html_help_viewer
      – cooking_the_code
      – events_record_playback
    + colibri_helpers
    + delphi
    + firemonkey
    + compilers
  + delphi_training
  + delphi_developments
  + sweet_home
  – download_zip_sources
  + links
Contacts
Site Map
– search :

RSS feed  
Blog