Browse Source

* findobjectfile gets extra arg with directory where the unit is found
and the .o should be looked first

peter 25 years ago
parent
commit
b9e5501ba7
6 changed files with 53 additions and 25 deletions
  1. 22 14
      compiler/link.pas
  2. 6 2
      compiler/t_go32v1.pas
  3. 6 2
      compiler/t_go32v2.pas
  4. 6 2
      compiler/t_linux.pas
  5. 6 2
      compiler/t_os2.pas
  6. 7 3
      compiler/t_win32.pas

+ 22 - 14
compiler/link.pas

@@ -52,9 +52,9 @@ Type
        Constructor Init;
        Destructor Done;
        procedure AddModuleFiles(hp:pmodule);
-       function  FindObjectFile(s : string) : string;
+       function  FindObjectFile(s : string;const unitpath:string) : string;
        function  FindLibraryFile(s:string;const ext:string;var found : boolean) : string;
-       Procedure AddObject(const S : String);
+       Procedure AddObject(const S,unitpath : String);
        Procedure AddStaticLibrary(const S : String);
        Procedure AddSharedLibrary(S : String);
        Function  FindUtil(const s:string):String;
@@ -220,7 +220,7 @@ begin
          end;
         { unit files }
         while not linkunitofiles.empty do
-         AddObject(linkunitofiles.getusemask(mask));
+         AddObject(linkunitofiles.getusemask(mask),path^);
         while not linkunitstaticlibs.empty do
          AddStaticLibrary(linkunitstaticlibs.getusemask(mask));
         while not linkunitsharedlibs.empty do
@@ -229,7 +229,7 @@ begin
    { Other needed .o and libs, specified using $L,$LINKLIB,external }
      mask:=link_allways;
      while not linkotherofiles.empty do
-      AddObject(linkotherofiles.Getusemask(mask));
+      AddObject(linkotherofiles.Getusemask(mask),path^);
      while not linkotherstaticlibs.empty do
       AddStaticLibrary(linkotherstaticlibs.Getusemask(mask));
      while not linkothersharedlibs.empty do
@@ -260,7 +260,7 @@ end;
 
 
 { searches an object file }
-function TLinker.FindObjectFile(s:string) : string;
+function TLinker.FindObjectFile(s:string;const unitpath:string) : string;
 var
   found : boolean;
 begin
@@ -276,13 +276,17 @@ begin
      exit;
    end;
   { find object file
-     1. cwd
-     2. unit search path
-     3. local object path
-     4. global object path
-     5. exepath }
+     1. specified unit path (if specified)
+     2. cwd
+     3. unit search path
+     4. local object path
+     5. global object path
+     6. exepath }
   found:=false;
-  findobjectfile:=FindFile(s,'.'+DirSep,found)+s;
+  if unitpath<>'' then
+   findobjectfile:=FindFile(s,unitpath,found)+s;
+  if (not found) then
+   findobjectfile:=FindFile(s,'.'+DirSep,found)+s;
   if (not found) then
    findobjectfile:=UnitSearchPath.FindFile(s,found)+s;
   if (not found) then
@@ -327,9 +331,9 @@ begin
 end;
 
 
-Procedure TLinker.AddObject(const S : String);
+Procedure TLinker.AddObject(const S,unitpath : String);
 begin
-  ObjectFiles.Insert(FindObjectFile(s));
+  ObjectFiles.Insert(FindObjectFile(s,unitpath));
 end;
 
 
