///
/// \param Args - The input arguments.
/// \param Actions - The list to store the resulting actions onto.
- void BuildActions(ArgList &Args, ActionList &Actions) const;
+ void BuildActions(const ArgList &Args, ActionList &Actions) const;
/// BuildUniversalActions - Construct the list of actions to perform
/// for the given arguments, which may require a universal build.
///
/// \param Args - The input arguments.
/// \param Actions - The list to store the resulting actions onto.
- void BuildUniversalActions(ArgList &Args, ActionList &Actions) const;
+ /// \param DefaultArchName - The default arch name (required to know
+ /// what architecture to bind if no -arch options are present).
+
+ void BuildUniversalActions(const ArgList &Args, ActionList &Actions,
+ const char *DefaultArchName) const;
/// BuildJobs - Bind actions to concrete tools and translate
/// arguments to form the list of jobs to run.
///
/// \arg C - The compilation that is being built.
- void BuildJobs(Compilation &C, const ActionList &Actions) const;
+ void BuildJobs(Compilation &C) const;
/// @}
/// @name Helper Methods
/// GetFilePath - Lookup \arg Name in the list of file search paths.
///
- /// \arg TC - Use the provided tool chain for additional information
- /// on directories to search, or the DefaultToolChain if not
- /// provided.
+ /// \arg TC - The tool chain for additional information on
+ /// directories to search.
// FIXME: This should be in CompilationInfo.
- llvm::sys::Path GetFilePath(const char *Name, const ToolChain *TC=0) const;
+ llvm::sys::Path GetFilePath(const char *Name, const ToolChain &TC) const;
/// GetProgramPath - Lookup \arg Name in the list of program search
/// paths.
///
- /// \arg TC - Use the provided tool chain for additional information
- /// on directories to search, or the DefaultToolChain if not
- /// provided.
+ /// \arg TC - The provided tool chain for additional information on
+ /// directories to search.
// FIXME: This should be in CompilationInfo.
- llvm::sys::Path GetProgramPath(const char *Name, const ToolChain *TC=0) const;
+ llvm::sys::Path GetProgramPath(const char *Name, const ToolChain &TC) const;
/// HandleImmediateArgs - Handle any arguments which should be
/// treated before building actions or binding tools.
///
/// \return Whether any compilation should be built for this
/// invocation.
- bool HandleImmediateArgs(const ArgList &Args);
+ bool HandleImmediateArgs(const Compilation &C);
/// ConstructAction - Construct the appropriate action to do for
/// \arg Phase on the \arg Input, taking in to account arguments
// is part of the compilation (it is arg dependent).
DefaultToolChain = Host->getToolChain(*Args);
+ // The compilation takes ownership of Args.
+ Compilation *C = new Compilation(*DefaultToolChain, Args);
+
// FIXME: This behavior shouldn't be here.
if (CCCPrintOptions) {
- PrintOptions(*Args);
- return 0;
+ PrintOptions(C->getArgs());
+ return C;
}
- if (!HandleImmediateArgs(*Args))
- return 0;
+ if (!HandleImmediateArgs(*C))
+ return C;
// Construct the list of abstract actions to perform for this
- // compilation.
- ActionList Actions;
+ // compilation. We avoid passing a Compilation here simply to
+ // enforce the abstraction that pipelining is not host or toolchain
+ // dependent (other than the driver driver test).
if (Host->useDriverDriver())
- BuildUniversalActions(*Args, Actions);
+ BuildUniversalActions(C->getArgs(), C->getActions());
else
- BuildActions(*Args, Actions);
+ BuildActions(C->getArgs(), C->getActions());
if (CCCPrintActions) {
- PrintActions(*Args, Actions);
- return 0;
+ PrintActions(C->getArgs(), C->getActions());
+ return C;
}
- // The compilation takes ownership of Args.
- Compilation *C = new Compilation(*DefaultToolChain, Args);
- BuildJobs(*C, Actions);
+ BuildJobs(*C);
return C;
}
llvm::outs() << "ccc version 1.0" << "\n";
}
-bool Driver::HandleImmediateArgs(const ArgList &Args) {
+bool Driver::HandleImmediateArgs(const Compilation &C) {
// The order these options are handled in in gcc is all over the
// place, but we don't expect inconsistencies w.r.t. that to matter
// in practice.
- if (Args.hasArg(options::OPT_v) ||
- Args.hasArg(options::OPT__HASH_HASH_HASH)) {
+ if (C.getArgs().hasArg(options::OPT_v) ||
+ C.getArgs().hasArg(options::OPT__HASH_HASH_HASH)) {
PrintVersion();
SuppressMissingInputWarning = true;
}
+ const ToolChain &TC = C.getDefaultToolChain();
// FIXME: The following handlers should use a callback mechanism, we
// don't know what the client would like to do.
- if (Arg *A = Args.getLastArg(options::OPT_print_file_name_EQ)) {
- llvm::outs() << GetFilePath(A->getValue(Args)).toString() << "\n";
+ if (Arg *A = C.getArgs().getLastArg(options::OPT_print_file_name_EQ)) {
+ llvm::outs() << GetFilePath(A->getValue(C.getArgs()), TC).toString()
+ << "\n";
return false;
}
- if (Arg *A = Args.getLastArg(options::OPT_print_prog_name_EQ)) {
- llvm::outs() << GetProgramPath(A->getValue(Args)).toString() << "\n";
+ if (Arg *A = C.getArgs().getLastArg(options::OPT_print_prog_name_EQ)) {
+ llvm::outs() << GetProgramPath(A->getValue(C.getArgs()), TC).toString()
+ << "\n";
return false;
}
- if (Args.hasArg(options::OPT_print_libgcc_file_name)) {
- llvm::outs() << GetProgramPath("libgcc.a").toString() << "\n";
+ if (C.getArgs().hasArg(options::OPT_print_libgcc_file_name)) {
+ llvm::outs() << GetProgramPath("libgcc.a", TC).toString() << "\n";
return false;
}
PrintActions1(Args, *it, Ids);
}
-void Driver::BuildUniversalActions(ArgList &Args, ActionList &Actions) const {
+void Driver::BuildUniversalActions(const ArgList &Args,
+ ActionList &Actions) const {
llvm::PrettyStackTraceString CrashInfo("Building actions for universal build");
// Collect the list of architectures. Duplicates are allowed, but
// should only be handled once (in the order seen).
}
}
-void Driver::BuildActions(ArgList &Args, ActionList &Actions) const {
+void Driver::BuildActions(const ArgList &Args, ActionList &Actions) const {
llvm::PrettyStackTraceString CrashInfo("Building compilation actions");
// Start by constructing the list of inputs and their types.
return 0;
}
-void Driver::BuildJobs(Compilation &C, const ActionList &Actions) const {
+void Driver::BuildJobs(Compilation &C) const {
llvm::PrettyStackTraceString CrashInfo("Building compilation jobs");
bool SaveTemps = C.getArgs().hasArg(options::OPT_save_temps);
bool UsePipes = C.getArgs().hasArg(options::OPT_pipe);
// output files.
if (FinalOutput) {
unsigned NumOutputs = 0;
- for (ActionList::const_iterator it = Actions.begin(), ie = Actions.end();
- it != ie; ++it)
+ for (ActionList::const_iterator it = C.getActions().begin(),
+ ie = C.getActions().end(); it != ie; ++it)
if ((*it)->getType() != types::TY_Nothing)
++NumOutputs;
}
}
- for (ActionList::const_iterator it = Actions.begin(), ie = Actions.end();
- it != ie; ++it) {
+ for (ActionList::const_iterator it = C.getActions().begin(),
+ ie = C.getActions().end(); it != ie; ++it) {
Action *A = *it;
// If we are linking an image for multiple archs then the linker
}
llvm::sys::Path Driver::GetFilePath(const char *Name,
- const ToolChain *TC) const {
+ const ToolChain &TC) const {
// FIXME: Implement.
- if (!TC) TC = DefaultToolChain;
-
return llvm::sys::Path(Name);
}
llvm::sys::Path Driver::GetProgramPath(const char *Name,
- const ToolChain *TC) const {
+ const ToolChain &TC) const {
// FIXME: Implement.
- if (!TC) TC = DefaultToolChain;
-
return llvm::sys::Path(Name);
}