ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Multi​Task​Build

by bizoo ST2

Multi task (target) build for Sublime Text 2

Details

  • 2013.03.11.07.38.07
  • github.​com
  • github.​com
  • 11 years ago
  • 2 hours ago
  • 12 years ago

Installs

  • Total 617
  • Win 294
  • Mac 149
  • Linux 174
Apr 18 Apr 17 Apr 16 Apr 15 Apr 14 Apr 13 Apr 12 Apr 11 Apr 10 Apr 9 Apr 8 Apr 7 Apr 6 Apr 5 Apr 4 Apr 3 Apr 2 Apr 1 Mar 31 Mar 30 Mar 29 Mar 28 Mar 27 Mar 26 Mar 25 Mar 24 Mar 23 Mar 22 Mar 21 Mar 20 Mar 19 Mar 18 Mar 17 Mar 16 Mar 15 Mar 14 Mar 13 Mar 12 Mar 11 Mar 10 Mar 9 Mar 8 Mar 7 Mar 6 Mar 5
Windows 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Mac 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Linux 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Readme

Source
raw.​githubusercontent.​com

Multi task Builder for SublimeText 2

This plugin adds the ability to define more than one task (target) in a single sublime-build file.

When you run the Build command, a menu ask you which task you want to execute.

Update variants:

SublimeText 2 Build 2197 introduce a new option "variants" in sublime-build file.

See this link for more info.

Like this plugin, you can now have different tasks that is available on the Command Palette prefixed with "Build: ".

How it works

This plugin is designed to be a drop in replacement for the standard exec command (the command that is executed by the Build command in ST2). It means that actual sublime-build files must run exactly the same way as before.

This plugin define a new format for sublime-build file that supports multi target build.

The best way to understand new format is to look at Example: Multi task Python Builder.

In brief:

  • cmd become a dictionary that contain one entry for each task.
  • The fields that could be declared in each task are exactly the same as the standard fields (cmd, file_regex, working_dir, ...)
  • The fields declared in the root are the defaults for all tasks. Same fields declared inside the task as upper priority.
  • There is a new optional field default_task that define the default task. The default value is 'build'.

Example: Multi task Python Builder

This is the standard Python sublime-build included with ST2:

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

Now this is a multi task Python sublime-build:

{
    "cmd": {
            "build": {
                    "cmd": ["python", "-u", "$file"]
            },
            "verbose": {
                    "cmd": ["python", "-u", "-v", "$file"],
                    "quiet": true
            }
    },
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "selector": "source.python",
    "default_task": "verbose",
    "target": "multi_task_exec"
}

If you compare these files, this exactly the same structure except:

  • To use this plugin you have to set multi_task_exec in the target field.
  • cmd field become a dictionary that contain one entry for each task. The fields that could be declared in each task are exactly the same as the standard fields (cmd, file_regex, working_dir, ...).
  • The optional field default_task define the default task. The default value is 'build'.
  • file_regex is the default for all task. This value is used for each task except for tasks that redeclare file_regex.

Known issues

There is actually only one things which can cause problems:

Expandable variables (like '$file', '$file_path', ...) are expanded by ST2 before calling the exec command. And not all fields from the sublime-build file are expanded (cmd and working_dir only I think).

So for the variables of tasks to be expanded, I have to put tasks in the cmd fields. The drawback is that all fields from tasks are expanded, so if you put a '$file' string in the path field, the text is replaced by the full path of the current file, which is not the case for standard build file.

In practice, I don't think it's really an issue.