public CppInclusionContextResult CreateInclusionContextResult(CppGlobalSymbolCache cache, CppFileLocation rootFile, FileProcessingOptions options, long cacheVersion, Lifetime lifetime) { var locationTracker = cache.Solution.GetComponent <InjectedHlslFileLocationTracker>(); if (!locationTracker.IsValid(rootFile)) { return(CppInclusionContextResult.Fail(CppInclusionContextResult.Status.UNSUITABLE_PROJECT_FILE)); } var properties = new CppCompilationProperties() { LanguageKind = CppLanguageKind.HLSL, ClrSupport = VCXCompileAsManagedOptions.ManagedNotSet, }; var cgIncludeFolder = CgIncludeDirectoryTracker.GetCgIncludeFolderPath(cache.Solution.GetComponent <UnityVersion>()); if (!cgIncludeFolder.IsEmpty) { properties.IncludePaths.Add(cgIncludeFolder); } properties.IncludePaths.Add(cache.Solution.SolutionDirectory); return(CreateInclusionContextResult(cache, rootFile, options, properties, null, cacheVersion, lifetime)); }
public CppInclusionContextResult CreateInclusionContextResult(CppGlobalSymbolCache cache, CppFileLocation rootFile, FileProcessingOptions options, long cacheVersion, Lifetime lifetime) { var locationTracker = cache.Solution.GetComponent <ShaderLabCppFileLocationTracker>(); if (!locationTracker.IsValid(rootFile)) { return(CppInclusionContextResult.Fail(CppInclusionContextResult.Status.UNSUITABLE_PROJECT_FILE)); } var properties = new CppCompilationProperties() { LanguageKind = CppLanguageKind.HLSL, ClrSupport = VCXCompileAsManagedOptions.ManagedNotSet, }; var cgIncludeFolder = CgIncludeDirectoryTracker.GetCgIncludeFolderPath(cache.Solution.GetComponent <UnityVersion>()); if (!cgIncludeFolder.IsEmpty) { properties.IncludePaths.Add(cgIncludeFolder); } var shaderCache = cache.Solution.GetComponent <ShaderLabCppFileLocationTracker>(); // TODO 1) is cache ready? what will happen under document transaction? check for bad moment? // TODO 2) what will happen under psi transaction? include in cache could be out-of date. Try use include quickfix when cginclude is after cgprogram where QF is used var includeLocation = shaderCache.GetIncludes(rootFile); return(InjectInclusionContextProviderUtil.CreateInclusionContextResult(cache, rootFile, includeLocation, options, properties, null, cacheVersion, lifetime)); }
public static CppInclusionContextResult CreateInclusionContextResult( CppGlobalSymbolCache cache, CppFileLocation rootFile, IEnumerable <CppFileLocation> includeLocations, FileProcessingOptions options, CppCompilationProperties compilationProperties, ISymbolScope symbolScope, long cacheVersion, Lifetime lifetime) { var languageDialect = CppProjectConfigurationUtil.GetLanguageDialect(compilationProperties); var randomProjectFile = rootFile.GetRandomProjectFile(cache.Solution); var inclusionContext = CppRootInclusionContext.Create(compilationProperties, randomProjectFile.GetProject(), randomProjectFile, cache, rootFile, options.File, languageDialect, cacheVersion, options.AllowPendingActions, options.CollectPPUsages, lifetime, symbolScope); var directory = randomProjectFile.Location.Directory; inclusionContext.ProcessDefine(CppPPDefineSymbol.ParsePredefinedMacro("SHADER_API_D3D11")); inclusionContext.ProcessDefine(CppPPDefineSymbol.ParsePredefinedMacro("__RESHARPER__")); inclusionContext.ProcessDefine(CppPPDefineSymbol.ParsePredefinedMacro("INTERNAL_DATA= ")); inclusionContext.ProcessDefine(CppPPDefineSymbol.ParsePredefinedMacro("WorldReflectionVector(data,normal)=data.worldRefl")); inclusionContext.ProcessDefine(CppPPDefineSymbol.ParsePredefinedMacro("WorldNormalVector(data,normal)=normal")); inclusionContext.PushInclude(rootFile, directory, false); foreach (CppFileLocation includeLocation in includeLocations) { if (includeLocation.IsValid() && !includeLocation.Equals(rootFile)) { cache.LookupAndProcessTableForFile(rootFile, includeLocation, options, inclusionContext, directory); } } inclusionContext.PopInclude(false); return(CppInclusionContextResult.Ok(inclusionContext)); }
public static CppInclusionContextResult CreateInclusionContextResult( CppGlobalSymbolCache cache, CppFileLocation rootFile, FileProcessingOptions options, CppCompilationProperties compilationProperties, ISymbolScope symbolScope, long cacheVersion, Lifetime lifetime) { var languageDialect = CppProjectConfigurationUtil.GetLanguageDialect(compilationProperties); var randomProjectFile = rootFile.GetRandomProjectFile(cache.Solution); var inclusionContext = CppRootInclusionContext.Create(compilationProperties, randomProjectFile.GetProject(), randomProjectFile, cache, rootFile, options.File, languageDialect, cacheVersion, options.AllowPendingActions, options.CollectPPUsages, lifetime, symbolScope); var directory = randomProjectFile.Location.Directory; var shaderCache = cache.Solution.GetComponent <InjectedHlslFileLocationTracker>(); var(includes, defines) = shaderCache.GetProgramInfo(rootFile); inclusionContext.ProcessDefine(CppPPDefineSymbol.ParsePredefinedMacro("SHADER_API_D3D11")); inclusionContext.ProcessDefine(CppPPDefineSymbol.ParsePredefinedMacro("__RESHARPER__")); inclusionContext.ProcessDefine(CppPPDefineSymbol.ParsePredefinedMacro("INTERNAL_DATA= ")); inclusionContext.ProcessDefine(CppPPDefineSymbol.ParsePredefinedMacro("WorldReflectionVector(data,normal)=data.worldRefl")); inclusionContext.ProcessDefine(CppPPDefineSymbol.ParsePredefinedMacro("WorldNormalVector(data,normal)=normal")); foreach (var define in defines) { inclusionContext.ProcessDefine(CppPPDefineSymbol.ParsePredefinedMacro($"{define.Key}={define.Value}")); } // TODO 1) is cache ready? what will happen under document transaction? check for bad moment? // TODO 2) what will happen under psi transaction? include in cache could be out-of date. Try use include quickfix when cginclude is after cgprogram where QF is used inclusionContext.PushInclude(rootFile, directory, false); foreach (CppFileLocation includeLocation in includes) { if (includeLocation.IsValid() && !includeLocation.Equals(rootFile)) { cache.LookupAndProcessTableForFile(rootFile, includeLocation, options, inclusionContext, directory); } } inclusionContext.PopInclude(false); return(CppInclusionContextResult.Ok(inclusionContext)); }
public CppCompilationProperties GetCompilationProperties(IProject project, IProjectFile projectFile, CppFileLocation rootFile, CppGlobalSymbolCache globalCache) { if (project.IsUnityProject() && CppProjectFileType.ALL_HLSL_EXTENSIONS.Contains(rootFile.Location.ExtensionWithDot)) { var properties = new CppCompilationProperties(); properties.LanguageKind = CppLanguageKind.HLSL; var path = CgIncludeDirectoryTracker.GetCgIncludeFolderPath(myUnityVersion); if (!path.IsEmpty) { properties.IncludePaths.Add(path); } return(properties); } return(null); }
public CppCompilationProperties GetCompilationProperties(IProject project, IProjectFile projectFile, CppFileLocation rootFile, CppGlobalSymbolCache globalCache) { if (project.IsUnityProject() && CppProjectFileType.ALL_HLSL_EXTENSIONS.Contains(rootFile.Location.ExtensionWithDot)) { var properties = new CppCompilationProperties(); properties.LanguageKind = CppLanguageKind.HLSL; var path = CgIncludeDirectoryTracker.GetCgIncludeFolderPath(myUnityVersion); if (!path.IsEmpty) { properties.IncludePaths.Add(path); } properties.ForcedIncludes.Add(globalCache.Solution.SolutionDirectory.Combine(Utils.ShaderConfigFile).FullPath); properties.PredefinedMacros.Add(CppPPDefineSymbol.ParsePredefinedMacro("SHADER_API_D3D11")); properties.IncludePaths.Add(globalCache.Solution.SolutionDirectory); return(properties); } return(null); }