erlc
命令
概要
描述
The
erlc
program provides a common way to run all compilers in the Erlang system. Depending on the extension of each input file,
erlc
will invoke the appropriate compiler. Regardless of which compiler is used, the same flags are used to provide parameters such as include paths and output directory.
erlc提供了一个公共的途径来运行Erlang系统的所有编译器.
erlc
会根据于各输入文件的扩展名,来调用合适的编译器.你无须关心哪个编译器被使用了.它们都使用相同的参数,例如include路径和输出目录.
输出
Erlc
compiles one or more files. The files must include the extension, for example
.erl
for Erlang source code, or
.yrl
for Yecc source code.
Erlc
uses the extension to invoke the correct compiler.
Erlc编译一个或一个以上文件.文件必须包括它们的扩展名.例如.erl代表Erlang源代码,而.yrl代表Yecc源代码.Erlc用扩展名来调用正确的编译器.
一般的有用标记
The following flags are supported:
下面的标记都支持:
-I
directory
-include
or
-include_dir
directive, the compiler searches for header files in the following directories:
指示编译器在指定的目录去查找include文件.编译器每碰到一个
-include或
-include_dir
标记, 就会在其后指定的目录中查找头文件.
-
"."
, the current working directory of the file server;
"."
, 当前工作目录
- the base name of the compiled file;
-
the directories specified using the
-I
option. The directory specified last is searched first.
-I
选项指定目录, 最后指定的目录,却最先被查找.
-o
directory
编译器输出文件的目录.如果没定义,输出文件将放置在当前工作目录.
-D
name
定义一条宏.
-D
name
=
value
定义一条拥有给定值的宏. 这个值可以是任意Erlang项.根据平台,如果shell自身会解释特定的字符,这个值可能需要用引号标注.在Unix中, 包含元组和list的项必须用引号标注. 有空格的项在所有平台,都得用引号标注.
-W
number
number
. Default is
1
. Use
-W0
to turn off warnings.
将警告级别定义为
number
级. 默认为
1. 用
-W0
关闭警告.
-W
-W1
. Default.
和
-W1意义一样.默认的.
-v
打开详细输出
-b
output-type
output-type
is the same as the file extension of the output file but without the period. This option will be ignored by compilers that have a a single output format.
指定输入文件类型.一般
output-type
如果输出类型只有一种,这个选项就会被忽略.
-hybrid
用混合堆模拟器编译. 这对于编译原生代码很有用,同时还需要编译此原生代码能运行的运行时系统.
-smp
用SMP模拟器编译. 这对于编译原生代码很有用,同时还需要编译此原生代码能运行的运行时系统.
—
告诉编译器之后没有选项了.它之后的参数全被当作文件名,尽管以连字符开头也一样. (译注, 连字符-后面一般是编译器选项,但定义了这个之后,就不是选项了)
+
term
+
‘) rather than a hyphen will be converted to an Erlang term and passed unchanged to the compiler. For instance, the
export_all
option for the Erlang compiler can be specified as follows:
一个以加号 (‘
+
‘)开头而不是连字符开头的选项,会被转义成一个Erlang项,且被原样传入编译器. 例如, Erlang 编译器的
export_all
选项可以写成如下形式:
代码
- erlc +export_all file.erl
Depending on the platform, the value may need to be quoted if the shell itself interprets certain characters. On Unix, terms which contain tuples and list must be quoted. Terms which contain spaces must be quoted on all platforms.
根据平台,如果shell自身会解释特定的字符,这个值可能需要用引号标注.在Unix中, 包含元组和list的项必须用引号标注. 有空格的项在所有平台,都得用引号标注.
特殊标记
The flags in this section are useful in special situations such as re-building the OTP system.
此节的标记在特殊情况下有用,比如重编译OTP系统.
-pa
directory
directory
to the front of the code path in the invoked Erlang emulator. This can be used to invoke another compiler than the default one.
-pz
directory
directory
to the code path in the invoked Erlang emulator.
支持的编译器
.erl
.beam
file.
The options -P, -E, and -S are equivalent to +’P’, +’E’, and +’S’, except that it is not necessary to include the single quotes to protect them from the shell.
Supported options: -I, -o, -D, -v, -W, -b.
Erlang源文件.生成
.beam
文件.
.yrl
.erl
file.
Use the -I option with the name of a file to use that file as a customized prologue file (the
includefile
option).
Supported options: -o, -v, -I, -W (see above).
.mib
.bin
file.
Supported options: -I, -o, -W.
.bin
.hrl
file.
Supported options: -o, -v.
.rel
Use the -I to name directories to be searched for application files (equivalent to the
path
in the option list for
systools:make_script/2
).
Supported options: -o.
脚本文件. 生成boot 文件.
.asn1
Creates an
.erl
,
.hrl
, and
.asn1db
file from an
.asn1
file. Also compiles the
.erl
using the Erlang compiler unless the
+noobj
options is given.
Supported options: -I, -o, -b, -W.
.idl
Runs the IDL compiler.
Supported options: -I, -o.
环境变量
ERLC_EMULATOR
erl
in the same directory as the
erlc
program itself, or if it doesn’t exist,
erl
in any of the directories given in the
PATH
environment variable.
启动模拟器的命令. 默认
erl
与
erlc
程序在同一目录, 如果此环境变量不存在,
erl
在
PATH
环境变量给出的一个目录中.
另见