From 69d2651056137eb7c6e542491ae5fd59af095022 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Sat, 2 Mar 2019 08:22:38 -0500 Subject: #include not using search paths (#873) * Fix warnings from visual studio due to coercion losing data. * Removed searchDirectories from FrontEndCompileRequest and use the one in Linkage as that is the one that is changed via Slang API. * * Add searchPaths back to FrontEndRequest * Add comments to explain the issue * Add a test to check include paths --- source/slang/compiler.h | 2 ++ source/slang/slang.cpp | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'source') 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 languageScope; switch (translationUnit->sourceLanguage) -- cgit v1.2.3