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
  • 12 years ago
  • 8 minutes ago
  • 13 years ago

Installs

  • Total 617
  • Win 294
  • Mac 149
  • Linux 174
Dec 3 Dec 2 Dec 1 Nov 30 Nov 29 Nov 28 Nov 27 Nov 26 Nov 25 Nov 24 Nov 23 Nov 22 Nov 21 Nov 20 Nov 19 Nov 18 Nov 17 Nov 16 Nov 15 Nov 14 Nov 13 Nov 12 Nov 11 Nov 10 Nov 9 Nov 8 Nov 7 Nov 6 Nov 5 Nov 4 Nov 3 Nov 2 Nov 1 Oct 31 Oct 30 Oct 29 Oct 28 Oct 27 Oct 26 Oct 25 Oct 24 Oct 23 Oct 22 Oct 21 Oct 20
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.