mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 10:11:04 +01:00
Add a clang subcommand. (#4322)
This makes something like `bazel run :toolchain -- clang -- -c test.cpp` work, because that can be run in-process. Note that `bazel run :toolchain -- clang -- test.cpp` still requires subprocessing, and does not work. Note, the vision here is that we are trying to align how clang and carbon compile c++ code. This is work towards intertwining command execution. --------- Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
This commit is contained in:
co-authored by
Chandler Carruth
parent
c7057eff89
commit
c107aaad13
@@ -10,12 +10,9 @@
|
||||
|
||||
#include "common/command_line.h"
|
||||
#include "common/version.h"
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "llvm/ADT/StringExtras.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/IR/LLVMContext.h"
|
||||
#include "llvm/Support/Path.h"
|
||||
#include "toolchain/base/value_store.h"
|
||||
#include "toolchain/driver/clang_subcommand.h"
|
||||
#include "toolchain/driver/compile_subcommand.h"
|
||||
#include "toolchain/driver/link_subcommand.h"
|
||||
|
||||
namespace Carbon {
|
||||
|
||||
@@ -27,6 +24,7 @@ struct Options {
|
||||
|
||||
bool verbose;
|
||||
|
||||
ClangSubcommand clang;
|
||||
CompileSubcommand compile;
|
||||
LinkSubcommand link;
|
||||
|
||||
@@ -63,6 +61,11 @@ auto Options::Build(CommandLine::CommandBuilder& b) -> void {
|
||||
},
|
||||
[&](CommandLine::FlagBuilder& arg_b) { arg_b.Set(&verbose); });
|
||||
|
||||
b.AddSubcommand(ClangOptions::Info, [&](CommandLine::CommandBuilder& sub_b) {
|
||||
clang.BuildOptions(sub_b);
|
||||
sub_b.Do([&] { subcommand = &clang; });
|
||||
});
|
||||
|
||||
b.AddSubcommand(CompileOptions::Info,
|
||||
[&](CommandLine::CommandBuilder& sub_b) {
|
||||
compile.BuildOptions(sub_b);
|
||||
|
||||
Reference in New Issue
Block a user