Delphi command-line compiler

类别:Delphi 点击:0 评论:0 推荐:

defproj.cfg__ Default configuration which compiled by all Projects

defproj.dof__Default configuration of all projects.

Delphi command-line compiler

The command-line compiler lets you invoke all the functions of the IDE compiler from the command line. Run the command-line compiler from the command line 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.

To display a help screen of command-line options and syntax:

dcc32

Borland Delphi Version 15.0

Copyright (c) 1983,2002 Borland Software Corporation

?

Syntax: dcc32 [options] filename [options]

?

? -A= = Set unit alias? ?????-LU

= Use package

? -B = Build all units?????????????? ?????????????? ???-M = Make modified units

? -CC = Console target?????????????????????????????-N

= DCU output directory

? -CG = GUI target???????????????????????????? ??? ???-O

= Object directories

? -D = Define conditionals???? ???-P = look for 8.3 file names als

? -E

= EXE output directory?? ????-Q = Quiet compile

? -F = Find error????????????????? ?? ????-R

= Resource directories

? -GD = Detailed map file?????????????????????????-U

= Unit directories

? -GP = Map file with publics??????????????????-V = Debug information in EXE

? -GS = Map file with segments??? ????? ????-VR = Generate remote debug (RSM

? -H = Output hint messages?????? ????????? ?-W = Output warning messages

? -I

= Include directories? ?????? ??-Z = Output 'never build' DCPs

? -J = Generate .obj file????????? ???????????????? ??-$ = Compiler directive

? -JP = Generate C++ .obj file???????????????????--help = Show this help screen

? -K = Set image base addr? ???? ???--version = Show name and versio

?

Compiler switches: -$ (defaults are shown below)

? A8? Aligned record fields?????? ?????????? ??? ??P+? Open string params

? B-? Full boolean Evaluation????? ??????????? ??Q-? Integer overflow checking

? C+? Evaluate assertions at runtime????? ??R-? Range checking

? D+? Debug information????????????????????? ???? T-? Typed @ operator

? G+? Use imported data references?? ??? ??U-? Pentium(tm)-safe divide

? H+? Use long strings by default???? ??? ???V+? Strict var-strings

? I+? I/O checking??????????????????????????????????? ???W-? Generate stack frames

? J-? Writeable structured consts??? ???? ????X+? Extended syntax

? L+? Local debug symbols???????????????????????Y+? Symbol reference info

? M-? Runtime type info???????????? ?????????????? ?Z1? Minimum size of enum types

? O+? Optimization

?

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 (/) or hyphen (-) 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.

?

?

cfg FILE

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

?

the compiler performs as if you had typed the following:

?

dcc32 -IC:\DELPHI\INC;C:\DELPHI\SRC -OC:\DELPHI\ASM -UC:\DELPHI\UNITS -$R+ -$O- MYSTUFF

?

?

Delphi compiler options

Delphi compiler options correspond to switch directives that you can also set directly in your program code.

Selecting an option is equivalent to setting the switch directive to its positive (+) state.

?

Code generation?????? Effect

?

Optimization?????? Enables compiler optimizations. Corresponds to {$O}.

Stack frames?? Forces compiler to generate stack frames on all procedures and functions. Corresponds to {$W}.

Pentium-safe FDIV Delphi only. Generates Delphi code that detects a faulty floating-point division instruction. Corresponds to {$U}.

Record field alignment Aligns elements in structures to the specified number of bytes (1, 2, 4, or 8). Choose the alignment type from the drop-down list. Corresponds to {$A}. ?Note: In older versions of Delphi, this option could be checked on or off. Choosing 1 is the equivalent of off and 8 is the equivalent of on.

?

Runtime errors?????? Effect

?

Range checking Checks that array and string subscripts are within bounds. Corresponds to {$R}.

I/O checking ??? Checks for I/O errors after every I/O call. Corresponds to {$I}.

Overflow checking ?????? Checks overflow for integer operations. Corresponds to {$Q}.

?

Syntax options ?????? Effect

?

Strict var-strings Sets up string parameter error checking. Corresponds to {$V}. (If the Open parameters option is selected, this option is not applicable.)

Complete boolean eval Evaluates every piece of an expression in Boolean terms, regardless of whether the result of an operand evaluates as false. Corresponds to {$B}.

Extended syntax Enables you to define a function call as a procedure and to ignore the function result. Also enables PChar support. Corresponds to {$X}.

Typed @ operator ?????? Controls the type of pointer returned by the @ operator. Corresponds to {$T}.

Open parameters Enables open string parameters in procedure and function declarations. Corresponds to {$P}. Open parameters are generally safer, and more efficient.

Huge strings ?? Enables new garbage collected strings. The string keyword corresponds to the AnsiString type with this option enabled. Otherwise the string keyword corresponds to the ShortString type. Corresponds to {$H}.?

Assignable typed constants Enable this for backward compatibility with Delphi 1.0 on Windows. When enabled, the compiler allows assignments to typed constants. Corresponds to {$J}.

?

Debugging?????? Effect

?

Debug information Puts debug information into the unit (.dcu or .dpu) file. Corresponds to {$D}.

Local symbols ?????? Generates local symbol information. Corresponds to {$L}..

Reference info/Definitions only Generates symbol reference information used by the Code Browser, Code Explorer, and Project Browser. Corresponds to {$Y}. If Reference Info and Definitions Only are both checked ({$YD}), the compiler records information about where identifiers are defined. If Reference Info is checked but Definitions Only is unchecked ({$Y+}), the compiler records information about where each identifier is defined and where it is used. These options have no effect unless Debug Information and Local Symbols (see above) are selected.

?

Assertions ??? Generates code for assertions placed in code. Corresponds to {$C}.. Unlike exceptions, assertions can be removed for the final build. After disabling the option, rebuild the code base to eliminate assertions.

Use Debug DCUs Allows you to link in debug versions of CLX. The Debug DCUs contain debug information and are built with stack frames. When this option is checked, the compliler prepends the Debug DCU path (specified in Tools|Debugger Options on the General page) to the unit Search path specified in Project|Options on the Directories/Conditionals page.

?

Default check box

Default check box saves the current settings as the default for each new project.

?

?

Compiler mode options

A few options affect how the compiler itself functions. As with the other options, you can use these with either the hyphen or the slash format. Remember to separate the options with at least one blank.

?

Note:?????? Command line compiling without an explicit make (-M) or build (-B) switch performs an in-memory compile (make) and link, without flushing anything to disk except the specified compilation unit (unit, program, library, or package).

?

For example:

?

dcc

?

will create a binary represenatation only for the specified file; any used units will not get their dcu or dpu files written to disk.

?

Make (-M) option

?

The command-line compiler has built-in MAKE logic to aid in project maintenance. The -M option instructs command-line compiler to check all units upon which the file being compiled depends. Using this option results in a much quicker compile time.

?

A unit is recompiled under the following conditions:

?

The source file for that unit has been modified since the unit file was created.

?????? Any file included with the $I directive, any .OBJ file linked in by the $L directive, or any .res file referenced by the $R directive, is newer than the unit file.

?????? The interface section of a unit referenced in a uses statement has changed.

?

Units compiled with the -Z option are excluded from the make logic.

?

If you were applying this option to the previous example, the command would be:

?

dcc32 MYSTUFF -M

?

Build all (-B) option

?

Instead of relying on the -M option to determine what needs to be updated, you can tell command-line compiler to update all units upon which your program depends using the -B option. You can't use -M and -B at the same time. The -B option is slower than the -M option and is usually unnecessary.

?

If you were using this option in the previous example, the command would be

?

dcc32 MYSTUFF -B

?

Find error (-F) option

?

When a program terminates due to a runtime error, it displays an error code and the address at which the error occurred. By specifying that address in a -Faddress option, you can locate the statement in the source text that caused the error, provided your program and units were compiled with debug information enabled (via the $D compiler directive).

?

In order for the command-line compiler to find the runtime error with -F, you must compile the program with all the same command-line parameters you used the first time you compiled it.

?

As mentioned previously, you must compile your program and units with debug information enabled for the command-line compiler to be able to find runtime errors. By default, all programs and units are compiled with debug information enabled, but if you turn it off, using a {$D-} compiler directive or a -$D- option, the command-line compiler will not be able to locate runtime errors.

?

Generate object file (-J) option

?

Using the -J option will generate an object file.

?

Use packages (-LU) option

?

Use the -LU option to list additional runtime packages that you want to use in the application being compiled. Runtime packages already listed in the Project Options dialog box need not be repeated on the command line.

?

Disable implicit compilation (-Z) option

?

The -Z option prevents packages and units from being implicitly recompiled later. With packages, it is equivalent to placing {$ IMPLICITBUILD OFF} in the .dpk file. Use -Z when compiling packages that provide low-level functionality, that change infrequently between builds, or whose source code will not be distributed.

?

Target file extension (-TX) option

?

The -TX option lets you override the default extension for the output file. For example,

?

dcc32 MYSTUFF -TXSYS

?

generates compiled output in a file called MYSTUFF.SYS.

?

Quiet (-Q) option

?

The quiet mode option suppresses the printing of file names and line numbers during compilation. When the command-line compiler is invoked with the quiet mode option

?

dcc32 MYSTUFF -Q

?

its output is limited to the startup copyright message and the usual statistics at the end of compilation. If any errors occur, they will be reported.

本文地址:http://com.8s8s.com/it/it4921.htm