Stephen Hines | f33f6de | 2014-02-14 18:00:16 -0800 | [diff] [blame] | 1 | //===- OutputCmd.cpp -----------------------------------------------------===// |
| 2 | // |
| 3 | // The MCLinker Project |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 9 | #include "mcld/Script/OutputCmd.h" |
| 10 | #include "mcld/Support/raw_ostream.h" |
| 11 | #include "mcld/LinkerScript.h" |
| 12 | #include "mcld/Module.h" |
Stephen Hines | f33f6de | 2014-02-14 18:00:16 -0800 | [diff] [blame] | 13 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 14 | namespace mcld { |
Stephen Hines | f33f6de | 2014-02-14 18:00:16 -0800 | [diff] [blame] | 15 | |
| 16 | //===----------------------------------------------------------------------===// |
| 17 | // OutputCmd |
| 18 | //===----------------------------------------------------------------------===// |
| 19 | OutputCmd::OutputCmd(const std::string& pOutputFile) |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 20 | : ScriptCommand(ScriptCommand::OUTPUT), m_OutputFile(pOutputFile) { |
Stephen Hines | f33f6de | 2014-02-14 18:00:16 -0800 | [diff] [blame] | 21 | } |
| 22 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 23 | OutputCmd::~OutputCmd() { |
Stephen Hines | f33f6de | 2014-02-14 18:00:16 -0800 | [diff] [blame] | 24 | } |
| 25 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 26 | void OutputCmd::dump() const { |
Stephen Hines | f33f6de | 2014-02-14 18:00:16 -0800 | [diff] [blame] | 27 | mcld::outs() << "OUTPUT ( " << m_OutputFile << " )\n"; |
| 28 | } |
| 29 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 30 | void OutputCmd::activate(Module& pModule) { |
Stephen Hines | f33f6de | 2014-02-14 18:00:16 -0800 | [diff] [blame] | 31 | pModule.getScript().setOutputFile(m_OutputFile); |
| 32 | // TODO: set the output name if there is no `-o filename' on the cmdline. |
| 33 | // This option is to define a default name for the output file other than the |
| 34 | // usual default of a.out. |
| 35 | } |
| 36 | |
Stephen Hines | 37b74a3 | 2014-11-26 18:48:20 -0800 | [diff] [blame] | 37 | } // namespace mcld |