[SymbolGraph] Add macCatalyst compatibility

- Add `setDefaultPrebuiltCacheIfNecessary` a `CompilerInvocation` method
- Call that while setting up the invocation in `swift-symbolgraph-extract`
- Add `Fsystem` argument to add iOSSupport directory to the search paths
- Add `resource-dir` argument for local builds

rdar://59262057
This commit is contained in:
Ashley Garland
2020-03-12 10:47:12 -07:00
parent d23082ff44
commit 8f96f67581
3 changed files with 30 additions and 15 deletions

View File

@@ -38,6 +38,10 @@ static llvm::cl::list<std::string>
FrameworkSearchPaths("F", llvm::cl::desc("Add a directory to the framework search paths"), llvm::cl::ZeroOrMore,
llvm::cl::cat(Category));
static llvm::cl::list<std::string>
SystemFrameworkSearchPaths("Fsystem", llvm::cl::desc("Add directory to system framework search path"), llvm::cl::ZeroOrMore,
llvm::cl::cat(Category));
static llvm::cl::list<std::string>
LibrarySearchPaths("L", llvm::cl::desc("Add a directory to the library search paths"), llvm::cl::ZeroOrMore,
llvm::cl::cat(Category));
@@ -75,6 +79,11 @@ static llvm::cl::list<std::string>
Xcc("Xcc", llvm::cl::desc("Pass the following command-line flag to Clang"),
llvm::cl::cat(Category));
static llvm::cl::opt<std::string>
ResourceDir("resource-dir",
llvm::cl::desc("Override the directory that holds the compiler resource files"),
llvm::cl::cat(Category));
static llvm::cl::opt<std::string>
OutputDir("output-dir", llvm::cl::desc("Symbol Graph JSON Output Directory (Required)"), llvm::cl::cat(Category));
} // end namespace options
@@ -132,6 +141,9 @@ int swift_symbolgraph_extract_main(ArrayRef<const char *> Args, const char *Argv
Invocation.setMainExecutablePath(
llvm::sys::fs::getMainExecutable(Argv0, MainAddr));
Invocation.setModuleName("swift_symbolgraph_extract");
if (!options::ResourceDir.empty()) {
Invocation.setRuntimeResourcePath(options::ResourceDir);
}
Invocation.setSDKPath(options::SDK);
Invocation.setTargetTriple(options::Target);
@@ -143,6 +155,9 @@ int swift_symbolgraph_extract_main(ArrayRef<const char *> Args, const char *Argv
for (const auto &Path : options::FrameworkSearchPaths) {
FrameworkSearchPaths.push_back({ Path, /*isSystem*/ false});
}
for (const auto &Path : options::SystemFrameworkSearchPaths) {
FrameworkSearchPaths.push_back({ Path, /*isSystem*/ true });
}
Invocation.setFrameworkSearchPaths(FrameworkSearchPaths);
Invocation.getSearchPathOptions().LibrarySearchPaths = options::LibrarySearchPaths;
Invocation.setImportSearchPaths(options::ImportSearchPaths);
@@ -154,6 +169,7 @@ int swift_symbolgraph_extract_main(ArrayRef<const char *> Args, const char *Argv
Invocation.setClangModuleCachePath(options::ModuleCachePath);
Invocation.getClangImporterOptions().ModuleCachePath = options::ModuleCachePath;
Invocation.setDefaultPrebuiltCacheIfNecessary();
if (!options::SwiftVersion.empty()) {
using version::Version;