17

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

R.J. Dunnill
  • 2,049
  • 3
  • 10
  • 21
gath
  • 24,504
  • 36
  • 94
  • 124

6 Answers6

15

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.

mghie
  • 32,028
  • 6
  • 87
  • 129
  • 3
    Talking about the Delphi wiki: There is also a page about exactly this topic: http://delphi.wikia.com/wiki/Compile_from_Commandline which I just extended. – dummzeuch Sep 13 '11 at 19:11
9

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.

mjn
  • 36,362
  • 28
  • 176
  • 378
5

You can build everything using this command line:

"C:\Program Files\Borland\Delphi7\Bin\DCC32.exe" -Q -B your-project.dpr

Put this line in a .bat file so you don't need to type it always. Take a look at the command line options running this:

"C:\Program Files\Borland\Delphi7\Bin\DCC32.exe" -h

BTW: -Q is quiet compile and -B will rebuild everything. If you want a quickier compilation don't use -B.

It will use all the options in your-project.cfg file. I've found this dof2cfg executable very useful. With it I can edit the .dof text file and propagate the change to the command line and IDE. No need to edit it for each project.

Important warning for long paths: Delphi 7 command line compiler has a very weird bug. If your path is very long, it will fail with an inscrutable error: a access violation without any meaningful information. If it fails without any reasonable motive, try to reduce the maximum path size and the filename size. Put the project in the root folder usually solve it.

neves
  • 33,186
  • 27
  • 159
  • 192
  • 2
    I have just written and uploaded bdsproj2cfg to CodeCentral which does the same for the .bdsproj files used by Delphi 2005 and 2006. Just in case somebody needs it... – dummzeuch Sep 26 '11 at 16:17
3

FinalBuilder makes it very easy. Give it a try.

mj2008
  • 6,647
  • 2
  • 38
  • 56
Francesca
  • 21,452
  • 4
  • 49
  • 90
  • 2
    Without adding the actual instructions on how solve the issue (or even linking to the instructions) this answer just sounds like product placement. – blerontin May 12 '20 at 13:14
1

I would suggest combination of NAnt and dcc32, but there's also Juancarlo Añez's "WAnt - A Pascal-Friendly Build Tool". I've been using modified version of the 1.x instead of the 2.x alpha. Since it's open source, I could extend the code to output log in XML with the same format as NAnt, so I can integrate it with CruiseControl.NET.

Eugene Yokota
  • 94,654
  • 45
  • 215
  • 319
  • I'm using CruiseControl.NET with NAnt. What's the problem with NAnt so you would use WAnt instead? – mghie Dec 03 '09 at 08:34
  • When I first started using WAnt, the out of the box support for building Delphi project and running DUnit test seemed more attractive to me. Like I said, I'd try NAnt if I were to start from scratch. – Eugene Yokota Dec 03 '09 at 08:41
  • @gath: There would not be any problem to use this environment for Delphi 2, even. – mghie Dec 03 '09 at 09:08
  • Yup, I've got multiple build machines running CruiseControl.NET, NAnt & Delphi. Works nicely. @Gath: if you actually try some of the suggestions here, and read the doco and the links posted, you would quickly realise, as mghie reiterates, that all these suggestions will work with any Delphi version. – Conor Boyd Dec 03 '09 at 21:58
0

For later versions of Delphi, this should be changed to:

"C:\Program Files (x86)\Embarcadero\RAD Studio\8.0\bin\DCC32.exe" -h

PCPGMR
  • 340
  • 2
  • 7