* fixed -dUSE_SYSUTILS compilation

* the call to "ar" is now automatically broken into multiple calls, avoiding shell errors when expanding the '*' in the original commandline

git-svn-id: trunk@2378 -
This commit is contained in:
tom_at_work 2006-01-29 18:01:53 +00:00
parent 64c8d25dcf
commit a2307edf2c
2 changed files with 30 additions and 5 deletions

View File

@ -718,7 +718,8 @@ implementation
then
Delete (F, Length (F), 1);
{$IFDEF USE_SYSUTILS}
PathExists := FileGetAttr(F) and faDirectory = faDirectory;
I := FileGetAttr(F);
PathExists := (I <> -1) and (I and faDirectory = faDirectory);
{$ELSE USE_SYSUTILS}
Assign (FF, FExpand (F));
GetFAttr (FF, A);

View File

@ -196,7 +196,11 @@ end;
Found:=librarysearchpath.FindFile(s,founddll);
if (not found) then
begin
{$IFDEF USE_SYSUTILS}
sysdir:=FixPath(GetEnvironmentVariable('windir'),false);
{$ELSE USE_SYSUTILS}
sysdir:=FixPath(GetEnv('windir'),false);
{$ENDIF USE_SYSUTILS}
Found:=FindFile(s,sysdir+';'+sysdir+'system'+source_info.DirSep+';'+sysdir+'system32'+source_info.DirSep,founddll);
end;
if (not found) then
@ -592,10 +596,22 @@ end;
Function TExternalLinker.MakeStaticLibrary:boolean;
var
smartpath,
cmdstr : TCmdStr;
smartpath : TCmdStr;
function GetNextFiles(const maxCmdLength : AInt; var item : TStringListItem) : string;
begin
result := '';
while (assigned(item) and ((length(result) + length(item.str) + 1) < maxCmdLength)) do begin
result := result + ' ' + item.str;
item := TStringListItem(item.next);
end;
end;
var
binstr : string;
success : boolean;
cmdstr, nextcmd : TCmdStr;
current : TStringListItem;
begin
MakeStaticLibrary:=false;
{ remove the library, to be sure that it is rewritten }
@ -604,8 +620,16 @@ begin
smartpath:=current_module.outputpath^+FixPath(lower(current_module.modulename^)+target_info.smartext,false);
SplitBinCmd(target_ar.arcmd,binstr,cmdstr);
Replace(cmdstr,'$LIB',maybequoted(current_module.staticlibfilename^));
Replace(cmdstr,'$FILES',FixFileName(smartpath+current_module.asmprefix^+'*'+target_info.objext));
success:=DoExec(FindUtil(binstr),cmdstr,false,true);
{ create AR commands }
success := true;
nextcmd := cmdstr;
current := TStringListItem(SmartLinkOFiles.First);
repeat
Replace(nextcmd,'$FILES',GetNextFiles(240 - length(nextcmd), current));
success:=DoExec(FindUtil(binstr),nextcmd,false,true);
nextcmd := cmdstr;
until (not assigned(current)) or (not success);
{ Clean up }
if not(cs_asm_leave in aktglobalswitches) then
if not(cs_link_extern in aktglobalswitches) then