http://sublime-text.readthedocs.io/en/latest/reference/build_systems.html
Build Systems
Build systems let you run your files through external programs and see the output they generate within Sublime Text.
构建系统可以让您通过外部程序来运行文件,并可以在Sublime Text查看输出。
Build systems consist of two –or optionally three– parts:
- configuration data in JSON format (the .sublime-build file contents)
- a Sublime Text command driving the build process
- optionally, an external executable file (script, binary file)
构建系统包括两 – 或者说三个 – 部分
- 使用JSON格式保存配置文件 (.sublime-build 内容)
- 使用Sublime Text命令来驱动构建过程
- 还包括一个外部的可执行程序(脚本或者二进制)
Essentially, .sublime-build files are configuration data for an external program as well as for the Sublime Text command just mentioned. In them, you specify the switches, options and environment information you want forwarded.
从根本上来讲,.sublime-build 配置文件对于外部可执行程序与前面提到的Sublime Text命令是一样的。在配置文件中可以指定开关、配置以及环境变量。
The Sublime Text command then receives the data stored in the .sublime-build file. At this point, it can do whatever it needs to build the files. By default, build systems will use the exec
command, implemented in Packages/Default/exec.py. As we’ll explain below, you can override this command.
Sublime Text命令从 .sublime-build 中读取配置数据,然后根据需要*构建*这些文件。 构建系统缺省会使用``exec`` 命令,该命令在 Packages/Default/exec.py 中实现。 在后续的讲解中,我们会重写这个命令。
Lastly, the external program may be a shell script you’ve created to process your files, or a well-known utility like make
or tidy
. Usually, these executable files will receive paths to files or directories, along with switches and options to be run with.
外部程序可能是你用来处理文件的脚本,也可以能是类似 make
或 tidy
这类的命令。通常,这些可执行文件从配置中获取文件路径或者目录以及运行是需要的开关及选项。
Note that build systems need not call any external program at all if there isn’t any reason to; you could implement a build system entirely in a Sublime Text command.
注意,构建系统可以完全不依赖调用外部程序,完全可以通过Sublime Text
文件格式
.构建系统 文件使用JSON. 以下是一个例子:
{
"cmd": ["python", "-u", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python"
}
选项
-
Array containing the command to run and its desired arguments. If you don’t specify an absolute path, the external program will be searched in your
PATH
, one of your system’s environmental variables.
cmd
cmd
包括命令及其参数数组。如果不指定绝对路径,外部程序会在你系统的:const:PATH 环境变量中搜索。
On Windows, GUIs are supressed.
在Windows 系统中,*TBT*
-
Optional. Regular expression (Perl-style) to capture error output of
cmd
. See the next section for details. - 可选。 Perl格式的正则表达式可以获取``cmd``的错误输出,详情参考下一节
-
Optional. If
file_regex
doesn’t match on the current line, butline_regex
exists, and it does match on the current line, then walk backwards through the buffer until a line matching
file_regex
file_regex
line_regex