OpenASIP  2.0
Functions | Variables
BuildOpset.cc File Reference
#include <string>
#include <iostream>
#include <vector>
#include "BuildOpset.hh"
#include "FileSystem.hh"
#include "CmdLineOptions.hh"
#include "Environment.hh"
#include "Conversion.hh"
#include "tce_config.h"
#include "OperationBuilder.hh"
Include dependency graph for BuildOpset.cc:

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Variables

const string SCHEMA_FILE_NAME = "Operation_Schema.xsd"
 

Detailed Description

Program that builds operation behavior module and locates them to the target directory.

Author
Jussi Nykänen 2004 (nykanen-no.spam-cs.tut.fi)
Pekka Jääskeläinen 2013
Note
rating: red

Definition in file BuildOpset.cc.

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Main program.

Searches for XML file given to it as a parameter. Then searches for a corresponding operation behavior source file and compiles it.

Definition at line 124 of file BuildOpset.cc.

124  {
125 
126  Application::initialize(argc, argv);
127 
128  try {
131 
132  options->parse(argv, argc);
134 
135  int arguments = options->numberOfArguments();
136  string module = "";
137  // first argument is XML data file
138  if (arguments == 0 || arguments > 1) {
139  options->printHelp();
140  return EXIT_FAILURE;
141  } else {
142  module = options->argument(1);
143  }
144 
145  // get the path for the files
146  if (!FileSystem::isAbsolutePath(module)) {
149  }
150  string path = FileSystem::directoryOfPath(module);
151 
152  // get the base name of the module
153  string moduleName = FileSystem::fileOfPath(module);
154 
155  // get the path for the behavior file
156  string behaviorPath = options->sourceDir();
157  if (behaviorPath == "") {
158  behaviorPath = path;
159  }
160 
161  // verify that the operation properties file is legal
162  if (!builder.verifyXML(module + ".opp")) {
163  return EXIT_FAILURE;
164  }
165 
166 
167  // find the behavior source file and check if it should be ignored
168  // if it's not found
169  string behFile = builder.behaviorFile(moduleName, behaviorPath);
170  if (behFile == "" && !options->ignore()) {
171  string errorMessage = "Behavior source file '";
172  errorMessage += behaviorPath + FileSystem::DIRECTORY_SEPARATOR
173  + moduleName + ".cc" + "' not found";
174  cerr << errorMessage << endl;
175  return EXIT_FAILURE;
176  }
177 
178  // build and install the behavior module
179  vector<string> output;
180  builder.buildObject(moduleName, behFile, path, output);
181  if (output.size() > 0) {
182  cerr << "Error building shared objects:" << endl;
183  for (size_t i = 0; i < output.size(); i++) {
184  cerr << output[i] << endl;
185  }
186  return EXIT_FAILURE;
187  }
188 
189  } catch (ParserStopRequest) {
190  return EXIT_SUCCESS;
191  } catch (const IllegalCommandLine& i) {
192  cerr << i.errorMessage() << endl;
193  return EXIT_FAILURE;
194  } catch (const Exception& e) {
195  string linenum = Conversion::toString(e.lineNum());
196  cerr << "Exception thrown: " << e.fileName() << ": "
197  << linenum << ": " << e.procedureName() << ": "
198  << e.errorMessage() << endl;
199  return EXIT_FAILURE;
200  }
201 
202  return EXIT_SUCCESS;
203 }

References CmdLineParser::argument(), OperationBuilder::behaviorFile(), OperationBuilder::buildObject(), FileSystem::currentWorkingDir(), FileSystem::DIRECTORY_SEPARATOR, FileSystem::directoryOfPath(), Exception::errorMessage(), Exception::fileName(), FileSystem::fileOfPath(), Application::initialize(), OperationBuilder::instance(), FileSystem::isAbsolutePath(), Exception::lineNum(), CmdLineParser::numberOfArguments(), options, CmdLineOptions::parse(), MachInfoCmdLineOptions::printHelp(), Exception::procedureName(), Application::setCmdLineOptions(), Conversion::toString(), and OperationBuilder::verifyXML().

Here is the call graph for this function:

Variable Documentation

◆ SCHEMA_FILE_NAME

const string SCHEMA_FILE_NAME = "Operation_Schema.xsd"

Definition at line 53 of file BuildOpset.cc.

BuildOpsetOptions
Definition: BuildOpset.hh:42
MachInfoCmdLineOptions::printHelp
virtual void printHelp() const
Definition: MachInfoCmdLineOptions.cc:89
Exception::procedureName
std::string procedureName() const
Exception::lineNum
int lineNum() const
ParserStopRequest
Definition: Exception.hh:491
CmdLineParser::numberOfArguments
virtual int numberOfArguments() const
Application::setCmdLineOptions
static void setCmdLineOptions(CmdLineOptions *options_)
Definition: Application.cc:381
IllegalCommandLine
Definition: Exception.hh:438
FileSystem::fileOfPath
static std::string fileOfPath(const std::string pathName)
Definition: FileSystem.cc:101
Conversion::toString
static std::string toString(const T &source)
Exception::fileName
std::string fileName() const
OperationBuilder::behaviorFile
std::string behaviorFile(const std::string &baseName, std::string &path)
Definition: OperationBuilder.cc:115
OperationBuilder
Definition: OperationBuilder.hh:42
FileSystem::directoryOfPath
static std::string directoryOfPath(const std::string fileName)
Definition: FileSystem.cc:79
Exception
Definition: Exception.hh:54
Exception::errorMessage
std::string errorMessage() const
Definition: Exception.cc:123
CmdLineOptions::parse
void parse(char *argv[], int argc)
Definition: CmdLineOptions.cc:107
FileSystem::DIRECTORY_SEPARATOR
static const std::string DIRECTORY_SEPARATOR
Definition: FileSystem.hh:189
options
static MachInfoCmdLineOptions options
Definition: MachInfo.cc:46
OperationBuilder::buildObject
bool buildObject(const std::string &baseName, const std::string &behaviorFile, const std::string &path, std::vector< std::string > &output)
Definition: OperationBuilder.cc:141
OperationBuilder::verifyXML
bool verifyXML(const std::string file)
Definition: OperationBuilder.cc:263
Application::initialize
static void initialize()
Definition: Application.cc:99
FileSystem::currentWorkingDir
static std::string currentWorkingDir()
Definition: FileSystem.cc:142
FileSystem::isAbsolutePath
static bool isAbsolutePath(const std::string &pathName)
Definition: FileSystem.cc:234
CmdLineParser::argument
virtual std::string argument(int index) const
OperationBuilder::instance
static OperationBuilder & instance()
Definition: OperationBuilder.cc:71