mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[ModuleInterface] Intro export-as for Swift modules
Introduce a new flag `-export-as` to specify a name used to identify the target module in swiftinterfaces. This provides an analoguous feature for Swift module as Clang's `export_as` feature. In practice it should be used when a lower level module `MyKitCore` is desired to be shown publicly as a downstream module `MyKit`. This should be used in conjunction with `@_exported import MyKitCore` from `MyKit` that allows clients to refer to all services as being part of `MyKit`, while the new `-export-as MyKit` from `MyKitCore` will ensure that the clients swiftinterfaces also use the `MyKit` name for all services. In the current implementation, the export-as name is used in the module's clients and not in the declarer's swiftinterface (e.g. `MyKitCore`'s swiftinterface still uses the `MyKitCore` module name). This way the module swiftinterface can be verified. In the future, we may want a similar behavior for other modules in between `MyKitCore` and `MyKit` as verifying a swiftinterface referencing `MyKit` without it being imported would fail. rdar://103888618
This commit is contained in:
@@ -166,6 +166,9 @@ static bool readOptionsBlock(llvm::BitstreamCursor &cursor,
|
||||
case options_block::MODULE_PACKAGE_NAME:
|
||||
extendedInfo.setModulePackageName(blobData);
|
||||
break;
|
||||
case options_block::MODULE_EXPORT_AS_NAME:
|
||||
extendedInfo.setExportAsName(blobData);
|
||||
break;
|
||||
default:
|
||||
// Unknown options record, possibly for use by a future version of the
|
||||
// module format.
|
||||
@@ -1350,6 +1353,7 @@ ModuleFileSharedCore::ModuleFileSharedCore(
|
||||
MiscVersion = info.miscVersion;
|
||||
ModuleABIName = extInfo.getModuleABIName();
|
||||
ModulePackageName = extInfo.getModulePackageName();
|
||||
ModuleExportAsName = extInfo.getExportAsName();
|
||||
|
||||
hasValidControlBlock = true;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user