@@ -521,7 +525,11 @@ end;
 end.
 {
   $Log$
-  Revision 1.89  2000-06-28 03:34:06  hajny
+  Revision 1.90  2000-07-08 20:43:37  peter
+    * findobjectfile gets extra arg with directory where the unit is found
+      and the .o should be looked first
+
+  Revision 1.89  2000/06/28 03:34:06  hajny
     * little corrections for EMX resources
 
   Revision 1.88  2000/05/17 18:30:35  peter

+ 6 - 2
compiler/t_go32v1.pas

@@ -100,7 +100,7 @@ begin
    end;
 
   { add objectfiles, start with prt0 always }
-  LinkRes.AddFileName(FindObjectFile('prt0'));
+  LinkRes.AddFileName(FindObjectFile('prt0',''));
   while not ObjectFiles.Empty do
    begin
      s:=ObjectFiles.Get;
@@ -190,7 +190,11 @@ end;
 end.
 {
   $Log$
-  Revision 1.9  2000-02-28 17:23:57  daniel
+  Revision 1.10  2000-07-08 20:43:38  peter
+    * findobjectfile gets extra arg with directory where the unit is found
+      and the .o should be looked first
+
+  Revision 1.9  2000/02/28 17:23:57  daniel
   * Current work of symtable integration committed. The symtable can be
     activated by defining 'newst', but doesn't compile yet. Changes in type
     checking and oop are completed. What is left is to write a new

+ 6 - 2
compiler/t_go32v2.pas

@@ -99,7 +99,7 @@ begin
    end;
 
   { add objectfiles, start with prt0 always }
-  LinkRes.AddFileName(GetShortName(FindObjectFile('prt0')));
+  LinkRes.AddFileName(GetShortName(FindObjectFile('prt0','')));
   while not ObjectFiles.Empty do
    begin
      s:=ObjectFiles.Get;
@@ -292,7 +292,11 @@ end;
 end.
 {
   $Log$
-  Revision 1.10  2000-02-28 17:23:57  daniel
+  Revision 1.11  2000-07-08 20:43:38  peter
+    * findobjectfile gets extra arg with directory where the unit is found
+      and the .o should be looked first
+
+  Revision 1.10  2000/02/28 17:23:57  daniel
   * Current work of symtable integration committed. The symtable can be
     activated by defining 'newst', but doesn't compile yet. Changes in type
     checking and oop are completed. What is left is to write a new

+ 6 - 2
compiler/t_linux.pas

@@ -312,7 +312,7 @@ begin
   LinkRes.Add('INPUT(');
   { add objectfiles, start with prt0 always }
   if prtobj<>'' then
-   LinkRes.AddFileName(FindObjectFile(prtobj));
+   LinkRes.AddFileName(FindObjectFile(prtobj,''));
   { try to add crti and crtbegin if linking to C }
   if linklibc then
    begin
@@ -477,7 +477,11 @@ end;
 end.
 {
   $Log$
-  Revision 1.14  2000-03-21 21:36:52  peter
+  Revision 1.15  2000-07-08 20:43:38  peter
+    * findobjectfile gets extra arg with directory where the unit is found
+      and the .o should be looked first
+
+  Revision 1.14  2000/03/21 21:36:52  peter
     * only include crtbegin when linking to libc
 
   Revision 1.13  2000/03/12 08:24:03  daniel

+ 6 - 2
compiler/t_os2.pas

@@ -402,7 +402,7 @@ begin
    end;
 
   { add objectfiles, start with prt0 always }
-  LinkRes.AddFileName(FindObjectFile('prt0'));
+  LinkRes.AddFileName(FindObjectFile('prt0',''));
   while not ObjectFiles.Empty do
    begin
      s:=ObjectFiles.Get;
@@ -507,7 +507,11 @@ end;
 end.
 {
   $Log$
-  Revision 1.13  2000-06-28 03:34:06  hajny
+  Revision 1.14  2000-07-08 20:43:38  peter
+    * findobjectfile gets extra arg with directory where the unit is found
+      and the .o should be looked first
+
+  Revision 1.13  2000/06/28 03:34:06  hajny
     * little corrections for EMX resources
 
   Revision 1.12  2000/06/25 19:08:28  hajny

+ 7 - 3
compiler/t_win32.pas

@@ -689,9 +689,9 @@ begin
   { add objectfiles, start with prt0 always }
   LinkRes.Add('INPUT(');
   if isdll then
-   LinkRes.AddFileName(GetShortName(FindObjectFile('wdllprt0')))
+   LinkRes.AddFileName(GetShortName(FindObjectFile('wdllprt0','')))
   else
-   LinkRes.AddFileName(GetShortName(FindObjectFile('wprt0')));
+   LinkRes.AddFileName(GetShortName(FindObjectFile('wprt0','')));
   while not ObjectFiles.Empty do
    begin
      s:=ObjectFiles.Get;
@@ -1303,7 +1303,11 @@ end;
 end.
 {
   $Log$
-  Revision 1.24  2000-06-20 12:44:30  pierre
+  Revision 1.25  2000-07-08 20:43:38  peter
+    * findobjectfile gets extra arg with directory where the unit is found
+      and the .o should be looked first
+
+  Revision 1.24  2000/06/20 12:44:30  pierre
    * do not create an empty export section
 
   Revision 1.23  2000/05/23 20:18:25  pierre