/* ScummVM - Graphic Adventure Engine * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT * file distributed with this source distribution. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ #include "config.h" #include "codeblocks.h" #include namespace CreateProjectTool { CodeBlocksProvider::CodeBlocksProvider(StringList &global_warnings, std::map &project_warnings, const int version) : ProjectProvider(global_warnings, project_warnings, version) { } void CodeBlocksProvider::createWorkspace(const BuildSetup &setup) { std::ofstream workspace((setup.outputDir + '/' + setup.projectName + ".workspace").c_str()); if (!workspace) error("Could not open \"" + setup.outputDir + '/' + setup.projectName + ".workspace\" for writing"); workspace << "\n" "\n"; workspace << "\t\n"; writeReferences(setup, workspace); // Note we assume that the UUID map only includes UUIDs for enabled engines! for (UUIDMap::const_iterator i = _uuidMap.begin(); i != _uuidMap.end(); ++i) { if (i->first == setup.projectName) continue; workspace << "\t\tfirst << ".cbp\" />\n"; } workspace << "\t\n" ""; } // HACK We need to pre-process library names // since the MSVC and mingw precompiled // libraries have different names :( std::string processLibraryName(std::string name) { // Remove "_static" in lib name size_t pos = name.find("_static"); if (pos != std::string::npos) return name.replace(pos, 7, ""); // Remove "-static" in lib name pos = name.find("-static"); if (pos != std::string::npos) return name.replace(pos, 7, ""); // Replace "zlib" by "libz" if (name == "zlib") return "libz"; return name; } void CodeBlocksProvider::createProjectFile(const std::string &name, const std::string &, const BuildSetup &setup, const std::string &moduleDir, const StringList &includeList, const StringList &excludeList) { const std::string projectFile = setup.outputDir + '/' + name + getProjectExtension(); std::ofstream project(projectFile.c_str()); if (!project) error("Could not open \"" + projectFile + "\" for writing"); project << "\n" "\n" "\t\n" "\t\n" "\t\t\n" ""; } void CodeBlocksProvider::addResourceFiles(const BuildSetup &setup, StringList &includeList, StringList &excludeList) { includeList.push_back(setup.srcDir + "/icons/" + setup.projectName + ".ico"); includeList.push_back(setup.srcDir + "/dists/" + setup.projectName + ".rc"); } void CodeBlocksProvider::writeWarnings(const std::string &name, std::ofstream &output) const { // Global warnings for (StringList::const_iterator i = _globalWarnings.begin(); i != _globalWarnings.end(); ++i) output << "\t\t\t\t\t\n"; // Check for project-specific warnings: std::map::iterator warningsIterator = _projectWarnings.find(name); if (warningsIterator != _projectWarnings.end()) for (StringList::const_iterator i = warningsIterator->second.begin(); i != warningsIterator->second.end(); ++i) output << "\t\t\t\t\t\n"; } void CodeBlocksProvider::writeDefines(const StringList &defines, std::ofstream &output) const { for (StringList::const_iterator i = defines.begin(); i != defines.end(); ++i) output << "\t\t\t\t\t\n"; } void CodeBlocksProvider::writeFileListToProject(const FileNode &dir, std::ofstream &projectFile, const int indentation, const StringList &duplicate, const std::string &objPrefix, const std::string &filePrefix) { for (FileNode::NodeList::const_iterator i = dir.children.begin(); i != dir.children.end(); ++i) { const FileNode *node = *i; if (!node->children.empty()) { writeFileListToProject(*node, projectFile, indentation + 1, duplicate, objPrefix + node->name + '_', filePrefix + node->name + '/'); } else { std::string name, ext; splitFilename(node->name, name, ext); if (ext == "rc") { projectFile << "\t\tname) << "\">\n" "\t\t\t\n"; } else if (ext == "asm") { projectFile << "\t\tname) << "\">\n" "\t\t\t\n"; } else { projectFile << "\t\tname) << "\" />\n"; } } } } void CodeBlocksProvider::writeReferences(const BuildSetup &setup, std::ofstream &output) { output << "\t\t\n"; for (UUIDMap::const_iterator i = _uuidMap.begin(); i != _uuidMap.end(); ++i) { if (i->first == " << PROJECT_NAME << ") continue; output << "\t\t\tfirst << ".cbp\" />\n"; } output << "\t\t\n"; } const char *CodeBlocksProvider::getProjectExtension() { return ".cbp"; } } // End of CreateProjectTool namespace