使用命令行的Sublime Text自定义构建系统

时间:2015-03-28 20:27:05

标签: python sublimetext

有没有人在Sublime Text 3中有自定义构建系统的经验,特别是以python为基础?

目前我在这里遇到的问题是应该调用extern命令行程序来烘焙用户文件。

我目前的" .sublime-build"看起来像这样:

{
    "target": "convert2libpart",
    "selector": "text.xml.gdl"
}

目标设置为python文件, 这就是:

from __future__ import print_function 
import sublime
import sublime_plugin
import os, os.path
from subprocess import call

# convert the current XML to binary via
# the converter -> who does actual work

class convert2libpart(sublime_plugin.WindowCommand):
    def run(self, cmd="", file_regex="", path=""):

        view = self.window.active_view()

        self.plat = sublime.platform()

        # get the settings
        s = sublime.load_settings("somesettings.sublime-settings")
        version = s.get("version") # this is from a settingsfile, as you can see
        version = str(version)

        if self.plat == "windows":
            converter_path = "C:\\Program Files\\folder " + version + "\\"
        #else:
            # osx path... (program is available on both systems)


        file_name = os.path.basename(view.file_name())
        dir_path = os.path.dirname(view.file_name())
        # XMLConverter xml2libpart source dest
        cmd = "XMLConverter.exe xml2libpart " + "\"" + dir_path + "\\" + file_name + "\"" + " " + "\"" + dir_path + "output" + "\""


        proc = call("start cmd /K " + cmd, cwd=converter_path, shell=True)

如果我使用这个构建系统,我可以在任务管理器中看到转换器将启动,但不会生成输出。这是程序的错吗? 使用完全相同的命令手动执行此操作将产生所需的输出。 有什么想法吗?提前谢谢。

0 个答案:

没有答案