fs2open.github.com icon indicating copy to clipboard operation
fs2open.github.com copied to clipboard

Game won't build when FSO_USE_VOICEREC is enabled on freshly cloned copy of the project

Open Kiloku opened this issue 6 years ago • 20 comments

When I first tried building the project, it failed, complaining about the lack of the phrases.cfg file. The oldest mention I could find of this issue is in this forum thread. While they say it was solved, it might have regressed at some point.

Talking to @Goober5000 on Discord, he said

I looked through the project file. There's no actual custom build step to build phrases.cfg
My guess is this was never done when we switched to CMake. It existed in the old Visual Studio project files.

Currently, to build the project from a freshly cloned copy on Windows, FSO_USE_VOICEREC needs to be disabled.

Kiloku avatar Nov 28 '19 11:11 Kiloku

That functionality still worked with our supported compilers last I checked, but it's been a while. What is your build environment?

chief1983 avatar Nov 28 '19 15:11 chief1983

I should say, we've been on CMake for a while now and I would have sworn I'd done a fresh checkout and build on Windows since we switched.

chief1983 avatar Nov 28 '19 15:11 chief1983

I'm on Windows 10, using Visual Studio 2017 and CMake 3.16.0-rc3

Is it possible that when you built it, the phrases.cfg file was cached somewhere or something? I don't know how the file is supposed to be generated, but the only thing I'm sure of is that it wasn't there.

Kiloku avatar Nov 28 '19 17:11 Kiloku

Er, hold on. Previously I searched just the project files, when I really should have searched all files. I found this:

voice_rec.cmake

SET(VOICE_REC_FILES)
IF(FSO_USE_VOICEREC)
	ADD_DEFINITIONS(-DFS2_VOICER)
	
	SET(SOUND_DIR "${CMAKE_CURRENT_SOURCE_DIR}/sound")
	SET(VOICE_REC_FILES
		"${GENERATED_SOURCE_DIR}/code/sound/grammar.h"
		"${GENERATED_SOURCE_DIR}/code/sound/phrases.cfg")
	
	ADD_CUSTOM_COMMAND(
		OUTPUT ${VOICE_REC_FILES}
		COMMAND "${SOUND_DIR}/gc.exe" /o "${GENERATED_SOURCE_DIR}/code/sound/phrases.cfg" /h "${GENERATED_SOURCE_DIR}/code/sound/grammar.h" "${SOUND_DIR}/phrases.xml"
		DEPENDS "${SOUND_DIR}/phrases.xml"
		COMMENT "Compiling voice recognition files"
		)

	SOURCE_GROUP("Generated Files\\Voice Recognition files" FILES ${VOICE_REC_FILES})
ENDIF(FSO_USE_VOICEREC)

This is what the project is supposed to do: use gc.exe to generate phrases.cfg from phrases.xml and grammar.h.

Goober5000 avatar Nov 28 '19 18:11 Goober5000

Yeah I was just about to comment on this. This is why I always use git grep to look for this kind of stuff :)

gc.exe (Grammar Compiler) is part of the SAPI which should be included in VS 2017, I thought. Although searching for Visual Studio 2017 SAPI showed me I have been to this link previously https://www.microsoft.com/en-us/download/details.aspx?id=10121

chief1983 avatar Nov 28 '19 18:11 chief1983

Ok seems like it was as I thought, the Speech SDK and SAPI are in the Windows SDK now that it is integrated into the OS. I believe it was installed through the Visual Studio installer, so there may have been a necessary component left unchecked during installation. Might be able to fix it by running the Uninstall/Modify dialog for Visual Studio and seeing if that allows installing other components that were skipped previously.

chief1983 avatar Nov 28 '19 18:11 chief1983

Even so, since there's a CMake configuration for this step, shouldn't it have been added to the Visual Studio project or solution somewhere?

Goober5000 avatar Nov 28 '19 18:11 Goober5000

It references the phrases.cfg in the freespace.rc file, that might be all that needs to be done for it. Then it would be available to the game engine. See the snippet in voicerec.cpp that looks for it.

freespace2/resources/win/freespace.rc:IDR_CMD_CFG SRGRAMMAR DISCARDABLE "code\sound\phrases.cfg"

		// user defined ("SRGRAMMAR") resource type.
		hr = p_grammarObject->LoadCmdFromFile(L"data\\phrases.xml", SPLO_STATIC);
		if (FAILED(hr))
		{
			hr = p_grammarObject->LoadCmdFromResource(NULL, MAKEINTRESOURCEW(command_resource),
												L"SRGRAMMAR", MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL),
												SPLO_STATIC);
			if (FAILED(hr))
			{
				os::dialogs::Message(os::dialogs::MESSAGEBOX_ERROR,"Failed to load resource SRGRAMMAR\n","Error");
				break;
			}
		}

