Browse Source

* shell now returns an exitcode
* print an error if linking failed when linking was done using a script

Jonas Maebe 21 years ago
parent
commit
75c3c8b259
2 changed files with 26 additions and 7 deletions
  1. 16 4
      compiler/globals.pas
  2. 10 3
      compiler/link.pas

+ 16 - 4
compiler/globals.pas

@@ -302,7 +302,7 @@ interface
     function  FindExe(const bin:string;var foundfile:string):boolean;
     function  GetShortName(const n:string):string;
 
-    Procedure Shell(const command:string);
+    function Shell(const command:string): longint;
     function  GetEnvPChar(const envname:string):pchar;
     procedure FreeEnvPChar(p:pchar);
 
@@ -1326,17 +1326,21 @@ implementation
       end;
 
 
-    Procedure Shell(const command:string);
+    function Shell(const command:string): longint;
       { This is already defined in the linux.ppu for linux, need for the *
         expansion under linux }
       {$ifdef hasunix}
       begin
-        {$ifdef havelinuxrtl10}Linux{$else}Unix{$endif}.Shell(command);
+        result := {$ifdef havelinuxrtl10}Linux{$else}Unix{$endif}.Shell(command);
       end;
       {$else}
       {$ifdef amiga}
       begin
         exec('',command);
+        if (doserror <> 0) then
+          result := doserror
+        else
+          result := dosexitcode;
       end;
       {$else}
       var
@@ -1344,6 +1348,10 @@ implementation
       begin
         comspec:=getenv('COMSPEC');
         Exec(comspec,' /C '+command);
+        if (doserror <> 0) then
+          result := doserror
+        else
+          result := dosexitcode;
       end;
       {$endif}
       {$endif}
@@ -1905,7 +1913,11 @@ implementation
 end.
 {
   $Log$
-  Revision 1.132  2004-07-05 23:28:24  olle
+  Revision 1.133  2004-07-17 15:51:57  jonas
+    * shell now returns an exitcode
+    * print an error if linking failed when linking was done using a script
+
+  Revision 1.132  2004/07/05 23:28:24  olle
     + FixFileName now handles Mac OS paths
 
   Revision 1.131  2004/06/20 08:55:29  florian

+ 10 - 3
compiler/link.pas

@@ -479,17 +479,20 @@ end;
 
 
 Function TExternalLinker.DoExec(const command,para:string;showinfo,useshell:boolean):boolean;
+var
+  exitcode: longint;
 begin
   DoExec:=true;
   if not(cs_link_extern in aktglobalswitches) then
    begin
      if useshell then
-       shell(maybequoted(command)+' '+para)
+       exitcode := shell(maybequoted(command)+' '+para)
      else
        begin
          swapvectors;
          exec(command,para);
          swapvectors;
+         exitcode := dosexitcode;
        end;
      if (doserror<>0) then
       begin
@@ -498,7 +501,7 @@ begin
          DoExec:=false;
       end
      else
-      if (dosexitcode<>0) then
+      if (exitcode<>0) then
        begin
         Message(exec_e_error_while_linking);
         aktglobalswitches:=aktglobalswitches+[cs_link_extern];
@@ -676,7 +679,11 @@ initialization
 end.
 {
   $Log$
-  Revision 1.42  2004-06-20 08:55:29  florian
+  Revision 1.43  2004-07-17 15:51:57  jonas
+    * shell now returns an exitcode
+    * print an error if linking failed when linking was done using a script
+
+  Revision 1.42  2004/06/20 08:55:29  florian
     * logs truncated
 
   Revision 1.41  2004/02/24 00:53:49  olle