+ unitpath,librarypath,includepath,objectpath directives

This commit is contained in:
peter 1999-03-25 16:55:29 +00:00
parent f9306d5210
commit 633fcc0bda
4 changed files with 251 additions and 93 deletions

View File

@ -155,6 +155,10 @@ unit files;
linkofiles : tstringcontainer; linkofiles : tstringcontainer;
used_units : tlinkedlist; used_units : tlinkedlist;
localunitsearchpath, { local searchpaths }
localobjectsearchpath,
localincludesearchpath,
locallibrarysearchpath : pstring;
path, { path where the module is find/created } path, { path where the module is find/created }
outpath, outpath,
@ -799,12 +803,8 @@ uses
function tmodule.search_unit(const n : string;onlysource:boolean):boolean; function tmodule.search_unit(const n : string;onlysource:boolean):boolean;
var var
ext : string[8];
singlepathstring, singlepathstring,
unitPath, filename : string;
filename : string;
found : boolean;
start,i : longint;
Function UnitExists(const ext:string):boolean; Function UnitExists(const ext:string):boolean;
begin begin
@ -812,70 +812,89 @@ uses
UnitExists:=FileExists(Singlepathstring+FileName+ext); UnitExists:=FileExists(Singlepathstring+FileName+ext);
end; end;
Function SearchPath(unitpath:string):boolean;
var
found : boolean;
start,i : longint;
ext : string[8];
begin
start:=1;
Found:=false;
repeat
{ Create current path to check }
i:=pos(';',unitpath);
if i=0 then
i:=length(unitpath)+1;
singlepathstring:=FixPath(copy(unitpath,start,i-start),false);
delete(unitpath,start,i-start+1);
if not onlysource then
begin
{ Check for PPL file }
if not Found then
begin
Found:=UnitExists(target_info.unitlibext);
if Found then
Begin
SetFileName(SinglePathString+FileName,false);
Found:=OpenPPU;
End;
end;
{ Check for PPU file }
if not Found then
begin
Found:=UnitExists(target_info.unitext);
if Found then
Begin
SetFileName(SinglePathString+FileName,false);
Found:=OpenPPU;
End;
end;
end;
{ Check for Sources }
if not Found then
begin
ppufile:=nil;
do_compile:=true;
{Check for .pp file}
Found:=UnitExists(target_os.sourceext);
if Found then
Ext:=target_os.sourceext
else
begin
{Check for .pas}
Found:=UnitExists(target_os.pasext);
if Found then
Ext:=target_os.pasext;
end;
stringdispose(mainsource);
if Found then
begin
sources_avail:=true;
{Load Filenames when found}
mainsource:=StringDup(SinglePathString+FileName+Ext);
SetFileName(SinglePathString+FileName,false);
end
else
sources_avail:=false;
end;
until Found or (unitpath='');
SearchPath:=Found;
end;
var
fnd : boolean;
begin begin
start:=1;
filename:=FixFileName(n); filename:=FixFileName(n);
unitpath:=UnitSearchPath; { try to find unit
Found:=false; 1. cwd
repeat 2. local unit path
{ Create current path to check } 3. global unit path }
i:=pos(';',unitpath); fnd:=SearchPath('.');
if i=0 then if (not fnd) and assigned(current_module^.LocalUnitSearchPath) then
i:=length(unitpath)+1; fnd:=SearchPath(current_module^.LocalUnitSearchPath^);
singlepathstring:=FixPath(copy(unitpath,start,i-start),false); if not fnd then
delete(unitpath,start,i-start+1); fnd:=SearchPath(UnitSearchPath);
if not onlysource then search_unit:=fnd;
begin
{ Check for PPL file }
if not Found then
begin
Found:=UnitExists(target_info.unitlibext);
if Found then
Begin
SetFileName(SinglePathString+FileName,false);
Found:=OpenPPU;
End;
end;
{ Check for PPU file }
if not Found then
begin
Found:=UnitExists(target_info.unitext);
if Found then
Begin
SetFileName(SinglePathString+FileName,false);
Found:=OpenPPU;
End;
end;
end;
{ Check for Sources }
if not Found then
begin
ppufile:=nil;
do_compile:=true;
{Check for .pp file}
Found:=UnitExists(target_os.sourceext);
if Found then
Ext:=target_os.sourceext
else
begin
{Check for .pas}
Found:=UnitExists(target_os.pasext);
if Found then
Ext:=target_os.pasext;
end;
stringdispose(mainsource);
if Found then
begin
sources_avail:=true;
{Load Filenames when found}
mainsource:=StringDup(SinglePathString+FileName+Ext);
SetFileName(SinglePathString+FileName,false);
end
else
sources_avail:=false;
end;
until Found or (unitpath='');
search_unit:=Found;
end; end;
procedure tmodule.reset; procedure tmodule.reset;
@ -974,6 +993,10 @@ uses
{$endif tp} {$endif tp}
path:=nil; path:=nil;
setfilename(p+n,true); setfilename(p+n,true);
localunitsearchpath:=nil;
localobjectsearchpath:=nil;
localincludesearchpath:=nil;
locallibrarysearchpath:=nil;
used_units.init; used_units.init;
new(sourcefiles,init); new(sourcefiles,init);
resourcefiles.init_no_double; resourcefiles.init_no_double;
@ -1048,6 +1071,10 @@ uses
stringdispose(modulename); stringdispose(modulename);
stringdispose(mainsource); stringdispose(mainsource);
stringdispose(asmprefix); stringdispose(asmprefix);
stringdispose(localunitsearchpath);
stringdispose(localobjectsearchpath);
stringdispose(localincludesearchpath);
stringdispose(locallibrarysearchpath);
if assigned(globalsymtable) then if assigned(globalsymtable) then
dispose(punitsymtable(globalsymtable),done); dispose(punitsymtable(globalsymtable),done);
globalsymtable:=nil; globalsymtable:=nil;
@ -1097,7 +1124,10 @@ uses
end. end.
{ {
$Log$ $Log$
Revision 1.87 1999-02-16 00:48:23 peter Revision 1.88 1999-03-25 16:55:29 peter
+ unitpath,librarypath,includepath,objectpath directives
Revision 1.87 1999/02/16 00:48:23 peter
* save in the ppu if linked with obj file instead of using the * save in the ppu if linked with obj file instead of using the
library flag, so the .inc files are also checked library flag, so the .inc files are also checked

View File

@ -105,7 +105,7 @@ begin
Glibc2:=true Glibc2:=true
else else
DynamicLinker:='/lib/ld-linux.so.1'; DynamicLinker:='/lib/ld-linux.so.1';
LibrarySearchPath:='/lib;/usr/lib'; LibrarySearchPath:='/lib;/usr/lib;/usr/lib/X11';
{$else} {$else}
DynamicLinker:=''; DynamicLinker:='';
LibrarySearchPath:=''; LibrarySearchPath:='';
@ -178,10 +178,22 @@ begin
Findobjectfile:=s; Findobjectfile:=s;
exit; exit;
end; end;
findobjectfile:=search(s,'.;'+unitsearchpath+';'+exepath,found)+s; { find object file
{ if not found then check the object searchpath also } 1. cwd
if not found then 2. unit search path
3. local object path
4. global object path
5. exepath }
found:=false;
findobjectfile:=search(s,'.',found)+s;
if (not found) then
findobjectfile:=search(s,unitsearchpath,found)+s;
if (not found) and assigned(current_module^.localobjectsearchpath) then
findobjectfile:=search(s,current_module^.localobjectsearchpath^,found)+s;
if (not found) then
findobjectfile:=search(s,objectsearchpath,found)+s; findobjectfile:=search(s,objectsearchpath,found)+s;
if (not found) then
findobjectfile:=search(s,exepath,found)+s;
if not(cs_link_extern in aktglobalswitches) and (not found) then if not(cs_link_extern in aktglobalswitches) and (not found) then
Message1(exec_w_objfile_not_found,s); Message1(exec_w_objfile_not_found,s);
end; end;
@ -199,7 +211,19 @@ begin
FindLibraryFile:=s; FindLibraryFile:=s;
exit; exit;
end; end;
findlibraryfile:=search(s,'.;'+librarysearchpath+';'+exepath,found)+s; { find libary
1. cwd
2. local libary dir
3. global libary dir
4. exe path of the compiler }
found:=false;
findlibraryfile:=search(s,'.',found)+s;
if (not found) and assigned(current_module^.locallibrarysearchpath) then
findlibraryfile:=search(s,current_module^.locallibrarysearchpath^,found)+s;
if (not found) then
findlibraryfile:=search(s,librarysearchpath,found)+s;
if (not found) then
findlibraryfile:=search(s,exepath,found)+s;
if not(cs_link_extern in aktglobalswitches) and (not found) then if not(cs_link_extern in aktglobalswitches) and (not found) then
Message1(exec_w_libfile_not_found,s); Message1(exec_w_libfile_not_found,s);
end; end;
@ -280,6 +304,17 @@ Var
WriteLn(Linkresponse,s); WriteLn(Linkresponse,s);
end; end;
procedure WriteResFileName(const s:string);
begin
if s<>'' then
begin
if (pos('\',s)=0) and (pos('/',s)=0) then
WriteLn(Linkresponse,'.'+DirSep+s)
else
WriteLn(Linkresponse,s);
end;
end;
begin begin
WriteResponseFile:=False; WriteResponseFile:=False;
linux_link_c:=false; linux_link_c:=false;
@ -331,6 +366,19 @@ begin
exit; exit;
{ Write library searchpath } { Write library searchpath }
if assigned(current_module^.locallibrarysearchpath) then
begin
S2:=current_module^.locallibrarysearchpath^;
Repeat
i:=Pos(';',S2);
If i=0 then
i:=255;
S:=Copy(S2,1,i-1);
If S<>'' then
WriteRes(target_link.libpathprefix+s+target_link.libpathsuffix);
Delete (S2,1,i);
until S2='';
end;
S2:=LibrarySearchPath; S2:=LibrarySearchPath;
Repeat Repeat
i:=Pos(';',S2); i:=Pos(';',S2);
@ -345,32 +393,32 @@ begin
WriteRes(target_link.inputstart); WriteRes(target_link.inputstart);
{ add objectfiles, start with prt0 always } { add objectfiles, start with prt0 always }
if prtobj<>'' then if prtobj<>'' then
WriteRes(FindObjectFile(prtobj)); WriteResFileName(FindObjectFile(prtobj));
{ try to add crti and crtbegin, they are normally not required, but { try to add crti and crtbegin, they are normally not required, but
adding can sometimes be usefull } adding can sometimes be usefull }
if linux_link_c then if linux_link_c then
begin begin
s:=search('crtbegin.o',librarysearchpath,found)+'crtbegin.o'; s:=search('crtbegin.o',librarysearchpath,found)+'crtbegin.o';
if found then if found then
WriteRes(s); WriteResFileName(s);
s:=search('crti.o',librarysearchpath,found)+'crti.o'; s:=search('crti.o',librarysearchpath,found)+'crti.o';
if found then if found then
WriteRes(s); WriteResFileName(s);
end; end;
while not ObjectFiles.Empty do while not ObjectFiles.Empty do
begin begin
s:=ObjectFiles.Get; s:=ObjectFiles.Get;
if s<>'' then if s<>'' then
WriteRes(s); WriteResFileName(s);
end; end;
if linux_link_c then if linux_link_c then
begin begin
s:=search('crtend.o',librarysearchpath,found)+'crtend.o'; s:=search('crtend.o',librarysearchpath,found)+'crtend.o';
if found then if found then
WriteRes(s); WriteResFileName(s);
s:=search('crtn.o',librarysearchpath,found)+'crtn.o'; s:=search('crtn.o',librarysearchpath,found)+'crtn.o';
if found then if found then
WriteRes(s); WriteResFileName(s);
end; end;
{ Write sharedlibraries like -l<lib> } { Write sharedlibraries like -l<lib> }
@ -404,7 +452,7 @@ begin
While not StaticLibFiles.Empty do While not StaticLibFiles.Empty do
begin begin
S:=StaticLibFiles.Get; S:=StaticLibFiles.Get;
WriteRes(s) WriteResFileName(s)
end; end;
WriteRes(target_link.GroupEnd); WriteRes(target_link.GroupEnd);
end; end;
@ -562,7 +610,10 @@ end;
end. end.
{ {
$Log$ $Log$
Revision 1.48 1999-03-23 16:22:43 peter Revision 1.49 1999-03-25 16:55:30 peter
+ unitpath,librarypath,includepath,objectpath directives
Revision 1.48 1999/03/23 16:22:43 peter
* crtbegin/crtend only added if found * crtbegin/crtend only added if found
Revision 1.47 1999/02/05 16:45:47 michael Revision 1.47 1999/02/05 16:45:47 michael

View File

@ -17,7 +17,7 @@ Changes in the syntax or semantic of FPC:
anymore (solved several bugs) but this could lead to errors anymore (solved several bugs) but this could lead to errors
on previously accepted code (PM) on previously accepted code (PM)
01/02/99: c styled comments are supported (/* ... */), mainly 01/02/99: c styled comments are supported (/* ... */), mainly
for the Sibyl sources of Medigo (FK) for the Sibyl sources of Medigo (FK)
02/02/99: class destructors take now two parameters: flag 02/02/99: class destructors take now two parameters: flag
if the helper routine should free the instance and if the helper routine should free the instance and
self pointer (FK) self pointer (FK)
@ -27,4 +27,6 @@ Changes in the syntax or semantic of FPC:
into a 4 bytes parameter (needed for C and DLL calls) (PM) into a 4 bytes parameter (needed for C and DLL calls) (PM)
11/03/99 the makefile.fpc is now also needed for the compiler and RTL, you can 11/03/99 the makefile.fpc is now also needed for the compiler and RTL, you can
find it in the base.zip package (PFV) find it in the base.zip package (PFV)
24/03/99 new directives UNITPATH,INCLUDEPATH,OBJECTPATH,LIBRARYPATH to
set the searchpaths where to find the files for that module (PFV)

View File

@ -33,16 +33,18 @@ type
_DIR_FATAL, _DIR_FATAL,
_DIR_HINT,_DIR_HINTS, _DIR_HINT,_DIR_HINTS,
_DIR_I,_DIR_I386_ATT,_DIR_I386_DIRECT,_DIR_I386_INTEL,_DIR_IOCHECKS, _DIR_I,_DIR_I386_ATT,_DIR_I386_DIRECT,_DIR_I386_INTEL,_DIR_IOCHECKS,
_DIR_IF,_DIR_IFDEF,_DIR_IFNDEF,_DIR_IFOPT,_DIR_INCLUDE,_DIR_INFO, _DIR_IF,_DIR_IFDEF,_DIR_IFNDEF,_DIR_IFOPT,_DIR_INCLUDE,_DIR_INCLUDEPATH,
_DIR_L,_DIR_LINK,_DIR_LINKLIB,_DIR_LOCALSYMBOLS,_DIR_LONGSTRINGS, _DIR_INFO,
_DIR_L,_DIR_LIBRARYPATH,_DIR_LINK,_DIR_LINKLIB,_DIR_LOCALSYMBOLS,
_DIR_LONGSTRINGS,
_DIR_M,_DIR_MEMORY,_DIR_MESSAGE,_DIR_MINENUMSIZE,_DIR_MMX,_DIR_MODE, _DIR_M,_DIR_MEMORY,_DIR_MESSAGE,_DIR_MINENUMSIZE,_DIR_MMX,_DIR_MODE,
_DIR_NOTE,_DIR_NOTES, _DIR_NOTE,_DIR_NOTES,
_DIR_OPENSTRINGS,_DIR_OUTPUT_FORMAT,_DIR_OVERFLOWCHECKS, _DIR_OBJECTPATH,_DIR_OPENSTRINGS,_DIR_OUTPUT_FORMAT,_DIR_OVERFLOWCHECKS,
_DIR_PACKENUM,_DIR_PACKRECORDS, _DIR_PACKENUM,_DIR_PACKRECORDS,
_DIR_R,_DIR_RANGECHECKS,_DIR_REFERENCEINFO, _DIR_R,_DIR_RANGECHECKS,_DIR_REFERENCEINFO,
_DIR_SATURATION,_DIR_SMARTLINK,_DIR_STACKFRAMES,_DIR_STOP, _DIR_SATURATION,_DIR_SMARTLINK,_DIR_STACKFRAMES,_DIR_STOP,
_DIR_TYPEDADDRESS,_DIR_TYPEINFO, _DIR_TYPEDADDRESS,_DIR_TYPEINFO,
_DIR_UNDEF, _DIR_UNDEF,_DIR_UNITPATH,
_DIR_VARSTRINGCHECKS, _DIR_VARSTRINGCHECKS,
_DIR_WAIT,_DIR_WARNING,_DIR_WARNINGS, _DIR_WAIT,_DIR_WARNING,_DIR_WARNINGS,
_DIR_Z1,_DIR_Z2,_DIR_Z4 _DIR_Z1,_DIR_Z2,_DIR_Z4
@ -59,16 +61,18 @@ const
'FATAL', 'FATAL',
'HINT','HINTS', 'HINT','HINTS',
'I','I386_ATT','I386_DIRECT','I386_INTEL','IOCHECKS', 'I','I386_ATT','I386_DIRECT','I386_INTEL','IOCHECKS',
'IF','IFDEF','IFNDEF','IFOPT','INCLUDE','INFO', 'IF','IFDEF','IFNDEF','IFOPT','INCLUDE','INCLUDEPATH',
'L','LINK','LINKLIB','LOCALSYMBOLS','LONGSTRINGS', 'INFO',
'L','LIBRARYPATH','LINK','LINKLIB','LOCALSYMBOLS',
'LONGSTRINGS',
'M','MEMORY','MESSAGE','MINENUMSIZE','MMX','MODE', 'M','MEMORY','MESSAGE','MINENUMSIZE','MMX','MODE',
'NOTE','NOTES', 'NOTE','NOTES',
'OPENSTRINGS','OUTPUT_FORMAT','OVERFLOWCHECKS', 'OBJECTPATH','OPENSTRINGS','OUTPUT_FORMAT','OVERFLOWCHECKS',
'PACKENUM','PACKRECORDS', 'PACKENUM','PACKRECORDS',
'R','RANGECHECKS','REFERENCEINFO', 'R','RANGECHECKS','REFERENCEINFO',
'SATURATION','SMARTLINK','STACKFRAMES','STOP', 'SATURATION','SMARTLINK','STACKFRAMES','STOP',
'TYPEDADDRESS','TYPEINFO', 'TYPEDADDRESS','TYPEINFO',
'UNDEF', 'UNDEF','UNITPATH',
'VARSTRINGCHECKS', 'VARSTRINGCHECKS',
'WAIT','WARNING','WARNINGS', 'WAIT','WARNING','WARNINGS',
'Z1','Z2','Z4' 'Z1','Z2','Z4'
@ -570,8 +574,16 @@ const
begin begin
hs:=FixFileName(hs); hs:=FixFileName(hs);
fsplit(hs,path,name,ext); fsplit(hs,path,name,ext);
{ first look in the path of _d then currentmodule } { look for the include file
path:=search(name+ext,path+';'+current_scanner^.inputfile^.path^+';'+includesearchpath,found); 1. specified path,path of current inputfile,current dir
2. local includepath
3. global includepath }
found:=false;
path:=search(name+ext,path+';'+current_scanner^.inputfile^.path^+';.',found);
if (not found) and assigned(current_module^.localincludesearchpath) then
path:=search(name+ext,current_module^.localincludesearchpath^,found);
if (not found) then
path:=search(name+ext,includesearchpath,found);
{ shutdown current file } { shutdown current file }
current_scanner^.tempcloseinputfile; current_scanner^.tempcloseinputfile;
{ load new file } { load new file }
@ -638,6 +650,62 @@ const
end; end;
procedure dir_unitpath(t:tdirectivetoken);
begin
if not current_module^.in_global then
Message(scan_w_switch_is_global)
else
begin
current_scanner^.skipspace;
if assigned(current_module^.localunitsearchpath) then
stringdispose(current_module^.localunitsearchpath);
current_module^.localunitsearchpath:=stringdup(current_scanner^.readcomment);
end;
end;
procedure dir_includepath(t:tdirectivetoken);
begin
if not current_module^.in_global then
Message(scan_w_switch_is_global)
else
begin
current_scanner^.skipspace;
if assigned(current_module^.localincludesearchpath) then
stringdispose(current_module^.localincludesearchpath);
current_module^.localincludesearchpath:=stringdup(current_scanner^.readcomment);
end;
end;
procedure dir_librarypath(t:tdirectivetoken);
begin
if not current_module^.in_global then
Message(scan_w_switch_is_global)
else
begin
current_scanner^.skipspace;
if assigned(current_module^.locallibrarysearchpath) then
stringdispose(current_module^.locallibrarysearchpath);
current_module^.locallibrarysearchpath:=stringdup(current_scanner^.readcomment);
end;
end;
procedure dir_objectpath(t:tdirectivetoken);
begin
if not current_module^.in_global then
Message(scan_w_switch_is_global)
else
begin
current_scanner^.skipspace;
if assigned(current_module^.localobjectsearchpath) then
stringdispose(current_module^.localobjectsearchpath);
current_module^.localobjectsearchpath:=stringdup(current_scanner^.readcomment);
end;
end;
procedure dir_mode(t:tdirectivetoken); procedure dir_mode(t:tdirectivetoken);
begin begin
if not current_module^.in_global then if not current_module^.in_global then
@ -901,8 +969,10 @@ const
{_DIR_IFNDEF} dir_conditional, {_DIR_IFNDEF} dir_conditional,
{_DIR_IFOPT} dir_conditional, {_DIR_IFOPT} dir_conditional,
{_DIR_INCLUDE} dir_include, {_DIR_INCLUDE} dir_include,
{_DIR_INCLUDEPATH} dir_includepath,
{_DIR_INFO} dir_message, {_DIR_INFO} dir_message,
{_DIR_L} dir_linkobject, {_DIR_L} dir_linkobject,
{_DIR_LIBRARYPATH} dir_librarypath,
{_DIR_LINK} dir_linkobject, {_DIR_LINK} dir_linkobject,
{_DIR_LINKLIB} dir_linklib, {_DIR_LINKLIB} dir_linklib,
{_DIR_LOCALSYMBOLS} dir_delphiswitch, {_DIR_LOCALSYMBOLS} dir_delphiswitch,
@ -915,6 +985,7 @@ const
{_DIR_MODE} dir_mode, {_DIR_MODE} dir_mode,
{_DIR_NOTE} dir_message, {_DIR_NOTE} dir_message,
{_DIR_NOTES} dir_setverbose, {_DIR_NOTES} dir_setverbose,
{_DIR_OBJECTPATH} dir_objectpath,
{_DIR_OPENSTRINGS} dir_delphiswitch, {_DIR_OPENSTRINGS} dir_delphiswitch,
{_DIR_OUTPUT_FORMAT} dir_outputformat, {_DIR_OUTPUT_FORMAT} dir_outputformat,
{_DIR_OVERFLOWCHECKS} dir_delphiswitch, {_DIR_OVERFLOWCHECKS} dir_delphiswitch,
@ -930,6 +1001,7 @@ const
{_DIR_TYPEDADDRESS} dir_delphiswitch, {_DIR_TYPEDADDRESS} dir_delphiswitch,
{_DIR_TYPEINFO} dir_delphiswitch, {_DIR_TYPEINFO} dir_delphiswitch,
{_DIR_UNDEF} dir_undef, {_DIR_UNDEF} dir_undef,
{_DIR_UNITPATH} dir_unitpath,
{_DIR_VARSTRINGCHECKS} dir_delphiswitch, {_DIR_VARSTRINGCHECKS} dir_delphiswitch,
{_DIR_WAIT} dir_wait, {_DIR_WAIT} dir_wait,
{_DIR_WARNING} dir_message, {_DIR_WARNING} dir_message,
@ -1005,7 +1077,10 @@ const
{ {
$Log$ $Log$
Revision 1.47 1999-02-22 13:07:05 pierre Revision 1.48 1999-03-25 16:55:34 peter
+ unitpath,librarypath,includepath,objectpath directives
Revision 1.47 1999/02/22 13:07:05 pierre
+ -b and -bl options work ! + -b and -bl options work !
+ cs_local_browser ($L+) is disabled if cs_browser ($Y+) + cs_local_browser ($L+) is disabled if cs_browser ($Y+)
is not enabled when quitting global section is not enabled when quitting global section