Browse Source

* 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 -

tom_at_work 19 years ago
parent
commit
a2307edf2c
2 changed files with 30 additions and 5 deletions
  1. 2 1
      compiler/globals.pas
  2. 28 4
      compiler/link.pas

+ 2 - 1
compiler/globals.pas

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

+ 28 - 4
compiler/link.pas

@@ -196,7 +196,11 @@ end;
          Found:=librarysearchpath.FindFile(s,founddll);
          Found:=librarysearchpath.FindFile(s,founddll);
         if (not found) then
         if (not found) then
          begin
          begin
+           {$IFDEF USE_SYSUTILS}
+           sysdir:=FixPath(GetEnvironmentVariable('windir'),false);
+           {$ELSE USE_SYSUTILS}
            sysdir:=FixPath(GetEnv('windir'),false);
            sysdir:=FixPath(GetEnv('windir'),false);
+           {$ENDIF USE_SYSUTILS}
            Found:=FindFile(s,sysdir+';'+sysdir+'system'+source_info.DirSep+';'+sysdir+'system32'+source_info.DirSep,founddll);
            Found:=FindFile(s,sysdir+';'+sysdir+'system'+source_info.DirSep+';'+sysdir+'system32'+source_info.DirSep,founddll);
          end;
          end;
         if (not found) then
         if (not found) then
@@ -592,10 +596,22 @@ end;
 
 
 Function TExternalLinker.MakeStaticLibrary:boolean;
 Function TExternalLinker.MakeStaticLibrary:boolean;
 var
 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;
   binstr  : string;
   success : boolean;
   success : boolean;
+  cmdstr, nextcmd : TCmdStr;
+  current : TStringListItem;
 begin
 begin
   MakeStaticLibrary:=false;
   MakeStaticLibrary:=false;
 { remove the library, to be sure that it is rewritten }
 { 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);
   smartpath:=current_module.outputpath^+FixPath(lower(current_module.modulename^)+target_info.smartext,false);
   SplitBinCmd(target_ar.arcmd,binstr,cmdstr);
   SplitBinCmd(target_ar.arcmd,binstr,cmdstr);
   Replace(cmdstr,'$LIB',maybequoted(current_module.staticlibfilename^));
   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 }
 { Clean up }
   if not(cs_asm_leave in aktglobalswitches) then
   if not(cs_asm_leave in aktglobalswitches) then
    if not(cs_link_extern in aktglobalswitches) then
    if not(cs_link_extern in aktglobalswitches) then