mirror of
https://github.com/gcc-mirror/gcc.git
synced 2024-11-21 13:40:47 +00:00
Introduce new module to create search paths of dynamic strings.
Introduce a simple DynamicStringPath module to allow the front end to create and modify a search path from dynamic strings. gcc/m2/ChangeLog: * Make-lang.in (GM2-COMP-BOOT-DEFS): Add DynamicStringPath.def. (GM2-COMP-BOOT-MODS): Add DynamicStringPath.mod. (GM2-COMP-DEFS): Add DynamicStringPath.def. (GM2-COMP-MODS): Add DynamicStringPath.mod. ($(objdir)/m2/gm2-libs-min/SYSTEM.def): Split path into multiple -I components. ($(objdir)/m2/gm2-libs/SYSTEM.def): Ditto. ($(objdir)/m2/gm2-libs-coroutines/SYSTEM.def): Ditto. * gm2-compiler/M2Options.mod: Import DynamicStringPath. (SetSearchPath): Reimplement using DynamicStringPath procedures. * gm2-compiler/M2Search.def (InitSearchPath): Remove. (PrependSearchPath): Remove. * gm2-compiler/M2Search.mod (SFIO): Remove import. (DynamicStringPath): Add import. (Directory): Remove. (UserPath): Remove. (InitialPath): Remove. (InitSearchPath): Remove. (PrependSearchPath): Remove. (FindSourceFile): Re-implement. (FindSourceDefFile): Re-implement. (FindSourceModFile): Re-implement. * gm2-gcc/init.cc (_M2_DynamicStringPath_init): New prototype. (init_FrontEndInit): Call _M2_DynamicStringPath_init. * tools-src/makeSystem: Allow multiple -I paths. * gm2-compiler/DynamicStringPath.def: New file. * gm2-compiler/DynamicStringPath.mod: New file. * gm2-gcc/m2options.h (M2Options_SetMakeIncludePath): Add prototype. Co-Authored by: Iain Sandoe <iain@sandoe.co.uk> libgm2/ChangeLog: * libm2cor/Makefile.am (SYSTEM.def): Split path into multiple -I components. * libm2cor/Makefile.in: Rebuild. * libm2min/Makefile.am (SYSTEM.def): Split path into multiple -I components. * libm2min/Makefile.in: Rebuild. * libm2iso/Makefile.am (SYSTEM.def): Split path into multiple -I components. * libm2iso/Makefile.in: Rebuild. Co-Authored by: Iain Sandoe <iain@sandoe.co.uk> Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
This commit is contained in:
parent
327d45c57e
commit
f235d69572
@ -690,6 +690,7 @@ GM2-COMP-BOOT-DEFS = \
|
||||
M2DebugStack.def \
|
||||
M2Defaults.def \
|
||||
M2DriverOptions.def \
|
||||
DynamicStringPath.def \
|
||||
M2Emit.def \
|
||||
M2Error.def \
|
||||
M2EvalSym.def \
|
||||
@ -761,6 +762,7 @@ GM2-COMP-BOOT-MODS = \
|
||||
M2DebugStack.mod \
|
||||
M2Defaults.mod \
|
||||
M2DriverOptions.mod \
|
||||
DynamicStringPath.mod \
|
||||
M2Emit.mod \
|
||||
M2Error.mod \
|
||||
M2FileName.mod \
|
||||
@ -965,6 +967,7 @@ GM2-COMP-DEFS = \
|
||||
M2DebugStack.def \
|
||||
M2Defaults.def \
|
||||
M2DriverOptions.def \
|
||||
DynamicStringPath.def \
|
||||
M2Emit.def \
|
||||
M2Error.def \
|
||||
M2FileName.def \
|
||||
@ -1032,6 +1035,7 @@ GM2-COMP-MODS = \
|
||||
M2DebugStack.mod \
|
||||
M2Defaults.mod \
|
||||
M2DriverOptions.mod \
|
||||
DynamicStringPath.mod \
|
||||
M2Emit.mod \
|
||||
M2Error.mod \
|
||||
M2FileName.mod \
|
||||
@ -1522,7 +1526,7 @@ $(objdir)/m2/gm2-libs-min/SYSTEM.def: $(GM2_PROG_DEP)
|
||||
$(SHELL) $(srcdir)/m2/tools-src/makeSystem -fpim \
|
||||
$(srcdir)/m2/gm2-libs-min/SYSTEM.def \
|
||||
$(srcdir)/m2/gm2-libs-min/SYSTEM.mod \
|
||||
-I$(srcdir)/m2/gm2-libs-min:$(srcdir)/m2/gm2-libs \
|
||||
-I$(srcdir)/m2/gm2-libs-min -I$(srcdir)/m2/gm2-libs \
|
||||
"$(GM2_FOR_TARGET)" $@
|
||||
|
||||
$(objdir)/m2/gm2-libs/SYSTEM.def: $(GM2_PROG_DEP)
|
||||
@ -1540,7 +1544,7 @@ $(objdir)/m2/gm2-libs-iso/SYSTEM.def: $(GM2_PROG_DEP)
|
||||
$(SHELL) $(srcdir)/m2/tools-src/makeSystem -fiso \
|
||||
$(srcdir)/m2/gm2-libs-iso/SYSTEM.def \
|
||||
$(srcdir)/m2/gm2-libs-iso/SYSTEM.mod \
|
||||
-I$(srcdir)/m2/gm2-libs-iso:$(srcdir)/m2/gm2-libs \
|
||||
-I$(srcdir)/m2/gm2-libs-iso -I$(srcdir)/m2/gm2-libs \
|
||||
"$(GM2_FOR_TARGET)" $@
|
||||
|
||||
$(objdir)/m2/gm2-libs-coroutines/SYSTEM.def: $(GM2_PROG_DEP)
|
||||
@ -1548,7 +1552,7 @@ $(objdir)/m2/gm2-libs-coroutines/SYSTEM.def: $(GM2_PROG_DEP)
|
||||
$(SHELL) $(srcdir)/m2/tools-src/makeSystem -fpim \
|
||||
$(srcdir)/m2/gm2-libs-coroutines/SYSTEM.def \
|
||||
$(srcdir)/m2/gm2-libs-coroutines/SYSTEM.mod \
|
||||
-I$(srcdir)/m2/gm2-libs-coroutines:$(srcdir)/m2/gm2-libs-iso:$(srcdir)/m2/gm2-libs \
|
||||
-I$(srcdir)/m2/gm2-libs-coroutines -I$(srcdir)/m2/gm2-libs-iso -I$(srcdir)/m2/gm2-libs \
|
||||
"$(GM2_FOR_TARGET)" $@
|
||||
|
||||
build-compiler: $(GM2-COMP-MODS:%.mod=m2/gm2-compiler/%.o) \
|
||||
|
113
gcc/m2/gm2-compiler/DynamicStringPath.def
Normal file
113
gcc/m2/gm2-compiler/DynamicStringPath.def
Normal file
@ -0,0 +1,113 @@
|
||||
(* DynamicStringPath.def implements a path for DynamicStrings.
|
||||
|
||||
Copyright (C) 2001-2023 Free Software Foundation, Inc.
|
||||
Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
|
||||
|
||||
This file is part of GNU Modula-2.
|
||||
|
||||
GNU Modula-2 is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Modula-2 is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
Under Section 7 of GPL version 3, you are granted additional
|
||||
permissions described in the GCC Runtime Library Exception, version
|
||||
3.1, as published by the Free Software Foundation.
|
||||
|
||||
You should have received a copy of the GNU General Public License and
|
||||
a copy of the GCC Runtime Library Exception along with this program;
|
||||
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
<http://www.gnu.org/licenses/>. *)
|
||||
|
||||
DEFINITION MODULE DynamicStringPath ; (*!m2iso+gm2*)
|
||||
|
||||
FROM DynamicStrings IMPORT String ;
|
||||
|
||||
TYPE
|
||||
PathList ;
|
||||
|
||||
|
||||
(*
|
||||
GetUserPath - returns the current UserPath.
|
||||
*)
|
||||
|
||||
PROCEDURE GetUserPath () : PathList ;
|
||||
|
||||
|
||||
(*
|
||||
GetSystemPath - returns the current SystemPath.
|
||||
*)
|
||||
|
||||
PROCEDURE GetSystemPath () : PathList ;
|
||||
|
||||
|
||||
(*
|
||||
SetUserPath - assigns UserPath to pl.
|
||||
*)
|
||||
|
||||
PROCEDURE SetUserPath (pl: PathList) ;
|
||||
|
||||
|
||||
(*
|
||||
SetSystemPath - assigns SystemPath to pl.
|
||||
*)
|
||||
|
||||
PROCEDURE SetSystemPath (pl: PathList) ;
|
||||
|
||||
|
||||
(*
|
||||
InitPathList - creates a new empty path list.
|
||||
*)
|
||||
|
||||
PROCEDURE InitPathList (str: String) : PathList ;
|
||||
|
||||
|
||||
(*
|
||||
KillPathList - places list pl onto the freelist.
|
||||
Postcondition: pl will be NIL.
|
||||
*)
|
||||
|
||||
PROCEDURE KillPathList (VAR pl: PathList) ;
|
||||
|
||||
|
||||
(*
|
||||
Cons - appends str to the end of a path list.
|
||||
If pl is NIL a new list is created and returned
|
||||
containing str.
|
||||
*)
|
||||
|
||||
PROCEDURE Cons (pl: PathList; str: String) : PathList ;
|
||||
|
||||
|
||||
(*
|
||||
ConsList - concatenates path list left and right together.
|
||||
It always returns NIL which should be assigned
|
||||
to the callers right parameter after ConsList
|
||||
has been completed signifying that right should
|
||||
no longer be accessed.
|
||||
*)
|
||||
|
||||
PROCEDURE ConsList (left, right: PathList) : PathList ;
|
||||
|
||||
|
||||
(*
|
||||
Stash - returns pl before setting pl to NIL.
|
||||
*)
|
||||
|
||||
PROCEDURE Stash (VAR pl: PathList) : PathList ;
|
||||
|
||||
|
||||
(*
|
||||
FindFileName - returns NIL if a file cannot be found otherwise
|
||||
it returns the path including the filename.
|
||||
*)
|
||||
|
||||
PROCEDURE FindFileName (filename: String; pl: PathList) : String ;
|
||||
|
||||
|
||||
END DynamicStringPath.
|
265
gcc/m2/gm2-compiler/DynamicStringPath.mod
Normal file
265
gcc/m2/gm2-compiler/DynamicStringPath.mod
Normal file
@ -0,0 +1,265 @@
|
||||
(* DynamicStringPath.def implements a path for DynamicStrings.
|
||||
|
||||
Copyright (C) 2001-2023 Free Software Foundation, Inc.
|
||||
Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
|
||||
|
||||
This file is part of GNU Modula-2.
|
||||
|
||||
GNU Modula-2 is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Modula-2 is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
Under Section 7 of GPL version 3, you are granted additional
|
||||
permissions described in the GCC Runtime Library Exception, version
|
||||
3.1, as published by the Free Software Foundation.
|
||||
|
||||
You should have received a copy of the GNU General Public License and
|
||||
a copy of the GCC Runtime Library Exception along with this program;
|
||||
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
<http://www.gnu.org/licenses/>. *)
|
||||
|
||||
IMPLEMENTATION MODULE DynamicStringPath ; (*!m2iso+gm2*)
|
||||
|
||||
FROM Storage IMPORT ALLOCATE, DEALLOCATE ;
|
||||
FROM DynamicStrings IMPORT InitString, ConCat, ConCatChar, char, Dup,
|
||||
KillString, Length ;
|
||||
FROM SFIO IMPORT Exists ;
|
||||
FROM FIO IMPORT StdErr ;
|
||||
FROM M2Printf IMPORT fprintf0, fprintf1 ;
|
||||
|
||||
CONST
|
||||
Directory = '/' ;
|
||||
Debugging = FALSE ;
|
||||
|
||||
TYPE
|
||||
PathList = POINTER TO RECORD
|
||||
tail,
|
||||
next : PathList ;
|
||||
entry: String ;
|
||||
END ;
|
||||
|
||||
|
||||
VAR
|
||||
FreeList,
|
||||
DefaultUserPath,
|
||||
DefaultSystemPath: PathList ;
|
||||
|
||||
|
||||
(*
|
||||
GetUserPath - returns the current UserPath.
|
||||
*)
|
||||
|
||||
PROCEDURE GetUserPath () : PathList ;
|
||||
BEGIN
|
||||
RETURN DefaultUserPath
|
||||
END GetUserPath ;
|
||||
|
||||
|
||||
(*
|
||||
GetSystemPath - returns the current SystemPath.
|
||||
*)
|
||||
|
||||
PROCEDURE GetSystemPath () : PathList ;
|
||||
BEGIN
|
||||
RETURN DefaultSystemPath
|
||||
END GetSystemPath ;
|
||||
|
||||
|
||||
(*
|
||||
SetUserPath - assigns UserPath to pl.
|
||||
*)
|
||||
|
||||
PROCEDURE SetUserPath (pl: PathList) ;
|
||||
BEGIN
|
||||
DefaultUserPath := pl ;
|
||||
DumpPath ('DefaultUserPath', DefaultUserPath)
|
||||
END SetUserPath ;
|
||||
|
||||
|
||||
(*
|
||||
SetSystemPath - assigns SystemPath to pl.
|
||||
*)
|
||||
|
||||
PROCEDURE SetSystemPath (pl: PathList) ;
|
||||
BEGIN
|
||||
DefaultSystemPath := pl ;
|
||||
DumpPath ('DefaultSystemPath', DefaultSystemPath)
|
||||
END SetSystemPath ;
|
||||
|
||||
|
||||
(*
|
||||
KillPathList - places list pl onto the freelist.
|
||||
Postcondition: pl will be NIL.
|
||||
*)
|
||||
|
||||
PROCEDURE KillPathList (VAR pl: PathList) ;
|
||||
BEGIN
|
||||
IF pl # NIL
|
||||
THEN
|
||||
pl^.tail^.next := FreeList ;
|
||||
FreeList := pl ;
|
||||
pl := NIL
|
||||
END
|
||||
END KillPathList ;
|
||||
|
||||
|
||||
(*
|
||||
InitPathList - creates a new empty path list.
|
||||
It takes a copy of the string.
|
||||
*)
|
||||
|
||||
PROCEDURE InitPathList (str: String) : PathList ;
|
||||
VAR
|
||||
pl: PathList ;
|
||||
BEGIN
|
||||
NEW (pl) ;
|
||||
WITH pl^ DO
|
||||
tail := pl ;
|
||||
next := NIL ;
|
||||
entry := Dup (str)
|
||||
END ;
|
||||
RETURN pl
|
||||
END InitPathList ;
|
||||
|
||||
|
||||
(*
|
||||
Cons - appends str to the end of a path list.
|
||||
If pl is NIL a new list is created and returned
|
||||
containing str.
|
||||
*)
|
||||
|
||||
PROCEDURE Cons (pl: PathList; str: String) : PathList ;
|
||||
BEGIN
|
||||
IF pl = NIL
|
||||
THEN
|
||||
pl := InitPathList (str)
|
||||
ELSE
|
||||
pl := ConsList (pl, InitPathList (str))
|
||||
END ;
|
||||
RETURN pl
|
||||
END Cons ;
|
||||
|
||||
|
||||
(*
|
||||
ConsList - concatenates path list left and right together.
|
||||
It always returns NIL which should be assigned
|
||||
to the callers right parameter after ConsList
|
||||
has been completed signifying that right should
|
||||
no longer be accessed.
|
||||
*)
|
||||
|
||||
PROCEDURE ConsList (left, right: PathList) : PathList ;
|
||||
BEGIN
|
||||
IF right # NIL
|
||||
THEN
|
||||
left^.tail^.next := right ;
|
||||
left^.tail := right^.tail
|
||||
END ;
|
||||
RETURN left
|
||||
END ConsList ;
|
||||
|
||||
|
||||
(*
|
||||
Stash - returns pl before setting pl to NIL.
|
||||
*)
|
||||
|
||||
PROCEDURE Stash (VAR pl: PathList) : PathList ;
|
||||
VAR
|
||||
old: PathList ;
|
||||
BEGIN
|
||||
old := pl ;
|
||||
pl := NIL ;
|
||||
RETURN old
|
||||
END Stash ;
|
||||
|
||||
|
||||
(*
|
||||
AddDir - if str is not empty and does not end with / then add
|
||||
a directory.
|
||||
Postcondition: str is returned (with a '/' at the end)
|
||||
or is empty.
|
||||
*)
|
||||
|
||||
PROCEDURE AddDir (str: String) : String ;
|
||||
BEGIN
|
||||
IF Length (str) > 0
|
||||
THEN
|
||||
IF char (str, -1) # Directory
|
||||
THEN
|
||||
str := ConCatChar (str, Directory)
|
||||
END
|
||||
END ;
|
||||
RETURN str
|
||||
END AddDir ;
|
||||
|
||||
|
||||
(*
|
||||
FindFileName - returns NIL if a file cannot be found otherwise
|
||||
it returns the path including the filename.
|
||||
*)
|
||||
|
||||
PROCEDURE FindFileName (filename: String; pl: PathList) : String ;
|
||||
VAR
|
||||
s: String ;
|
||||
BEGIN
|
||||
WHILE pl # NIL DO
|
||||
s := ConCat (AddDir (Dup (pl^.entry)), Dup (filename)) ;
|
||||
IF Debugging
|
||||
THEN
|
||||
fprintf1 (StdErr, "testing for %s: ", s)
|
||||
END ;
|
||||
IF Exists (s)
|
||||
THEN
|
||||
IF Debugging
|
||||
THEN
|
||||
fprintf0 (StdErr, "yes\n")
|
||||
END ;
|
||||
RETURN s
|
||||
END ;
|
||||
IF Debugging
|
||||
THEN
|
||||
fprintf0 (StdErr, "no\n")
|
||||
END ;
|
||||
s := KillString (s) ;
|
||||
pl := pl^.next
|
||||
END ;
|
||||
IF Debugging
|
||||
THEN
|
||||
fprintf1 (StdErr, "FindFileName did not find: %s in path\n", filename)
|
||||
END ;
|
||||
RETURN NIL
|
||||
END FindFileName ;
|
||||
|
||||
|
||||
(*
|
||||
DumpPath - debugging dump of the pathlist.
|
||||
*)
|
||||
|
||||
PROCEDURE DumpPath (name: ARRAY OF CHAR; pl: PathList) ;
|
||||
BEGIN
|
||||
IF Debugging
|
||||
THEN
|
||||
fprintf0 (StdErr, name) ;
|
||||
fprintf0 (StdErr, ":") ;
|
||||
WHILE pl # NIL DO
|
||||
fprintf0 (StdErr, " {") ;
|
||||
fprintf1 (StdErr, "%s", pl^.entry) ;
|
||||
fprintf0 (StdErr, "}") ;
|
||||
pl := pl^.next
|
||||
END ;
|
||||
fprintf0 (StdErr, "\n")
|
||||
END
|
||||
END DumpPath ;
|
||||
|
||||
|
||||
BEGIN
|
||||
DefaultSystemPath := NIL ;
|
||||
DefaultUserPath := NIL ;
|
||||
FreeList := NIL
|
||||
END DynamicStringPath.
|
@ -24,8 +24,10 @@ IMPLEMENTATION MODULE M2Options ;
|
||||
|
||||
IMPORT CmdArgs ;
|
||||
FROM SArgs IMPORT GetArg, Narg ;
|
||||
FROM M2Search IMPORT PrependSearchPath, SetDefExtension, SetModExtension ;
|
||||
FROM M2Printf IMPORT printf0, printf1 ;
|
||||
FROM M2Search IMPORT SetDefExtension, SetModExtension ;
|
||||
FROM DynamicStringPath IMPORT Cons, GetUserPath, SetUserPath, Cons ;
|
||||
FROM M2Printf IMPORT printf0, printf1, fprintf1 ;
|
||||
FROM FIO IMPORT StdErr ;
|
||||
FROM libc IMPORT exit ;
|
||||
FROM Debug IMPORT Halt ;
|
||||
FROM m2linemap IMPORT location_t ;
|
||||
@ -789,10 +791,10 @@ BEGIN
|
||||
s := InitStringCharStar(arg) ;
|
||||
IF Debugging
|
||||
THEN
|
||||
printf1("setting search path to: %s\n", s)
|
||||
fprintf1 (StdErr, "M2Search.SetSearchPath setting search path to: %s\n", s)
|
||||
END ;
|
||||
PrependSearchPath(s) ;
|
||||
s := KillString(s)
|
||||
SetUserPath (Cons (GetUserPath (), s)) ;
|
||||
s := KillString (s)
|
||||
END SetSearchPath ;
|
||||
|
||||
|
||||
|
@ -31,31 +31,6 @@ DEFINITION MODULE M2Search ;
|
||||
*)
|
||||
|
||||
FROM DynamicStrings IMPORT String ;
|
||||
EXPORT QUALIFIED InitSearchPath, PrependSearchPath, FindSourceFile,
|
||||
FindSourceDefFile, FindSourceModFile,
|
||||
SetDefExtension, SetModExtension ;
|
||||
|
||||
|
||||
(*
|
||||
InitSearchPath - assigns the search path to Path.
|
||||
The string Path may take the form:
|
||||
|
||||
Path ::= IndividualPath { ":" IndividualPath }
|
||||
IndividualPath ::= "." | DirectoryPath
|
||||
DirectoryPath ::= [ "/" ] Name { "/" Name }
|
||||
Name ::= Letter { (Letter | Number) }
|
||||
Letter ::= A..Z | a..z
|
||||
Number ::= 0..9
|
||||
*)
|
||||
|
||||
PROCEDURE InitSearchPath (Path: String) ;
|
||||
|
||||
|
||||
(*
|
||||
PrependSearchPath - prepends a new path to the initial search path.
|
||||
*)
|
||||
|
||||
PROCEDURE PrependSearchPath (path: String) ;
|
||||
|
||||
|
||||
(*
|
||||
|
@ -22,9 +22,9 @@ along with GNU Modula-2; see the file COPYING3. If not see
|
||||
IMPLEMENTATION MODULE M2Search ;
|
||||
|
||||
|
||||
FROM SFIO IMPORT Exists ;
|
||||
FROM M2FileName IMPORT CalculateFileName ;
|
||||
FROM Assertion IMPORT Assert ;
|
||||
FROM DynamicStringPath IMPORT GetUserPath, GetSystemPath, FindFileName ;
|
||||
|
||||
FROM DynamicStrings IMPORT InitString, InitStringChar,
|
||||
KillString, ConCat, ConCatChar, Index, Slice,
|
||||
@ -35,13 +35,10 @@ FROM DynamicStrings IMPORT InitString, InitStringChar,
|
||||
|
||||
|
||||
CONST
|
||||
Directory = '/' ;
|
||||
GarbageDebugging = FALSE ;
|
||||
|
||||
VAR
|
||||
Def, Mod,
|
||||
UserPath,
|
||||
InitialPath: String ;
|
||||
Def, Mod: String ;
|
||||
|
||||
(* Internal garbage collection debugging routines. *)
|
||||
|
||||
@ -109,24 +106,6 @@ END DSdbExit ;
|
||||
*)
|
||||
|
||||
|
||||
(*
|
||||
PrependSearchPath - prepends a new path to the initial search path.
|
||||
*)
|
||||
|
||||
PROCEDURE PrependSearchPath (path: String) ;
|
||||
BEGIN
|
||||
DSdbEnter ;
|
||||
IF EqualArray(UserPath, '')
|
||||
THEN
|
||||
UserPath := KillString(UserPath) ;
|
||||
UserPath := Dup(path)
|
||||
ELSE
|
||||
UserPath := ConCat(ConCatChar(UserPath, ':'), path)
|
||||
END ;
|
||||
DSdbExit (UserPath)
|
||||
END PrependSearchPath ;
|
||||
|
||||
|
||||
(*
|
||||
FindSourceFile - attempts to locate the source file FileName.
|
||||
If a file is found then TRUE is returned otherwise
|
||||
@ -143,55 +122,13 @@ END PrependSearchPath ;
|
||||
|
||||
PROCEDURE FindSourceFile (FileName: String;
|
||||
VAR FullPath: String) : BOOLEAN ;
|
||||
VAR
|
||||
CompleteSearchPath: String ;
|
||||
start, end : INTEGER ;
|
||||
newpath : String ;
|
||||
BEGIN
|
||||
IF EqualArray(UserPath, '')
|
||||
FullPath := FindFileName (FileName, GetUserPath ()) ;
|
||||
IF FullPath = NIL
|
||||
THEN
|
||||
IF EqualArray(InitialPath, '')
|
||||
THEN
|
||||
CompleteSearchPath := InitString('.')
|
||||
ELSE
|
||||
CompleteSearchPath := Dup(InitialPath)
|
||||
END
|
||||
ELSE
|
||||
CompleteSearchPath := ConCat(ConCatChar(Dup(UserPath), ':'), InitialPath)
|
||||
FullPath := FindFileName (FileName, GetSystemPath ())
|
||||
END ;
|
||||
start := 0 ;
|
||||
end := Index(CompleteSearchPath, ':', CARDINAL(start)) ;
|
||||
REPEAT
|
||||
IF end=-1
|
||||
THEN
|
||||
end := 0
|
||||
END ;
|
||||
newpath := Slice(CompleteSearchPath, start, end) ;
|
||||
IF EqualArray(newpath, '.')
|
||||
THEN
|
||||
newpath := KillString(newpath) ;
|
||||
newpath := Dup(FileName)
|
||||
ELSE
|
||||
newpath := ConCat(ConCatChar(newpath, Directory), FileName)
|
||||
END ;
|
||||
IF Exists(newpath)
|
||||
THEN
|
||||
FullPath := newpath ;
|
||||
CompleteSearchPath := KillString(CompleteSearchPath) ;
|
||||
RETURN( TRUE )
|
||||
END ;
|
||||
newpath := KillString(newpath) ;
|
||||
IF end#0
|
||||
THEN
|
||||
start := end+1 ;
|
||||
end := Index(CompleteSearchPath, ':', CARDINAL(start))
|
||||
END
|
||||
UNTIL end=0 ;
|
||||
|
||||
FullPath := NIL ;
|
||||
newpath := KillString(newpath) ;
|
||||
CompleteSearchPath := KillString(CompleteSearchPath) ;
|
||||
RETURN( FALSE )
|
||||
RETURN FullPath # NIL
|
||||
END FindSourceFile ;
|
||||
|
||||
|
||||
@ -206,18 +143,18 @@ PROCEDURE FindSourceDefFile (Stem: String; VAR FullPath: String) : BOOLEAN ;
|
||||
VAR
|
||||
f: String ;
|
||||
BEGIN
|
||||
IF Def#NIL
|
||||
IF Def # NIL
|
||||
THEN
|
||||
f := CalculateFileName(Stem, Def) ;
|
||||
IF FindSourceFile(f, FullPath)
|
||||
f := CalculateFileName (Stem, Def) ;
|
||||
IF FindSourceFile (f, FullPath)
|
||||
THEN
|
||||
RETURN( TRUE )
|
||||
RETURN TRUE
|
||||
END ;
|
||||
f := KillString(f)
|
||||
f := KillString (f)
|
||||
END ;
|
||||
(* and try the GNU Modula-2 default extension *)
|
||||
f := CalculateFileName(Stem, Mark(InitString('def'))) ;
|
||||
RETURN( FindSourceFile(f, FullPath) )
|
||||
(* Try the GNU Modula-2 default extension. *)
|
||||
f := CalculateFileName (Stem, Mark(InitString ('def'))) ;
|
||||
RETURN FindSourceFile (f, FullPath)
|
||||
END FindSourceDefFile ;
|
||||
|
||||
|
||||
@ -234,16 +171,16 @@ VAR
|
||||
BEGIN
|
||||
IF Mod#NIL
|
||||
THEN
|
||||
f := CalculateFileName(Stem, Mod) ;
|
||||
IF FindSourceFile(f, FullPath)
|
||||
f := CalculateFileName (Stem, Mod) ;
|
||||
IF FindSourceFile (f, FullPath)
|
||||
THEN
|
||||
RETURN( TRUE )
|
||||
RETURN TRUE
|
||||
END ;
|
||||
f := KillString(f)
|
||||
f := KillString (f)
|
||||
END ;
|
||||
(* and try the GNU Modula-2 default extension *)
|
||||
f := CalculateFileName(Stem, Mark(InitString('mod'))) ;
|
||||
RETURN( FindSourceFile(f, FullPath) )
|
||||
(* Try the GNU Modula-2 default extension. *)
|
||||
f := CalculateFileName (Stem, Mark(InitString ('mod'))) ;
|
||||
RETURN FindSourceFile (f, FullPath)
|
||||
END FindSourceModFile ;
|
||||
|
||||
|
||||
@ -274,35 +211,11 @@ END SetModExtension ;
|
||||
|
||||
|
||||
(*
|
||||
InitSearchPath - assigns the search path to Path.
|
||||
The string Path may take the form:
|
||||
|
||||
Path ::= IndividualPath { ":" IndividualPath }
|
||||
IndividualPath ::= "." | DirectoryPath
|
||||
DirectoryPath ::= [ "/" ] Name { "/" Name }
|
||||
Name ::= Letter { (Letter | Number) }
|
||||
Letter ::= A..Z | a..z
|
||||
Number ::= 0..9
|
||||
*)
|
||||
|
||||
PROCEDURE InitSearchPath (Path: String) ;
|
||||
BEGIN
|
||||
IF InitialPath#NIL
|
||||
THEN
|
||||
InitialPath := KillString(InitialPath)
|
||||
END ;
|
||||
InitialPath := Path
|
||||
END InitSearchPath ;
|
||||
|
||||
|
||||
(*
|
||||
Init - initializes the search path.
|
||||
Init - initializes the def and mod default string names to NIL.
|
||||
*)
|
||||
|
||||
PROCEDURE Init ;
|
||||
BEGIN
|
||||
UserPath := InitString('') ;
|
||||
InitialPath := InitStringChar('.') ;
|
||||
Def := NIL ;
|
||||
Mod := NIL
|
||||
END Init ;
|
||||
|
@ -55,6 +55,7 @@ EXTERN void _M2_CmdArgs_init (int argc, char *argv[], char *envp[]);
|
||||
EXTERN void _M2_M2Preprocess_init (int argc, char *argv[], char *envp[]);
|
||||
EXTERN void _M2_M2Error_init (int argc, char *argv[], char *envp[]);
|
||||
EXTERN void _M2_M2Search_init (int argc, char *argv[], char *envp[]);
|
||||
EXTERN void _M2_DynamicStringPath_init (int argc, char *argv[], char *envp[]);
|
||||
EXTERN void _M2_Indexing_init (int argc, char *argv[], char *envp[]);
|
||||
EXTERN void _M2_NameKey_init (int argc, char *argv[], char *envp[]);
|
||||
EXTERN void _M2_NumberIO_init (int argc, char *argv[], char *envp[]);
|
||||
@ -141,6 +142,7 @@ init_FrontEndInit (void)
|
||||
_M2_StrLib_init (0, NULL, NULL);
|
||||
_M2_dtoa_init (0, NULL, NULL);
|
||||
_M2_ldtoa_init (0, NULL, NULL);
|
||||
_M2_DynamicStringPath_init (0, NULL, NULL);
|
||||
_M2_M2Search_init (0, NULL, NULL);
|
||||
_M2_M2Options_init (0, NULL, NULL);
|
||||
}
|
||||
|
@ -38,7 +38,6 @@ along with GNU Modula-2; see the file COPYING3. If not see
|
||||
|
||||
#include "input.h"
|
||||
|
||||
EXTERN void M2Options_SetMakeIncludePath (const char *arg);
|
||||
EXTERN void M2Options_SetSearchPath (const char *arg);
|
||||
EXTERN void M2Options_setdefextension (const char *arg);
|
||||
EXTERN void M2Options_setmodextension (const char *arg);
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
|
||||
Usage () {
|
||||
echo "Usage: makesystem dialectflag SYSTEM.def SYSTEM.mod librarypath compiler"
|
||||
echo "Usage: makesystem dialectflag SYSTEM.def SYSTEM.mod { librarypath } compiler"
|
||||
}
|
||||
|
||||
if [ $# -lt 6 ] ; then
|
||||
@ -34,9 +34,18 @@ fi
|
||||
DIALECT=$1
|
||||
SYSTEMDEF=$2
|
||||
SYSTEMMOD=$3
|
||||
LIBRARY=$4
|
||||
COMPILER=$5
|
||||
OUTPUTFILE=$6
|
||||
shift 3
|
||||
LIBRARY=""
|
||||
while [ $# -gt 2 ] ; do
|
||||
if [ "$LIBRARY" = "" ] ; then
|
||||
LIBRARY=$1
|
||||
else
|
||||
LIBRARY="${LIBRARY} $1"
|
||||
fi
|
||||
shift
|
||||
done
|
||||
COMPILER=$1
|
||||
OUTPUTFILE=$2
|
||||
|
||||
if [ "$COMPILER" = "" ] ; then
|
||||
echo "parameter 5 of makeSystem is incorrect, GM2_FOR_TARGET was unset"
|
||||
|
@ -129,7 +129,7 @@ SYSTEM.def: Makefile
|
||||
bash $(GM2_SRC)/tools-src/makeSystem -fpim \
|
||||
$(GM2_SRC)/gm2-libs-coroutines/SYSTEM.def \
|
||||
$(GM2_SRC)/gm2-libs-coroutines/SYSTEM.mod \
|
||||
-I$(GM2_SRC)/gm2-libs-coroutines:$(GM2_SRC)/gm2-libs:$(GM2_SRC)/gm2-libs-iso \
|
||||
-I$(GM2_SRC)/gm2-libs-coroutines -I$(GM2_SRC)/gm2-libs -I$(GM2_SRC)/gm2-libs-iso \
|
||||
"$(GM2_FOR_TARGET)" $@
|
||||
|
||||
.mod.lo:
|
||||
|
@ -795,7 +795,7 @@ uninstall-am: uninstall-toolexeclibLTLIBRARIES
|
||||
@BUILD_CORLIB_TRUE@ bash $(GM2_SRC)/tools-src/makeSystem -fpim \
|
||||
@BUILD_CORLIB_TRUE@ $(GM2_SRC)/gm2-libs-coroutines/SYSTEM.def \
|
||||
@BUILD_CORLIB_TRUE@ $(GM2_SRC)/gm2-libs-coroutines/SYSTEM.mod \
|
||||
@BUILD_CORLIB_TRUE@ -I$(GM2_SRC)/gm2-libs-coroutines:$(GM2_SRC)/gm2-libs:$(GM2_SRC)/gm2-libs-iso \
|
||||
@BUILD_CORLIB_TRUE@ -I$(GM2_SRC)/gm2-libs-coroutines -I$(GM2_SRC)/gm2-libs -I$(GM2_SRC)/gm2-libs-iso \
|
||||
@BUILD_CORLIB_TRUE@ "$(GM2_FOR_TARGET)" $@
|
||||
|
||||
@BUILD_CORLIB_TRUE@.mod.lo:
|
||||
|
@ -204,7 +204,7 @@ SYSTEM.def: Makefile
|
||||
bash $(GM2_SRC)/tools-src/makeSystem -fiso \
|
||||
$(GM2_SRC)/gm2-libs-iso/SYSTEM.def \
|
||||
$(GM2_SRC)/gm2-libs-iso/SYSTEM.mod \
|
||||
-I$(GM2_SRC)/gm2-libs-iso:$(GM2_SRC)/gm2-libs \
|
||||
-I$(GM2_SRC)/gm2-libs-iso -I$(GM2_SRC)/gm2-libs \
|
||||
"$(GM2_FOR_TARGET)" $@
|
||||
|
||||
## add these to the .mod.o rule when optimization is fixed $(CFLAGS_FOR_TARGET) $(LIBCFLAGS)
|
||||
|
@ -905,7 +905,7 @@ uninstall-am: uninstall-toolexeclibLTLIBRARIES
|
||||
@BUILD_ISOLIB_TRUE@ bash $(GM2_SRC)/tools-src/makeSystem -fiso \
|
||||
@BUILD_ISOLIB_TRUE@ $(GM2_SRC)/gm2-libs-iso/SYSTEM.def \
|
||||
@BUILD_ISOLIB_TRUE@ $(GM2_SRC)/gm2-libs-iso/SYSTEM.mod \
|
||||
@BUILD_ISOLIB_TRUE@ -I$(GM2_SRC)/gm2-libs-iso:$(GM2_SRC)/gm2-libs \
|
||||
@BUILD_ISOLIB_TRUE@ -I$(GM2_SRC)/gm2-libs-iso -I$(GM2_SRC)/gm2-libs \
|
||||
@BUILD_ISOLIB_TRUE@ "$(GM2_FOR_TARGET)" $@
|
||||
|
||||
@BUILD_ISOLIB_TRUE@.mod.lo:
|
||||
|
@ -128,7 +128,7 @@ SYSTEM.def: Makefile
|
||||
bash $(GM2_SRC)/tools-src/makeSystem -fpim \
|
||||
$(GM2_SRC)/gm2-libs-min/SYSTEM.def \
|
||||
$(GM2_SRC)/gm2-libs-min/SYSTEM.mod \
|
||||
-I$(GM2_SRC)/gm2-libs-min:$(GM2_SRC)/gm2-libs \
|
||||
-I$(GM2_SRC)/gm2-libs-min -I$(GM2_SRC)/gm2-libs \
|
||||
"$(GM2_FOR_TARGET) -fno-exceptions" $@
|
||||
|
||||
install-data-local: force
|
||||
|
@ -754,7 +754,7 @@ SYSTEM.def: Makefile
|
||||
bash $(GM2_SRC)/tools-src/makeSystem -fpim \
|
||||
$(GM2_SRC)/gm2-libs-min/SYSTEM.def \
|
||||
$(GM2_SRC)/gm2-libs-min/SYSTEM.mod \
|
||||
-I$(GM2_SRC)/gm2-libs-min:$(GM2_SRC)/gm2-libs \
|
||||
-I$(GM2_SRC)/gm2-libs-min -I$(GM2_SRC)/gm2-libs \
|
||||
"$(GM2_FOR_TARGET) -fno-exceptions" $@
|
||||
|
||||
install-data-local: force
|
||||
|
Loading…
Reference in New Issue
Block a user