ConfigCacheIni doesn't allow user-defined sections to be read from INIs anymore

I’m currently working on a plugin where I’d like to exclude some libraries in the Build.cs depending on an Ini setting defined on a RuntimeSettings class.

I’m doing something similar to the following:

bool bIncludeLibs = true;
FileReference ProjectFile;

if (UProjectInfo.TryGetProjectForTarget(ProjectID, out ProjectFile))
{
	ConfigCacheIni IniFile = ConfigCacheIni.CreateConfigCacheIni(Target.Platform, "Engine", DirectoryReference.FromFile(ProjectFile));
	bool bFound = IniFile.GetBool("/Script/MyAndroidPlugin.MyAndroidPluginRuntimeSettings", "bIncludeLibs", out bIncludeLibs);

	Log.TraceInformation("Should Include Libs?: {0} {1}", bIncludeLibs, bFound);

	if (!bFound)
		bIncludeLibs = true;
}

I found that bFound was always returning false and had no idea why.

After some digging i found in Engine\Source\Programs\UnrealBuildTool\Configuration\EngineConfiguration.cs there was a variable added called “RequiredSections” between 4.10 and 4.11.

Now in 4.11 there is a check in FindOrAddSection() (which is used to parse an ini section) that only allows sections defined here to be parsed.

Is this intended? This seems sorely limiting.

I should also mention this has broken your own code as well. The “OnlineSubsystemGooglePlay.Store” used for Android IAP is not in this list, so it breaks the code in Engine\Source\Programs\UnrealBuildTool\Android\UEDeployAndroid.cs

If this is now expected behaviour, what is the alternative? (if any)

Cheers.

Hey FacePalm.exe,

On the surface it does look like there might be a an oversight in the way the FIndOrAddSection( ) handles parsing a ini section.

Because I am not 100% sure how you are using the Game.Build.cs file to parse the .ini file(s), can you provide me with a more thorough code example of what you are doing?

Thanks.

Sure. Find the entire Build.cs attached here.

The main reason for this is because we want to create 2 different apk’s.

One with the libs and one without. We can’t just disable the plugin, as the plugin contains blueprint nodes (so cooking breaks if we disable it…)

I’ve worked around it locally by just adding my section to the ‘RequiredSections’ It’s a half-■■■■■ solution for now.

Hello FacePalm.exe,

I apologize for the delay. I’ve just taken a look at this and checked the FindOrAddSection() function in 4.12 and 4.13. It seems that the check for RequiredSection is gone from this function in these versions, when comparing it to the 4.11 version. Can you confirm if this is still occurring in these newer versions or not?

So adding my code to 4.13 I now get the build exception: “Section Name - X - is not being cached. Add the specific section to the RequiredSections list in EngineConfiguration.cs” defined in FindSection() in EngineConfiguration.cs

This means that I have to modify Engine code for a Game module level plugin, which is not great.

I’m assuming i’ll have to do the following which is done in Engine\Source\Programs\UnrealBuildTool\System\UnrealPluginLanguage.cs?

// note: use our own ConfigCacheIni since EngineConfiguration.cs only parses RequiredSections!
config = ConfigCacheIni_UPL.CreateConfigCacheIni_UPL(TargetPlatform, baseIniName, DirectoryReference.FromFile(ProjectFile));
ConfigCache.Add(baseIniName, config);

If so, then this is so-so. I havn’t gone and tested that, however i’m assuming this is the correct way to do it. (basically write my own config reading system like ConfigCacheIni_UPL) I’d like to be able to use an existing system, but at least I know this is possible.

It does seem like that is the intended workflow at this point, especially due to that comment in UnrealPluginLanguage.cs.