From bb8ca272541d319013219a6d540b6a84f46efd11 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Thu, 23 Feb 2023 21:08:13 -0800 Subject: [PATCH] sil-opt: introduce `-vfsoverlay` to support Windows Add an option to `sil-opt` to pass along VFS overlay files to the clang importer. This is required to make the tests pass with the upcoming work to avoid modifying the Visual Studio installation and instead to prefer to inject the content via VFS overlays. --- include/swift/Frontend/Frontend.h | 4 ++++ tools/sil-opt/SILOpt.cpp | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/include/swift/Frontend/Frontend.h b/include/swift/Frontend/Frontend.h index bdfa5fa2c9c13..4ea8e4c963a40 100644 --- a/include/swift/Frontend/Frontend.h +++ b/include/swift/Frontend/Frontend.h @@ -188,6 +188,10 @@ class CompilerInvocation { return SearchPathOpts.getFrameworkSearchPaths(); } + void setVFSOverlays(const std::vector &Overlays) { + SearchPathOpts.VFSOverlayFiles = Overlays; + } + void setCompilerPluginLibraryPaths(const std::vector &Paths) { SearchPathOpts.setCompilerPluginLibraryPaths(Paths); } diff --git a/tools/sil-opt/SILOpt.cpp b/tools/sil-opt/SILOpt.cpp index 1142346c22600..c7dabc6075b82 100644 --- a/tools/sil-opt/SILOpt.cpp +++ b/tools/sil-opt/SILOpt.cpp @@ -86,6 +86,9 @@ ImportPaths("I", llvm::cl::desc("add a directory to the import search path")); static llvm::cl::list FrameworkPaths("F", llvm::cl::desc("add a directory to the framework search path")); +static llvm::cl::list +VFSOverlays("vfsoverlay", llvm::cl::desc("add a VFS overlay")); + static llvm::cl::opt ModuleName("module-name", llvm::cl::desc("The name of the module if processing" " a module. Necessary for processing " @@ -542,6 +545,9 @@ int main(int argc, char **argv) { FramePaths.push_back({path, /*isSystem=*/false}); } Invocation.setFrameworkSearchPaths(FramePaths); + + Invocation.setVFSOverlays(VFSOverlays); + // Set the SDK path and target if given. if (SDKPath.getNumOccurrences() == 0) { const char *SDKROOT = getenv("SDKROOT");