mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge pull request #82031 from artemcm/RemovePlaceholdersInDepScanner
[Dependency Scanning] Remove obsolete placeholder module concept
This commit is contained in:
@@ -36,7 +36,6 @@ typedef enum {
|
|||||||
// SwiftInterface and SwiftSource.
|
// SwiftInterface and SwiftSource.
|
||||||
SWIFTSCAN_DEPENDENCY_INFO_SWIFT_TEXTUAL = 0,
|
SWIFTSCAN_DEPENDENCY_INFO_SWIFT_TEXTUAL = 0,
|
||||||
SWIFTSCAN_DEPENDENCY_INFO_SWIFT_BINARY = 1,
|
SWIFTSCAN_DEPENDENCY_INFO_SWIFT_BINARY = 1,
|
||||||
SWIFTSCAN_DEPENDENCY_INFO_SWIFT_PLACEHOLDER = 2,
|
|
||||||
SWIFTSCAN_DEPENDENCY_INFO_CLANG = 3
|
SWIFTSCAN_DEPENDENCY_INFO_CLANG = 3
|
||||||
} swiftscan_dependency_info_kind_t;
|
} swiftscan_dependency_info_kind_t;
|
||||||
|
|
||||||
@@ -310,7 +309,8 @@ swiftscan_swift_binary_detail_get_module_cache_key(
|
|||||||
SWIFTSCAN_PUBLIC swiftscan_string_ref_t
|
SWIFTSCAN_PUBLIC swiftscan_string_ref_t
|
||||||
swiftscan_swift_binary_detail_get_user_module_version(
|
swiftscan_swift_binary_detail_get_user_module_version(
|
||||||
swiftscan_module_details_t details);
|
swiftscan_module_details_t details);
|
||||||
//=== Swift Placeholder Module Details query APIs -------------------------===//
|
|
||||||
|
//=== Swift Placeholder Module Details query APIs - DEPRECATED -----------===//
|
||||||
|
|
||||||
SWIFTSCAN_PUBLIC swiftscan_string_ref_t
|
SWIFTSCAN_PUBLIC swiftscan_string_ref_t
|
||||||
swiftscan_swift_placeholder_detail_get_compiled_module_path(
|
swiftscan_swift_placeholder_detail_get_compiled_module_path(
|
||||||
|
|||||||
@@ -360,14 +360,6 @@ ERROR(explicit_swift_module_map_corrupted,none,
|
|||||||
"explicit Swift module map from %0 is malformed",
|
"explicit Swift module map from %0 is malformed",
|
||||||
(StringRef))
|
(StringRef))
|
||||||
|
|
||||||
ERROR(placeholder_dependency_module_map_missing,none,
|
|
||||||
"cannot open Swift placeholder dependency module map from %0",
|
|
||||||
(StringRef))
|
|
||||||
|
|
||||||
ERROR(placeholder_dependency_module_map_corrupted,none,
|
|
||||||
"Swift placeholder dependency module map from %0 is malformed",
|
|
||||||
(StringRef))
|
|
||||||
|
|
||||||
ERROR(const_extract_protocol_list_input_file_missing,none,
|
ERROR(const_extract_protocol_list_input_file_missing,none,
|
||||||
"cannot open constant extraction protocol list input file from %0",
|
"cannot open constant extraction protocol list input file from %0",
|
||||||
(StringRef))
|
(StringRef))
|
||||||
|
|||||||
@@ -69,30 +69,7 @@ enum class ModuleDependencyKind : int8_t {
|
|||||||
Clang,
|
Clang,
|
||||||
// Used to model the translation unit's source module
|
// Used to model the translation unit's source module
|
||||||
SwiftSource,
|
SwiftSource,
|
||||||
// Placeholder dependencies are a kind of dependencies used only by the
|
LastKind = SwiftSource + 1
|
||||||
// dependency scanner. They are swift modules that the scanner will not be
|
|
||||||
// able to locate in its search paths and which are the responsibility of the
|
|
||||||
// scanner's client to ensure are provided.
|
|
||||||
//
|
|
||||||
// Placeholder dependencies will be specified in the scanner's output
|
|
||||||
// dependency graph where it is the responsibility of the scanner's client to
|
|
||||||
// ensure required post-processing takes place to "resolve" them. In order to
|
|
||||||
// do so, the client (swift driver, or any other client build system) is
|
|
||||||
// expected to have access to a full dependency graph of all placeholder
|
|
||||||
// dependencies and be able to replace placeholder nodes in the dependency
|
|
||||||
// graph with their full dependency trees, `uniquing` common dependency module
|
|
||||||
// nodes in the process.
|
|
||||||
//
|
|
||||||
// One example where placeholder dependencies are employed is when using
|
|
||||||
// SwiftPM in Explicit Module Build mode. SwiftPM constructs a build plan for
|
|
||||||
// all targets ahead-of-time. When planning a build for a target that depends
|
|
||||||
// on other targets, the dependency scanning action is not able to locate
|
|
||||||
// dependency target modules, because they have not yet been built. Instead,
|
|
||||||
// the build system treats them as placeholder dependencies and resolves them
|
|
||||||
// with `actual` dependencies in a post-processing step once dependency graphs
|
|
||||||
// of all targets, individually, have been computed.
|
|
||||||
SwiftPlaceholder,
|
|
||||||
LastKind = SwiftPlaceholder + 1
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// This is used to idenfity a specific macro plugin dependency.
|
/// This is used to idenfity a specific macro plugin dependency.
|
||||||
@@ -542,39 +519,6 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Describes an placeholder Swift module dependency module stub.
|
|
||||||
///
|
|
||||||
/// This class is mostly an implementation detail for \c ModuleDependencyInfo.
|
|
||||||
|
|
||||||
class SwiftPlaceholderModuleDependencyStorage
|
|
||||||
: public ModuleDependencyInfoStorageBase {
|
|
||||||
public:
|
|
||||||
SwiftPlaceholderModuleDependencyStorage(StringRef compiledModulePath,
|
|
||||||
StringRef moduleDocPath,
|
|
||||||
StringRef sourceInfoPath)
|
|
||||||
: ModuleDependencyInfoStorageBase(ModuleDependencyKind::SwiftPlaceholder, {}, {},
|
|
||||||
{}),
|
|
||||||
compiledModulePath(compiledModulePath), moduleDocPath(moduleDocPath),
|
|
||||||
sourceInfoPath(sourceInfoPath) {}
|
|
||||||
|
|
||||||
ModuleDependencyInfoStorageBase *clone() const override {
|
|
||||||
return new SwiftPlaceholderModuleDependencyStorage(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The path to the .swiftmodule file.
|
|
||||||
const std::string compiledModulePath;
|
|
||||||
|
|
||||||
/// The path to the .swiftModuleDoc file.
|
|
||||||
const std::string moduleDocPath;
|
|
||||||
|
|
||||||
/// The path to the .swiftSourceInfo file.
|
|
||||||
const std::string sourceInfoPath;
|
|
||||||
|
|
||||||
static bool classof(const ModuleDependencyInfoStorageBase *base) {
|
|
||||||
return base->dependencyKind == ModuleDependencyKind::SwiftPlaceholder;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// MARK: Module Dependency Info
|
// MARK: Module Dependency Info
|
||||||
/// Describes the dependencies of a given module.
|
/// Describes the dependencies of a given module.
|
||||||
///
|
///
|
||||||
@@ -675,16 +619,6 @@ public:
|
|||||||
CASFileSystemRootID, clangIncludeTreeRoot, moduleCacheKey, IsSystem));
|
CASFileSystemRootID, clangIncludeTreeRoot, moduleCacheKey, IsSystem));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Describe a placeholder dependency swift module.
|
|
||||||
static ModuleDependencyInfo
|
|
||||||
forPlaceholderSwiftModuleStub(StringRef compiledModulePath,
|
|
||||||
StringRef moduleDocPath,
|
|
||||||
StringRef sourceInfoPath) {
|
|
||||||
return ModuleDependencyInfo(
|
|
||||||
std::make_unique<SwiftPlaceholderModuleDependencyStorage>(
|
|
||||||
compiledModulePath, moduleDocPath, sourceInfoPath));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Retrieve the module-level imports.
|
/// Retrieve the module-level imports.
|
||||||
ArrayRef<ScannerImportStatementInfo> getModuleImports() const {
|
ArrayRef<ScannerImportStatementInfo> getModuleImports() const {
|
||||||
return storage->moduleImports;
|
return storage->moduleImports;
|
||||||
@@ -903,7 +837,7 @@ public:
|
|||||||
bool isTestableImport(StringRef moduleName) const;
|
bool isTestableImport(StringRef moduleName) const;
|
||||||
|
|
||||||
/// Whether the dependencies are for a Swift module: either Textual, Source,
|
/// Whether the dependencies are for a Swift module: either Textual, Source,
|
||||||
/// Binary, or Placeholder.
|
/// or Binary
|
||||||
bool isSwiftModule() const;
|
bool isSwiftModule() const;
|
||||||
|
|
||||||
/// Whether the dependencies are for a textual interface Swift module or a
|
/// Whether the dependencies are for a textual interface Swift module or a
|
||||||
@@ -919,9 +853,6 @@ public:
|
|||||||
/// Whether the dependencies are for a binary Swift module.
|
/// Whether the dependencies are for a binary Swift module.
|
||||||
bool isSwiftBinaryModule() const;
|
bool isSwiftBinaryModule() const;
|
||||||
|
|
||||||
/// Whether this represents a placeholder module stub
|
|
||||||
bool isSwiftPlaceholderModule() const;
|
|
||||||
|
|
||||||
/// Whether the dependencies are for a Clang module.
|
/// Whether the dependencies are for a Clang module.
|
||||||
bool isClangModule() const;
|
bool isClangModule() const;
|
||||||
|
|
||||||
@@ -940,10 +871,6 @@ public:
|
|||||||
/// Retrieve the dependencies for a Clang module.
|
/// Retrieve the dependencies for a Clang module.
|
||||||
const ClangModuleDependencyStorage *getAsClangModule() const;
|
const ClangModuleDependencyStorage *getAsClangModule() const;
|
||||||
|
|
||||||
/// Retrieve the dependencies for a placeholder dependency module stub.
|
|
||||||
const SwiftPlaceholderModuleDependencyStorage *
|
|
||||||
getAsPlaceholderDependencyModule() const;
|
|
||||||
|
|
||||||
/// Add a dependency on the given module, if it was not already in the set.
|
/// Add a dependency on the given module, if it was not already in the set.
|
||||||
void
|
void
|
||||||
addOptionalModuleImport(StringRef module, bool isExported,
|
addOptionalModuleImport(StringRef module, bool isExported,
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ struct swiftscan_dependency_info_s {
|
|||||||
/// "swiftInterface"
|
/// "swiftInterface"
|
||||||
/// "swiftSource"
|
/// "swiftSource"
|
||||||
/// "swiftBinary"
|
/// "swiftBinary"
|
||||||
/// "swiftPlaceholder"
|
|
||||||
/// "clang""
|
/// "clang""
|
||||||
swiftscan_string_ref_t module_name;
|
swiftscan_string_ref_t module_name;
|
||||||
|
|
||||||
@@ -192,19 +191,6 @@ typedef struct {
|
|||||||
swiftscan_string_ref_t user_module_version;
|
swiftscan_string_ref_t user_module_version;
|
||||||
} swiftscan_swift_binary_details_t;
|
} swiftscan_swift_binary_details_t;
|
||||||
|
|
||||||
/// Swift placeholder modules carry additional details that specify their
|
|
||||||
/// module doc path and source info paths.
|
|
||||||
typedef struct {
|
|
||||||
/// The path to the pre-compiled binary module
|
|
||||||
swiftscan_string_ref_t compiled_module_path;
|
|
||||||
|
|
||||||
/// The path to the .swiftModuleDoc file.
|
|
||||||
swiftscan_string_ref_t module_doc_path;
|
|
||||||
|
|
||||||
/// The path to the .swiftSourceInfo file.
|
|
||||||
swiftscan_string_ref_t module_source_info_path;
|
|
||||||
} swiftscan_swift_placeholder_details_t;
|
|
||||||
|
|
||||||
/// Clang modules are built from a module map file.
|
/// Clang modules are built from a module map file.
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/// The path to the module map used to build this module.
|
/// The path to the module map used to build this module.
|
||||||
@@ -231,7 +217,6 @@ struct swiftscan_module_details_s {
|
|||||||
union {
|
union {
|
||||||
swiftscan_swift_textual_details_t swift_textual_details;
|
swiftscan_swift_textual_details_t swift_textual_details;
|
||||||
swiftscan_swift_binary_details_t swift_binary_details;
|
swiftscan_swift_binary_details_t swift_binary_details;
|
||||||
swiftscan_swift_placeholder_details_t swift_placeholder_details;
|
|
||||||
swiftscan_clang_details_t clang_details;
|
swiftscan_clang_details_t clang_details;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -68,14 +68,12 @@ public:
|
|||||||
/// Construct a dependency scanning tool.
|
/// Construct a dependency scanning tool.
|
||||||
DependencyScanningTool();
|
DependencyScanningTool();
|
||||||
|
|
||||||
/// Collect the full module dependency graph for the input, ignoring any
|
/// Collect the full module dependency graph for the input.
|
||||||
/// placeholder modules.
|
|
||||||
///
|
///
|
||||||
/// \returns a \c StringError with the diagnostic output if errors
|
/// \returns a \c StringError with the diagnostic output if errors
|
||||||
/// occurred, \c swiftscan_dependency_result_t otherwise.
|
/// occurred, \c swiftscan_dependency_result_t otherwise.
|
||||||
llvm::ErrorOr<swiftscan_dependency_graph_t>
|
llvm::ErrorOr<swiftscan_dependency_graph_t>
|
||||||
getDependencies(ArrayRef<const char *> Command,
|
getDependencies(ArrayRef<const char *> Command,
|
||||||
const llvm::StringSet<> &PlaceholderModules,
|
|
||||||
StringRef WorkingDirectory);
|
StringRef WorkingDirectory);
|
||||||
|
|
||||||
/// Collect the set of imports for the input module
|
/// Collect the set of imports for the input module
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ using llvm::BCVBR;
|
|||||||
|
|
||||||
/// Every .moddepcache file begins with these 4 bytes, for easy identification.
|
/// Every .moddepcache file begins with these 4 bytes, for easy identification.
|
||||||
const unsigned char MODULE_DEPENDENCY_CACHE_FORMAT_SIGNATURE[] = {'I', 'M', 'D','C'};
|
const unsigned char MODULE_DEPENDENCY_CACHE_FORMAT_SIGNATURE[] = {'I', 'M', 'D','C'};
|
||||||
const unsigned MODULE_DEPENDENCY_CACHE_FORMAT_VERSION_MAJOR = 9;
|
const unsigned MODULE_DEPENDENCY_CACHE_FORMAT_VERSION_MAJOR = 10;
|
||||||
/// Increment this on every change.
|
/// Increment this on every change.
|
||||||
const unsigned MODULE_DEPENDENCY_CACHE_FORMAT_VERSION_MINOR = 3;
|
const unsigned MODULE_DEPENDENCY_CACHE_FORMAT_VERSION_MINOR = 3;
|
||||||
|
|
||||||
@@ -112,7 +112,6 @@ enum {
|
|||||||
OPTIONAL_IMPORT_STATEMENT_ARRAY_NODE,
|
OPTIONAL_IMPORT_STATEMENT_ARRAY_NODE,
|
||||||
SWIFT_INTERFACE_MODULE_DETAILS_NODE,
|
SWIFT_INTERFACE_MODULE_DETAILS_NODE,
|
||||||
SWIFT_SOURCE_MODULE_DETAILS_NODE,
|
SWIFT_SOURCE_MODULE_DETAILS_NODE,
|
||||||
SWIFT_PLACEHOLDER_MODULE_DETAILS_NODE,
|
|
||||||
SWIFT_BINARY_MODULE_DETAILS_NODE,
|
SWIFT_BINARY_MODULE_DETAILS_NODE,
|
||||||
CLANG_MODULE_DETAILS_NODE,
|
CLANG_MODULE_DETAILS_NODE,
|
||||||
IDENTIFIER_NODE,
|
IDENTIFIER_NODE,
|
||||||
@@ -208,7 +207,6 @@ using OptionalImportStatementArrayLayout =
|
|||||||
// - SwiftInterfaceModuleDetails
|
// - SwiftInterfaceModuleDetails
|
||||||
// - SwiftSourceModuleDetails
|
// - SwiftSourceModuleDetails
|
||||||
// - SwiftBinaryModuleDetails
|
// - SwiftBinaryModuleDetails
|
||||||
// - SwiftPlaceholderModuleDetails
|
|
||||||
// - ClangModuleDetails
|
// - ClangModuleDetails
|
||||||
using ModuleInfoLayout =
|
using ModuleInfoLayout =
|
||||||
BCRecordLayout<MODULE_NODE, // ID
|
BCRecordLayout<MODULE_NODE, // ID
|
||||||
@@ -273,13 +271,6 @@ using SwiftBinaryModuleDetailsLayout =
|
|||||||
IdentifierIDField // UserModuleVersion
|
IdentifierIDField // UserModuleVersion
|
||||||
>;
|
>;
|
||||||
|
|
||||||
using SwiftPlaceholderModuleDetailsLayout =
|
|
||||||
BCRecordLayout<SWIFT_PLACEHOLDER_MODULE_DETAILS_NODE, // ID
|
|
||||||
FileIDField, // compiledModulePath
|
|
||||||
FileIDField, // moduleDocPath
|
|
||||||
FileIDField // moduleSourceInfoPath
|
|
||||||
>;
|
|
||||||
|
|
||||||
using ClangModuleDetailsLayout =
|
using ClangModuleDetailsLayout =
|
||||||
BCRecordLayout<CLANG_MODULE_DETAILS_NODE, // ID
|
BCRecordLayout<CLANG_MODULE_DETAILS_NODE, // ID
|
||||||
FileIDField, // pcmOutputPath
|
FileIDField, // pcmOutputPath
|
||||||
|
|||||||
@@ -258,10 +258,6 @@ def const_gather_protocols_file
|
|||||||
: Separate<["-"], "const-gather-protocols-file">, MetaVarName<"<path>">,
|
: Separate<["-"], "const-gather-protocols-file">, MetaVarName<"<path>">,
|
||||||
HelpText<"Specify a list of protocols for extraction of conformances' const values'">;
|
HelpText<"Specify a list of protocols for extraction of conformances' const values'">;
|
||||||
|
|
||||||
def placeholder_dependency_module_map
|
|
||||||
: Separate<["-"], "placeholder-dependency-module-map-file">, MetaVarName<"<path>">,
|
|
||||||
HelpText<"Specify a JSON file containing information of external Swift module dependencies">;
|
|
||||||
|
|
||||||
def import_prescan : Flag<["-"], "import-prescan">,
|
def import_prescan : Flag<["-"], "import-prescan">,
|
||||||
HelpText<"When performing a dependency scan, only identify all imports of the main Swift module sources">;
|
HelpText<"When performing a dependency scan, only identify all imports of the main Swift module sources">;
|
||||||
|
|
||||||
|
|||||||
@@ -83,51 +83,6 @@ public:
|
|||||||
return MDS->getKind() == MDS_plain;
|
return MDS->getKind() == MDS_plain;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A ModuleLoader that loads placeholder dependency module stubs specified in
|
|
||||||
/// -placeholder-dependency-module-map-file
|
|
||||||
/// This loader is used only in dependency scanning to inform the scanner that a
|
|
||||||
/// set of modules constitute placeholder dependencies that are not visible to
|
|
||||||
/// the scanner but will nevertheless be provided by the scanner's clients. This
|
|
||||||
/// "loader" will not attempt to load any module files.
|
|
||||||
class PlaceholderSwiftModuleScanner : public SwiftModuleScanner {
|
|
||||||
/// Scan the given placeholder module map
|
|
||||||
void parsePlaceholderModuleMap(StringRef fileName);
|
|
||||||
|
|
||||||
llvm::StringMap<ExplicitSwiftModuleInputInfo> PlaceholderDependencyModuleMap;
|
|
||||||
llvm::BumpPtrAllocator Allocator;
|
|
||||||
|
|
||||||
public:
|
|
||||||
PlaceholderSwiftModuleScanner(ASTContext &ctx, ModuleLoadingMode LoadMode,
|
|
||||||
Identifier moduleName,
|
|
||||||
StringRef PlaceholderDependencyModuleMap,
|
|
||||||
InterfaceSubContextDelegate &astDelegate,
|
|
||||||
StringRef moduleOutputPath,
|
|
||||||
StringRef sdkModuleOutputPath)
|
|
||||||
: SwiftModuleScanner(ctx, LoadMode, moduleName, astDelegate,
|
|
||||||
moduleOutputPath, sdkModuleOutputPath, {},
|
|
||||||
MDS_placeholder) {
|
|
||||||
// FIXME: Find a better place for this map to live, to avoid
|
|
||||||
// doing the parsing on every module.
|
|
||||||
if (!PlaceholderDependencyModuleMap.empty()) {
|
|
||||||
parsePlaceholderModuleMap(PlaceholderDependencyModuleMap);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual bool
|
|
||||||
findModule(ImportPath::Element moduleID,
|
|
||||||
SmallVectorImpl<char> *moduleInterfacePath,
|
|
||||||
SmallVectorImpl<char> *moduleInterfaceSourcePath,
|
|
||||||
std::unique_ptr<llvm::MemoryBuffer> *moduleBuffer,
|
|
||||||
std::unique_ptr<llvm::MemoryBuffer> *moduleDocBuffer,
|
|
||||||
std::unique_ptr<llvm::MemoryBuffer> *moduleSourceInfoBuffer,
|
|
||||||
bool skipBuildingInterface, bool isTestableDependencyLookup,
|
|
||||||
bool &isFramework, bool &isSystemModule) override;
|
|
||||||
|
|
||||||
static bool classof(const SwiftModuleScanner *MDS) {
|
|
||||||
return MDS->getKind() == MDS_placeholder;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} // namespace swift
|
} // namespace swift
|
||||||
|
|
||||||
#endif // SWIFT_SCANNINGLOADERS_H
|
#endif // SWIFT_SCANNINGLOADERS_H
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ ModuleDependencyInfoStorageBase::~ModuleDependencyInfoStorageBase() {}
|
|||||||
|
|
||||||
bool ModuleDependencyInfo::isSwiftModule() const {
|
bool ModuleDependencyInfo::isSwiftModule() const {
|
||||||
return isSwiftInterfaceModule() || isSwiftSourceModule() ||
|
return isSwiftInterfaceModule() || isSwiftSourceModule() ||
|
||||||
isSwiftBinaryModule() || isSwiftPlaceholderModule();
|
isSwiftBinaryModule();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ModuleDependencyInfo::isTextualSwiftModule() const {
|
bool ModuleDependencyInfo::isTextualSwiftModule() const {
|
||||||
@@ -66,10 +66,6 @@ bool ModuleDependencyInfo::isSwiftBinaryModule() const {
|
|||||||
return isa<SwiftBinaryModuleDependencyStorage>(storage.get());
|
return isa<SwiftBinaryModuleDependencyStorage>(storage.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ModuleDependencyInfo::isSwiftPlaceholderModule() const {
|
|
||||||
return isa<SwiftPlaceholderModuleDependencyStorage>(storage.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ModuleDependencyInfo::isClangModule() const {
|
bool ModuleDependencyInfo::isClangModule() const {
|
||||||
return isa<ClangModuleDependencyStorage>(storage.get());
|
return isa<ClangModuleDependencyStorage>(storage.get());
|
||||||
}
|
}
|
||||||
@@ -97,12 +93,6 @@ ModuleDependencyInfo::getAsClangModule() const {
|
|||||||
return dyn_cast<ClangModuleDependencyStorage>(storage.get());
|
return dyn_cast<ClangModuleDependencyStorage>(storage.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Retrieve the dependencies for a placeholder dependency module stub.
|
|
||||||
const SwiftPlaceholderModuleDependencyStorage *
|
|
||||||
ModuleDependencyInfo::getAsPlaceholderDependencyModule() const {
|
|
||||||
return dyn_cast<SwiftPlaceholderModuleDependencyStorage>(storage.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
void ModuleDependencyInfo::addTestableImport(ImportPath::Module module) {
|
void ModuleDependencyInfo::addTestableImport(ImportPath::Module module) {
|
||||||
assert(getAsSwiftSourceModule() && "Expected source module for addTestableImport.");
|
assert(getAsSwiftSourceModule() && "Expected source module for addTestableImport.");
|
||||||
dyn_cast<SwiftSourceModuleDependenciesStorage>(storage.get())->addTestableImport(module);
|
dyn_cast<SwiftSourceModuleDependenciesStorage>(storage.get())->addTestableImport(module);
|
||||||
@@ -388,11 +378,6 @@ std::string ModuleDependencyInfo::getModuleOutputPath() const {
|
|||||||
cast<SwiftBinaryModuleDependencyStorage>(storage.get());
|
cast<SwiftBinaryModuleDependencyStorage>(storage.get());
|
||||||
return swiftBinaryStorage->compiledModulePath;
|
return swiftBinaryStorage->compiledModulePath;
|
||||||
}
|
}
|
||||||
case swift::ModuleDependencyKind::SwiftPlaceholder: {
|
|
||||||
auto swiftPlaceholderStorage =
|
|
||||||
cast<SwiftPlaceholderModuleDependencyStorage>(storage.get());
|
|
||||||
return swiftPlaceholderStorage->compiledModulePath;
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
llvm_unreachable("Unexpected dependency kind");
|
llvm_unreachable("Unexpected dependency kind");
|
||||||
}
|
}
|
||||||
@@ -876,8 +861,6 @@ ModuleDependenciesCache::findSwiftDependency(StringRef moduleName) const {
|
|||||||
return found;
|
return found;
|
||||||
if (auto found = findDependency(moduleName, ModuleDependencyKind::SwiftSource))
|
if (auto found = findDependency(moduleName, ModuleDependencyKind::SwiftSource))
|
||||||
return found;
|
return found;
|
||||||
if (auto found = findDependency(moduleName, ModuleDependencyKind::SwiftPlaceholder))
|
|
||||||
return found;
|
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -240,9 +240,6 @@ ModuleDependencyInfo::collectCrossImportOverlayNames(
|
|||||||
case swift::ModuleDependencyKind::SwiftSource: {
|
case swift::ModuleDependencyKind::SwiftSource: {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
case swift::ModuleDependencyKind::SwiftPlaceholder: {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
case swift::ModuleDependencyKind::LastKind:
|
case swift::ModuleDependencyKind::LastKind:
|
||||||
llvm_unreachable("Unhandled dependency kind.");
|
llvm_unreachable("Unhandled dependency kind.");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -134,7 +134,6 @@ void writeEncodedModuleIdJSONValue(llvm::raw_ostream &out,
|
|||||||
out << "{\n";
|
out << "{\n";
|
||||||
static const std::string textualPrefix("swiftTextual");
|
static const std::string textualPrefix("swiftTextual");
|
||||||
static const std::string binaryPrefix("swiftBinary");
|
static const std::string binaryPrefix("swiftBinary");
|
||||||
static const std::string placeholderPrefix("swiftPlaceholder");
|
|
||||||
static const std::string clangPrefix("clang");
|
static const std::string clangPrefix("clang");
|
||||||
std::string valueStr = get_C_string(value);
|
std::string valueStr = get_C_string(value);
|
||||||
std::string moduleKind;
|
std::string moduleKind;
|
||||||
@@ -146,10 +145,6 @@ void writeEncodedModuleIdJSONValue(llvm::raw_ostream &out,
|
|||||||
// FIXME: rename to be consistent in the clients (swift-driver)
|
// FIXME: rename to be consistent in the clients (swift-driver)
|
||||||
moduleKind = "swiftPrebuiltExternal";
|
moduleKind = "swiftPrebuiltExternal";
|
||||||
moduleName = valueStr.substr(binaryPrefix.size() + 1);
|
moduleName = valueStr.substr(binaryPrefix.size() + 1);
|
||||||
} else if (!valueStr.compare(0, placeholderPrefix.size(),
|
|
||||||
placeholderPrefix)) {
|
|
||||||
moduleKind = "swiftPlaceholder";
|
|
||||||
moduleName = valueStr.substr(placeholderPrefix.size() + 1);
|
|
||||||
} else {
|
} else {
|
||||||
moduleKind = "clang";
|
moduleKind = "clang";
|
||||||
moduleName = valueStr.substr(clangPrefix.size() + 1);
|
moduleName = valueStr.substr(clangPrefix.size() + 1);
|
||||||
@@ -365,13 +360,6 @@ getAsTextualDependencyModule(swiftscan_module_details_t details) {
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const swiftscan_swift_placeholder_details_t *
|
|
||||||
getAsPlaceholderDependencyModule(swiftscan_module_details_t details) {
|
|
||||||
if (details->kind == SWIFTSCAN_DEPENDENCY_INFO_SWIFT_PLACEHOLDER)
|
|
||||||
return &details->swift_placeholder_details;
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const swiftscan_swift_binary_details_t *
|
static const swiftscan_swift_binary_details_t *
|
||||||
getAsBinaryDependencyModule(swiftscan_module_details_t details) {
|
getAsBinaryDependencyModule(swiftscan_module_details_t details) {
|
||||||
if (details->kind == SWIFTSCAN_DEPENDENCY_INFO_SWIFT_BINARY)
|
if (details->kind == SWIFTSCAN_DEPENDENCY_INFO_SWIFT_BINARY)
|
||||||
@@ -418,8 +406,6 @@ void writeJSON(llvm::raw_ostream &out,
|
|||||||
out << ",\n";
|
out << ",\n";
|
||||||
out.indent(2 * 2);
|
out.indent(2 * 2);
|
||||||
out << "{\n";
|
out << "{\n";
|
||||||
auto swiftPlaceholderDeps =
|
|
||||||
getAsPlaceholderDependencyModule(moduleInfo.details);
|
|
||||||
auto swiftTextualDeps = getAsTextualDependencyModule(moduleInfo.details);
|
auto swiftTextualDeps = getAsTextualDependencyModule(moduleInfo.details);
|
||||||
auto swiftBinaryDeps = getAsBinaryDependencyModule(moduleInfo.details);
|
auto swiftBinaryDeps = getAsBinaryDependencyModule(moduleInfo.details);
|
||||||
auto clangDeps = getAsClangDependencyModule(moduleInfo.details);
|
auto clangDeps = getAsClangDependencyModule(moduleInfo.details);
|
||||||
@@ -432,9 +418,7 @@ void writeJSON(llvm::raw_ostream &out,
|
|||||||
std::string(get_C_string(moduleInfo.module_name));
|
std::string(get_C_string(moduleInfo.module_name));
|
||||||
std::string moduleName =
|
std::string moduleName =
|
||||||
moduleKindAndName.substr(moduleKindAndName.find(":") + 1);
|
moduleKindAndName.substr(moduleKindAndName.find(":") + 1);
|
||||||
if (swiftPlaceholderDeps)
|
if (swiftBinaryDeps)
|
||||||
modulePath = get_C_string(swiftPlaceholderDeps->compiled_module_path);
|
|
||||||
else if (swiftBinaryDeps)
|
|
||||||
modulePath = get_C_string(swiftBinaryDeps->compiled_module_path);
|
modulePath = get_C_string(swiftBinaryDeps->compiled_module_path);
|
||||||
else if (clangDeps || swiftTextualDeps)
|
else if (clangDeps || swiftTextualDeps)
|
||||||
modulePath = get_C_string(moduleInfo.module_path);
|
modulePath = get_C_string(moduleInfo.module_path);
|
||||||
@@ -590,25 +574,6 @@ void writeJSON(llvm::raw_ostream &out,
|
|||||||
"swiftOverlayDependencies", 5,
|
"swiftOverlayDependencies", 5,
|
||||||
/*trailingComma=*/false);
|
/*trailingComma=*/false);
|
||||||
}
|
}
|
||||||
} else if (swiftPlaceholderDeps) {
|
|
||||||
out << "\"swiftPlaceholder\": {\n";
|
|
||||||
|
|
||||||
// Module doc file
|
|
||||||
if (swiftPlaceholderDeps->module_doc_path.data &&
|
|
||||||
get_C_string(swiftPlaceholderDeps->module_doc_path)[0] != '\0')
|
|
||||||
writeJSONSingleField(out, "moduleDocPath",
|
|
||||||
swiftPlaceholderDeps->module_doc_path,
|
|
||||||
/*indentLevel=*/5,
|
|
||||||
/*trailingComma=*/true);
|
|
||||||
|
|
||||||
// Module Source Info file
|
|
||||||
if (swiftPlaceholderDeps->module_source_info_path.data &&
|
|
||||||
get_C_string(swiftPlaceholderDeps->module_source_info_path)[0] !=
|
|
||||||
'\0')
|
|
||||||
writeJSONSingleField(out, "moduleSourceInfoPath",
|
|
||||||
swiftPlaceholderDeps->module_source_info_path,
|
|
||||||
/*indentLevel=*/5,
|
|
||||||
/*trailingComma=*/false);
|
|
||||||
} else if (swiftBinaryDeps) {
|
} else if (swiftBinaryDeps) {
|
||||||
bool hasOverlayDependencies =
|
bool hasOverlayDependencies =
|
||||||
swiftBinaryDeps->swift_overlay_module_dependencies &&
|
swiftBinaryDeps->swift_overlay_module_dependencies &&
|
||||||
|
|||||||
@@ -271,7 +271,6 @@ DependencyScanningTool::DependencyScanningTool()
|
|||||||
llvm::ErrorOr<swiftscan_dependency_graph_t>
|
llvm::ErrorOr<swiftscan_dependency_graph_t>
|
||||||
DependencyScanningTool::getDependencies(
|
DependencyScanningTool::getDependencies(
|
||||||
ArrayRef<const char *> Command,
|
ArrayRef<const char *> Command,
|
||||||
const llvm::StringSet<> &PlaceholderModules,
|
|
||||||
StringRef WorkingDirectory) {
|
StringRef WorkingDirectory) {
|
||||||
// There may be errors as early as in instance initialization, so we must ensure
|
// There may be errors as early as in instance initialization, so we must ensure
|
||||||
// we can catch those.
|
// we can catch those.
|
||||||
|
|||||||
@@ -751,34 +751,6 @@ bool ModuleDependenciesCacheDeserializer::readGraph(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case SWIFT_PLACEHOLDER_MODULE_DETAILS_NODE: {
|
|
||||||
if (!hasCurrentModule)
|
|
||||||
llvm::report_fatal_error(
|
|
||||||
"Unexpected SWIFT_PLACEHOLDER_MODULE_DETAILS_NODE record");
|
|
||||||
unsigned compiledModulePathID, moduleDocPathID, moduleSourceInfoPathID;
|
|
||||||
SwiftPlaceholderModuleDetailsLayout::readRecord(
|
|
||||||
Scratch, compiledModulePathID, moduleDocPathID,
|
|
||||||
moduleSourceInfoPathID);
|
|
||||||
|
|
||||||
auto compiledModulePath = getIdentifier(compiledModulePathID);
|
|
||||||
if (!compiledModulePath)
|
|
||||||
llvm::report_fatal_error("Bad compiled module path");
|
|
||||||
auto moduleDocPath = getIdentifier(moduleDocPathID);
|
|
||||||
if (!moduleDocPath)
|
|
||||||
llvm::report_fatal_error("Bad module doc path");
|
|
||||||
auto moduleSourceInfoPath = getIdentifier(moduleSourceInfoPathID);
|
|
||||||
if (!moduleSourceInfoPath)
|
|
||||||
llvm::report_fatal_error("Bad module source info path");
|
|
||||||
|
|
||||||
// Form the dependencies storage object
|
|
||||||
auto moduleDep = ModuleDependencyInfo::forPlaceholderSwiftModuleStub(
|
|
||||||
*compiledModulePath, *moduleDocPath, *moduleSourceInfoPath);
|
|
||||||
|
|
||||||
cache.recordDependency(currentModuleName, std::move(moduleDep));
|
|
||||||
hasCurrentModule = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case CLANG_MODULE_DETAILS_NODE: {
|
case CLANG_MODULE_DETAILS_NODE: {
|
||||||
if (!hasCurrentModule)
|
if (!hasCurrentModule)
|
||||||
llvm::report_fatal_error("Unexpected CLANG_MODULE_DETAILS_NODE record");
|
llvm::report_fatal_error("Unexpected CLANG_MODULE_DETAILS_NODE record");
|
||||||
@@ -1013,7 +985,6 @@ ModuleDependenciesCacheDeserializer::getModuleDependencyIDArray(unsigned n) {
|
|||||||
if (encodedIdentifierStringArray) {
|
if (encodedIdentifierStringArray) {
|
||||||
static const std::string textualPrefix("swiftTextual");
|
static const std::string textualPrefix("swiftTextual");
|
||||||
static const std::string binaryPrefix("swiftBinary");
|
static const std::string binaryPrefix("swiftBinary");
|
||||||
static const std::string placeholderPrefix("swiftPlaceholder");
|
|
||||||
static const std::string clangPrefix("clang");
|
static const std::string clangPrefix("clang");
|
||||||
std::vector<ModuleDependencyID> result;
|
std::vector<ModuleDependencyID> result;
|
||||||
for (const auto &encodedIdentifierString : *encodedIdentifierStringArray) {
|
for (const auto &encodedIdentifierString : *encodedIdentifierStringArray) {
|
||||||
@@ -1028,11 +999,6 @@ ModuleDependenciesCacheDeserializer::getModuleDependencyIDArray(unsigned n) {
|
|||||||
auto moduleName =
|
auto moduleName =
|
||||||
encodedIdentifierString.substr(binaryPrefix.size() + 1);
|
encodedIdentifierString.substr(binaryPrefix.size() + 1);
|
||||||
id = {moduleName, ModuleDependencyKind::SwiftBinary};
|
id = {moduleName, ModuleDependencyKind::SwiftBinary};
|
||||||
} else if (!encodedIdentifierString.compare(0, placeholderPrefix.size(),
|
|
||||||
placeholderPrefix)) {
|
|
||||||
auto moduleName =
|
|
||||||
encodedIdentifierString.substr(placeholderPrefix.size() + 1);
|
|
||||||
id = {moduleName, ModuleDependencyKind::SwiftPlaceholder};
|
|
||||||
} else {
|
} else {
|
||||||
auto moduleName =
|
auto moduleName =
|
||||||
encodedIdentifierString.substr(clangPrefix.size() + 1);
|
encodedIdentifierString.substr(clangPrefix.size() + 1);
|
||||||
@@ -1268,7 +1234,6 @@ void ModuleDependenciesCacheSerializer::writeBlockInfoBlock() {
|
|||||||
BLOCK_RECORD(graph_block, SWIFT_INTERFACE_MODULE_DETAILS_NODE);
|
BLOCK_RECORD(graph_block, SWIFT_INTERFACE_MODULE_DETAILS_NODE);
|
||||||
BLOCK_RECORD(graph_block, SWIFT_SOURCE_MODULE_DETAILS_NODE);
|
BLOCK_RECORD(graph_block, SWIFT_SOURCE_MODULE_DETAILS_NODE);
|
||||||
BLOCK_RECORD(graph_block, SWIFT_BINARY_MODULE_DETAILS_NODE);
|
BLOCK_RECORD(graph_block, SWIFT_BINARY_MODULE_DETAILS_NODE);
|
||||||
BLOCK_RECORD(graph_block, SWIFT_PLACEHOLDER_MODULE_DETAILS_NODE);
|
|
||||||
BLOCK_RECORD(graph_block, CLANG_MODULE_DETAILS_NODE);
|
BLOCK_RECORD(graph_block, CLANG_MODULE_DETAILS_NODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1668,17 +1633,6 @@ void ModuleDependenciesCacheSerializer::writeModuleInfo(
|
|||||||
getIdentifier(swiftBinDeps->userModuleVersion));
|
getIdentifier(swiftBinDeps->userModuleVersion));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case swift::ModuleDependencyKind::SwiftPlaceholder: {
|
|
||||||
auto swiftPHDeps = dependencyInfo.getAsPlaceholderDependencyModule();
|
|
||||||
assert(swiftPHDeps);
|
|
||||||
SwiftPlaceholderModuleDetailsLayout::emitRecord(
|
|
||||||
Out, ScratchRecord,
|
|
||||||
AbbrCodes[SwiftPlaceholderModuleDetailsLayout::Code],
|
|
||||||
getIdentifier(swiftPHDeps->compiledModulePath),
|
|
||||||
getIdentifier(swiftPHDeps->moduleDocPath),
|
|
||||||
getIdentifier(swiftPHDeps->sourceInfoPath));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case swift::ModuleDependencyKind::Clang: {
|
case swift::ModuleDependencyKind::Clang: {
|
||||||
auto clangDeps = dependencyInfo.getAsClangModule();
|
auto clangDeps = dependencyInfo.getAsClangModule();
|
||||||
assert(clangDeps);
|
assert(clangDeps);
|
||||||
@@ -1936,14 +1890,6 @@ void ModuleDependenciesCacheSerializer::collectStringsAndArrays(
|
|||||||
[this](auto &sp) { addIdentifier(sp.Path); });
|
[this](auto &sp) { addIdentifier(sp.Path); });
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case swift::ModuleDependencyKind::SwiftPlaceholder: {
|
|
||||||
auto swiftPHDeps = dependencyInfo->getAsPlaceholderDependencyModule();
|
|
||||||
assert(swiftPHDeps);
|
|
||||||
addIdentifier(swiftPHDeps->compiledModulePath);
|
|
||||||
addIdentifier(swiftPHDeps->moduleDocPath);
|
|
||||||
addIdentifier(swiftPHDeps->sourceInfoPath);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case swift::ModuleDependencyKind::SwiftSource: {
|
case swift::ModuleDependencyKind::SwiftSource: {
|
||||||
auto swiftSourceDeps = dependencyInfo->getAsSwiftSourceModule();
|
auto swiftSourceDeps = dependencyInfo->getAsSwiftSourceModule();
|
||||||
assert(swiftSourceDeps);
|
assert(swiftSourceDeps);
|
||||||
@@ -2021,7 +1967,6 @@ void ModuleDependenciesCacheSerializer::writeInterModuleDependenciesCache(
|
|||||||
registerRecordAbbr<SwiftSourceModuleDetailsLayout>();
|
registerRecordAbbr<SwiftSourceModuleDetailsLayout>();
|
||||||
registerRecordAbbr<SwiftInterfaceModuleDetailsLayout>();
|
registerRecordAbbr<SwiftInterfaceModuleDetailsLayout>();
|
||||||
registerRecordAbbr<SwiftBinaryModuleDetailsLayout>();
|
registerRecordAbbr<SwiftBinaryModuleDetailsLayout>();
|
||||||
registerRecordAbbr<SwiftPlaceholderModuleDetailsLayout>();
|
|
||||||
registerRecordAbbr<ClangModuleDetailsLayout>();
|
registerRecordAbbr<ClangModuleDetailsLayout>();
|
||||||
|
|
||||||
// Make a pass to collect all unique strings and arrays
|
// Make a pass to collect all unique strings and arrays
|
||||||
|
|||||||
@@ -104,8 +104,7 @@ findPathToDependency(ModuleDependencyID dependency,
|
|||||||
static bool isSwiftDependencyKind(ModuleDependencyKind Kind) {
|
static bool isSwiftDependencyKind(ModuleDependencyKind Kind) {
|
||||||
return Kind == ModuleDependencyKind::SwiftInterface ||
|
return Kind == ModuleDependencyKind::SwiftInterface ||
|
||||||
Kind == ModuleDependencyKind::SwiftSource ||
|
Kind == ModuleDependencyKind::SwiftSource ||
|
||||||
Kind == ModuleDependencyKind::SwiftBinary ||
|
Kind == ModuleDependencyKind::SwiftBinary;
|
||||||
Kind == ModuleDependencyKind::SwiftPlaceholder;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// The Swift compiler does not have a concept of a working directory.
|
// The Swift compiler does not have a concept of a working directory.
|
||||||
@@ -1371,8 +1370,7 @@ void ModuleDependencyScanner::resolveSwiftOverlayDependenciesForModule(
|
|||||||
Identifier moduleIdentifier) {
|
Identifier moduleIdentifier) {
|
||||||
auto moduleName = moduleIdentifier.str();
|
auto moduleName = moduleIdentifier.str();
|
||||||
if (cache.hasDependency(moduleName, ModuleDependencyKind::SwiftInterface) ||
|
if (cache.hasDependency(moduleName, ModuleDependencyKind::SwiftInterface) ||
|
||||||
cache.hasDependency(moduleName, ModuleDependencyKind::SwiftBinary) ||
|
cache.hasDependency(moduleName, ModuleDependencyKind::SwiftBinary))
|
||||||
cache.hasDependency(moduleName, ModuleDependencyKind::SwiftPlaceholder))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto moduleDependencies = withDependencyScanningWorker(
|
auto moduleDependencies = withDependencyScanningWorker(
|
||||||
@@ -1713,10 +1711,6 @@ void ModuleDependencyScanner::diagnoseScannerFailure(
|
|||||||
moduleFilePath =
|
moduleFilePath =
|
||||||
entryNode->getAsSwiftBinaryModule()->compiledModulePath;
|
entryNode->getAsSwiftBinaryModule()->compiledModulePath;
|
||||||
break;
|
break;
|
||||||
case swift::ModuleDependencyKind::SwiftPlaceholder:
|
|
||||||
moduleFilePath =
|
|
||||||
entryNode->getAsPlaceholderDependencyModule()->compiledModulePath;
|
|
||||||
break;
|
|
||||||
case swift::ModuleDependencyKind::Clang:
|
case swift::ModuleDependencyKind::Clang:
|
||||||
moduleFilePath = entryNode->getAsClangModule()->moduleMapFile;
|
moduleFilePath = entryNode->getAsClangModule()->moduleMapFile;
|
||||||
isClang = true;
|
isClang = true;
|
||||||
@@ -1751,9 +1745,6 @@ static std::string getModuleDefiningPath(const ModuleDependencyInfo &info) {
|
|||||||
case swift::ModuleDependencyKind::SwiftBinary:
|
case swift::ModuleDependencyKind::SwiftBinary:
|
||||||
path = info.getAsSwiftBinaryModule()->compiledModulePath;
|
path = info.getAsSwiftBinaryModule()->compiledModulePath;
|
||||||
break;
|
break;
|
||||||
case swift::ModuleDependencyKind::SwiftPlaceholder:
|
|
||||||
path = info.getAsPlaceholderDependencyModule()->compiledModulePath;
|
|
||||||
break;
|
|
||||||
case swift::ModuleDependencyKind::Clang:
|
case swift::ModuleDependencyKind::Clang:
|
||||||
path = info.getAsClangModule()->moduleMapFile;
|
path = info.getAsClangModule()->moduleMapFile;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -92,10 +92,6 @@ public:
|
|||||||
// Resolve the dependencies for the current moduleID. Return true on error.
|
// Resolve the dependencies for the current moduleID. Return true on error.
|
||||||
bool resolve(const std::set<ModuleDependencyID> &dependencies,
|
bool resolve(const std::set<ModuleDependencyID> &dependencies,
|
||||||
std::optional<std::set<ModuleDependencyID>> bridgingHeaderDeps) {
|
std::optional<std::set<ModuleDependencyID>> bridgingHeaderDeps) {
|
||||||
// No need to resolve dependency for placeholder.
|
|
||||||
if (moduleID.Kind == ModuleDependencyKind::SwiftPlaceholder)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// If the dependency is already finalized, nothing needs to be done.
|
// If the dependency is already finalized, nothing needs to be done.
|
||||||
if (resolvingDepInfo.isFinalized())
|
if (resolvingDepInfo.isFinalized())
|
||||||
return false;
|
return false;
|
||||||
@@ -116,13 +112,6 @@ public:
|
|||||||
if (handleSwiftBinaryModuleDependency(depModuleID, *binaryDepDetails))
|
if (handleSwiftBinaryModuleDependency(depModuleID, *binaryDepDetails))
|
||||||
return true;
|
return true;
|
||||||
} break;
|
} break;
|
||||||
case swift::ModuleDependencyKind::SwiftPlaceholder: {
|
|
||||||
auto placeholderDetails = depInfo.getAsPlaceholderDependencyModule();
|
|
||||||
assert(placeholderDetails && "Expected Swift Placeholder dependency.");
|
|
||||||
if (handleSwiftPlaceholderModuleDependency(depModuleID,
|
|
||||||
*placeholderDetails))
|
|
||||||
return true;
|
|
||||||
} break;
|
|
||||||
case swift::ModuleDependencyKind::Clang: {
|
case swift::ModuleDependencyKind::Clang: {
|
||||||
auto clangDepDetails = depInfo.getAsClangModule();
|
auto clangDepDetails = depInfo.getAsClangModule();
|
||||||
assert(clangDepDetails && "Expected Clang Module dependency.");
|
assert(clangDepDetails && "Expected Clang Module dependency.");
|
||||||
@@ -195,9 +184,6 @@ private:
|
|||||||
bool finalize(ModuleDependencyInfo &depInfo,
|
bool finalize(ModuleDependencyInfo &depInfo,
|
||||||
const SwiftInterfaceModuleOutputPathResolution::ResultTy
|
const SwiftInterfaceModuleOutputPathResolution::ResultTy
|
||||||
&swiftInterfaceModuleOutputPath) {
|
&swiftInterfaceModuleOutputPath) {
|
||||||
if (resolvingDepInfo.isSwiftPlaceholderModule())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (resolvingDepInfo.isSwiftInterfaceModule())
|
if (resolvingDepInfo.isSwiftInterfaceModule())
|
||||||
depInfo.setOutputPathAndHash(
|
depInfo.setOutputPathAndHash(
|
||||||
swiftInterfaceModuleOutputPath.outputPath.str().str(),
|
swiftInterfaceModuleOutputPath.outputPath.str().str(),
|
||||||
@@ -287,15 +273,6 @@ private:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool handleSwiftPlaceholderModuleDependency(
|
|
||||||
ModuleDependencyID depModuleID,
|
|
||||||
const SwiftPlaceholderModuleDependencyStorage &placeholderDetails) {
|
|
||||||
if (!resolvingDepInfo.isSwiftSourceModule())
|
|
||||||
commandline.push_back("-swift-module-file=" + depModuleID.ModuleName +
|
|
||||||
"=" + placeholderDetails.compiledModulePath);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool handleClangModuleDependency(
|
bool handleClangModuleDependency(
|
||||||
ModuleDependencyID depModuleID,
|
ModuleDependencyID depModuleID,
|
||||||
const ClangModuleDependencyStorage &clangDepDetails) {
|
const ClangModuleDependencyStorage &clangDepDetails) {
|
||||||
@@ -721,9 +698,6 @@ static void bridgeDependencyIDs(const ArrayRef<ModuleDependencyID> dependencies,
|
|||||||
case ModuleDependencyKind::SwiftBinary:
|
case ModuleDependencyKind::SwiftBinary:
|
||||||
dependencyKindAndName = "swiftBinary";
|
dependencyKindAndName = "swiftBinary";
|
||||||
break;
|
break;
|
||||||
case ModuleDependencyKind::SwiftPlaceholder:
|
|
||||||
dependencyKindAndName = "swiftPlaceholder";
|
|
||||||
break;
|
|
||||||
case ModuleDependencyKind::Clang:
|
case ModuleDependencyKind::Clang:
|
||||||
dependencyKindAndName = "clang";
|
dependencyKindAndName = "clang";
|
||||||
break;
|
break;
|
||||||
@@ -776,7 +750,6 @@ generateFullDependencyGraph(const CompilerInstance &instance,
|
|||||||
const auto &moduleID = allModules[i];
|
const auto &moduleID = allModules[i];
|
||||||
auto &moduleDependencyInfo = cache.findKnownDependency(moduleID);
|
auto &moduleDependencyInfo = cache.findKnownDependency(moduleID);
|
||||||
// Collect all the required pieces to build a ModuleInfo
|
// Collect all the required pieces to build a ModuleInfo
|
||||||
auto swiftPlaceholderDeps = moduleDependencyInfo.getAsPlaceholderDependencyModule();
|
|
||||||
auto swiftTextualDeps = moduleDependencyInfo.getAsSwiftInterfaceModule();
|
auto swiftTextualDeps = moduleDependencyInfo.getAsSwiftInterfaceModule();
|
||||||
auto swiftSourceDeps = moduleDependencyInfo.getAsSwiftSourceModule();
|
auto swiftSourceDeps = moduleDependencyInfo.getAsSwiftSourceModule();
|
||||||
auto swiftBinaryDeps = moduleDependencyInfo.getAsSwiftBinaryModule();
|
auto swiftBinaryDeps = moduleDependencyInfo.getAsSwiftBinaryModule();
|
||||||
@@ -788,8 +761,6 @@ generateFullDependencyGraph(const CompilerInstance &instance,
|
|||||||
std::string modulePath;
|
std::string modulePath;
|
||||||
if (swiftTextualDeps)
|
if (swiftTextualDeps)
|
||||||
modulePath = swiftTextualDeps->moduleOutputPath;
|
modulePath = swiftTextualDeps->moduleOutputPath;
|
||||||
else if (swiftPlaceholderDeps)
|
|
||||||
modulePath = swiftPlaceholderDeps->compiledModulePath;
|
|
||||||
else if (swiftBinaryDeps)
|
else if (swiftBinaryDeps)
|
||||||
modulePath = swiftBinaryDeps->compiledModulePath;
|
modulePath = swiftBinaryDeps->compiledModulePath;
|
||||||
else if (clangDeps)
|
else if (clangDeps)
|
||||||
@@ -904,12 +875,6 @@ generateFullDependencyGraph(const CompilerInstance &instance,
|
|||||||
create_clone(swiftSourceDeps->chainedBridgingHeaderPath.c_str()),
|
create_clone(swiftSourceDeps->chainedBridgingHeaderPath.c_str()),
|
||||||
create_clone(
|
create_clone(
|
||||||
swiftSourceDeps->chainedBridgingHeaderContent.c_str())};
|
swiftSourceDeps->chainedBridgingHeaderContent.c_str())};
|
||||||
} else if (swiftPlaceholderDeps) {
|
|
||||||
details->kind = SWIFTSCAN_DEPENDENCY_INFO_SWIFT_PLACEHOLDER;
|
|
||||||
details->swift_placeholder_details = {
|
|
||||||
create_clone(swiftPlaceholderDeps->compiledModulePath.c_str()),
|
|
||||||
create_clone(swiftPlaceholderDeps->moduleDocPath.c_str()),
|
|
||||||
create_clone(swiftPlaceholderDeps->sourceInfoPath.c_str())};
|
|
||||||
} else if (swiftBinaryDeps) {
|
} else if (swiftBinaryDeps) {
|
||||||
details->kind = SWIFTSCAN_DEPENDENCY_INFO_SWIFT_BINARY;
|
details->kind = SWIFTSCAN_DEPENDENCY_INFO_SWIFT_BINARY;
|
||||||
// Create an overlay dependencies set according to the output format
|
// Create an overlay dependencies set according to the output format
|
||||||
@@ -1346,8 +1311,6 @@ swift::dependencies::createEncodedModuleKindAndName(ModuleDependencyID id) {
|
|||||||
return "swiftTextual:" + id.ModuleName;
|
return "swiftTextual:" + id.ModuleName;
|
||||||
case ModuleDependencyKind::SwiftBinary:
|
case ModuleDependencyKind::SwiftBinary:
|
||||||
return "swiftBinary:" + id.ModuleName;
|
return "swiftBinary:" + id.ModuleName;
|
||||||
case ModuleDependencyKind::SwiftPlaceholder:
|
|
||||||
return "swiftPlaceholder:" + id.ModuleName;
|
|
||||||
case ModuleDependencyKind::Clang:
|
case ModuleDependencyKind::Clang:
|
||||||
return "clang:" + id.ModuleName;
|
return "clang:" + id.ModuleName;
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -193,8 +193,6 @@ static void validateProfilingArgs(DiagnosticEngine &diags,
|
|||||||
|
|
||||||
static void validateDependencyScanningArgs(DiagnosticEngine &diags,
|
static void validateDependencyScanningArgs(DiagnosticEngine &diags,
|
||||||
const ArgList &args) {
|
const ArgList &args) {
|
||||||
const Arg *ExternalDependencyMap =
|
|
||||||
args.getLastArg(options::OPT_placeholder_dependency_module_map);
|
|
||||||
const Arg *ScanDependencies = args.getLastArg(options::OPT_scan_dependencies);
|
const Arg *ScanDependencies = args.getLastArg(options::OPT_scan_dependencies);
|
||||||
const Arg *Prescan = args.getLastArg(options::OPT_import_prescan);
|
const Arg *Prescan = args.getLastArg(options::OPT_import_prescan);
|
||||||
|
|
||||||
@@ -207,11 +205,6 @@ static void validateDependencyScanningArgs(DiagnosticEngine &diags,
|
|||||||
const Arg *ValidatePriorCache =
|
const Arg *ValidatePriorCache =
|
||||||
args.getLastArg(options::OPT_validate_prior_dependency_scan_cache);
|
args.getLastArg(options::OPT_validate_prior_dependency_scan_cache);
|
||||||
|
|
||||||
if (ExternalDependencyMap && !ScanDependencies) {
|
|
||||||
diags.diagnose(SourceLoc(), diag::error_requirement_not_met,
|
|
||||||
"-placeholder-dependency-module-map-file",
|
|
||||||
"-scan-dependencies");
|
|
||||||
}
|
|
||||||
if (Prescan && !ScanDependencies) {
|
if (Prescan && !ScanDependencies) {
|
||||||
diags.diagnose(SourceLoc(), diag::error_requirement_not_met,
|
diags.diagnose(SourceLoc(), diag::error_requirement_not_met,
|
||||||
"-import-prescan", "-scan-dependencies");
|
"-import-prescan", "-scan-dependencies");
|
||||||
|
|||||||
@@ -2441,8 +2441,6 @@ static bool ParseSearchPathArgs(SearchPathOptions &Opts, ArgList &Args,
|
|||||||
for (auto A: Args.filtered(OPT_candidate_module_file)) {
|
for (auto A: Args.filtered(OPT_candidate_module_file)) {
|
||||||
Opts.CandidateCompiledModules.push_back(resolveSearchPath(A->getValue()));
|
Opts.CandidateCompiledModules.push_back(resolveSearchPath(A->getValue()));
|
||||||
}
|
}
|
||||||
if (const Arg *A = Args.getLastArg(OPT_placeholder_dependency_module_map))
|
|
||||||
Opts.PlaceholderDependencyModuleMap = A->getValue();
|
|
||||||
|
|
||||||
if (const Arg *A = Args.getLastArg(OPT_const_gather_protocols_file))
|
if (const Arg *A = Args.getLastArg(OPT_const_gather_protocols_file))
|
||||||
Opts.ConstGatherProtocolListFilePath = A->getValue();
|
Opts.ConstGatherProtocolListFilePath = A->getValue();
|
||||||
|
|||||||
@@ -899,14 +899,6 @@ bool CompilerInstance::setUpModuleLoaders() {
|
|||||||
FEOpts.SerializeModuleInterfaceDependencyHashes,
|
FEOpts.SerializeModuleInterfaceDependencyHashes,
|
||||||
FEOpts.shouldTrackSystemDependencies(),
|
FEOpts.shouldTrackSystemDependencies(),
|
||||||
RequireOSSAModules_t(Invocation.getSILOptions()));
|
RequireOSSAModules_t(Invocation.getSILOptions()));
|
||||||
auto mainModuleName = Context->getIdentifier(FEOpts.ModuleName);
|
|
||||||
std::unique_ptr<PlaceholderSwiftModuleScanner> PSMS =
|
|
||||||
std::make_unique<PlaceholderSwiftModuleScanner>(
|
|
||||||
*Context, MLM, mainModuleName,
|
|
||||||
Context->SearchPathOpts.PlaceholderDependencyModuleMap, ASTDelegate,
|
|
||||||
getInvocation().getFrontendOptions().ExplicitModulesOutputPath,
|
|
||||||
getInvocation().getFrontendOptions().ExplicitSDKModulesOutputPath);
|
|
||||||
Context->addModuleLoader(std::move(PSMS));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -83,56 +83,6 @@ std::error_code SwiftModuleScanner::findModuleFilesInDirectory(
|
|||||||
return dependencies.getError();
|
return dependencies.getError();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PlaceholderSwiftModuleScanner::findModule(
|
|
||||||
ImportPath::Element moduleID, SmallVectorImpl<char> *moduleInterfacePath,
|
|
||||||
SmallVectorImpl<char> *moduleInterfaceSourcePath,
|
|
||||||
std::unique_ptr<llvm::MemoryBuffer> *moduleBuffer,
|
|
||||||
std::unique_ptr<llvm::MemoryBuffer> *moduleDocBuffer,
|
|
||||||
std::unique_ptr<llvm::MemoryBuffer> *moduleSourceInfoBuffer,
|
|
||||||
bool skipBuildingInterface, bool isTestableDependencyLookup,
|
|
||||||
bool &isFramework, bool &isSystemModule) {
|
|
||||||
StringRef moduleName = Ctx.getRealModuleName(moduleID.Item).str();
|
|
||||||
auto it = PlaceholderDependencyModuleMap.find(moduleName);
|
|
||||||
if (it == PlaceholderDependencyModuleMap.end()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
auto &moduleInfo = it->getValue();
|
|
||||||
auto dependencies = ModuleDependencyInfo::forPlaceholderSwiftModuleStub(
|
|
||||||
moduleInfo.modulePath,
|
|
||||||
moduleInfo.moduleDocPath.has_value() ? moduleInfo.moduleDocPath.value()
|
|
||||||
: "",
|
|
||||||
moduleInfo.moduleSourceInfoPath.has_value()
|
|
||||||
? moduleInfo.moduleSourceInfoPath.value()
|
|
||||||
: "");
|
|
||||||
this->dependencies = std::move(dependencies);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PlaceholderSwiftModuleScanner::parsePlaceholderModuleMap(
|
|
||||||
StringRef fileName) {
|
|
||||||
ExplicitModuleMapParser parser(Allocator);
|
|
||||||
llvm::StringMap<ExplicitClangModuleInputInfo> ClangDependencyModuleMap;
|
|
||||||
llvm::StringMap<std::string> ModuleAliases;
|
|
||||||
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> fileBufOrErr =
|
|
||||||
llvm::MemoryBuffer::getFile(fileName);
|
|
||||||
if (!fileBufOrErr) {
|
|
||||||
Ctx.Diags.diagnose(SourceLoc(), diag::explicit_swift_module_map_missing,
|
|
||||||
fileName);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
auto result = parser.parseSwiftExplicitModuleMap(
|
|
||||||
(*fileBufOrErr)->getMemBufferRef(), PlaceholderDependencyModuleMap,
|
|
||||||
ClangDependencyModuleMap, ModuleAliases);
|
|
||||||
if (result == std::errc::invalid_argument) {
|
|
||||||
Ctx.Diags.diagnose(SourceLoc(),
|
|
||||||
diag::placeholder_dependency_module_map_corrupted,
|
|
||||||
fileName);
|
|
||||||
} else if (result == std::errc::no_such_file_or_directory) {
|
|
||||||
Ctx.Diags.diagnose(
|
|
||||||
SourceLoc(), diag::placeholder_dependency_module_map_missing, fileName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::vector<std::string> getCompiledCandidates(ASTContext &ctx,
|
static std::vector<std::string> getCompiledCandidates(ASTContext &ctx,
|
||||||
StringRef moduleName,
|
StringRef moduleName,
|
||||||
StringRef interfacePath) {
|
StringRef interfacePath) {
|
||||||
@@ -297,36 +247,20 @@ ModuleDependencyVector SerializedModuleLoaderBase::getModuleDependencies(
|
|||||||
auto modulePath = builder.get();
|
auto modulePath = builder.get();
|
||||||
auto moduleId = modulePath.front().Item;
|
auto moduleId = modulePath.front().Item;
|
||||||
|
|
||||||
// Instantiate dependency scanning "loaders".
|
auto scanner = std::make_unique<SwiftModuleScanner>(
|
||||||
SmallVector<std::unique_ptr<SwiftModuleScanner>, 2> scanners;
|
|
||||||
// Placeholder dependencies must be resolved first, to prevent the
|
|
||||||
// ModuleDependencyScanner from first discovering artifacts of a previous
|
|
||||||
// build. Such artifacts are captured as compiledModuleCandidates in the
|
|
||||||
// dependency graph of the placeholder dependency module itself.
|
|
||||||
// FIXME: submodules?
|
|
||||||
scanners.push_back(std::make_unique<PlaceholderSwiftModuleScanner>(
|
|
||||||
Ctx, LoadMode, moduleId, Ctx.SearchPathOpts.PlaceholderDependencyModuleMap,
|
|
||||||
delegate, moduleOutputPath, sdkModuleOutputPath));
|
|
||||||
scanners.push_back(std::make_unique<SwiftModuleScanner>(
|
|
||||||
Ctx, LoadMode, moduleId, delegate, moduleOutputPath, sdkModuleOutputPath,
|
Ctx, LoadMode, moduleId, delegate, moduleOutputPath, sdkModuleOutputPath,
|
||||||
swiftModuleClangCC1CommandLineArgs,
|
swiftModuleClangCC1CommandLineArgs, SwiftModuleScanner::MDS_plain);
|
||||||
SwiftModuleScanner::MDS_plain));
|
|
||||||
|
|
||||||
// Check whether there is a module with this name that we can import.
|
// Check whether there is a module with this name that we can import.
|
||||||
assert(isa<PlaceholderSwiftModuleScanner>(scanners[0].get()) &&
|
if (scanner->canImportModule(modulePath, SourceLoc(), nullptr,
|
||||||
"Expected PlaceholderSwiftModuleScanner as the first dependency "
|
isTestableDependencyLookup)) {
|
||||||
"scanner loader.");
|
|
||||||
for (auto &scanner : scanners) {
|
|
||||||
if (scanner->canImportModule(modulePath, SourceLoc(), nullptr,
|
|
||||||
isTestableDependencyLookup)) {
|
|
||||||
|
|
||||||
ModuleDependencyVector moduleDependnecies;
|
ModuleDependencyVector moduleDependnecies;
|
||||||
moduleDependnecies.push_back(
|
moduleDependnecies.push_back(
|
||||||
std::make_pair(ModuleDependencyID{moduleName.str().str(),
|
std::make_pair(ModuleDependencyID{moduleName.str().str(),
|
||||||
scanner->dependencies->getKind()},
|
scanner->dependencies->getKind()},
|
||||||
*(scanner->dependencies)));
|
*(scanner->dependencies)));
|
||||||
return moduleDependnecies;
|
return moduleDependnecies;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
|
|||||||
@@ -93,14 +93,6 @@ void swiftscan_dependency_info_details_dispose(
|
|||||||
swiftscan_string_dispose(
|
swiftscan_string_dispose(
|
||||||
details_impl->swift_binary_details.user_module_version);
|
details_impl->swift_binary_details.user_module_version);
|
||||||
break;
|
break;
|
||||||
case SWIFTSCAN_DEPENDENCY_INFO_SWIFT_PLACEHOLDER:
|
|
||||||
swiftscan_string_dispose(
|
|
||||||
details_impl->swift_placeholder_details.compiled_module_path);
|
|
||||||
swiftscan_string_dispose(
|
|
||||||
details_impl->swift_placeholder_details.module_doc_path);
|
|
||||||
swiftscan_string_dispose(
|
|
||||||
details_impl->swift_placeholder_details.module_source_info_path);
|
|
||||||
break;
|
|
||||||
case SWIFTSCAN_DEPENDENCY_INFO_CLANG:
|
case SWIFTSCAN_DEPENDENCY_INFO_CLANG:
|
||||||
swiftscan_string_dispose(details_impl->clang_details.module_map_path);
|
swiftscan_string_dispose(details_impl->clang_details.module_map_path);
|
||||||
swiftscan_string_dispose(details_impl->clang_details.context_hash);
|
swiftscan_string_dispose(details_impl->clang_details.context_hash);
|
||||||
@@ -168,7 +160,7 @@ swiftscan_dependency_graph_create(swiftscan_scanner_t scanner,
|
|||||||
|
|
||||||
// Execute the scan and bridge the result
|
// Execute the scan and bridge the result
|
||||||
auto ScanResult = ScanningTool->getDependencies(
|
auto ScanResult = ScanningTool->getDependencies(
|
||||||
Compilation, {},
|
Compilation,
|
||||||
swift::c_string_utils::get_C_string(invocation->working_directory));
|
swift::c_string_utils::get_C_string(invocation->working_directory));
|
||||||
if (ScanResult.getError())
|
if (ScanResult.getError())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@@ -433,23 +425,23 @@ swiftscan_swift_binary_detail_get_user_module_version(
|
|||||||
return details->swift_binary_details.user_module_version;
|
return details->swift_binary_details.user_module_version;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=== Swift Placeholder Module Details query APIs -------------------------===//
|
//=== Swift Placeholder Module Details query APIs - DEPRECATED -----------===//
|
||||||
|
|
||||||
swiftscan_string_ref_t
|
swiftscan_string_ref_t
|
||||||
swiftscan_swift_placeholder_detail_get_compiled_module_path(
|
swiftscan_swift_placeholder_detail_get_compiled_module_path(
|
||||||
swiftscan_module_details_t details) {
|
swiftscan_module_details_t details) {
|
||||||
return details->swift_placeholder_details.module_source_info_path;
|
return swift::c_string_utils::create_null();
|
||||||
}
|
}
|
||||||
|
|
||||||
swiftscan_string_ref_t swiftscan_swift_placeholder_detail_get_module_doc_path(
|
swiftscan_string_ref_t swiftscan_swift_placeholder_detail_get_module_doc_path(
|
||||||
swiftscan_module_details_t details) {
|
swiftscan_module_details_t details) {
|
||||||
return details->swift_placeholder_details.module_source_info_path;
|
return swift::c_string_utils::create_null();
|
||||||
}
|
}
|
||||||
|
|
||||||
swiftscan_string_ref_t
|
swiftscan_string_ref_t
|
||||||
swiftscan_swift_placeholder_detail_get_module_source_info_path(
|
swiftscan_swift_placeholder_detail_get_module_source_info_path(
|
||||||
swiftscan_module_details_t details) {
|
swiftscan_module_details_t details) {
|
||||||
return details->swift_placeholder_details.module_source_info_path;
|
return swift::c_string_utils::create_null();
|
||||||
}
|
}
|
||||||
|
|
||||||
//=== Clang Module Details query APIs -------------------------------------===//
|
//=== Clang Module Details query APIs -------------------------------------===//
|
||||||
|
|||||||
@@ -13,14 +13,12 @@ import Foundation
|
|||||||
|
|
||||||
enum ModuleDependencyId: Hashable {
|
enum ModuleDependencyId: Hashable {
|
||||||
case swift(String)
|
case swift(String)
|
||||||
case swiftPlaceholder(String)
|
|
||||||
case swiftPrebuiltExternal(String)
|
case swiftPrebuiltExternal(String)
|
||||||
case clang(String)
|
case clang(String)
|
||||||
|
|
||||||
var moduleName: String {
|
var moduleName: String {
|
||||||
switch self {
|
switch self {
|
||||||
case .swift(let name): return name
|
case .swift(let name): return name
|
||||||
case .swiftPlaceholder(let name): return name
|
|
||||||
case .swiftPrebuiltExternal(let name): return name
|
case .swiftPrebuiltExternal(let name): return name
|
||||||
case .clang(let name): return name
|
case .clang(let name): return name
|
||||||
}
|
}
|
||||||
@@ -30,7 +28,6 @@ enum ModuleDependencyId: Hashable {
|
|||||||
extension ModuleDependencyId: Codable {
|
extension ModuleDependencyId: Codable {
|
||||||
enum CodingKeys: CodingKey {
|
enum CodingKeys: CodingKey {
|
||||||
case swift
|
case swift
|
||||||
case swiftPlaceholder
|
|
||||||
case swiftPrebuiltExternal
|
case swiftPrebuiltExternal
|
||||||
case clang
|
case clang
|
||||||
}
|
}
|
||||||
@@ -42,16 +39,11 @@ extension ModuleDependencyId: Codable {
|
|||||||
self = .swift(moduleName)
|
self = .swift(moduleName)
|
||||||
} catch {
|
} catch {
|
||||||
do {
|
do {
|
||||||
let moduleName = try container.decode(String.self, forKey: .swiftPlaceholder)
|
let moduleName = try container.decode(String.self, forKey: .swiftPrebuiltExternal)
|
||||||
self = .swiftPlaceholder(moduleName)
|
self = .swiftPrebuiltExternal(moduleName)
|
||||||
} catch {
|
} catch {
|
||||||
do {
|
let moduleName = try container.decode(String.self, forKey: .clang)
|
||||||
let moduleName = try container.decode(String.self, forKey: .swiftPrebuiltExternal)
|
self = .clang(moduleName)
|
||||||
self = .swiftPrebuiltExternal(moduleName)
|
|
||||||
} catch {
|
|
||||||
let moduleName = try container.decode(String.self, forKey: .clang)
|
|
||||||
self = .clang(moduleName)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -61,8 +53,6 @@ extension ModuleDependencyId: Codable {
|
|||||||
switch self {
|
switch self {
|
||||||
case .swift(let moduleName):
|
case .swift(let moduleName):
|
||||||
try container.encode(moduleName, forKey: .swift)
|
try container.encode(moduleName, forKey: .swift)
|
||||||
case .swiftPlaceholder(let moduleName):
|
|
||||||
try container.encode(moduleName, forKey: .swiftPlaceholder)
|
|
||||||
case .swiftPrebuiltExternal(let moduleName):
|
case .swiftPrebuiltExternal(let moduleName):
|
||||||
try container.encode(moduleName, forKey: .swiftPrebuiltExternal)
|
try container.encode(moduleName, forKey: .swiftPrebuiltExternal)
|
||||||
case .clang(let moduleName):
|
case .clang(let moduleName):
|
||||||
@@ -99,15 +89,6 @@ struct SwiftModuleDetails: Codable {
|
|||||||
var swiftOverlayDependencies: [ModuleDependencyId]?
|
var swiftOverlayDependencies: [ModuleDependencyId]?
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Details specific to Swift placeholder dependencies.
|
|
||||||
struct SwiftPlaceholderModuleDetails: Codable {
|
|
||||||
/// The path to the .swiftModuleDoc file.
|
|
||||||
var moduleDocPath: String?
|
|
||||||
|
|
||||||
/// The path to the .swiftSourceInfo file.
|
|
||||||
var moduleSourceInfoPath: String?
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Details specific to Swift externally-pre-built modules.
|
/// Details specific to Swift externally-pre-built modules.
|
||||||
struct SwiftPrebuiltExternalModuleDetails: Codable {
|
struct SwiftPrebuiltExternalModuleDetails: Codable {
|
||||||
/// The path to the already-compiled module that must be used instead of
|
/// The path to the already-compiled module that must be used instead of
|
||||||
@@ -152,10 +133,6 @@ struct ModuleInfo: Codable {
|
|||||||
/// a bridging header.
|
/// a bridging header.
|
||||||
case swift(SwiftModuleDetails)
|
case swift(SwiftModuleDetails)
|
||||||
|
|
||||||
/// Swift placeholder modules carry additional details that specify their
|
|
||||||
/// module doc path and source info paths.
|
|
||||||
case swiftPlaceholder(SwiftPlaceholderModuleDetails)
|
|
||||||
|
|
||||||
/// Swift externally-prebuilt modules must communicate the path to pre-built binary artifacts
|
/// Swift externally-prebuilt modules must communicate the path to pre-built binary artifacts
|
||||||
case swiftPrebuiltExternal(SwiftPrebuiltExternalModuleDetails)
|
case swiftPrebuiltExternal(SwiftPrebuiltExternalModuleDetails)
|
||||||
|
|
||||||
@@ -167,7 +144,6 @@ struct ModuleInfo: Codable {
|
|||||||
extension ModuleInfo.Details: Codable {
|
extension ModuleInfo.Details: Codable {
|
||||||
enum CodingKeys: CodingKey {
|
enum CodingKeys: CodingKey {
|
||||||
case swift
|
case swift
|
||||||
case swiftPlaceholder
|
|
||||||
case swiftPrebuiltExternal
|
case swiftPrebuiltExternal
|
||||||
case clang
|
case clang
|
||||||
}
|
}
|
||||||
@@ -179,18 +155,12 @@ extension ModuleInfo.Details: Codable {
|
|||||||
self = .swift(details)
|
self = .swift(details)
|
||||||
} catch {
|
} catch {
|
||||||
do {
|
do {
|
||||||
let details = try container.decode(SwiftPlaceholderModuleDetails.self,
|
let details = try container.decode(SwiftPrebuiltExternalModuleDetails.self,
|
||||||
forKey: .swiftPlaceholder)
|
forKey: .swiftPrebuiltExternal)
|
||||||
self = .swiftPlaceholder(details)
|
self = .swiftPrebuiltExternal(details)
|
||||||
} catch {
|
} catch {
|
||||||
do {
|
let details = try container.decode(ClangModuleDetails.self, forKey: .clang)
|
||||||
let details = try container.decode(SwiftPrebuiltExternalModuleDetails.self,
|
self = .clang(details)
|
||||||
forKey: .swiftPrebuiltExternal)
|
|
||||||
self = .swiftPrebuiltExternal(details)
|
|
||||||
} catch {
|
|
||||||
let details = try container.decode(ClangModuleDetails.self, forKey: .clang)
|
|
||||||
self = .clang(details)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -200,8 +170,6 @@ extension ModuleInfo.Details: Codable {
|
|||||||
switch self {
|
switch self {
|
||||||
case .swift(let details):
|
case .swift(let details):
|
||||||
try container.encode(details, forKey: .swift)
|
try container.encode(details, forKey: .swift)
|
||||||
case .swiftPlaceholder(let details):
|
|
||||||
try container.encode(details, forKey: .swiftPlaceholder)
|
|
||||||
case .swiftPrebuiltExternal(let details):
|
case .swiftPrebuiltExternal(let details):
|
||||||
try container.encode(details, forKey: .swiftPrebuiltExternal)
|
try container.encode(details, forKey: .swiftPrebuiltExternal)
|
||||||
case .clang(let details):
|
case .clang(let details):
|
||||||
|
|||||||
@@ -1,42 +0,0 @@
|
|||||||
// RUN: %empty-directory(%t)
|
|
||||||
// RUN: mkdir -p %t/clang-module-cache
|
|
||||||
// RUN: mkdir -p %t/inputs
|
|
||||||
|
|
||||||
// RUN: echo "[{" > %/t/inputs/map.json
|
|
||||||
// RUN: echo "\"moduleName\": \"SomeExternalModule\"," >> %/t/inputs/map.json
|
|
||||||
// RUN: echo "\"modulePath\": \"%/t/inputs/SomeExternalModule.swiftmodule\"," >> %/t/inputs/map.json
|
|
||||||
// RUN: echo "\"docPath\": \"%/t/inputs/SomeExternalModule.swiftdoc\"," >> %/t/inputs/map.json
|
|
||||||
// RUN: echo "\"sourceInfoPath\": \"%/t/inputs/SomeExternalModule.swiftsourceinfo\"," >> %/t/inputs/map.json
|
|
||||||
// RUN: echo "\"isFramework\": false" >> %/t/inputs/map.json
|
|
||||||
// RUN: echo "}]" >> %/t/inputs/map.json
|
|
||||||
|
|
||||||
// RUN: %target-swift-frontend -scan-dependencies -module-load-mode prefer-interface -module-cache-path %t/clang-module-cache %s -placeholder-dependency-module-map-file %t/inputs/map.json -o %t/deps.json -I %S/Inputs/CHeaders -I %S/Inputs/Swift -emit-dependencies -emit-dependencies-path %t/deps.d -import-objc-header %S/Inputs/CHeaders/Bridging.h -swift-version 4
|
|
||||||
// RUN: %validate-json %t/deps.json | %FileCheck %s
|
|
||||||
|
|
||||||
// Ensure that round-trip serialization does not affect result
|
|
||||||
// RUN: %target-swift-frontend -scan-dependencies -module-load-mode prefer-interface -test-dependency-scan-cache-serialization -module-cache-path %t/clang-module-cache %s -placeholder-dependency-module-map-file %t/inputs/map.json -o %t/deps.json -I %S/Inputs/CHeaders -I %S/Inputs/Swift -emit-dependencies -emit-dependencies-path %t/deps.d -import-objc-header %S/Inputs/CHeaders/Bridging.h -swift-version 4
|
|
||||||
// RUN: %validate-json %t/deps.json | %FileCheck %s
|
|
||||||
|
|
||||||
// REQUIRES: executable_test
|
|
||||||
// REQUIRES: objc_interop
|
|
||||||
#if canImport(SomeExternalModule)
|
|
||||||
import SomeExternalModule
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// CHECK: "mainModuleName": "deps"
|
|
||||||
|
|
||||||
/// --------Main module
|
|
||||||
// CHECK-LABEL: "modulePath": "deps.swiftmodule",
|
|
||||||
// CHECK-NEXT: sourceFiles
|
|
||||||
// CHECK-NEXT: can_import_placeholder.swift
|
|
||||||
|
|
||||||
// CHECK: directDependencies
|
|
||||||
// CHECK-NEXT: {
|
|
||||||
// CHECK-DAG: "swift": "F"
|
|
||||||
// CHECK-DAG: "swiftPlaceholder": "SomeExternalModule"
|
|
||||||
// CHECK-DAG: "swift": "Swift"
|
|
||||||
// CHECK-DAG: "swift": "SwiftOnoneSupport"
|
|
||||||
// CHECK-DAG: "swift": "_Concurrency"
|
|
||||||
// CHECK-DAG: "swift": "_StringProcessing"
|
|
||||||
// CHECK-DAG: "clang": "_SwiftConcurrencyShims"
|
|
||||||
// CHECK: ],
|
|
||||||
@@ -1,96 +0,0 @@
|
|||||||
// RUN: %empty-directory(%t)
|
|
||||||
// RUN: mkdir -p %t/clang-module-cache
|
|
||||||
// RUN: mkdir -p %t/inputs
|
|
||||||
|
|
||||||
// RUN: echo "[{" > %/t/inputs/map.json
|
|
||||||
// RUN: echo "\"moduleName\": \"SomeExternalModule\"," >> %/t/inputs/map.json
|
|
||||||
// RUN: echo "\"modulePath\": \"%/t/inputs/SomeExternalModule.swiftmodule\"," >> %/t/inputs/map.json
|
|
||||||
// RUN: echo "\"docPath\": \"%/t/inputs/SomeExternalModule.swiftdoc\"," >> %/t/inputs/map.json
|
|
||||||
// RUN: echo "\"sourceInfoPath\": \"%/t/inputs/SomeExternalModule.swiftsourceinfo\"," >> %/t/inputs/map.json
|
|
||||||
// RUN: echo "\"isFramework\": false" >> %/t/inputs/map.json
|
|
||||||
// RUN: echo "}]" >> %/t/inputs/map.json
|
|
||||||
|
|
||||||
// RUN: %target-swift-frontend -scan-dependencies -module-load-mode prefer-interface -module-cache-path %t/clang-module-cache %s -placeholder-dependency-module-map-file %t/inputs/map.json -o %t/deps.json -I %S/Inputs/CHeaders -I %S/Inputs/Swift -emit-dependencies -emit-dependencies-path %t/deps.d -import-objc-header %S/Inputs/CHeaders/Bridging.h -swift-version 4
|
|
||||||
|
|
||||||
// Check the contents of the JSON output
|
|
||||||
// RUN: %validate-json %t/deps.json | %FileCheck %s
|
|
||||||
|
|
||||||
// Check the make-style dependencies file
|
|
||||||
// RUN: %FileCheck %s -check-prefix CHECK-MAKE-DEPS < %t/deps.d
|
|
||||||
|
|
||||||
// Check that the JSON parses correctly into the canonical Swift data
|
|
||||||
// structures.
|
|
||||||
|
|
||||||
// RUN: mkdir -p %t/PrintGraph
|
|
||||||
// RUN: cp %S/Inputs/PrintGraph.swift %t/main.swift
|
|
||||||
// RUN: %target-build-swift %S/Inputs/ModuleDependencyGraph.swift %t/main.swift -o %t/main
|
|
||||||
// RUN: %target-codesign %t/main
|
|
||||||
// RUN: %target-run %t/main %t/deps.json
|
|
||||||
|
|
||||||
// Ensure that round-trip serialization does not affect result
|
|
||||||
// RUN: %target-swift-frontend -scan-dependencies -module-load-mode prefer-interface -test-dependency-scan-cache-serialization -module-cache-path %t/clang-module-cache %s -placeholder-dependency-module-map-file %t/inputs/map.json -o %t/deps.json -I %S/Inputs/CHeaders -I %S/Inputs/Swift -import-objc-header %S/Inputs/CHeaders/Bridging.h -swift-version 4
|
|
||||||
// RUN: %validate-json %t/deps.json | %FileCheck %s
|
|
||||||
|
|
||||||
// REQUIRES: executable_test
|
|
||||||
// REQUIRES: objc_interop
|
|
||||||
import SomeExternalModule
|
|
||||||
|
|
||||||
// CHECK: "mainModuleName": "deps"
|
|
||||||
|
|
||||||
/// --------Main module
|
|
||||||
// CHECK-LABEL: "modulePath": "deps.swiftmodule",
|
|
||||||
// CHECK-NEXT: sourceFiles
|
|
||||||
// CHECK-NEXT: module_deps_external.swift
|
|
||||||
|
|
||||||
// CHECK: directDependencies
|
|
||||||
// CHECK-NEXT: {
|
|
||||||
// CHECK-DAG: "clang": "F"
|
|
||||||
// CHECK-DAG: "swiftPlaceholder": "SomeExternalModule"
|
|
||||||
// CHECK-DAG: "swift": "Swift"
|
|
||||||
// CHECK-DAG: "swift": "SwiftOnoneSupport"
|
|
||||||
// CHECK-DAG: "swift": "_Concurrency"
|
|
||||||
// CHECK-DAG: "swift": "_StringProcessing"
|
|
||||||
// CHECK-DAG: "clang": "_SwiftConcurrencyShims"
|
|
||||||
// CHECK: ],
|
|
||||||
|
|
||||||
// CHECK: "bridgingHeader":
|
|
||||||
// CHECK-NEXT: "path":
|
|
||||||
// CHECK-SAME: Bridging.h
|
|
||||||
|
|
||||||
// CHECK-NEXT: "sourceFiles":
|
|
||||||
// CHECK-NEXT: Bridging.h
|
|
||||||
// CHECK-NEXT: BridgingOther.h
|
|
||||||
|
|
||||||
// CHECK: "moduleDependencies": [
|
|
||||||
// CHECK-NEXT: "F"
|
|
||||||
// CHECK-NEXT: ],
|
|
||||||
|
|
||||||
// CHECK: "swiftOverlayDependencies": [
|
|
||||||
// CHECK-NEXT: {
|
|
||||||
// CHECK-NEXT: "swift": "F"
|
|
||||||
// CHECK-NEXT: }
|
|
||||||
// CHECK-NEXT: ]
|
|
||||||
|
|
||||||
/// --------Swift external module SomeExternalModule
|
|
||||||
// CHECK-LABEL: "modulePath": "{{.*}}{{/|\\}}SomeExternalModule.swiftmodule",
|
|
||||||
// CHECK-NEXT: "details": {
|
|
||||||
// CHECK-NEXT: "swiftPlaceholder": {
|
|
||||||
// CHECK-NEXT: "moduleDocPath": "BUILD_DIR/{{.*}}/ScanDependencies/Output/module_deps_external.swift.tmp/inputs/SomeExternalModule.swiftdoc",
|
|
||||||
// CHECK-NEXT: "moduleSourceInfoPath": "BUILD_DIR/{{.*}}/ScanDependencies/Output/module_deps_external.swift.tmp/inputs/SomeExternalModule.swiftsourceinfo"
|
|
||||||
|
|
||||||
/// --------Swift module Swift
|
|
||||||
// CHECK-LABEL: "modulePath": "{{.*}}{{/|\\}}Swift-{{.*}}.swiftmodule",
|
|
||||||
|
|
||||||
// CHECK: directDependencies
|
|
||||||
// CHECK-NEXT: {
|
|
||||||
// CHECK-NEXT: "clang": "SwiftShims"
|
|
||||||
|
|
||||||
/// --------Clang module SwiftShims
|
|
||||||
// CHECK-LABEL: "modulePath": "{{.*}}/SwiftShims-{{.*}}.pcm",
|
|
||||||
|
|
||||||
// Check make-style dependencies
|
|
||||||
// CHECK-MAKE-DEPS: module_deps_external.swift
|
|
||||||
// CHECK-MAKE-DEPS-SAME: Bridging.h
|
|
||||||
// CHECK-MAKE-DEPS-SAME: BridgingOther.h
|
|
||||||
// CHECK-MAKE-DEPS-SAME: module.modulemap
|
|
||||||
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
// RUN: %empty-directory(%t)
|
|
||||||
// RUN: mkdir -p %t/clang-module-cache
|
|
||||||
// RUN: mkdir -p %t/inputs
|
|
||||||
|
|
||||||
// RUN: echo "[{" > %/t/inputs/map.json
|
|
||||||
// RUN: echo "\"moduleName\": \"Darwin\"," >> %/t/inputs/map.json
|
|
||||||
// RUN: echo "\"modulePath\": \"%/t/inputs/Darwin.swiftmodule\"," >> %/t/inputs/map.json
|
|
||||||
// RUN: echo "\"docPath\": \"%/t/inputs/Darwin.swiftdoc\"," >> %/t/inputs/map.json
|
|
||||||
// RUN: echo "\"sourceInfoPath\": \"%/t/inputs/Darwin.swiftsourceinfo\"," >> %/t/inputs/map.json
|
|
||||||
// RUN: echo "\"isFramework\": false," >> %/t/inputs/map.json
|
|
||||||
// RUN: echo "\"isSystem\": true" >> %/t/inputs/map.json
|
|
||||||
// RUN: echo "}]" >> %/t/inputs/map.json
|
|
||||||
|
|
||||||
// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t/clang-module-cache %s -placeholder-dependency-module-map-file %t/inputs/map.json -o %t/deps.json
|
|
||||||
|
|
||||||
// Check the contents of the JSON output
|
|
||||||
// RUN: %validate-json %t/deps.json > %t/validated_deps.json
|
|
||||||
// RUN: %FileCheck %s < %t/validated_deps.json
|
|
||||||
|
|
||||||
// REQUIRES: executable_test
|
|
||||||
// REQUIRES: objc_interop
|
|
||||||
// REQUIRES: OS=macosx
|
|
||||||
import Metal
|
|
||||||
|
|
||||||
// Ensure the dependency on Darwin is captured even though it is a placeholder
|
|
||||||
|
|
||||||
// CHECK: "modulePath": "{{.*}}{{/|\\}}Metal-{{.*}}.swiftmodule",
|
|
||||||
// CHECK: "directDependencies": [
|
|
||||||
// CHECK: {
|
|
||||||
// CHECK: "swiftPlaceholder": "Darwin"
|
|
||||||
// CHECK: },
|
|
||||||
@@ -175,7 +175,7 @@ export *\n\
|
|||||||
for (auto &command : CommandStrArr) {
|
for (auto &command : CommandStrArr) {
|
||||||
Command.push_back(command.c_str());
|
Command.push_back(command.c_str());
|
||||||
}
|
}
|
||||||
auto DependenciesOrErr = ScannerTool.getDependencies(Command, {}, {});
|
auto DependenciesOrErr = ScannerTool.getDependencies(Command, {});
|
||||||
ASSERT_FALSE(DependenciesOrErr.getError());
|
ASSERT_FALSE(DependenciesOrErr.getError());
|
||||||
auto Dependencies = DependenciesOrErr.get();
|
auto Dependencies = DependenciesOrErr.get();
|
||||||
// TODO: Output/verify dependency graph correctness
|
// TODO: Output/verify dependency graph correctness
|
||||||
@@ -309,7 +309,7 @@ public func funcB() { }\n"));
|
|||||||
|
|
||||||
auto ScanDiagnosticConsumer = std::make_shared<DependencyScanDiagnosticCollector>();
|
auto ScanDiagnosticConsumer = std::make_shared<DependencyScanDiagnosticCollector>();
|
||||||
|
|
||||||
auto DependenciesOrErr = ScannerTool.getDependencies(Command, {}, {});
|
auto DependenciesOrErr = ScannerTool.getDependencies(Command, {});
|
||||||
|
|
||||||
// Ensure a hollow output with diagnostic info is produced
|
// Ensure a hollow output with diagnostic info is produced
|
||||||
ASSERT_FALSE(DependenciesOrErr.getError());
|
ASSERT_FALSE(DependenciesOrErr.getError());
|
||||||
|
|||||||
Reference in New Issue
Block a user