As a ridiculously simple test;
test.c
#include <stdio.h>
int main (int argc, char **argv)
{
printf("Hello, World!\n")
return 0;
}
Makefile
all: test
./test
test: test.o
clang -o test test.o
test.o: test.c
clang -c test.c
Lozminda.sublime-build
{
"shell_cmd" : "make",
"selector" : "source.c",
"file_regex":"^(|..[^:]*):([0-9]*):?([0-9]*)?:? (.*)$",
"working_dir": "${folder:${project_path:${file_path}}}",
"syntax": "Packages/Makefile/Make Output.sublime-syntax"
}
The folder structure has the Makefile
and test.c
sitting in the same folder; executing the build with the build you have here produces this output:
clang -c test.c
clang -o test test.o
./test
Hello, World!
[Finished in 0.1s]
All as we would expect. Now, remove the semicolon on the printf
and build again:
lang -c test.c
test.c:5:30: error: expected ';' after expression
printf("Hello, World!\n")
^
;
1 error generated.
make: *** [Makefile:8: test.o] Error 1
[Finished in 0.0s with exit code 2]
[shell_cmd: make]
[dir: /tmp/bob/test]
[path: ... ]
An error is detected by clang, which reports it. Also because make
returns a failure, Sublime displays a diagnostic that tells you what command it executed, what directory was the current directory, and the path at the time (which I have clipped just because my path is excessively long).
Seems like things work on the face of it, based on the output.
The file_regex
is what tells Sublime that a line contains a result to be navigated. Yours looks like this:
^(|..[^:]*):([0-9]*):?([0-9]*)?:? (.*)$
The first capture group is the name of the file:
(|..[^:]*):
So, the filename is either any two characters (..
), followed by 0 or more characters that aren’t a colon ([^:]*
), followed by a :
. OR, due to the alternation operator, the filename can be nothing at all.
Then, there’s this output:
[dir:
So, [
matches the first .
, and d
matches the second .
, and then ir
matches [^:]*
, the next character is :
which closes off the capture group, and what was captured was [dir
as a filename.
What you expect? No. What you told it was acceptable? yep.
Your regex looks like it’s based on the one from C Single File.sublime-build
(or one of my examples perhaps, which come from there), except that the filename field has the alternation in it.
That one is meant to parse gcc
output, but clang
produces different output than gcc
does. I’d try something like this:
"file_regex":"^(..[^:]*):([0-9]*):([0-9]*): (.*)$",
Similar to the one you’re using, but the row and column for the error are now not optional (and the filename isn’t allowed to be empty), which should match a bit better based on my sample of this case right here.