Sublime Forum

File Paths on Windows in MSVC Compiler Build System

#1

So I’ve been having this problem for a while now and so far have been unable to find a workaround. The problem comes from the fact that windows treats capitalization in paths as irrelevant and therefore so does the Microsoft Visual C Command Line Compiler. I have a custom build tool that runs a batch script to compile my code using Microsoft’s “cl” compiler. This build tool has “file_regex” set up to capture the file paths of errors outputted by the compiler. However, these file paths are always output all lower case. Since Sublime Text treats capitalization as significant when I open these files using F4 (or double click) it opens a new instance of the file location with the path and file name all lowercase. This is extremely frustrating for a few reasons.

1: It means many of my files end up being opened twice as I debug stuff.

2: The error phantoms do not show up in the original tab that I opened the file with

3: The open file palette built into Sublime always opens files with their proper capitalization which means I always open the caps version first only for the build_tool (lowercase) version to be opened when an error is jumped to

4: Even if I try to get rid of all capitalization in my file paths in order to remedy the issue, the drive paths on windows are ALWAYS uppercase. Which means it will originally open the file as C:/main.cpp but the build tool will open it as c:/main.cpp. There are also support libraries in directories that I can’t change the names of to solve this issue and some of them have capital letters in their folder/file names. If these files have an error then we run into this problem.

Telling the compiler to output relative file paths kind of works but it sometimes decides to output full file paths for some reason which, again, causes the drive letter lowercase problem. And the MSVC compiler doesn’t have an option to preserve filename capitalization.

This has been frustrating me for a long while now and I’ve tried everything I can think of to get it to work. I’m at the point that it seems like the only option is to replace the BuildCommand plugin that comes with Sublime Text with my own version that does a proper search for file paths and opens the file with it’s correct capitalization. This is a terribly arduous process as far as I can tell so I would really rather not have to go down that path.

I would like one of two things:
1: Some way to get the build system working without replacing BuildCommand.
2: Confirmation that maybe this will get fixed in a newer version of Sublime Text. (I’m using 3.1.1, Build 3176)

I love this editor but there are some small things like this that are just driving me up the wall and ruining my build process. This may seem like a minor annoyance but when you deal with this same problem hundreds of times a day it adds up really fast.

I’ve provided a copy of what I thought might be relevant code snippets and a screenshot to help illustrate the problem. If you need any other information let me know. Thank you for your time.

runbuildbat.sublime-build

{
	"cmd": "..\\build.bat",
	"working_dir": "$project_path\\build",
	"shell": true,
	
	"syntax": "MSVC Build.sublime-syntax",
	
	"file_regex": "^((?:\\w\\:)?[^\\:\\n]+\\.[A-Za-z]+)\\((\\d+)\\)\\ ?: (?:fatal )?(?:error|warning) \\w\\d+: ()([^\\n]+)$",
}

build.bat (Edited down for brevity)

IF EXIST "build*" (
	echo Moving into build folder
	cd build
)

REM I've tried this with and without /FC which gives full filepaths in output
cl /Fegame.exe ..\code\win32_main.cpp

Output Examples (one with /FC compiler flag, and one without)

c:\gamedev\projects\tower_of_babylon\code\win32_main.cpp(51): error C2144: syntax error: 'bool' should be preceded by ';'

..\code\win32_main.cpp(51): error C2144: syntax error: 'bool' should be preceded by ';'

"file_regex" (without JSON escaping so it’s easier to read)

^((?:\w\:)?[^\:\n]+\.[A-Za-z]+)\((\d+)\)\ ?: (?:fatal )?(?:error|warning) \w\d+: ()([^\n]+)$

Regular Expression Matched Groups Examples (One for full file path, and one for relative)

$0: c:\gamedev\projects\tower_of_babylon\code\win32_main.cpp(51): error C2144: syntax error: 'bool' should be preceded by ';'
$1: c:\gamedev\projects\tower_of_babylon\code\win32_main.cpp
$2: 51
$3: 
$4: syntax error: 'bool' should be preceded by ';'

$0: ..\code\win32_main.cpp(51): error C2144: syntax error: 'bool' should be preceded by ';'
$1: ..\code\win32_main.cpp
$2: 51
$3: 
$4: syntax error: 'bool' should be preceded by ';'

Duplicate Files Screenshot

0 Likes

#2

this is a known regression, I believe SublimeHQ will fix it in the next build

0 Likes