Files
swift-mirror/lib/Driver/ToolChain.cpp
Jordan Rose 9c6ddc085f [driver] Add -lldb-repl and -integrated-repl modes.
Since LLDB is taking over as the REPL for Swift, we eventually want "swift"
and "swift -repl" to invoke "lldb --repl" rather than the frontend. However,
we only want to do this if the LLDB that's present is related to the Swift
that's present -- we don't want to invoke some random LLDB on the system
or in some other Xcode installation. Therefore, Swift searches for LLDB--
first next to the driver, then in the usr/bin/ outside of a toolchain--
before choosing to use it.

If the user just passes -repl and an LLDB is not found relative to the
driver, the existing "integrated" REPL will be launched instead.*

If the user passes -lldb-repl and an LLDB is not found relative to the
driver, one from the user's PATH will be chosen (like the linker).

The user can also pass -integrated-repl to get the existing behavior.
"swift -frontend -repl" always uses the integrated REPL.

* Since LLDB's not quite ready to be the REPL yet, "swift -repl" still
invokes the integrated REPL. "swift -repl -experimental-prefer-lldb" tests
the new behavior; this option will become the default (and the flag removed)
in <rdar://problem/16776719>.

<rdar://problem/16776705>

Swift SVN r17134
2014-05-01 02:15:53 +00:00

75 lines
2.0 KiB
C++

//===--- ToolChain.cpp - Collections of tools for one platform ------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
#include "swift/Driver/ToolChain.h"
#include "Tools.h"
#include "swift/Driver/Tool.h"
using namespace swift;
using namespace swift::driver;
using namespace llvm::opt;
Tool *ToolChain::getSwift() const {
if (!Swift)
Swift.reset(new tools::Swift(*this));
return Swift.get();
}
Tool *ToolChain::getMergeModule() const {
if (!MergeModule)
MergeModule.reset(new tools::MergeModule(*this));
return MergeModule.get();
}
Tool *ToolChain::getLLDB() const {
if (!LLDB)
LLDB.reset(new tools::LLDB(*this));
return LLDB.get();
}
Tool *ToolChain::getLinker() const {
if (!Linker)
Linker = buildLinker();
return Linker.get();
}
Tool *ToolChain::selectTool(const JobAction &JA) const {
switch (JA.getKind()) {
case Action::CompileJob:
return getSwift();
case Action::MergeModuleJob:
return getMergeModule();
case Action::LinkJob:
return getLinker();
case Action::REPLJob:
switch (cast<REPLJobAction>(JA).getRequestedMode()) {
case REPLJobAction::Mode::Integrated:
return getSwift();
case REPLJobAction::Mode::RequireLLDB:
return getLLDB();
case REPLJobAction::Mode::PreferLLDB:
if (static_cast<tools::LLDB *>(getLLDB())->isPresentRelativeToDriver())
return getLLDB();
return getSwift();
}
case Action::Input:
llvm_unreachable("Invalid tool kind.");
}
llvm_unreachable("Invalid tool kind.");
}
types::ID ToolChain::lookupTypeForExtension(StringRef Ext) const {
return types::lookupTypeForExtension(Ext);
}