2019-12-26 23:08:00 -05:00
// Copyright Epic Games, Inc. All Rights Reserved.
2019-07-16 08:45:13 -04:00
using Microsoft.Win32 ;
using System.IO ;
2020-12-21 23:07:37 -04:00
using EpicGames.Core ;
2020-02-26 11:26:51 -05:00
using UnrealBuildTool ;
2019-07-16 08:45:13 -04:00
namespace UnrealBuildTool.Rules
{
public class VisualStudioDTE : ModuleRules
{
2020-02-24 15:45:01 -05:00
public VisualStudioDTE ( ReadOnlyTargetRules Target ) : base ( Target )
2019-07-16 08:45:13 -04:00
{
Type = ModuleType . External ;
2022-10-31 20:55:55 -04:00
PublicSystemIncludePaths . Add ( ModuleDirectory ) ;
2019-07-16 08:45:13 -04:00
2020-02-26 11:26:51 -05:00
if ( Target . Platform ! = UnrealBuildTool . UnrealTargetPlatform . Win64 | |
2022-07-06 15:06:26 -04:00
Target . StaticAnalyzer = = StaticAnalyzer . PVSStudio )
2019-07-16 08:45:13 -04:00
{
2020-02-25 12:26:06 -05:00
PublicDefinitions . Add ( "WITH_VISUALSTUDIO_DTE=0" ) ;
2019-07-16 08:45:13 -04:00
}
else
{
2020-02-25 12:26:06 -05:00
// In order to support building the plugin on build machines (which may not have the IDE installed), allow using an OLB rather than registered component.
string DteOlbPath ;
if ( TryGetDteOlbPath ( out DteOlbPath ) )
{
TypeLibraries . Add ( new TypeLibrary ( DteOlbPath , "lcid(\"0\") raw_interfaces_only named_guids" , "dte80a.tlh" ) ) ;
PublicDefinitions . Add ( "WITH_VISUALSTUDIO_DTE=1" ) ;
}
else
{
Log . TraceWarningOnce ( "Unable to find Visual Studio SDK. Editor integration will be disabled" ) ;
PublicDefinitions . Add ( "WITH_VISUALSTUDIO_DTE=0" ) ;
}
2019-07-16 08:45:13 -04:00
}
2020-02-24 15:45:01 -05:00
}
2019-10-11 15:33:31 -04:00
2020-02-24 15:45:01 -05:00
bool TryGetDteOlbPath ( out string OutDteOlbPath )
{
// Check AutoSDK for the type library
string AutoSdkDir = AutoSdkDirectory ;
if ( AutoSdkDir ! = null )
{
string AutoSdkDteOlbPath = Path . Combine ( AutoSdkDir , "Win64" , "VisualStudioDTE" , "dte80a.olb" ) ;
if ( File . Exists ( AutoSdkDteOlbPath ) )
{
OutDteOlbPath = AutoSdkDteOlbPath ;
return true ;
}
}
// Look in the registry for the appropriate type library
string RegistryPath = Registry . GetValue ( "HKEY_CLASSES_ROOT\\TypeLib\\{80CC9F66-E7D8-4DDD-85B6-D9E6CD0E93E2}\\8.0\\0\\win32" , null , null ) as string ;
if ( RegistryPath ! = null & & File . Exists ( RegistryPath ) )
{
OutDteOlbPath = RegistryPath ;
return true ;
}
// Fail
OutDteOlbPath = null ;
return false ;
2019-07-16 08:45:13 -04:00
}
}
}