Sublime 2 配置编译环境[Windows]

Build System 说明(下面的文字摘自官方文档Build_Systems):

File Format

.build-system files use JSON. Here’s an example:

{
    "cmd": ["python", "-u", "$file"],
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "selector": "source.python"
}

Options

cmd

Array containing the command to run and its desired arguments. If you don’tspecify an absolute path, the external program will be searched in yourPATH, one of your system’s environmental variables.

On Windows, GUIs are supressed.

file_regex
Optional. Regular expression (Perl-style) to capture error output of cmd. See the next section for details.
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, thenwalk backwards through the buffer until a line matching fileregex isfound, and use these two matches to determine the file and line to go to.
selector
Optional. Used when Tools | Build System | Automatic is set to true.Sublime Text uses this scope selector to find the appropriate build systemfor the active view.
working_dir
Optional. Directory to change the current directory to before running cmd.The original current directory is restored afterwards.
encoding
Optional. Output encoding of cmd. Must be a valid python encoding.Defaults to UTF-8.
target

Optional. Sublime Text command to run. Defaults toexec (Packages/Default/exec.py).This command receives the configuration data specified in the.build-system file.

Used to override the default build system command. Note that if you chooseto override the default command for build systems, you can add arbitraryvariables in the.sublime-build file.

env

Optional. Dictionary of environment variables to be merged with the currentprocess’ before passing them tocmd.

Use this element, for example, to add or modify environment variableswithout modifying your system’s settings.

shell
Optional. If true, cmd will be run through the shell ( cmd.exe, bash…).
path

Optional. This string will replace the current process’PATH beforecallingcmd. The old PATHvalue will be restored after that.

Use this option to add directories toPATH without having to modifyyour system’s settings.

Capturing Error Output withfile_regex

The file_regex option uses a Perl-style regular expression to capture upto four fields of error information from the build program’s output, namely:file name,line number,column number anderror message. Usegroups in the pattern to capture this information. Thefile name field andtheline numberfield are required.

When error information is captured, you can navigate to error instances inyour project’s files withF4 andShift+F4. If available, the capturederror message will be displayed in the status bar.

Platform-specific Options

The windows,osx andlinux elements let you provideplatform-specific data in the build system. Here’s an example:

{
    "cmd": ["ant"],
    "file_regex": "^ *\\[javac\\] (.+):([0-9]+):() (.*)$",
    "working_dir": "${project_path:${folder}}",
    "selector": "source.java",

    "windows":
    {
        "cmd": ["ant.bat"]
    }
}

In this case,ant will be executed for every platform except Windows, whereant.bat will be used instead.

Variables

Build systems expand the following variables in.sublime-build files:

$file_pathThe directory of the current file, e. g.,C:Files.
$fileThe full path to the current file, e. g.,C:FilesChapter1.txt.
$file_nameThe name portion of the current file, e. g.,Chapter1.txt.
$file_extensionThe extension portion of the current file, e. g.,txt.
$file_base_nameThe name only portion of the current file, e. g.,Document.
$packagesThe full path to thePackages folder.
$projectThe full path to the current project file.
$project_pathThe directory of the current project file.
$project_nameThe name portion of the current project file.
$project_extensionThe extension portion of the current project file.
$project_base_nameThe name only portion of the current project file.

Place Holders for Variables

Features found in snippets can be used with these variables. For example:

${project_name:Default}

This will emit the name of the current project if there is one, otherwiseDefault.

${file/\.php/\.txt/}

This will emit the full path of the current file, replacing.php with.txt.



配置方法:

摘自 http://www.cnblogs.com/akira90/archive/2013/01/02/2842571.html

在“我的电脑”上,右键找到“属性”,选择“高级系统设置”,进到“环境变量”里面;

(1)创建三个系统变量

  在命令行输入set命令会有对应的VS信息,vs2010是VS100COMNTOOLS

<1>名字: VS100Common

       值: C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7

<2>名字: VS100VC

       值: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC

<3>名字: VS100SDK

       值: C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A

(2)创建(或追加)三个用户变量

<1>名字: PATH

值 :%VS100VC%\BIN;%VS100Common%\IDE;%VS100Common%\TOOLS;%VS100SDK%\BIN;%PATH%

<2>名字: INCLUDE

值 :%VS100VC%\INCLUDE;%VS100VC%\ATLMFC\INCLUDE;%VS100SDK%\INCLUDE;%INCLUDE%

 

<3>名字: LIB

值 :%VS100VC%\LIB;%VS100VC%\ATLMFC\LIB;%VS100SDK%\LIB;%LIB%

(2)创建(或追加)三个用户变量


      "cmd": ["CL", "/EHsc", "/Fo${file_base_name}", "/O2", "${file}"],   
      "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",  
      "working_dir": "${file_path}",  
      "selector": "source.c, source.c++",  
      "encoding":"cp936",




      "variants":  
      [  
           {  
              "name": "Run", 
              "cmd": ["CMD", "/U", "/C", "CL /Fo${file_base_name} /O2 ${file} && ${file_base_name}"] 
          }  
      ]  

 }


CTRL+B 显示Building ,无法显示信息解决方案:

exec.py里面替换
proc_env[k] = os.path.expandvars(v).encode(sys.getfilesystemencoding())

proc_env[k] = os.path.expandvars(v.decode(sys.getfilesystemencoding())).encode(sys.getfilesystemencoding())

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值