yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
f65d756bf
master
1#ifndef SLANG_INCLUDE_SYSTEM_H 2#define SLANG_INCLUDE_SYSTEM_H 3// slang-include-system.h 4 5#include "../compiler-core/slang-source-loc.h" 6 7namespace Slang 8{ 9 10// A directory to be searched when looking for files (e.g., `#include`) 11struct SearchDirectory 12{ 13SearchDirectory ()= default ; 14SearchDirectory (SearchDirectory const & other )= default ; 15SearchDirectory (String const & path ) 16 :path (path ) 17 { 18 } 19SearchDirectory & operator = (SearchDirectory const & other )= default ; 20 21String path ; 22}; 23 24/// A list of directories to search for files (e.g., `#include`) 25struct SearchDirectoryList 26{ 27// A parent list that should also be searched 28SearchDirectoryList * parent = nullptr; 29 30// Directories to be searched 31List < SearchDirectory > searchDirectories ; 32}; 33 34/* A helper class that builds basic include handling on top of searchDirectories/fileSystemExt and 35* optionally a sourceManager */ 36struct IncludeSystem 37{ 38SlangResult findFile ( 39const String & pathToInclude , 40const String & pathIncludedFrom , 41PathInfo & outPathInfo ); 42SlangResult findFile ( 43SlangPathType fromPathType , 44const String & fromPath , 45const String & path , 46PathInfo & outPathInfo ); 47String simplifyPath (const String & path ); 48SlangResult loadFile ( 49const PathInfo & pathInfo , 50ComPtr < ISlangBlob >& outBlob , 51SourceFile *& outSourceFile ); 52inline SlangResult loadFile (const PathInfo & pathInfo ,ComPtr < ISlangBlob >& outBlob ) 53 { 54SourceFile * sourceFile ; 55return loadFile (pathInfo ,outBlob ,sourceFile ); 56 } 57 58SlangResult findAndLoadFile ( 59const String & pathToInclude , 60const String & pathIncludedFrom , 61PathInfo & outPathInfo , 62ComPtr < ISlangBlob >& outBlob ); 63 64SearchDirectoryList * getSearchDirectoryList ()const {return m_searchDirectories ; } 65ISlangFileSystemExt * getFileSystem ()const {return m_fileSystemExt ; } 66SourceManager * getSourceManager ()const {return m_sourceManager ; } 67 68/// Ctor 69IncludeSystem ()= default ; 70IncludeSystem ( 71SearchDirectoryList * searchDirectories , 72ISlangFileSystemExt * fileSystemExt , 73SourceManager * sourceManager = nullptr ); 74 75protected : 76SearchDirectoryList * m_searchDirectories ; 77ISlangFileSystemExt * m_fileSystemExt ; 78SourceManager * 79m_sourceManager ;///< If not set, will not look up the content in the source manager 80}; 81 82}// namespace Slang 83 84#endif // SLANG_INCLUDE_HANDLER_H