mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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
82 lines
2.2 KiB
C++
82 lines
2.2 KiB
C++
//===--- ToolChain.h - Collections of tools for one platform ----*- C++ -*-===//
|
|
//
|
|
// 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
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef SWIFT_DRIVER_TOOLCHAIN_H
|
|
#define SWIFT_DRIVER_TOOLCHAIN_H
|
|
|
|
#include "swift/Basic/LLVM.h"
|
|
#include "swift/Driver/Action.h"
|
|
#include "swift/Driver/Types.h"
|
|
#include "llvm/ADT/Triple.h"
|
|
|
|
#include <memory>
|
|
|
|
namespace llvm {
|
|
namespace opt {
|
|
class ArgList;
|
|
class DerivedArgList;
|
|
class InputArgList;
|
|
}
|
|
}
|
|
|
|
namespace swift {
|
|
namespace driver {
|
|
class Compilation;
|
|
class Driver;
|
|
class Tool;
|
|
|
|
class ToolChain {
|
|
const Driver &D;
|
|
const llvm::Triple Triple;
|
|
|
|
mutable std::unique_ptr<Tool> Swift;
|
|
mutable std::unique_ptr<Tool> MergeModule;
|
|
mutable std::unique_ptr<Tool> LLDB;
|
|
mutable std::unique_ptr<Tool> Linker;
|
|
Tool *getSwift() const;
|
|
Tool *getMergeModule() const;
|
|
Tool *getLLDB() const;
|
|
Tool *getLinker() const;
|
|
|
|
protected:
|
|
ToolChain(const Driver &D, const llvm::Triple &T) : D(D), Triple(T) {}
|
|
|
|
virtual std::unique_ptr<Tool> buildLinker() const = 0;
|
|
|
|
public:
|
|
virtual ~ToolChain() = default;
|
|
|
|
// Accessors
|
|
|
|
const Driver &getDriver() const { return D; }
|
|
const llvm::Triple &getTriple() const { return Triple; }
|
|
|
|
llvm::Triple::ArchType getArch() const { return Triple.getArch(); }
|
|
StringRef getArchName() const { return Triple.getArchName(); }
|
|
StringRef getPlatform() const { return Triple.getVendorName(); }
|
|
StringRef getOS() const { return Triple.getOSName(); }
|
|
|
|
std::string getTripleString() const { return Triple.getTriple(); }
|
|
|
|
/// Choose a tool to use to handle the action \p JA.
|
|
virtual Tool *selectTool(const JobAction &JA) const;
|
|
|
|
// Platform defaults information
|
|
|
|
/// Return the default langauge type to use for the given extension.
|
|
virtual types::ID lookupTypeForExtension(StringRef Ext) const;
|
|
};
|
|
} // end namespace driver
|
|
} // end namespace swift
|
|
|
|
#endif
|