Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compiling C++Builder project on command line

Is there a way to compile a C++Builder project (a specific build configuration) from the command line?

Something like:

CommandToBuild ProjectNameToBuild BuildConfiguration ...
like image 617
Srki Avatar asked Nov 26 '10 17:11

Srki


1 Answers

There are different ways for automating your builds in C++Builder (as of my experience, I'm speaking about old C++Builder versions like 5 and 6).

You can manually call compilers - bcc32.exe (also dcc32.exe, brcc32.exe and tasm32.exe if you have to compile Delphi units, resource files or assembly language lines of code in your sources) and linker - ilink32.exe.

In this case, you will need to manually provide the necessary input files, paths, and keys as arguments for each stage of compilation and linking.

All data necessary for compilation and linking is stored in project files and, hopefully there are special utilities, included in the C++Builder installation, which can automate this dirty work, provide necessary parameters to compilers and linker and run them. Their names are bpr2mak.exe and make.exe.

First you have to run bpr2mak.exe, passing your project *.bpr or *.bpk file as a parameter and then you will get a special *.mak file as output, which you can use to feed on make.exe, which finally will build your project.

Look at this simple cmd script:

@bpr2mak.exe YourProject.bpr
@ren YourProject.mak makefile
@make.exe

You can provide the real name of "YourProject.mak" as a parameter to make.exe, but the most straightforward way is to rename the *.mak file to "makefile", and then make.exe will find it.

To have different build options, you can do the following:

The first way: you can open your project in the IDE, edit options and save it with a different project name in the same folder (usually there are two project files for debug and release compile options). Then you can provide your building script with different *.bpr files. This way, it looks simple, because it doesn't involves scripting, but the user will have to manually maintain coherency of all project files if something changes (forms or units added and so on).

The second way is to make a script which edits the project file or make file. You will have to parse files, find compiler and linker related lines and put in the necessary keys. You can do it even in a cmd script, but surely a specialised scripting language like Python is preferable.

like image 123
Sergey Karpukhin Avatar answered Oct 16 '22 08:10

Sergey Karpukhin