link_subcommand.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. #ifndef CARBON_TOOLCHAIN_DRIVER_LINK_SUBCOMMAND_H_
  5. #define CARBON_TOOLCHAIN_DRIVER_LINK_SUBCOMMAND_H_
  6. #include "common/command_line.h"
  7. #include "llvm/ADT/SmallVector.h"
  8. #include "llvm/ADT/StringRef.h"
  9. #include "toolchain/driver/codegen_options.h"
  10. #include "toolchain/driver/driver_env.h"
  11. #include "toolchain/driver/driver_subcommand.h"
  12. namespace Carbon {
  13. // Options for the link subcommand.
  14. //
  15. // See the implementation of `Build` for documentation on members.
  16. struct LinkOptions {
  17. static const CommandLine::CommandInfo Info;
  18. auto Build(CommandLine::CommandBuilder& b) -> void;
  19. CodegenOptions codegen_options;
  20. llvm::StringRef output_filename;
  21. llvm::SmallVector<llvm::StringRef> object_filenames;
  22. };
  23. // Implements the link subcommand of the driver.
  24. class LinkSubcommand : public DriverSubcommand {
  25. public:
  26. auto BuildOptions(CommandLine::CommandBuilder& b) { options_.Build(b); }
  27. auto Run(DriverEnv& driver_env) -> DriverResult override;
  28. private:
  29. LinkOptions options_;
  30. };
  31. } // namespace Carbon
  32. #endif // CARBON_TOOLCHAIN_DRIVER_LINK_SUBCOMMAND_H_