summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--source/slang/compiler.h2
-rw-r--r--source/slang/slang.cpp14
-rw-r--r--tests/preprocessor/include-search-path.slang13
-rw-r--r--tools/render-test/slang-support.cpp8
4 files changed, 31 insertions, 6 deletions
diff --git a/source/slang/compiler.h b/source/slang/compiler.h
index 843cae1b3..27728bc84 100644
--- a/source/slang/compiler.h
+++ b/source/slang/compiler.h
@@ -791,6 +791,8 @@ namespace Slang
FrontEndEntryPointRequest* getEntryPointReq(UInt index) { return m_entryPointReqs[index]; }
// Directories to search for `#include` files or `import`ed modules
+ // NOTE! That for now these search directories are not settable via the API
+ // so the search directories on Linkage is used for #include as well as for modules.
SearchDirectoryList searchDirectories;
SearchDirectoryList const& getSearchDirectories() { return searchDirectories; }
diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp
index 0bba68aa6..c6946a93d 100644
--- a/source/slang/slang.cpp
+++ b/source/slang/slang.cpp
@@ -587,8 +587,18 @@ void FrontEndCompileRequest::parseTranslationUnit(
TranslationUnitRequest* translationUnit)
{
IncludeHandlerImpl includeHandler;
- includeHandler.linkage = getLinkage();
- includeHandler.searchDirectories = &searchDirectories;
+
+ auto linkage = getLinkage();
+
+ // TODO(JS): NOTE! Here we are using the searchDirectories on the linkage. This is because
+ // currently the API only allows the setting search paths on linkage.
+ //
+ // Here we should probably be using the searchDirectories on the FrontEndCompileRequest.
+ // If searchDirectories.parent pointed to the one in the Linkage would mean linkage paths
+ // would be checked too (after those on the FrontEndCompileRequest).
+
+ includeHandler.linkage = linkage;
+ includeHandler.searchDirectories = &linkage->searchDirectories;
RefPtr<Scope> languageScope;
switch (translationUnit->sourceLanguage)
diff --git a/tests/preprocessor/include-search-path.slang b/tests/preprocessor/include-search-path.slang
new file mode 100644
index 000000000..77781b7bc
--- /dev/null
+++ b/tests/preprocessor/include-search-path.slang
@@ -0,0 +1,13 @@
+//TEST:SIMPLE: -Itests/preprocessor/include
+// #include support
+
+int foo() { return 0; }
+
+#include "pragma-once-c.h"
+
+// If include worked this will be defined
+#ifndef ONLY_DEFINED_ONCE_C
+// And so hitting this indicates and error (and will fail as bar isn't defined)
+int baz() { return bar(); }
+#endif
+
diff --git a/tools/render-test/slang-support.cpp b/tools/render-test/slang-support.cpp
index f3042828f..269df5a69 100644
--- a/tools/render-test/slang-support.cpp
+++ b/tools/render-test/slang-support.cpp
@@ -105,16 +105,16 @@ RefPtr<ShaderProgram> ShaderCompiler::compileProgram(
for (auto typeName : request.entryPointGenericTypeArguments)
rawEntryPointTypeNames.Add(typeName.Buffer());
- UInt globalExistentialTypeCount = request.globalExistentialTypeArguments.Count();
- for( UInt ii = 0; ii < globalExistentialTypeCount; ++ii )
+ const int globalExistentialTypeCount = int(request.globalExistentialTypeArguments.Count());
+ for(int ii = 0; ii < globalExistentialTypeCount; ++ii )
{
spSetTypeNameForGlobalExistentialSlot(slangRequest, ii, request.globalExistentialTypeArguments[ii].Buffer());
}
- UInt entryPointExistentialTypeCount = request.entryPointExistentialTypeArguments.Count();
+ const int entryPointExistentialTypeCount = int(request.entryPointExistentialTypeArguments.Count());
auto setEntryPointExistentialTypeArgs = [&](int entryPoint)
{
- for( UInt ii = 0; ii < entryPointExistentialTypeCount; ++ii )
+ for( int ii = 0; ii < entryPointExistentialTypeCount; ++ii )
{
spSetTypeNameForEntryPointExistentialSlot(slangRequest, entryPoint, ii, request.entryPointExistentialTypeArguments[ii].Buffer());
}