*ide: Fix in msc builder for huge number of linked files (thanks Massimo)

git-svn-id: svn://ultimatepp.org/upp/trunk@4427 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2012-01-16 11:44:58 +00:00
parent 3ab7261388
commit 560aef6120

View file

@ -314,8 +314,8 @@ bool MscBuilder::BuildPackage(const String& package, Vector<String>& linkfile, S
c = cc_speed;
int slot = AllocSlot();
if(slot < 0 || !Run(c + PdbPch(package, slot, !sContainsPchOptions(cc) && !sContainsPchOptions(soptions[i]))
+ " " + soptions[i] + (ext ".c" ? " -Tc " : " -Tp ")
+ GetHostPathQ(fn) + " -Fo" + GetHostPathQ(objfile), slot, GetHostPath(objfile), 1))
+ " " + soptions[i] + (ext == ".c" ? " -Tc " : " -Tp ")
+ GetHostPathQ(fn) + " -Fo" + GetHostPathQ(objfile), slot, GetHostPath(objfile), 1))
execerr = true;
}
if(execerr)
@ -373,9 +373,10 @@ bool MscBuilder::BuildPackage(const String& package, Vector<String>& linkfile, S
Vector<Host::FileInfo> objinfo = host->GetFileInfo(obj);
for(int i = 0; i < obj.GetCount(); i++)
if(objinfo[i] > producttime) {
String lib;
String linker, lib;
if(is_shared) {
lib << LinkerName() << " -dll -nologo -machine:" << MachineName()
linker << LinkerName() << "-dll -nologo ";
lib << "-machine:" << MachineName()
<< " -pdb:" << GetHostPathQ(ForceExt(product, ".pdb"))
<< " -out:" << GetHostPathQ(product);
if(!HasFlag("MSC10") && !HasFlag("MSC10X64"))
@ -435,7 +436,7 @@ bool MscBuilder::BuildPackage(const String& package, Vector<String>& linkfile, S
}
}
else{
lib << (HasFlag("INTEL") ? "xilib" : "link /lib") << " -nologo";
linker << (HasFlag("INTEL") ? "xilib" : "link /lib") << " -nologo ";
if(HasFlag("FORCE_SIZE")){
if(sContainsPchOptions(release_size_options))
lib << " -ltcg";
@ -451,7 +452,41 @@ bool MscBuilder::BuildPackage(const String& package, Vector<String>& linkfile, S
PutConsole("Creating library...");
IdeConsoleEndGroup();
DeleteFile(product);
if(Execute(lib)) {
String tmpFileName;
if(linker.GetCount() + lib.GetCount() >= 8192)
{
tmpFileName = GetTempFileName();
// we can't simply put all data on a single line
// as it has a limit of around 130000 chars too, so we split
// in multiple lines
FileOut f(tmpFileName);
while(lib != "")
{
int found = 0;
bool quotes = false;
int lim = min(8192, lib.GetCount());
for(int i = 0; i < lim; i++)
{
char c = lib[i];
if(isspace(c) && !quotes)
found = i;
else if(c == '"')
quotes = !quotes;
}
if(!found)
found = lib.GetCount();
f.PutLine(lib.Left(found));
lib.Remove(0, found);
}
f.Close();
linker << "@" << tmpFileName;
}
else
linker << lib;
bool res = Execute(linker);
if(tmpFileName != "")
FileDelete(tmpFileName);
if(res) {
DeleteFile(product);
return false;
}