22 #include <boost/filesystem.hpp>
23 #include <boost/regex.hpp>
44 std::ofstream outputStream(outputPath.string().c_str(), std::ios::out | std::ios::binary);
45 if(!outputStream.is_open()) {
46 std::cerr <<
"Output static device information file could not be opened: "
47 << outputPath.string() << std::endl;
53 /
"torc" /
"bitstream" /
"build" / inTemplateName;
54 std::ifstream templateStream(templatePath.string().c_str(),
55 std::ios::in | std::ios::binary | std::ios::ate);
56 if(!templateStream.is_open()) {
57 std::cerr <<
"Input static device information template could not be opened: "
58 << outputPath.string() << std::endl;
63 std::ifstream::pos_type size = templateStream.tellg();
64 templateString.resize(size);
66 templateStream.seekg(0, std::ios::beg);
67 templateStream.read(const_cast<char*>(templateString.data()), size);
69 templateStream.close();
72 std::stringstream allDeviceInfo;
73 torc::common::DeviceVector::const_iterator dp = inDeviceNames.begin();
74 torc::common::DeviceVector::const_iterator de = inDeviceNames.end();
77 if(device.empty())
break;
80 if(dp < de) allDeviceInfo << std::endl;
84 typedef std::map<std::string, std::string> SubstitutionMap;
85 SubstitutionMap substitutions;
86 substitutions[
"%%ARCHITECTURE%%"] = inFamilyName;
87 substitutions[
"%%DEVICES%%"] = allDeviceInfo.str();
88 substitutions[
"%%GENERATED%%"] = __FILE__;
91 SubstitutionMap::iterator p = substitutions.begin();
92 SubstitutionMap::iterator e = substitutions.end();
95 boost::regex re(p->first);
96 std::stringstream stringStream;
97 std::ostream_iterator<char, char> stringIterator(stringStream);
99 boost::regex_replace(stringIterator, templateString.begin(), templateString.end(), re,
100 p->second, boost::match_default);
102 templateString = stringStream.str();
107 outputStream << templateString;
108 outputStream.close();
Header for the DirectoryTree class.
Xilinx bitstream base class.
Header for the Spartan6BuildHelper class.
virtual void initializeDeviceInfo(const std::string &inDeviceName)
Initialize the maps between frame indexes and frame addresses. This is generally only useful for int...
boost::filesystem::path path
static const boost::filesystem::path & getWorkingPath(void)
Returns the absolute path to the working directory.
static void buildFamilyDeviceInfo(const std::string &inFamilyName, const std::string &inTemplateName, const std::string &inOutputName, const torc::common::DeviceVector &inDeviceNames, Bitstream &inBitstream)
Build the static device information for the specified family.
std::vector< std::string > DeviceVector
Vector of device names.
virtual void writeDeviceInfo(std::ostream &inStream, const std::string &inDeviceName)
Output static device information to a stream.
Header for the DeviceInfo class.