delphi可以支持批处理编译吗(100分)

  • 主题发起人 tangfengyang
  • 开始时间
T

tangfengyang

Unregistered / Unconfirmed
GUEST, unregistred user!
兄弟目前在作一个东西,
好多小模块放在不同的子目录下单独生成exe
其中共享了一个公共Pas。
有没有办法将指定文件夹下所有子目录中的Project批处理编译。
这样兄弟就不用打开一个编译一个了
 
Delphi's command-line compiler (DCC32.EXE) lets you invoke all the functions of the IDE compiler (DELPHI.EXE) from thedo
S command line. Run the command-line compiler from thedo
S prompt using the syntax:
DCC32 [options] filename [options]
where options are zero or more parameters that provide information to the compiler and filename is the name of the source file to compile. If you type DCC32 alone, it displays a help screen of command-line options and syntax.
If filenamedo
es not have an extension, the command-line compiler assumes .DPR, then
.PAS if no .DPR is found. If the file you're compiling todo
esn't have an extension, you must append a period (.) to the end of the filename.
If the source text contained in filename is a program, the compiler creates an executable file named filename.EXE. If filename contains a library, the compiler creates a file named filename.DLL. If filename contains a package, the compiler creates a file named filename.BPL. If filename contains a unit, the compiler creates a unit file named filename.DCU.
You can specify a number of options for the command-line compiler. An option consists of a slash (/) immediately followed by an option letter. In some cases, the option letter is followed by additional information, such as a number, a symbol, or a directory name. Options can be given in any order and can come before or after the file name.

Delphi supports several compiler directives, all described in "Compiler directives." The /$ and /D command-line options allow you to change the default states of most compiler directives. Using /$ and /D on the command line is equivalent to inserting the corresponding compiler directive at the begin
ning of each source file compiled.
The switch directive option
The /$ option lets you change the default state of all of the switch directives. The syntax of a switch directive option is /$ followed by the directive letter, followed by a plus (+) or a minus (-). For example,
DCC32 MYSTUFF /$R-
compiles MYSTUFF.PAS with range-checking turned off, while
DCC32 MYSTUFF /$R+
compiles it with range checking turned on. Note that if a {$R+} or {$R-} compiler directive appears in the source text, it overrides the /$R command-line option.
You can repeat the /$ option in order to specify multiple compiler directives:
DCC32 MYSTUFF /$R-/$I-/$V-/$U+
Alternately, the command-line compiler lets you write a list of directives (except for $M), separated by commas:
DCC32 MYSTUFF /$R-,I-,V-,U+
Only onedo
llar sign ($) is needed.
Note that, because of its format, you cannot use the $M directive in a list of directives separated by commas.
The conditional defines option
The /D option lets you define conditional symbols, corresponding to the {$DEFINE symbol} compiler directive. The /D option must be followed by one or more conditional symbols separated by semicolons (;). For example, the following command line
DCC32 MYSTUFF /DIOCHECK;DEBUG;LIST
defines three conditional symbols, iocheck, debug, and list, for the compilation of MYSTUFF.PAS. This is equivalent to inserting
{$DEFINE IOCHECK}
{$DEFINE DEBUG}
{$DEFINE LIST}
at the begin
ning of MYSTUFF.PAS. If you specify multiple /D directives, you can concatenate the symbol lists. Therefore,
DCC32 MYSTUFF /DIOCHECK/DDEBUG/DLIST
is equivalent to the first example.

You can set up a list of options in a configuration file called DCC32.CFG, which will then
be used in addition to the options entered on the command line. Each line in configuration file corresponds to an extra command-line argument inserted before the actual command-line arguments. Thus, by creating a configuration file, you can change the default setting of any command-line option.
The command-line compiler lets you enter the same command-line option several times, ignoring all but the last occurrence. This way, even though you've changed some settings with a configuration file, you can still override them on the command line.
When DCC32 starts, it looks for DCC32.CFG in the current directory. If the file isn't found there, DCC32 looks in the directory where DCC32.EXE resides.
Here's an example DCC32.CFG file, defining some default directories for include, object, and unit files, and changing the default states of the $O and $R compiler directives:
/IC:/DELPHI/INC;C:/DELPHI/SRC
/OC:/DELPHI/ASM
/UC:/DELPHI/UNITS
/$R+
/$O-
Now, if you type
DCC32 MYSTUFF
at the system prompt, DCC32 acts as if you had typed in the following:
DCC32 /IC:/DELPHI/INC;C:/DELPHI/SRC /OC:/DELPHI/ASM /UC:/DELPHI/UNITS /$R+ /$O- MYSTUFF
 
用DCC32.Exe 写成BAT, 批处理,
 
谢谢两位仁兄指教.
我try try.
 
不用那样麻烦,在Delphi的IDE编辑器内部使用bpg包,可以将多个dpr集合在一起,然后选择Project=->Build All Projects就可以了。
bpg包的产生方法,可以打开任何一个dpr然后关闭Delphi的编写界面(就是显示pas的那个),点击界面上的保存图标,出现保存bpg提示,就可以了。
Ctrl_+Alt+F11打开当前bpg包的文件列表,右键可以添加,都添加进来就好办了。
 
好啊 我再try
 
多人接受答案了。
 
顶部