怎么样才能不用打开Dephi,在外面编译和Link程序啊?(200分)

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

tanshudan

Unregistered / Unconfirmed
GUEST, unregistred user!
好像dcc32可以吧?但是俺不会用,能不能给个例子
包括相当于包括IDE中Project Options里Search Path、Output directory、Unit Output directory选项的语句
Tools Option里的参数要不要设啊?

还有,能不能介绍一下其相应的批处理的语句啊?最好给一个实际例子
听说JEDI封装了好多编译指令,而且速度比DCC要快,能不能说说啊?

自由言论
感激不尽
tanshudan@163.com
 
命令行编译
 
能不能具体点?命令该怎么写?
 
dcc32 -b xxx.dpr //编译所有单元

以下为本人一个工程的编译BAT
@ECHO OFF
rem 设置单元目录的路径
Set UnitPath=../Unit
rem 设置工程文件
Set BuildFile=SgEditor.Dpr
rem 设置输出文件路径或文件
Set OutputFile=SgEditor.Exe
rem 设置DELPHI7的主目录
Set DelphiPath=D:/Program Files/Borland/Delphi7
rem 设置命令行编译器的路径
Set DCC32EXE="%DelphiPath%/Bin/DCC32.exe"
rem 设置系统库的路径
Set LibPath=%DelphiPath%/Lib
rem 以下设置所用到的第三方控件的路径
Set OtherPath=D:/开发/DELPHI/控件/Other
Set Rc4Path=D:/开发/DELPHI/控件/RC4/Source
Set SynEditPath=D:/开发/DELPHI/控件/SynEdit
Set VclPath=%Rc4Path%;%SynEditPath%;%OtherPath%

rem EXE压缩的UPX的路径
Set UPXEXE="D:/Program Files/程序压缩器/UPX/UPX.EXE"

Echo.
Echo Compiling %BuildFile% File...
Echo.
rem 开始编译,-B编译所有单元 -R 资源文件的路径 -U 工程单元的路径 -I 包含的目录
%DCC32EXE% -Q -B -H -W %1 -R"%LibPath%" -U"%LibPath%;%UnitPath%;%VclPath%" -I"%VclPath%" %BuildFile%
rem 执行压缩
%UPXEXE% -9 --compress-icons=0 %OutputFile%
rem CRC32校验保护
"./../Crc32Chk/CRCTool.Exe" %OutputFile% /dos /nobak
rem 错误时跳转到错误信息并结束
if errorlevel 1 goto error
rem 删除临时文件
del Unit/*.dcu > nul
del Unit/*.~* > nul
rem 所有操作完成
goto Success

:Success
Echo.
Echo Build Was Successful.
goto end

:error
Echo.
Echo **ERROR**
goto end

:end
pause
 
话题1520141的标题是: delphi可以支持批处理编译吗 (100分)
分类:包装发布 tangfengyang (2002-12-18 13:43:00)
兄弟目前在作一个东西,
好多小模块放在不同的子目录下单独生成exe
其中共享了一个公共Pas。
有没有办法将指定文件夹下所有子目录中的Project批处理编译。
这样兄弟就不用打开一个编译一个了

jsxjd (2002-12-18 13:53:00)
Delphi's command-line compiler (DCC32.EXE) lets you invoke all the functions of the IDE compiler (DELPHI.EXE) from the DOS command line. Run the command-line compiler from the DOS 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 filename does not have an extension, the command-line compiler assumes .DPR, then .PAS if no .DPR is found. If the file you're compiling to doesn'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 beginning 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 one dollar 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 beginning 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

tseug (2002-12-18 13:53:00)
用DCC32.Exe 写成BAT, 批处理,

tangfengyang (2002-12-23 12:49:00)
谢谢两位仁兄指教.
我try try.

yzhshi (2002-12-23 12:54:00)
不用那样麻烦,在Delphi的IDE编辑器内部使用bpg包,可以将多个dpr集合在一起,然后选择Project=->Build All Projects就可以了。
bpg包的产生方法,可以打开任何一个dpr然后关闭Delphi的编写界面(就是显示pas的那个),点击界面上的保存图标,出现保存bpg提示,就可以了。
Ctrl_+Alt+F11打开当前bpg包的文件列表,右键可以添加,都添加进来就好办了。

tangfengyang (2002-12-23 12:59:00)
好啊 我再try

tangfengyang (2004-02-05 14:28:00)
多人接受答案了。


jsxjd-80,tseug-15,yzhshi-5,的回答最终被接受。
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
833
import
I
后退
顶部