forked from OSchip/llvm-project
Driver: Add simple Job classes, simple wrappers for information about
what processes to execute during a compilation. llvm-svn: 66985
This commit is contained in:
parent
5469f29aa9
commit
313c291269
|
@ -0,0 +1,104 @@
|
|||
//===--- Job.h - Commands to Execute ----------------------------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef CLANG_DRIVER_JOB_H_
|
||||
#define CLANG_DRIVER_JOB_H_
|
||||
|
||||
#include "clang/Driver/Util.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
|
||||
namespace clang {
|
||||
namespace driver {
|
||||
|
||||
class Job {
|
||||
public:
|
||||
enum JobClass {
|
||||
CommandClass,
|
||||
PipedJobClass,
|
||||
JobListClass
|
||||
};
|
||||
|
||||
private:
|
||||
JobClass Kind;
|
||||
|
||||
protected:
|
||||
Job(JobClass _Kind) : Kind(_Kind) {}
|
||||
public:
|
||||
virtual ~Job();
|
||||
|
||||
JobClass getKind() const { return Kind; }
|
||||
|
||||
static bool classof(const Job *) { return true; }
|
||||
};
|
||||
|
||||
/// Command - An executable path/name and argument vector to
|
||||
/// execute.
|
||||
class Command : public Job {
|
||||
const char *Executable;
|
||||
ArgStringList Argv;
|
||||
|
||||
public:
|
||||
Command(const char *_Executable, const ArgStringList &_Argv);
|
||||
|
||||
const char *getExecutable() const { return Executable; }
|
||||
const ArgStringList &getArgv() const { return Argv; }
|
||||
|
||||
static bool classof(const Job *J) {
|
||||
return J->getKind() == CommandClass;
|
||||
}
|
||||
static bool classof(const Command *) { return true; }
|
||||
};
|
||||
|
||||
/// PipedJob - A list of Commands which should be executed together
|
||||
/// with their standard inputs and outputs connected.
|
||||
class PipedJob : public Job {
|
||||
public:
|
||||
typedef llvm::SmallVector<Command*, 4> list_type;
|
||||
|
||||
private:
|
||||
list_type Commands;
|
||||
|
||||
public:
|
||||
PipedJob();
|
||||
|
||||
void addCommand(Command *C) { Commands.push_back(C); }
|
||||
|
||||
const list_type &getCommands() const { return Commands; }
|
||||
|
||||
static bool classof(const Job *J) {
|
||||
return J->getKind() == PipedJobClass;
|
||||
}
|
||||
static bool classof(const PipedJob *) { return true; }
|
||||
};
|
||||
|
||||
/// JobList - A sequence of jobs to perform.
|
||||
class JobList : public Job {
|
||||
public:
|
||||
typedef llvm::SmallVector<Job*, 4> list_type;
|
||||
|
||||
private:
|
||||
list_type Jobs;
|
||||
|
||||
public:
|
||||
JobList();
|
||||
|
||||
void addJob(Job *J) { Jobs.push_back(J); }
|
||||
|
||||
const list_type &getJobs() const { return Jobs; }
|
||||
|
||||
static bool classof(const Job *J) {
|
||||
return J->getKind() == JobListClass;
|
||||
}
|
||||
static bool classof(const JobList *) { return true; }
|
||||
};
|
||||
|
||||
} // end namespace driver
|
||||
} // end namespace clang
|
||||
|
||||
#endif
|
|
@ -0,0 +1,23 @@
|
|||
//===--- Job.cpp - Command to Execute -----------------------------------*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "clang/Driver/Job.h"
|
||||
|
||||
#include <cassert>
|
||||
using namespace clang::driver;
|
||||
|
||||
Job::~Job() {}
|
||||
|
||||
Command::Command(const char *_Executable, const ArgStringList &_Argv)
|
||||
: Job(CommandClass), Executable(_Executable), Argv(_Argv) {
|
||||
}
|
||||
|
||||
PipedJob::PipedJob() : Job(PipedJobClass) {}
|
||||
|
||||
JobList::JobList() : Job(JobListClass) {}
|
Loading…
Reference in New Issue