20
20
#include " swift/AST/FileSystem.h"
21
21
#include " swift/AST/Module.h"
22
22
#include " swift/Basic/Platform.h"
23
+ #include " swift/Basic/StringExtras.h"
23
24
#include " swift/Frontend/Frontend.h"
24
25
#include " swift/Frontend/ModuleInterfaceSupport.h"
25
26
#include " swift/Parse/ParseVersion.h"
@@ -227,6 +228,7 @@ struct ModuleRebuildInfo {
227
228
NotIgnored,
228
229
PublicFramework,
229
230
InterfacePreferred,
231
+ CompilerHostModule,
230
232
};
231
233
struct CandidateModule {
232
234
std::string path;
@@ -698,7 +700,28 @@ class ModuleInterfaceLoaderImpl {
698
700
bool isInResourceDir (StringRef path) {
699
701
StringRef resourceDir = ctx.SearchPathOpts .RuntimeResourcePath ;
700
702
if (resourceDir.empty ()) return false ;
701
- return path.startswith (resourceDir);
703
+ return pathStartsWith (resourceDir, path);
704
+ }
705
+
706
+ bool isInResourceHostDir (StringRef path) {
707
+ StringRef resourceDir = ctx.SearchPathOpts .RuntimeResourcePath ;
708
+ if (resourceDir.empty ()) return false ;
709
+
710
+ SmallString<128 > hostPath;
711
+ llvm::sys::path::append (hostPath,
712
+ resourceDir, " host" );
713
+ return pathStartsWith (hostPath, path);
714
+ }
715
+
716
+ bool isInSystemFrameworks (StringRef path) {
717
+ StringRef sdkPath = ctx.SearchPathOpts .getSDKPath ();
718
+ if (sdkPath.empty ()) return false ;
719
+
720
+ SmallString<128 > publicFrameworksPath;
721
+ llvm::sys::path::append (publicFrameworksPath,
722
+ sdkPath, " System" , " Library" , " Frameworks" );
723
+
724
+ return pathStartsWith (publicFrameworksPath, path);
702
725
}
703
726
704
727
std::pair<std::string, std::string> getCompiledModuleCandidates () {
@@ -713,10 +736,12 @@ class ModuleInterfaceLoaderImpl {
713
736
llvm::sys::path::append (publicFrameworksPath,
714
737
ctx.SearchPathOpts .getSDKPath (),
715
738
" System" , " Library" , " Frameworks" );
716
- if (!ctx.SearchPathOpts .getSDKPath ().empty () &&
717
- modulePath.startswith (publicFrameworksPath)) {
739
+ if (isInSystemFrameworks (modulePath)) {
718
740
shouldLoadAdjacentModule = false ;
719
741
rebuildInfo.addIgnoredModule (modulePath, ReasonIgnored::PublicFramework);
742
+ } else if (isInResourceHostDir (modulePath)) {
743
+ shouldLoadAdjacentModule = false ;
744
+ rebuildInfo.addIgnoredModule (modulePath, ReasonIgnored::CompilerHostModule);
720
745
}
721
746
722
747
switch (loadMode) {
0 commit comments