Sublime Forum

Debugging Building

#1

I suppose this is more technical support than plugin development, though the intent is to gradually fold that in. Anyhow, I can’t figure out why the build system is not working because it’s about as basic as possible and still not working.

So, command for doing a simulation compile of a file is as follows. I can open a terminal window and anywhere in my drive path I can issue the following and it’ll work:

C:\>vcom -work MFB_WORK c:\projects_rtc\ifr6000_mfb_cyclone_fpga\src\pulse_encoder\carb_player.vhd
QuestaSim-64 vcom 10.3a Compiler 2014.04 Apr 14 2014
Start time: 08:45:23 on Jul 28,2017
vcom -work MFB_WORK c:\projects_rtc\ifr6000_mfb_cyclone_fpga\src\pulse_encoder\carb_player.vhd
-- Loading package STANDARD
-- Loading package TEXTIO
-- Loading package std_logic_1164
-- Loading package NUMERIC_STD
-- Compiling entity carb_player
-- Compiling architecture rtl of carb_player
End time: 08:45:23 on Jul 28,2017, Elapsed time: 0: 0: 0
Errors: 0, Warnings: 0

My build system is as follows:

{
	"cmd": ["vcom", "-work MFB_WORK", "$file"],
	"selector": "source.vhdl"
}

And in the console it appears as if it’s executing the correct statement:

Running vcom -work MFB_WORK C:\projects_rtc\ifr6000_mfb_cyclone_fpga\src\pulse_encoder\carb_player.vhd

However the results seem to indicate that the command received by the compiler is getting mangled somehow.

QuestaSim-64 vcom 10.3a Compiler 2014.04 Apr 14 2014
** Error: (vcom-1902) Option "-work MFB_WORK" is either unknown, requires an argument, or was given with a bad argument.

Use the -help option for complete vcom usage.
End time: 08:51:36 on Jul 28,2017, Elapsed time: 0: 0: 0
Errors: 1, Warnings: 0
[Finished in 0.0s with exit code 1]
[cmd: ['vcom', '-work MFB_WORK', 'C:\\projects_rtc\\ifr6000_mfb_cyclone_fpga\\src\\pulse_encoder\\carb_player.vhd']]
[dir: C:\projects_rtc\ifr6000_mfb_cyclone_fpga\src\pulse_encoder]
[path: c:\mingw\bin;C:\ProgramData\Anaconda3;C:\ProgramData\Anaconda3\Scripts;C:\ProgramData\Anaconda3\Library\bin;C:\MentorGraphics\7.9.4EE\MGC_HOME.ixn\bin;C:\MentorGraphics\7.9.4EE\MGC_HOME.ixn\lib;C:\questasim64_10.3a\win64;C:\Microsemi\Libero_v11.5\Model\win32acoem;C:\Microsemi\Libero_v11.5\Designer\bin;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Common Files\Intel\Shared Files\fortran\bin\Intel64;C:\Program Files (x86)\Common Files\Intel\Shared Files\cpp\bin\ia32;C:\MentorGraphics\7.9.4EE\SDD_HOME\common\win32\bin;C:\MentorGraphics\7.9.4EE\SDD_HOME\common\win32\lib;C:\Xilinx\14.2\ISE_DS\EDK\bin\nt;C:\Program Files (x86)\FTDI\Vinculum II Toolchain\Tools\bin;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows;C:\Windows\system32;C:\Windows\System32\Wbem;C:\Program Files (x86)\cvsnt;C:\Program Files\MATLAB\R2008a\bin;C:\Program Files\MATLAB\R2008a\bin\win64;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Emacs\EmacsW32;C:\Program Files (x86)\Emacs\EmacsW32\gnuwin32\bin]

Like I said, I can do this anywhere in the command window, at root, at the directory the output specifies, etc. The path is the same. I can run this command in emacs and it works correctly. The environment seems identical but it can’t be.

Any notions on what I’ve got wrong here? Thanks!

0 Likes

#2

I’m guessing the problem is that you’ve got "-work MFB_WORK" as one parameter, where as you should split them:

"cmd": ["vcom", "-work", "MFB_WORK", "$file"],

you could also try using shell_cmd with a single string (which works exactly as it would in the shell - quote/escape what needs it) instead of cmd with an array of strings

3 Likes

#3

Yep, using shell command and putting in the command as a single string worked perfectly. I’ll admit, I was pretty confused as to the difference between cmd and shell_cmd from the documentation. They look more or less identical except for the array vs string. I’ll experiment with a cmd variation too now that I’ve got one working and can see what the expected outcome is.

0 Likes

#4

So that’s working in a basic sense. Now I’m seeing if I can capture the output and having some issues, and I don’t know if it’s a matter of Perl regex vs. Python regex or just a basic style problem.

My current .sublime-build file is:

{
	"shell_cmd":   "vcom -time -2008 -check_synthesis -pedanticerrors -work MFB_WORK $file",
	// Capture group MUST be in order: filename / line / column / message
	// Column is a dummy capture.
	"file_regex": "^\*\* .*?: (.*?)\(([0-9]+)\)(): (.*)",
	"selector":    "source.vhdl"
}

If I do not have the “file_regex” line, it works fine. If I introduce an error, the error line looks like:

** Error: C:\projects_rtc\ifr6000_mfb_cyclone_fpga\src\pulse_encoder\carb_player.vhd(77): near "signal": expecting ';'

My regex as shown works fine if I’m tinkering with it at the Python console. Note, the pattern p here was done with raw text, so it’s showing the extra slashes that are in a Python string to escape the backslashes.

In [21]: p
Out[21]: '^\\*\\* .*?: (.*?)\\(([0-9]+)\\)(): (.*)'

In [22]: str
Out[22]: '** Error: C:\\projects_rtc\\ifr6000_mfb_cyclone_fpga\\src\\pulse_encoder\\carb_player.vhd(77): near "signal": expecting \';\''

In [23]: s = re.search(p, str)

In [24]: print(s.group(1)+'\n'+s.group(2)+'\n'+s.group(3)+'\n'+s.group(4))
C:\projects_rtc\ifr6000_mfb_cyclone_fpga\src\pulse_encoder\carb_player.vhd
77

near "signal": expecting ';'

So… I think my pattern works. I seem to have the file format correct (have double and triple-checked the field names, etc). However if I have the file_regex line uncommented, when I try to build on a file, it says “No build system” and doesn’t do anything. There’s no console error that suggests Sublime found an error in the build system (though I’m starting to think the build system aspect of Sublime is less developed than say the plugin system as far as debugging – so there may be an unreported error in loading the bulid system).

What am I missing here?

0 Likes

#5

The file_regex line is making the file not be valid JSON because \*. \( and \) are not valid JSON string escapes, and since it’s not valid JSON Sublime won’t load it, so it thinks there’s no build system available.

To fix it you just need to escape the \ characters in your regex:

	"file_regex": "^\\*\\* .*?: (.*?)\\(([0-9]+)\\)(): (.*)",

Indeed it seems very weird and a somewhat missing feature that there’s no error message reported when this happens. It displays errors for settings files that it can’t load, so I’m not sure why it also doesn’t do the same for build systems.

2 Likes

#6

Oh okay. I did notice that those characters were highlighted in the editor, however I thought perhaps it was just identifying escaped characters. So for JSON I need to enter the backslash hell that raw strings usually protects me from (I do appreciate Python more and more as I use it.). I will give that a shot.

EDIT: That worked and HEY that’s neat. It would be pretty nifty if the system could be expanded upon to distinguish between errors and warnings and notes and that sort of thing, but perhaps that’s down the line. There’s definitely a lot of room for elaboration here.

0 Likes