[Scummvm-cvs-logs] SF.net SVN: scummvm:[45381] scummvm/trunk/tools/create_msvc/create_msvc.cpp
lordhoto at users.sourceforge.net
lordhoto at users.sourceforge.net
Mon Oct 26 00:03:13 CET 2009
Revision: 45381
http://scummvm.svn.sourceforge.net/scummvm/?rev=45381&view=rev
Author: lordhoto
Date: 2009-10-25 23:03:12 +0000 (Sun, 25 Oct 2009)
Log Message:
-----------
Use slashes instead of backslashes in internal path representation.
Modified Paths:
--------------
scummvm/trunk/tools/create_msvc/create_msvc.cpp
Modified: scummvm/trunk/tools/create_msvc/create_msvc.cpp
===================================================================
--- scummvm/trunk/tools/create_msvc/create_msvc.cpp 2009-10-25 22:47:43 UTC (rev 45380)
+++ scummvm/trunk/tools/create_msvc/create_msvc.cpp 2009-10-25 23:03:12 UTC (rev 45381)
@@ -47,6 +47,19 @@
std::string convertPathToWin(const std::string &path);
/**
+ * Converts the given path to only use slashes as
+ * delimiters.
+ * This means that for example the path:
+ * foo/bar\test.txt
+ * will be converted to:
+ * foo/bar/test.txt
+ *
+ * @param path Path string.
+ * @return Converted path.
+ */
+std::string unifyPath(const std::string &path);
+
+/**
* Returns the last path component.
*
* @param path Path string.
@@ -71,7 +84,7 @@
const std::string srcDir = argv[1];
BuildSetup setup;
- setup.srcDir = convertPathToWin(srcDir);
+ setup.srcDir = unifyPath(srcDir);
setup.engines = parseConfigure(setup.srcDir);
setup.features = getAllFeatures();
@@ -198,20 +211,19 @@
namespace {
std::string convertPathToWin(const std::string &path) {
- std::string result;
+ std::string result = path;
+ std::replace(result.begin(), result.end(), '/', '\\');
+ return result;
+}
- for (std::string::const_iterator i = path.begin(); i != path.end(); ++i) {
- if (*i == '/')
- result += '\\';
- else
- result += *i;
- }
-
+std::string unifyPath(const std::string &path) {
+ std::string result = path;
+ std::replace(result.begin(), result.end(), '\\', '/');
return result;
}
std::string getLastPathComponent(const std::string &path) {
- std::string::size_type pos = path.find_last_of('\\');
+ std::string::size_type pos = path.find_last_of('/');
if (pos == std::string::npos)
return path;
else
@@ -303,7 +315,7 @@
} // End of anonymous namespace
EngineDescList parseConfigure(const std::string &srcDir) {
- std::string configureFile = srcDir + "\\configure";
+ std::string configureFile = srcDir + "/configure";
std::ifstream configure(configureFile.c_str());
if (!configure)
@@ -592,7 +604,7 @@
continue;
in.clear(); ex.clear();
- const std::string moduleDir = setup.srcDir + "\\engines\\" + i->first;
+ const std::string moduleDir = setup.srcDir + "/engines/" + i->first;
createModuleList(moduleDir, setup.defines, in, ex);
createProjectFile(i->first, i->second, setup, moduleDir, in, ex, version);
@@ -602,28 +614,28 @@
in.clear(); ex.clear();
// File list for the ScummVM project file
- createModuleList(setup.srcDir + "\\backends", setup.defines, in, ex);
- createModuleList(setup.srcDir + "\\backends\\platform\\sdl", setup.defines, in, ex);
- createModuleList(setup.srcDir + "\\base", setup.defines, in, ex);
- createModuleList(setup.srcDir + "\\common", setup.defines, in, ex);
- createModuleList(setup.srcDir + "\\engines", setup.defines, in, ex);
- createModuleList(setup.srcDir + "\\graphics", setup.defines, in, ex);
- createModuleList(setup.srcDir + "\\gui", setup.defines, in, ex);
- createModuleList(setup.srcDir + "\\sound", setup.defines, in, ex);
- createModuleList(setup.srcDir + "\\sound\\softsynth\\mt32", setup.defines, in, ex);
+ createModuleList(setup.srcDir + "/backends", setup.defines, in, ex);
+ createModuleList(setup.srcDir + "/backends/platform/sdl", setup.defines, in, ex);
+ createModuleList(setup.srcDir + "/base", setup.defines, in, ex);
+ createModuleList(setup.srcDir + "/common", setup.defines, in, ex);
+ createModuleList(setup.srcDir + "/engines", setup.defines, in, ex);
+ createModuleList(setup.srcDir + "/graphics", setup.defines, in, ex);
+ createModuleList(setup.srcDir + "/gui", setup.defines, in, ex);
+ createModuleList(setup.srcDir + "/sound", setup.defines, in, ex);
+ createModuleList(setup.srcDir + "/sound/softsynth/mt32", setup.defines, in, ex);
// Resource files
- in.push_back(setup.srcDir + "\\icons\\scummvm.ico");
- in.push_back(setup.srcDir + "\\dists\\scummvm.rc");
+ in.push_back(setup.srcDir + "/icons/scummvm.ico");
+ in.push_back(setup.srcDir + "/dists/scummvm.rc");
// Various text files
- in.push_back(setup.srcDir + "\\AUTHORS");
- in.push_back(setup.srcDir + "\\COPYING");
- in.push_back(setup.srcDir + "\\COPYING.LGPL");
- in.push_back(setup.srcDir + "\\COPYRIGHT");
- in.push_back(setup.srcDir + "\\NEWS");
- in.push_back(setup.srcDir + "\\README");
- in.push_back(setup.srcDir + "\\TODO");
+ in.push_back(setup.srcDir + "/AUTHORS");
+ in.push_back(setup.srcDir + "/COPYING");
+ in.push_back(setup.srcDir + "/COPYING.LGPL");
+ in.push_back(setup.srcDir + "/COPYRIGHT");
+ in.push_back(setup.srcDir + "/NEWS");
+ in.push_back(setup.srcDir + "/README");
+ in.push_back(setup.srcDir + "/TODO");
// Create the "scummvm.vcproj" file.
createProjectFile("scummvm", svmUUID, setup, setup.srcDir, in, ex, version);
@@ -977,7 +989,7 @@
// the first character after the substring, having the same size as dir, must
// be a path delimiter.
if (compareName.empty()) {
- if (i->size() >= dir.size() + 1 && i->at(dir.size()) == '\\')
+ if (i->size() >= dir.size() + 1 && i->at(dir.size()) == '/')
return true;
else
continue;
@@ -1054,7 +1066,7 @@
*/
FileNode *scanFiles(const std::string &dir, const StringList &includeList, const StringList &excludeList) {
WIN32_FIND_DATA fileInformation;
- HANDLE fileHandle = FindFirstFile((dir + "\\*").c_str(), &fileInformation);
+ HANDLE fileHandle = FindFirstFile((dir + "/*").c_str(), &fileInformation);
if (fileHandle == INVALID_HANDLE_VALUE)
return 0;
@@ -1066,7 +1078,7 @@
continue;
if ((fileInformation.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0) {
- const std::string subDirName = dir + '\\' + fileInformation.cFileName;
+ const std::string subDirName = dir + '/' + fileInformation.cFileName;
if (!isInList(subDirName, std::string(), includeList))
continue;
@@ -1127,7 +1139,7 @@
const FileNode *node = *i;
if (!node->children.empty()) {
- writeFileListToProject(*node, projectFile, indentation + 1, duplicate, objPrefix + node->name + '_', filePrefix + node->name + '\\');
+ writeFileListToProject(*node, projectFile, indentation + 1, duplicate, objPrefix + node->name + '_', filePrefix + node->name + '/');
} else {
if (producesObjectFile(node->name)) {
std::string name, ext;
@@ -1142,7 +1154,7 @@
const std::string toolLine = indentString + "\t\t<Tool Name=\"VCCustomBuildTool\" CommandLine=\"nasm.exe -f win32 -g -o "" + objFileName + "" "$(InputPath)"
\" Outputs=\"" + objFileName + "\" />\n";
- projectFile << indentString << "<File RelativePath=\"" << filePrefix << node->name << "\">\n"
+ projectFile << indentString << "<File RelativePath=\"" << convertPathToWin(filePrefix + node->name) << "\">\n"
<< indentString << "\t<FileConfiguration Name=\"Debug|Win32\">\n"
<< toolLine
<< indentString << "\t</FileConfiguration>\n"
@@ -1154,7 +1166,7 @@
if (isDuplicate) {
const std::string toolLine = indentString + "\t\t<Tool Name=\"VCCLCompilerTool\" ObjectFile=\"$(IntDir)\\" + objPrefix + "$(InputName).obj\" XMLDocumentationFileName=\"$(IntDir)\\" + objPrefix + "$(InputName).xdc\" />\n";
- projectFile << indentString << "<File RelativePath=\"" << filePrefix << node->name << "\">\n"
+ projectFile << indentString << "<File RelativePath=\"" << convertPathToWin(filePrefix + node->name) << "\">\n"
<< indentString << "\t<FileConfiguration Name=\"Debug|Win32\">\n"
<< toolLine
<< indentString << "\t</FileConfiguration>\n"
@@ -1163,11 +1175,11 @@
<< indentString << "\t</FileConfiguration>\n"
<< indentString << "</File>\n";
} else {
- projectFile << indentString << "<File RelativePath=\"" << filePrefix << node->name << "\" />\n";
+ projectFile << indentString << "<File RelativePath=\"" << convertPathToWin(filePrefix + node->name) << "\" />\n";
}
}
} else {
- projectFile << indentString << "<File RelativePath=\"" << filePrefix << node->name << "\" />\n";
+ projectFile << indentString << "<File RelativePath=\"" << convertPathToWin(filePrefix + node->name) << "\" />\n";
}
}
}
@@ -1204,13 +1216,13 @@
FileNode *files = scanFiles(dir, includeList, excludeList);
- writeFileListToProject(*files, projectFile, 0, duplicate, std::string(), dir + '\\');
+ writeFileListToProject(*files, projectFile, 0, duplicate, std::string(), dir + '/');
delete files;
}
void createModuleList(const std::string &moduleDir, const StringList &defines, StringList &includeList, StringList &excludeList) {
- const std::string moduleMkFile = moduleDir + "\\module.mk";
+ const std::string moduleMkFile = moduleDir + "/module.mk";
std::ifstream moduleMk(moduleMkFile.c_str());
if (!moduleMk)
throw std::string(moduleMkFile + " is not present");
@@ -1247,7 +1259,7 @@
throw std::string("Malformed MODULE definition in " + moduleMkFile);
++i;
- std::string moduleRoot = convertPathToWin(*i);
+ std::string moduleRoot = unifyPath(*i);
if (moduleDir.compare(moduleDir.size() - moduleRoot.size(), moduleRoot.size(), moduleRoot))
throw std::string("MODULE root " + moduleRoot + " does not match base dir " + moduleDir);
@@ -1275,9 +1287,9 @@
i = tokens.begin();
} else {
if (shouldInclude.top())
- includeList.push_back(moduleDir + "\\" + convertPathToWin(*i));
+ includeList.push_back(moduleDir + "/" + unifyPath(*i));
else
- excludeList.push_back(moduleDir + "\\" + convertPathToWin(*i));
+ excludeList.push_back(moduleDir + "/" + unifyPath(*i));
++i;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list