Skip to content

Commit 3fe97c2

Browse files
committed
Frontend: Intro -public-module-name flag
Introduce the concept of public facing module name designed to hide support module from external clients. This name should be set on a support module that is an implementation detail of a public module, the public module name of the support module should be the name of the public module. For example, BigKitCore’s public module name can be set to BigKit for diagnostics to refer to both modules as BigKit. This name is used to refer to the support module in diagnostics for external clients. We determine if a client is external if they also import the module identified by the public module name. If a client doesn’t import the public module, diagnostics will always use the real name of the module. The public module name is set with the flag -public-module-name and it's preserved in textual swiftinterfaces and binary swiftmodules. rdar://134527933
1 parent 2eade1e commit 3fe97c2

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

include/swift/Frontend/FrontendOptions.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ class FrontendOptions {
7070
/// Module name to use when referenced in clients module interfaces.
7171
std::string ExportAsName;
7272

73+
/// The public facing name of the module to build.
74+
std::string PublicModuleName;
75+
7376
/// Arguments which should be passed in immediate mode.
7477
std::vector<std::string> ImmediateArgv;
7578

include/swift/Option/Options.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,9 @@ def package_name : Separate<["-"], "package-name">,
579579
def export_as : Separate<["-"], "export-as">,
580580
Flags<[FrontendOption, ModuleInterfaceOption]>,
581581
HelpText<"Module name to use when referenced in clients module interfaces">;
582+
def public_module_name : Separate<["-"], "public-module-name">,
583+
Flags<[FrontendOption, ModuleInterfaceOption]>,
584+
HelpText<"Public facing module name to use in diagnostics and documentation">;
582585

583586
def emit_module : Flag<["-"], "emit-module">,
584587
Flags<[FrontendOption, NoInteractiveOption, SupplementaryOutput]>,

lib/Frontend/ArgsToFrontendOptionsConverter.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,9 @@ bool ArgsToFrontendOptionsConverter::convert(
288288
Opts.ExportAsName = exportAs;
289289
}
290290

291+
if (const Arg *A = Args.getLastArg(OPT_public_module_name))
292+
Opts.PublicModuleName = A->getValue();
293+
291294
// This must be called after computing module name, module abi name,
292295
// and module link name. If computing module aliases is unsuccessful,
293296
// return early.

0 commit comments

Comments
 (0)