I’ve tried to do that in many ways without success, but finally nailed it!
This works for engine modules:
using System.IO; // Note this import, it's needed below
namespace UnrealBuildTool.Rules
{
public class Foo : ModuleRules
{
public Foo(TargetInfo Target)
{
// ...
// Get the engine path. Ends with "Engine/"
string engine_path = Path.GetFullPath(BuildConfiguration.RelativeEnginePath);
// Now get the base of UE4's modules dir (could also be Developer, Editor, ThirdParty)
string srcrt_path = engine_path + "Source/Runtime/";
// now you can include the module's private paths!
// as an example, you can expose UE4's abstraction of D3D11, located in Source/Runtime/Windows/D3D11RHI
PublicIncludePaths.Add(srcrt_path + "Windows/D3D11RHI/Private");
PublicIncludePaths.Add(srcrt_path + "Windows/D3D11RHI/Private/Windows");
}
}
}