sublime build 系统必读

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"
}

选项

cmd
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

包括命令及其参数数组。如果不指定绝对路径,外部程序会在你系统的:const:PATH 环境变量中搜索。

On Windows, GUIs are supressed.

在Windows 系统中,*TBT*

file_regex
Optional. Regular expression (Perl-style) to capture error output of  cmd. See the next section for details.
file_regex
可选。 Perl格式的正则表达式可以获取``cmd``的错误输出,详情参考下一节
line_regex
Optional. If  file_regex doesn’t match on the current line, but  line_regex exists, and it does match on the current line, then walk backwards through the buffer until a line matching 
  • 8
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值