Driver: Add -ccc-print-bindings option (for testing); the Python
driver has no corresponding option. llvm-svn: 67125
This commit is contained in:
parent
82116f8df4
commit
b39cc52eda
3 changed files with 41 additions and 15 deletions
|
|
@ -78,6 +78,9 @@ public:
|
|||
/// Echo commands while executing (in -v style).
|
||||
bool CCCEcho : 1;
|
||||
|
||||
/// Only print tool bindings, don't build any jobs.
|
||||
bool CCCPrintBindings : 1;
|
||||
|
||||
/// Don't use clang for any tasks.
|
||||
bool CCCNoClang : 1;
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ Driver::Driver(const char *_Name, const char *_Dir,
|
|||
Name(_Name), Dir(_Dir), DefaultHostTriple(_DefaultHostTriple),
|
||||
DefaultImageName(_DefaultImageName),
|
||||
Host(0),
|
||||
CCCIsCXX(false), CCCEcho(false),
|
||||
CCCIsCXX(false), CCCEcho(false), CCCPrintBindings(false),
|
||||
CCCNoClang(false), CCCNoClangCXX(false), CCCNoClangCPP(false),
|
||||
SuppressMissingInputWarning(false)
|
||||
{
|
||||
|
|
@ -114,6 +114,8 @@ Compilation *Driver::BuildCompilation(int argc, const char **argv) {
|
|||
CCCPrintOptions = true;
|
||||
} else if (!strcmp(Opt, "print-phases")) {
|
||||
CCCPrintActions = true;
|
||||
} else if (!strcmp(Opt, "print-bindings")) {
|
||||
CCCPrintBindings = true;
|
||||
} else if (!strcmp(Opt, "cxx")) {
|
||||
CCCIsCXX = true;
|
||||
} else if (!strcmp(Opt, "echo")) {
|
||||
|
|
@ -729,27 +731,32 @@ void Driver::BuildJobsForAction(Compilation &C,
|
|||
|
||||
// Determine the place to write output to (nothing, pipe, or
|
||||
// filename) and where to put the new job.
|
||||
PipedJob *OutputJob = 0;
|
||||
const char *Output = 0;
|
||||
if (JA->getType() == types::TY_Nothing) {
|
||||
;
|
||||
Result = InputInfo(A->getType(), BaseInput);
|
||||
} else if (OutputToPipe) {
|
||||
// Append to current piped job or create a new one as appropriate.
|
||||
if (PipedJob *PJ = dyn_cast<PipedJob>(Dest)) {
|
||||
OutputJob = PJ;
|
||||
Dest = OutputJob;
|
||||
} else {
|
||||
OutputJob = new PipedJob();
|
||||
cast<JobList>(Dest)->addJob(OutputJob);
|
||||
Dest = OutputJob;
|
||||
PipedJob *PJ = dyn_cast<PipedJob>(Dest);
|
||||
if (!PJ) {
|
||||
PJ = new PipedJob();
|
||||
cast<JobList>(Dest)->addJob(PJ);
|
||||
}
|
||||
Result = InputInfo(PJ, A->getType(), BaseInput);
|
||||
} else {
|
||||
Output = GetNamedOutputPath(C, *JA, BaseInput, AtTopLevel);
|
||||
Result = InputInfo(GetNamedOutputPath(C, *JA, BaseInput, AtTopLevel),
|
||||
A->getType(), BaseInput);
|
||||
}
|
||||
|
||||
// FIXME: Make the job.
|
||||
|
||||
Result = InputInfo(Output, A->getType(), BaseInput);
|
||||
if (CCCPrintBindings) {
|
||||
llvm::errs() << "bind - \"" << T.getName() << "\", inputs: [";
|
||||
for (unsigned i = 0, e = InputInfos.size(); i != e; ++i) {
|
||||
llvm::errs() << InputInfos[i].getAsString();
|
||||
if (i + 1 != e)
|
||||
llvm::errs() << ", ";
|
||||
}
|
||||
llvm::errs() << "], output: " << Result.getAsString() << "\n";
|
||||
} else {
|
||||
assert(0 && "FIXME: Make the job.");
|
||||
}
|
||||
}
|
||||
|
||||
const char *Driver::GetNamedOutputPath(Compilation &C,
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
#define CLANG_LIB_DRIVER_INPUTINFO_H_
|
||||
|
||||
#include <cassert>
|
||||
#include <string>
|
||||
|
||||
namespace clang {
|
||||
namespace driver {
|
||||
|
|
@ -28,6 +29,10 @@ class InputInfo {
|
|||
|
||||
public:
|
||||
InputInfo() {}
|
||||
InputInfo(types::ID _Type, const char *_BaseInput)
|
||||
: IsPipe(false), Type(_Type), BaseInput(_BaseInput) {
|
||||
Data.Filename = 0;
|
||||
}
|
||||
InputInfo(const char *Filename, types::ID _Type, const char *_BaseInput)
|
||||
: IsPipe(false), Type(_Type), BaseInput(_BaseInput) {
|
||||
Data.Filename = Filename;
|
||||
|
|
@ -49,6 +54,17 @@ public:
|
|||
assert(isPipe() && "Invalid accessor.");
|
||||
return *Data.Pipe;
|
||||
}
|
||||
|
||||
/// getAsString - Return a string name for this input, for
|
||||
/// debugging.
|
||||
std::string getAsString() const {
|
||||
if (isPipe())
|
||||
return "(pipe)";
|
||||
else if (const char *N = getInputFilename())
|
||||
return std::string("\"") + N + '"';
|
||||
else
|
||||
return "(nothing)";
|
||||
}
|
||||
};
|
||||
|
||||
} // end namespace driver
|
||||
|
|
|
|||
Loading…
Reference in a new issue