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

Installs

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