Sublime Forum

Build system variant not working

#1

Hi, I was playing around with the C++ build system (C++ Single File.sublime-build) to make it work with MSVC on Windows:

{
    "shell_cmd": "g++ \"${file}\" -o \"${file_path}/${file_base_name}\"",
    "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
    "working_dir": "${file_path}",
    "selector": "source.c++",

    "windows": {
        "shell_cmd": "vcvars64.bat && cl /Ehsc /Za $file",
    },

    "variants":
    [
        {
            "name": "Build & Run",
            "shell_cmd": "g++ \"${file}\" -o \"${file_path}/${file_base_name}\" && \"${file_path}/${file_base_name}\"",
            "windows": {
                "shell_cmd": "vcvars64.bat && cl /Ehsc /Za $file && \"${file_path}/${file_base_name}\"",
            },
        },
        {
            "name": "Run",
            "shell_cmd": "\"${file_path}/${file_base_name}\""
        }
    ]
}

so now I have 3 build options:

  • C++ Single File
  • C++ Single File - Build & Run
  • C++ Single File - Run

the first two work fine, but the Run variant is not detected and instead the first one (global) is run.
How can I fix this ?

  • OS: Windows 7
  • ST: 3189
0 Likes

#2

I suspect you have to add a windows shell_cmd section in your “Run” variant, like you’ve done for the “Build & Run” variant.
I suppose the variant are merged with the main replacing the existing entries of it.

2 Likes