chief1983 avatar Nov 28 '19 18:11 chief1983

Of course phrases.cfg is referenced. The problem is generating it in the first place, and the project or solution should have a step that does that.

Here is what that step looked like in code.vcproj in Visual Studio 2005:

			<File
				RelativePath="..\..\code\sound\phrases.xml"
				>
				<FileConfiguration
					Name="Debug|Win32"
					>
					<Tool
						Name="VCCustomBuildTool"
						CommandLine="&quot;$(InputDir)gc&quot; &quot;$(InputDir)$(InputName)&quot;&#x0D;&#x0A;&quot;$(InputDir)gc&quot; /h &quot;$(InputDir)grammar.h&quot; &quot;$(InputDir)$(InputName)&quot;&#x0D;&#x0A;"
						Outputs="$(InputDir)phrases.cfg;$(InputDir)grammar.h"
					/>
				</FileConfiguration>
				<FileConfiguration
					Name="Release|Win32"
					>
					<Tool
						Name="VCCustomBuildTool"
						CommandLine="&quot;$(InputDir)gc&quot; &quot;$(InputDir)$(InputName)&quot;&#x0D;&#x0A;&quot;$(InputDir)gc&quot; /h &quot;$(InputDir)grammar.h&quot; &quot;$(InputDir)$(InputName)&quot;&#x0D;&#x0A;"
						Outputs="$(InputDir)phrases.cfg;$(InputDir)grammar.h"
					/>
				</FileConfiguration>
			</File>

Goober5000 avatar Nov 28 '19 18:11 Goober5000

Perhaps CMake itself is what is supposed to run the gc.exe step so VS doesn't have to?

chief1983 avatar Nov 28 '19 19:11 chief1983

I doubt it. The purpose of CMake is to set up a project for VS. It is then VS that does the actual building, including custom build steps.

Goober5000 avatar Nov 29 '19 03:11 Goober5000

Searching through the project files for references to 'phrases' after generating the project files:

