在命令行上编译 C++Builder 项目 [英] Compiling C++Builder project on command line

查看:21
本文介绍了在命令行上编译 C++Builder 项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法编译 C++Builder 项目(一个特定的构建配置)从命令行?

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

类似于:

CommandToBuild ProjectNameToBuild BuildConfiguration ...

推荐答案

在 C++Builder 中有不同的自动化构建方法(根据我的经验,我说的是旧的 C++Builder 版本,例如 5 和 6).

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).

您可以手动调用编译器 - bcc32.exe(还有 dcc32.exebrcc32.exetasm32.exe 如果您必须编译 Delphi 单元、资源文件或汇编语言代码行源)和链接器 - ilink32.exe.

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.

编译和链接所需的所有数据都存储在项目文件中,并且希望 C++Builder 安装中包含特殊实用程序,它们可以自动执行这项繁琐的工作,为编译器和链接器提供必要的参数并运行它们.它们的名字是 bpr2mak.exemake.exe.

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.

首先你必须运行 bpr2mak.exe,将你的项目 *.bpr 或 *.bpk 文件作为参数传递,然后你会得到一个特殊的 *.mak 文件作为输出,你可以用于提供 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.

看看这个简单的 cmd 脚本:

Look at this simple cmd script:

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

您可以提供YourProject.mak"的真实名称作为make.exe的参数,但最直接的方法是将*.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:

第一种方式:你可以在IDE中打开你的项目,编辑选项并在同一个文件夹中用不同的项目名称保存(通常有两个项目文件用于调试和发布编译选项).然后您可以为您的构建脚本提供不同的 *.bpr 文件.这样,它看起来很简单,因为它不涉及脚本,但是如果发生变化(添加的表单或单元等),用户将不得不手动维护所有项目文件的一致性.

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).

第二种方法是制作一个脚本来编辑项目文件或制作文件.您必须解析文件,找到与编译器和链接器相关的行并输入必要的键.您甚至可以在 cmd 脚本中执行此操作,但肯定是一种专门的脚本语言,例如 Python 更可取.

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.

这篇关于在命令行上编译 C++Builder 项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