OpenASIP 2.2
Loading...
Searching...
No Matches
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) {
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)) {
147 module = FileSystem::currentWorkingDir()
148 + FileSystem::DIRECTORY_SEPARATOR + 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 const&) {
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}
static MachInfoCmdLineOptions options
Definition MachInfo.cc:46
static void setCmdLineOptions(CmdLineOptions *options_)
static void initialize()
void parse(char *argv[], int argc)
virtual int numberOfArguments() const
static std::string toString(const T &source)
std::string fileName() const
std::string errorMessage() const
Definition Exception.cc:123
std::string procedureName() const
int lineNum() const
static bool isAbsolutePath(const std::string &pathName)
static const std::string DIRECTORY_SEPARATOR
static std::string fileOfPath(const std::string pathName)
static std::string directoryOfPath(const std::string fileName)
Definition FileSystem.cc:79
virtual void printHelp() const
static OperationBuilder & instance()
bool verifyXML(const std::string file)
bool buildObject(const std::string &baseName, const std::string &behaviorFile, const std::string &path, std::vector< std::string > &output)
std::string behaviorFile(const std::string &baseName, std::string &path)

References OperationBuilder::behaviorFile(), OperationBuilder::buildObject(), 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.