Has anyone ever managed to compile their Delphi 6 & 7 (NOT any Delphi > 7 ) projects using the command line?
All the instructions I see are not very clear on what exactly needs to go where!
Am looking for step-by-step kind of instructions.
Answers should be limited to Delphi 6 & 7: I understand Delphi 2006 and > uses MSBuild which is far much easier.
Links are also high appreciated.
Gath
There are several ways to compile a project. If you run it (by pressing F9 or clicking on the toolbar icon), Delphi will compile it first. When Delphi compiles a project, it compiles only the files that have changed. If you select Compile | Build All, instead, every file is compiled, even if it has not changed.
A command-line compiler is one that you run from the command line. You type in "gcc filename" to compile a file (or something like that). Almost all compilers have a command-line version, and many have GUIs where you never see the command line, but the command line is still there.
To display the current compiler options in the Messages window each time you compile your project, choose Tools > Options > Environment Options and select Show command line. The next time you compile a project, the Messages window displays the command used to compile the project and the response file.
For build automation, I use Apache Ant, which is a software tool for automating software build processes. I use it for all my projects, from Delphi 6 to Delphi 2009, and Free Pascal.
Things it can do "out of the box" include MD5 checksum generation, ZIP file creation, text search/replace (useful for copyright header generation), execution of SQL statements, XSLT processing.
For example, to compile all projects with Delphi 6, this is (a part of) the script:
<target name="compile_d6">
<!-- Compile with Delphi 6 -->
<apply executable="${d6}\Bin\dcc32" failonerror="true" output="build-d6.log" >
<!-- rebuild quiet -->
<arg value="-B"/>
<arg value="-Q"/>
<!-- file paths -->
<arg value="-I${source};${indy10}/Lib/System"/>
<arg value="-O${source};${indy10}/D6;${jcl}/d6"/>
<arg value="-U${source};${indy10}/D6;${jcl}/d6"/>
<!-- all *.dpr files in current directory -->
<fileset dir=".">
<patternset><include name="*.dpr"/></patternset>
</fileset>
</apply>
</target>
Free open source CI (Continous Integration) servers like Hudson/Jenkins support Apache Ant build scripts out of the box, which means that you can have them build the project automatically whenever you checked in a change in the source repository.
This is not difficult to do. I have a standard Delphi 5 install on my machine here, and when I open a command prompt, navigate to the $(DELPHI)\Demos\Threads
directory and enter dcc32.exe thrddemo.dpr
the application is built on the command line.
For your own project you may need to add some switches to include file directories, output directories, defines or similar things. Running dcc32.exe
without parameters gives a list of switches and parameters. It is all described in the documentation, as well.
For repeatability you should create a batch file or a regular Makefile.
Note that both the project cfg
file and the common dcc32.cfg
in the Delphi directory contain important settings. For some information about how they affect the build see for example this link on Delphi Wikia.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With