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
  • 2 hours ago
  • 13 years ago

Installs

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