Sublime Forum

Can I run a program or a file using build system without compiling or Interpreting?

#1

If I create a Build System of C like:
{

“shell_cmd”: “gcc “${file}” -o “${file_path}/${file_base_name}” -Wformat=2”,
“file_regex”: “^(…[^:]):([0-9]+):?([0-9]+)?:? (.)$”,
“working_dir”: “${file_path}”,
“selector”: “source.c”,
“variants”:
[
{
“name”: “Run”,
“shell_cmd”: “gcc “${file}” -o “${file_path}/${file_base_name}” -Wformat=2 && “${file_path}/${file_base_name}””
}
]
}
I have to run the “gcc” command with a batch file, which in turn executes the output after creation.So I wander can I just execute a program/file like I did in bash:"./testprogram".Thanks a lot.

0 Likes

#2

ya, just remove the compilation part I guess.

For me it’s another case cause I only compile it. so for me it’s.

{
“shell_cmd”: “make all”
}

Just replace the “make all” with ./testprogram

0 Likes

#3

You can change your build system to compile it without the run option and limit it to the execution if Run is selected:

{
    "shell_cmd": "gcc \"${file}\" -o \"${file_path}/${file_base_name}\" -Wformat=2",
    "file_regex": "^(..[^:]):([0-9]+):?([0-9]+)?:? (.)$",
    "working_dir": "${file_path}",
    "selector": "source.c",
    "variants":
    [
        {
            "name": "Run",
            "shell_cmd": "\"${file_path}/${file_base_name}\""
        }
    ]
}
```
0 Likes