Refactor subcommand addition for sharing. (#4474)

Trying to standardize the setup a little more.
This commit is contained in:
Jon Ross-Perkins
2024-11-04 22:42:57 +00:00
committed by GitHub
parent ea0b0b4b48
commit 26e58b4587
12 changed files with 110 additions and 87 deletions
+14 -12
View File
@@ -9,18 +9,6 @@
namespace Carbon {
constexpr CommandLine::CommandInfo LinkOptions::Info = {
.name = "link",
.help = R"""(
Link Carbon executables.
This subcommand links Carbon executables by combining object files.
TODO: Support linking binary libraries, both archives and shared libraries.
TODO: Support linking against binary libraries.
)""",
};
auto LinkOptions::Build(CommandLine::CommandBuilder& b) -> void {
b.AddStringPositionalArg(
{
@@ -80,6 +68,20 @@ static void AddOSFlags(llvm::StringRef target,
}
}
static constexpr CommandLine::CommandInfo SubcommandInfo = {
.name = "link",
.help = R"""(
Link Carbon executables.
This subcommand links Carbon executables by combining object files.
TODO: Support linking binary libraries, both archives and shared libraries.
TODO: Support linking against binary libraries.
)""",
};
LinkSubcommand::LinkSubcommand() : DriverSubcommand(SubcommandInfo) {}
auto LinkSubcommand::Run(DriverEnv& driver_env) -> DriverResult {
// TODO: Currently we use the Clang driver to link. This works well on Unix
// OSes but we likely need to directly build logic to invoke `link.exe` on