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
120 lines
3.8 KiB
C++
120 lines
3.8 KiB
C++
//===--- Tools.h - Tool Implementations -------------------------*- 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_TOOLS_H
|
|
#define SWIFT_DRIVER_TOOLS_H
|
|
|
|
#include "swift/Basic/LLVM.h"
|
|
#include "swift/Driver/Tool.h"
|
|
#include "llvm/ADT/Triple.h"
|
|
#include "llvm/Option/Option.h"
|
|
#include "llvm/Support/Compiler.h"
|
|
|
|
namespace swift {
|
|
namespace driver {
|
|
|
|
namespace toolchains {
|
|
class Darwin;
|
|
}
|
|
|
|
namespace tools {
|
|
|
|
class LLVM_LIBRARY_VISIBILITY Swift : public Tool {
|
|
public:
|
|
explicit Swift(const ToolChain &TC) : Tool("swift", "swift frontend", TC) {}
|
|
|
|
virtual bool hasGoodDiagnostics() const { return true; }
|
|
|
|
virtual Job *constructJob(const JobAction &JA,
|
|
std::unique_ptr<JobList> Inputs,
|
|
std::unique_ptr<CommandOutput> Output,
|
|
const ActionList &InputActions,
|
|
const llvm::opt::ArgList &Args,
|
|
const OutputInfo &OI) const;
|
|
};
|
|
|
|
class LLVM_LIBRARY_VISIBILITY MergeModule : public Tool {
|
|
public:
|
|
explicit MergeModule(const ToolChain &TC)
|
|
: Tool("merge-module", "merge-module", TC) {}
|
|
|
|
virtual bool hasGoodDiagnostics() const { return true; }
|
|
|
|
virtual Job *constructJob(const JobAction &JA,
|
|
std::unique_ptr<JobList> Inputs,
|
|
std::unique_ptr<CommandOutput> Output,
|
|
const ActionList &InputActions,
|
|
const llvm::opt::ArgList &Args,
|
|
const OutputInfo &OI) const;
|
|
};
|
|
|
|
class LLVM_LIBRARY_VISIBILITY LLDB : public Tool {
|
|
mutable std::string Path;
|
|
struct {
|
|
mutable unsigned DidCheckRelativeToDriver : 1;
|
|
} Bits;
|
|
public:
|
|
explicit LLDB(const ToolChain &TC) : Tool("LLDB", "LLDB REPL", TC), Bits() {}
|
|
|
|
bool isPresentRelativeToDriver() const;
|
|
|
|
virtual Job *constructJob(const JobAction &JA,
|
|
std::unique_ptr<JobList> Inputs,
|
|
std::unique_ptr<CommandOutput> Output,
|
|
const ActionList &InputActions,
|
|
const llvm::opt::ArgList &Args,
|
|
const OutputInfo &OI) const;
|
|
};
|
|
|
|
|
|
namespace darwin {
|
|
|
|
llvm::Triple::ArchType getArchTypeForDarwinArchName(StringRef DarwinArchName);
|
|
|
|
class LLVM_LIBRARY_VISIBILITY DarwinTool : public Tool {
|
|
virtual void anchor();
|
|
protected:
|
|
/// Add the appropriate -arch argument based on \p Args.
|
|
void AddDarwinArch(const llvm::opt::ArgList &Args,
|
|
llvm::opt::ArgStringList &CmdArgs) const;
|
|
|
|
const toolchains::Darwin &getDarwinToolChain() const {
|
|
return reinterpret_cast<const toolchains::Darwin &>(getToolChain());
|
|
}
|
|
|
|
public:
|
|
DarwinTool(const char *Name, const char *ShortName, const ToolChain &TC)
|
|
: Tool(Name, ShortName, TC) {}
|
|
};
|
|
|
|
class LLVM_LIBRARY_VISIBILITY Linker : public DarwinTool {
|
|
public:
|
|
explicit Linker(const ToolChain &TC)
|
|
: DarwinTool("darwin::Linker", "linker", TC) {}
|
|
|
|
virtual Job *constructJob(const JobAction &JA,
|
|
std::unique_ptr<JobList> Inputs,
|
|
std::unique_ptr<CommandOutput> Output,
|
|
const ActionList &InputActions,
|
|
const llvm::opt::ArgList &Args,
|
|
const OutputInfo &OI) const;
|
|
};
|
|
|
|
} // end namespace darwin
|
|
|
|
} // end namespace tools
|
|
|
|
} // end namespace driver
|
|
} // end namespace swift
|
|
|
|
#endif
|