CREATE_PROJECT: Replace duplicate filename check with unique object files
This commit is contained in:
parent
562b60cb47
commit
e9b3974ff8
12 changed files with 33 additions and 95 deletions
|
@ -320,14 +320,14 @@ void CMakeProvider::writeDefines(const BuildSetup &setup, std::ofstream &output)
|
|||
}
|
||||
|
||||
void CMakeProvider::writeFileListToProject(const FileNode &dir, std::ofstream &projectFile, const int indentation,
|
||||
const StringList &duplicate, const std::string &objPrefix, const std::string &filePrefix) {
|
||||
const std::string &objPrefix, const std::string &filePrefix) {
|
||||
|
||||
std::string lastName;
|
||||
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 + '/');
|
||||
writeFileListToProject(*node, projectFile, indentation + 1, objPrefix + node->name + '_', filePrefix + node->name + '/');
|
||||
} else {
|
||||
std::string name, ext;
|
||||
splitFilename(node->name, name, ext);
|
||||
|
|
|
@ -48,7 +48,7 @@ protected:
|
|||
const StringList &includeList, const StringList &excludeList);
|
||||
|
||||
void writeFileListToProject(const FileNode &dir, std::ofstream &projectFile, const int indentation,
|
||||
const StringList &duplicate, const std::string &objPrefix, const std::string &filePrefix);
|
||||
const std::string &objPrefix, const std::string &filePrefix);
|
||||
|
||||
const char *getProjectExtension();
|
||||
|
||||
|
|
|
@ -248,13 +248,13 @@ void CodeBlocksProvider::writeDefines(const StringList &defines, std::ofstream &
|
|||
}
|
||||
|
||||
void CodeBlocksProvider::writeFileListToProject(const FileNode &dir, std::ofstream &projectFile, const int indentation,
|
||||
const StringList &duplicate, const std::string &objPrefix, const std::string &filePrefix) {
|
||||
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 + '/');
|
||||
writeFileListToProject(*node, projectFile, indentation + 1, objPrefix + node->name + '_', filePrefix + node->name + '/');
|
||||
} else {
|
||||
std::string name, ext;
|
||||
splitFilename(node->name, name, ext);
|
||||
|
|
|
@ -43,7 +43,7 @@ protected:
|
|||
const StringList &includeList, const StringList &excludeList);
|
||||
|
||||
void writeFileListToProject(const FileNode &dir, std::ofstream &projectFile, const int indentation,
|
||||
const StringList &duplicate, const std::string &objPrefix, const std::string &filePrefix);
|
||||
const std::string &objPrefix, const std::string &filePrefix);
|
||||
|
||||
void writeReferences(const BuildSetup &setup, std::ofstream &output);
|
||||
|
||||
|
|
|
@ -1757,37 +1757,9 @@ std::string ProjectProvider::getLastPathComponent(const std::string &path) {
|
|||
void ProjectProvider::addFilesToProject(const std::string &dir, std::ofstream &projectFile,
|
||||
const StringList &includeList, const StringList &excludeList,
|
||||
const std::string &filePrefix) {
|
||||
// Check for duplicate object file names
|
||||
StringList duplicate;
|
||||
|
||||
for (StringList::const_iterator i = includeList.begin(); i != includeList.end(); ++i) {
|
||||
std::string fileName = getLastPathComponent(*i);
|
||||
std::transform(fileName.begin(), fileName.end(), fileName.begin(), tolower);
|
||||
|
||||
// Leave out non object file names.
|
||||
if (fileName.size() < 2 || fileName.compare(fileName.size() - 2, 2, ".o"))
|
||||
continue;
|
||||
|
||||
// Check whether an duplicate has been found yet
|
||||
if (std::find(duplicate.begin(), duplicate.end(), fileName) != duplicate.end())
|
||||
continue;
|
||||
|
||||
// Search for duplicates
|
||||
StringList::const_iterator j = i;
|
||||
++j;
|
||||
for (; j != includeList.end(); ++j) {
|
||||
std::string candidateFileName = getLastPathComponent(*j);
|
||||
std::transform(candidateFileName.begin(), candidateFileName.end(), candidateFileName.begin(), tolower);
|
||||
if (fileName == candidateFileName) {
|
||||
duplicate.push_back(fileName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FileNode *files = scanFiles(dir, includeList, excludeList);
|
||||
|
||||
writeFileListToProject(*files, projectFile, 0, duplicate, std::string(), filePrefix + '/');
|
||||
writeFileListToProject(*files, projectFile, 0, std::string(), filePrefix + '/');
|
||||
|
||||
delete files;
|
||||
}
|
||||
|
|
|
@ -521,18 +521,16 @@ protected:
|
|||
|
||||
/**
|
||||
* Writes file entries for the specified directory node into
|
||||
* the given project file. It will also take care of duplicate
|
||||
* object files.
|
||||
* the given project file.
|
||||
*
|
||||
* @param dir Directory node.
|
||||
* @param projectFile File stream to write to.
|
||||
* @param indentation Indentation level to use.
|
||||
* @param duplicate List of duplicate object file names.
|
||||
* @param objPrefix Prefix to use for object files, which would name clash.
|
||||
* @param filePrefix Generic prefix to all files of the node.
|
||||
*/
|
||||
virtual void writeFileListToProject(const FileNode &dir, std::ofstream &projectFile, const int indentation,
|
||||
const StringList &duplicate, const std::string &objPrefix, const std::string &filePrefix) = 0;
|
||||
const std::string &objPrefix, const std::string &filePrefix) = 0;
|
||||
|
||||
/**
|
||||
* Output a list of project references to the file stream
|
||||
|
|
|
@ -382,6 +382,7 @@ void MSBuildProvider::outputGlobalPropFile(const BuildSetup &setup, std::ofstrea
|
|||
<< "\t\t\t<CompileAs>Default</CompileAs>\n"
|
||||
<< "\t\t\t<MultiProcessorCompilation>true</MultiProcessorCompilation>\n"
|
||||
<< "\t\t\t<ConformanceMode>true</ConformanceMode>\n"
|
||||
<< "\t\t\t<ObjectFileName>$(IntDir)dists\\msvc\\%(RelativeDir)</ObjectFileName>\n"
|
||||
<< "\t\t\t<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>\n"
|
||||
<< "\t\t</ClCompile>\n"
|
||||
<< "\t\t<Link>\n"
|
||||
|
@ -490,7 +491,7 @@ inline void outputNasmCommand(std::ostream &projectFile, const std::string &conf
|
|||
|
||||
} // End of anonymous namespace
|
||||
|
||||
void MSBuildProvider::writeFileListToProject(const FileNode &dir, std::ofstream &projectFile, const int, const StringList &duplicate,
|
||||
void MSBuildProvider::writeFileListToProject(const FileNode &dir, std::ofstream &projectFile, const int,
|
||||
const std::string &objPrefix, const std::string &filePrefix) {
|
||||
// Reset lists
|
||||
_filters.clear();
|
||||
|
@ -502,31 +503,11 @@ void MSBuildProvider::writeFileListToProject(const FileNode &dir, std::ofstream
|
|||
|
||||
// Compute the list of files
|
||||
_filters.push_back(""); // init filters
|
||||
computeFileList(dir, duplicate, objPrefix, filePrefix);
|
||||
computeFileList(dir, objPrefix, filePrefix);
|
||||
_filters.pop_back(); // remove last empty filter
|
||||
|
||||
// Output compile files
|
||||
if (!_compileFiles.empty()) {
|
||||
projectFile << "\t<ItemGroup>\n";
|
||||
for (std::list<FileEntry>::const_iterator entry = _compileFiles.begin(); entry != _compileFiles.end(); ++entry) {
|
||||
std::string fileName = (*entry).name + ".o";
|
||||
std::transform(fileName.begin(), fileName.end(), fileName.begin(), tolower);
|
||||
const bool isDuplicate = (std::find(duplicate.begin(), duplicate.end(), fileName) != duplicate.end());
|
||||
|
||||
// Deal with duplicated file names
|
||||
if (isDuplicate) {
|
||||
projectFile << "\t\t<ClCompile Include=\"" << (*entry).path << "\">\n"
|
||||
<< "\t\t\t<ObjectFileName>$(IntDir)" << (*entry).prefix << "%(Filename).obj</ObjectFileName>\n";
|
||||
|
||||
projectFile << "\t\t</ClCompile>\n";
|
||||
} else {
|
||||
projectFile << "\t\t<ClCompile Include=\"" << (*entry).path << "\" />\n";
|
||||
}
|
||||
}
|
||||
projectFile << "\t</ItemGroup>\n";
|
||||
}
|
||||
|
||||
// Output include, other and resource files
|
||||
// Output compile, include, other and resource files
|
||||
outputFiles(projectFile, _compileFiles, "ClCompile");
|
||||
outputFiles(projectFile, _includeFiles, "ClInclude");
|
||||
outputFiles(projectFile, _otherFiles, "None");
|
||||
outputFiles(projectFile, _resourceFiles, "ResourceCompile");
|
||||
|
@ -536,15 +517,13 @@ void MSBuildProvider::writeFileListToProject(const FileNode &dir, std::ofstream
|
|||
projectFile << "\t<ItemGroup>\n";
|
||||
for (std::list<FileEntry>::const_iterator entry = _asmFiles.begin(); entry != _asmFiles.end(); ++entry) {
|
||||
|
||||
const bool isDuplicate = (std::find(duplicate.begin(), duplicate.end(), (*entry).name + ".o") != duplicate.end());
|
||||
|
||||
projectFile << "\t\t<CustomBuild Include=\"" << (*entry).path << "\">\n"
|
||||
<< "\t\t\t<FileType>Document</FileType>\n";
|
||||
|
||||
outputNasmCommand(projectFile, "Debug", (isDuplicate ? (*entry).prefix : ""));
|
||||
outputNasmCommand(projectFile, "Analysis", (isDuplicate ? (*entry).prefix : ""));
|
||||
outputNasmCommand(projectFile, "Release", (isDuplicate ? (*entry).prefix : ""));
|
||||
outputNasmCommand(projectFile, "LLVM", (isDuplicate ? (*entry).prefix : ""));
|
||||
outputNasmCommand(projectFile, "Debug", (*entry).prefix);
|
||||
outputNasmCommand(projectFile, "Analysis", (*entry).prefix);
|
||||
outputNasmCommand(projectFile, "Release", (*entry).prefix);
|
||||
outputNasmCommand(projectFile, "LLVM", (*entry).prefix);
|
||||
|
||||
projectFile << "\t\t</CustomBuild>\n";
|
||||
}
|
||||
|
@ -562,7 +541,7 @@ void MSBuildProvider::outputFiles(std::ostream &projectFile, const FileEntries &
|
|||
}
|
||||
}
|
||||
|
||||
void MSBuildProvider::computeFileList(const FileNode &dir, const StringList &duplicate, const std::string &objPrefix, const std::string &filePrefix) {
|
||||
void MSBuildProvider::computeFileList(const FileNode &dir, 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;
|
||||
|
||||
|
@ -571,7 +550,7 @@ void MSBuildProvider::computeFileList(const FileNode &dir, const StringList &dup
|
|||
std::string _currentFilter = _filters.back();
|
||||
_filters.back().append((_filters.back() == "" ? "" : "\\") + node->name);
|
||||
|
||||
computeFileList(*node, duplicate, objPrefix + node->name + '_', filePrefix + node->name + '/');
|
||||
computeFileList(*node, objPrefix + node->name + '_', filePrefix + node->name + '/');
|
||||
|
||||
// Reset filter
|
||||
_filters.push_back(_currentFilter);
|
||||
|
|
|
@ -38,7 +38,7 @@ protected:
|
|||
void outputProjectSettings(std::ofstream &project, const std::string &name, const BuildSetup &setup, bool isRelease, MSVC_Architecture arch, const std::string &configuration);
|
||||
|
||||
void writeFileListToProject(const FileNode &dir, std::ofstream &projectFile, const int indentation,
|
||||
const StringList &duplicate, const std::string &objPrefix, const std::string &filePrefix) override;
|
||||
const std::string &objPrefix, const std::string &filePrefix) override;
|
||||
|
||||
void writeReferences(const BuildSetup &setup, std::ofstream &output) override;
|
||||
|
||||
|
@ -69,7 +69,7 @@ private:
|
|||
FileEntries _asmFiles;
|
||||
FileEntries _resourceFiles;
|
||||
|
||||
void computeFileList(const FileNode &dir, const StringList &duplicate, const std::string &objPrefix, const std::string &filePrefix);
|
||||
void computeFileList(const FileNode &dir, const std::string &objPrefix, const std::string &filePrefix);
|
||||
void createFiltersFile(const BuildSetup &setup, const std::string &name);
|
||||
|
||||
void outputFilter(std::ostream &filters, const FileEntries &files, const std::string &action);
|
||||
|
|
|
@ -226,6 +226,7 @@ void VisualStudioProvider::outputGlobalPropFile(const BuildSetup &setup, std::of
|
|||
properties << "\t\tWarningLevel=\"4\"\n"
|
||||
<< "\t\tWarnAsError=\"false\"\n"
|
||||
<< "\t\tCompileAs=\"0\"\n"
|
||||
<< "\t\tObjectFile=\"$(IntDir)dists\\msvc\\%(RelativeDir)\"\n"
|
||||
<< "\t\t/>\n"
|
||||
<< "\t<Tool\n"
|
||||
<< "\t\tName=\"VCLibrarianTool\"\n"
|
||||
|
@ -312,7 +313,7 @@ void VisualStudioProvider::createBuildProp(const BuildSetup &setup, bool isRelea
|
|||
}
|
||||
|
||||
void VisualStudioProvider::writeFileListToProject(const FileNode &dir, std::ofstream &projectFile, const int indentation,
|
||||
const StringList &duplicate, const std::string &objPrefix, const std::string &filePrefix) {
|
||||
const std::string &objPrefix, const std::string &filePrefix) {
|
||||
const std::string indentString = getIndent(indentation + 2);
|
||||
|
||||
if (indentation)
|
||||
|
@ -322,20 +323,16 @@ void VisualStudioProvider::writeFileListToProject(const FileNode &dir, std::ofst
|
|||
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, objPrefix + node->name + '_', filePrefix + node->name + '/');
|
||||
} else {
|
||||
std::string filePath = convertPathToWin(filePrefix + node->name);
|
||||
if (producesObjectFile(node->name)) {
|
||||
std::string name, ext;
|
||||
splitFilename(node->name, name, ext);
|
||||
name += ".o";
|
||||
std::transform(name.begin(), name.end(), name.begin(), tolower);
|
||||
const bool isDuplicate = (std::find(duplicate.begin(), duplicate.end(), name) != duplicate.end());
|
||||
std::string filePath = convertPathToWin(filePrefix + node->name);
|
||||
|
||||
if (ext == "asm") {
|
||||
std::string objFileName = "$(IntDir)\\";
|
||||
if (isDuplicate)
|
||||
objFileName += objPrefix;
|
||||
objFileName += objPrefix;
|
||||
objFileName += "$(InputName).obj";
|
||||
|
||||
const std::string toolLine = indentString + "\t\t<Tool Name=\"VCCustomBuildTool\" CommandLine=\"nasm.exe -f win32 -g -o "" + objFileName + "" "$(InputPath)"
\" Outputs=\"" + objFileName + "\" />\n";
|
||||
|
@ -343,18 +340,10 @@ void VisualStudioProvider::writeFileListToProject(const FileNode &dir, std::ofst
|
|||
// NASM is not supported for x64, thus we do not need to add additional entries here :-).
|
||||
writeFileToProject(projectFile, filePath, ARCH_X86, indentString, toolLine);
|
||||
} else {
|
||||
if (isDuplicate) {
|
||||
const std::string toolLine = indentString + "\t\t<Tool Name=\"VCCLCompilerTool\" ObjectFile=\"$(IntDir)\\" + objPrefix + "$(InputName).obj\" XMLDocumentationFileName=\"$(IntDir)\\" + objPrefix + "$(InputName).xdc\" />\n";
|
||||
|
||||
for (std::list<MSVC_Architecture>::const_iterator arch = _archs.begin(); arch != _archs.end(); ++arch) {
|
||||
writeFileToProject(projectFile, filePath, *arch, indentString, toolLine);
|
||||
}
|
||||
} else {
|
||||
projectFile << indentString << "<File RelativePath=\"" << convertPathToWin(filePrefix + node->name) << "\" />\n";
|
||||
}
|
||||
projectFile << indentString << "<File RelativePath=\"" << filePath << "\" />\n";
|
||||
}
|
||||
} else {
|
||||
projectFile << indentString << "<File RelativePath=\"" << convertPathToWin(filePrefix + node->name) << "\" />\n";
|
||||
projectFile << indentString << "<File RelativePath=\"" << filePath << "\" />\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ protected:
|
|||
const StringList &includeList, const StringList &excludeList);
|
||||
|
||||
void writeFileListToProject(const FileNode &dir, std::ofstream &projectFile, const int indentation,
|
||||
const StringList &duplicate, const std::string &objPrefix, const std::string &filePrefix);
|
||||
const std::string &objPrefix, const std::string &filePrefix);
|
||||
|
||||
void writeFileToProject(std::ofstream &projectFile, const std::string &filePath, MSVC_Architecture arch,
|
||||
const std::string &indentString, const std::string &toolLine);
|
||||
|
|
|
@ -379,7 +379,7 @@ void XcodeProvider::outputMainProjectFile(const BuildSetup &setup) {
|
|||
// Files
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void XcodeProvider::writeFileListToProject(const FileNode &dir, std::ofstream &projectFile, const int indentation,
|
||||
const StringList &duplicate, const std::string &objPrefix, const std::string &filePrefix) {
|
||||
const std::string &objPrefix, const std::string &filePrefix) {
|
||||
|
||||
// Ensure that top-level groups are generated for i.e. engines/
|
||||
Group *group = touchGroupsForPath(filePrefix);
|
||||
|
@ -393,7 +393,7 @@ void XcodeProvider::writeFileListToProject(const FileNode &dir, std::ofstream &p
|
|||
}
|
||||
// Process child nodes
|
||||
if (!node->children.empty())
|
||||
writeFileListToProject(*node, projectFile, indentation + 1, duplicate, objPrefix + node->name + '_', filePrefix + node->name + '/');
|
||||
writeFileListToProject(*node, projectFile, indentation + 1, objPrefix + node->name + '_', filePrefix + node->name + '/');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ protected:
|
|||
const StringList &includeList, const StringList &excludeList);
|
||||
|
||||
void writeFileListToProject(const FileNode &dir, std::ofstream &projectFile, const int indentation,
|
||||
const StringList &duplicate, const std::string &objPrefix, const std::string &filePrefix);
|
||||
const std::string &objPrefix, const std::string &filePrefix);
|
||||
private:
|
||||
enum {
|
||||
kSettingsAsList = 0x01,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue