Sublime Text 2构建系统(从输入文件获取输入)

时间:2014-03-22 15:23:20

标签: c++ sublimetext2 sublimetext build-system

{
    "cmd": ["g++", "${file}", "-o", "${file_path}/${file_base_name}"],
    "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
    "working_dir": "${file_path}",
    "selector": "source.c, source.c++",

    "variants":
    [
        {
            "name": "Run",
            "working_dir": "${file_path}",
            "cmd": ["${file_path}/${file_base_name} < ${file_path}/${file_base_name}.input"]
        }
    ]
}

这是我创建的sublime-text 2自定义构建文件,用于编译代码并使用输入文件运行代码。但是,它总是返回以下错误。

[Errno 2] No such file or directory
[cmd:  [u'/home/p-kar/codebase/codechef/CDR2014/test < /home/p-kar/codebase/codechef/CDR2014/test.input']]
[dir:  /home/p-kar/codebase/codechef/CDR2014]
[path: /home/p-kar/bin:/usr/local/bin:/home/p-kar/bin:/usr/local/bin:/home/p-kar/bin:/usr/local/bin:/home/p-kar/bin:/usr/local/bin:/home/p-kar/bin:/usr/local/bin:/home/p-kar/bin:/usr/local/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/p-kar/bin]
[Finished]

我哪里错了?

1 个答案:

答案 0 :(得分:0)

在您的示例中,您的run变体在运行之前不会编译任何内容。您需要将构建文件编辑为:

"variants":
    [
        {
            "name": "Run",
            "cmd": ["bash", "-c", "/usr/local/bin/gcc '${file}' -Wall -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}'"]
        }
    ]
}