$ grep -i phrases */*.vcxproj
code/code.vcxproj:..\..\code\sound\gc.exe /o C:/Code/fs2_open/build/generated_source/code/sound/phrases.cfg /h C:/Code/fs2_open/build/generated_source/code/sound/grammar.h C:/Code/fs2_open/code/sound/phrases.xml
code/code.vcxproj:      <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">C:\Code\fs2_open\code\sound\phrases.xml;%(AdditionalInputs)</AdditionalInputs>
code/code.vcxproj:      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">C:\Code\fs2_open\build\generated_source\code\sound\grammar.h;C:\Code\fs2_open\build\generated_source\code\sound\phrases.cfg</Outputs>
code/code.vcxproj:..\..\code\sound\gc.exe /o C:/Code/fs2_open/build/generated_source/code/sound/phrases.cfg /h C:/Code/fs2_open/build/generated_source/code/sound/grammar.h C:/Code/fs2_open/code/sound/phrases.xml
code/code.vcxproj:      <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">C:\Code\fs2_open\code\sound\phrases.xml;%(AdditionalInputs)</AdditionalInputs>
code/code.vcxproj:      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">C:\Code\fs2_open\build\generated_source\code\sound\grammar.h;C:\Code\fs2_open\build\generated_source\code\sound\phrases.cfg</Outputs>
code/code.vcxproj:..\..\code\sound\gc.exe /o C:/Code/fs2_open/build/generated_source/code/sound/phrases.cfg /h C:/Code/fs2_open/build/generated_source/code/sound/grammar.h C:/Code/fs2_open/code/sound/phrases.xml
code/code.vcxproj:      <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='FastDebug|Win32'">C:\Code\fs2_open\code\sound\phrases.xml;%(AdditionalInputs)</AdditionalInputs>
code/code.vcxproj:      <Outputs Condition="'$(Configuration)|$(Platform)'=='FastDebug|Win32'">C:\Code\fs2_open\build\generated_source\code\sound\grammar.h;C:\Code\fs2_open\build\generated_source\code\sound\phrases.cfg</Outputs>
code/code.vcxproj:    <XML Include="C:\Code\fs2_open\code\sound\phrases.xml" />
code/code.vcxproj:    <None Include="C:\Code\fs2_open\build\generated_source\code\sound\phrases.cfg" />
code/code_pch_pre.vcxproj:..\..\code\sound\gc.exe /o C:/Code/fs2_open/build/generated_source/code/sound/phrases.cfg /h C:/Code/fs2_open/build/generated_source/code/sound/grammar.h C:/Code/fs2_open/code/sound/phrases.xml
code/code_pch_pre.vcxproj:      <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">C:\Code\fs2_open\code\sound\phrases.xml;%(AdditionalInputs)</AdditionalInputs>
code/code_pch_pre.vcxproj:      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">C:\Code\fs2_open\build\generated_source\code\sound\grammar.h;C:\Code\fs2_open\build\generated_source\code\sound\phrases.cfg</Outputs>
code/code_pch_pre.vcxproj:..\..\code\sound\gc.exe /o C:/Code/fs2_open/build/generated_source/code/sound/phrases.cfg /h C:/Code/fs2_open/build/generated_source/code/sound/grammar.h C:/Code/fs2_open/code/sound/phrases.xml
code/code_pch_pre.vcxproj:      <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">C:\Code\fs2_open\code\sound\phrases.xml;%(AdditionalInputs)</AdditionalInputs>
code/code_pch_pre.vcxproj:      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">C:\Code\fs2_open\build\generated_source\code\sound\grammar.h;C:\Code\fs2_open\build\generated_source\code\sound\phrases.cfg</Outputs>
code/code_pch_pre.vcxproj:..\..\code\sound\gc.exe /o C:/Code/fs2_open/build/generated_source/code/sound/phrases.cfg /h C:/Code/fs2_open/build/generated_source/code/sound/grammar.h C:/Code/fs2_open/code/sound/phrases.xml
code/code_pch_pre.vcxproj:      <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='FastDebug|Win32'">C:\Code\fs2_open\code\sound\phrases.xml;%(AdditionalInputs)</AdditionalInputs>
code/code_pch_pre.vcxproj:      <Outputs Condition="'$(Configuration)|$(Platform)'=='FastDebug|Win32'">C:\Code\fs2_open\build\generated_source\code\sound\grammar.h;C:\Code\fs2_open\build\generated_source\code\sound\phrases.cfg</Outputs>
code/code_pch_pre.vcxproj:      <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">C:\Code\fs2_open\build\generated_source\code\sound\grammar.h;C:\Code\fs2_open\build\generated_source\code\sound\phrases.cfg;%(AdditionalInputs)</AdditionalInputs>
code/code_pch_pre.vcxproj:      <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">C:\Code\fs2_open\build\generated_source\code\sound\grammar.h;C:\Code\fs2_open\build\generated_source\code\sound\phrases.cfg;%(AdditionalInputs)</AdditionalInputs>
code/code_pch_pre.vcxproj:      <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='FastDebug|Win32'">C:\Code\fs2_open\build\generated_source\code\sound\grammar.h;C:\Code\fs2_open\build\generated_source\code\sound\phrases.cfg;%(AdditionalInputs)</AdditionalInputs>

chief1983 avatar Nov 29 '19 03:11 chief1983

Seeing this path: C:\Code\fs2_open\build\generated_source\code\sound\phrases.cfg

I checked that after starting a Build Solution and see grammar.h and phrases.cfg there. So it's working as expected still, as far as I can tell.

chief1983 avatar Nov 29 '19 03:11 chief1983

I have the following items checked under the VS installer's Individual Components -> SDKs section:

VC++ ATL for x86 and x64 VC++ MFC for ... Windows 10 SDK 10.0.14393.0 Windows 10 SDK (10.0.16299.0) for Desktop C++ (x86, x64) Windows 10 SDK (10.0.16299.0) for UWP: C#, VB, JS (not actually sure why, may be a dependency of the others) Windows 10 SDK (10.0.16299.0) for UWP: C++

I am not sure all of those are needed, but I'm fairly certain at least one of the Windows SDKs is.

chief1983 avatar Nov 29 '19 03:11 chief1983

Here is a copy of my .vsconfig file exported by the VS installer, it is a lot simpler than I thought it was going to be.

chief1983.vsconfig.txt

chief1983 avatar Nov 29 '19 03:11 chief1983

@Kiloku has this been figured out?

Goober5000 avatar Dec 23 '19 17:12 Goober5000

Not that I'm aware of.

I haven't tried reinstalling Visual Studio with chief's configs, as I work from home and I use VS for work.

Kiloku avatar Dec 24 '19 00:12 Kiloku

@Kiloku Has this been resolved?

z64555 avatar Nov 11 '20 16:11 z64555

What about the git submodule update --init --recursive step? It's easy to forget to run that on a freshly cloned repository.

Goober5000 avatar Nov 11 '20 17:11 Goober5000

I apologize for never giving an update, but I don't remember ever getting it to work with FSO_USE_VOICEREC.
I don't have a build environment set up anymore, so I can't test it again.

Kiloku avatar Nov 11 '20 20:11 Kiloku