From cb610113605f62e784b63012b31b751acb6fac72 Mon Sep 17 00:00:00 2001 From: skallweitNV <64953474+skallweitNV@users.noreply.github.com> Date: Thu, 27 Jun 2024 17:35:17 +0200 Subject: Add API for querying dependency files on IModule (#4493) * Add API for querying dependency files on IModule * return nullptr --- source/slang/slang-compiler.cpp | 12 ++++++++++++ source/slang/slang-compiler.h | 9 +++++++++ 2 files changed, 21 insertions(+) (limited to 'source/slang') diff --git a/source/slang/slang-compiler.cpp b/source/slang/slang-compiler.cpp index cee104dc9..e61c0f220 100644 --- a/source/slang/slang-compiler.cpp +++ b/source/slang/slang-compiler.cpp @@ -2471,6 +2471,18 @@ namespace Slang return nullptr; } + SLANG_NO_THROW SlangInt32 SLANG_MCALL Module::getDependencyFileCount() + { + return (SlangInt32)getFileDependencies().getCount(); + } + + SLANG_NO_THROW char const* SLANG_MCALL Module::getDependencyFilePath( + SlangInt32 index) + { + SourceFile* sourceFile = getFileDependencies()[index]; + return sourceFile->getPathInfo().hasFoundPath() ? sourceFile->getPathInfo().foundPath.getBuffer() : nullptr; + } + void validateEntryPoint( EntryPoint* entryPoint, DiagnosticSink* sink); diff --git a/source/slang/slang-compiler.h b/source/slang/slang-compiler.h index 056e6ea21..46724119b 100755 --- a/source/slang/slang-compiler.h +++ b/source/slang/slang-compiler.h @@ -1453,6 +1453,15 @@ namespace Slang /// Get the unique identity of the module. virtual SLANG_NO_THROW const char* SLANG_MCALL getUniqueIdentity() override; + /// Get the number of dependency files that this module depends on. + /// This includes both the explicit source files, as well as any + /// additional files that were transitively referenced (e.g., via + /// a `#include` directive). + virtual SLANG_NO_THROW SlangInt32 SLANG_MCALL getDependencyFileCount() override; + + /// Get the path to a file this module depends on. + virtual SLANG_NO_THROW char const* SLANG_MCALL getDependencyFilePath( + SlangInt32 index) override; virtual void buildHash(DigestBuilder& builder) SLANG_OVERRIDE; -- cgit v1.2.3