@nutjob2: Thanks, piping is a great idea!
It seems a bit counter efficient to run another script, my first impulse was indeed to hack exec.py (ideally I would have liked to be able to set a custom py script per-build system), but piping is a much more self-contained solution.
@FichteFoll: unfortunately setting the working_dir (which I’m already doing) is not enough, because the results are not all relative to the same base path.
I first tried a python script, but unfortunately it until build completion then dumped everything… odd. A bash script with sed however, processes line by line interactively.
For whoever’s interested, here’s my project file:
"build_systems":
[
// docs: http://www.sublimetext.com/docs/3/projects.html
// variants: http://docs.sublimetext.info/en/latest/reference/build_systems/configuration.html#variants
// ... although the ctrl+B vs ctrl+shift+B behavior described is obsolete, here's the correct one: http://stackoverflow.com/a/29290258/322119
//
// We pipe the KL build results to translate_kl_build_results.sh to get paths
// relative to the Sublime project (instead of relative to each extension).
// http://stackoverflow.com/a/2381643/322119 to pipe stderr but not stdin
{
"name": "System",
"variants":
[
{
"name": "make (C++)",
"shell_cmd": "./make_System.sh",
},
{
"name": "Compile (KL)",
"shell_cmd": "./compile_System.sh 3>&1 1>&2 2>&3 | ./translate_kl_build_results.sh",
"file_regex": "^\\./(.*):(\\d+):(\\d+)",
},
],
"working_dir": "$project_path",
},
... more systems here ...
],
and the script:
#!/usr/bin/env bash
# process each line interactively (ie line will be translated as the build occurs)
while read -r line; do
# example input:
#[FABRIC:MT] [DwarfCore] KL/test.kl:4:9: error: 'bla': symbol not found
#[FABRIC:MT] [ImGui] KL/test.kl:4:9: error: 'bla': symbol not found
# output:
#./Core/KL/test.kl:4:9: error: 'bla': symbol not found
#./ImGui/KL/test.kl:4:9: error: 'bla': symbol not found
#
# So basically we replace the extension name with the folder name (ie just remove any 'Dwarf' prefix),
# relative to the root of the Sublime project.
#
# Make sure we have a line number ([0-9]+), otherwise we might catch errors that are not tied
# to a particular file so of no interest to Sublime...
#
echo $line | sed -r 's/\[FABRIC:MT\] \[(Dwarf)?(.*)\] (.*):([0-9]+)/.\/\2\/\3:\4/'
done