MakeImports: skip wrong-architecture libraries

This commit is contained in:
Wolfgang Thaller 2019-01-02 00:13:51 +01:00
parent 3b0ef808de
commit 0f240969b4

View File

@ -212,7 +212,7 @@ void MakeImportLibrary(char *pefptr, size_t pefsize, fs::path dest, fs::path tmp
} }
} }
void MakeImportLibraryMulti(fs::path path, fs::path libname) bool MakeImportLibraryMulti(fs::path path, fs::path libname)
{ {
ResourceFile resFile(path.string()); ResourceFile resFile(path.string());
assert(resFile.read()); assert(resFile.read());
@ -226,7 +226,7 @@ void MakeImportLibraryMulti(fs::path path, fs::path libname)
if(data.size() < 8 || std::string(data.begin(), data.begin()+8) != "Joy!peff") if(data.size() < 8 || std::string(data.begin(), data.begin()+8) != "Joy!peff")
{ {
std::cerr << "Not a PEF shared library. Ignoring.\n"; std::cerr << "Not a PEF shared library. Ignoring.\n";
return; return false;
} }
if(resFile.resources.resources.find(ResRef("cfrg",0)) == resFile.resources.resources.end()) if(resFile.resources.resources.find(ResRef("cfrg",0)) == resFile.resources.resources.end())
@ -257,6 +257,14 @@ void MakeImportLibraryMulti(fs::path path, fs::path libname)
member = (CFragResourceMember*) (((char*)member) + member->memberSize); member = (CFragResourceMember*) (((char*)member) + member->memberSize);
} }
if(!std::any_of(members.begin(), members.end(), [](const auto& member) {
return member.architecture == 'pwpc' || member.architecture == '\?\?\?\?';
}))
{
std::cerr << "Does not contain a PowerPC variant. Ignoring.\n";
return false;
}
fs::path tmpdir = libname.parent_path() / fs::unique_path("makeimport-tmp-%%%%-%%%%-%%%%-%%%%"); fs::path tmpdir = libname.parent_path() / fs::unique_path("makeimport-tmp-%%%%-%%%%-%%%%-%%%%");
fs::create_directory(tmpdir); fs::create_directory(tmpdir);
try try
@ -331,6 +339,8 @@ void MakeImportLibraryMulti(fs::path path, fs::path libname)
throw; throw;
} }
fs::remove_all(tmpdir); fs::remove_all(tmpdir);
return true;
} }
int main (int argc, char * const argv[]) int main (int argc, char * const argv[])