codegen now falls back to su4sml_home, when $CODEGEN_HOME is not defined

git-svn-id: https://projects.brucker.ch/su4sml/svn/infsec-import/trunk/src/su4sml@5511 3260e6d1-4efc-4170-b0a7-36055960796d
This commit is contained in:
Jürgen Doser 2006-10-27 14:03:31 +00:00
parent 1b23e52a76
commit 852c559c24
3 changed files with 16 additions and 13 deletions

View File

@ -65,8 +65,8 @@ datatype TemplateTree = RootNode of TemplateTree list
(**
* replaceSafely (s,v,x) replaces every v in s with x or if v is escaped removes "\"
(**
* replaceSafely (s,v,x) replaces every v in s with x or if v is escaped removes "\"
*)
fun replaceSafely ("",_,_) = ""
| replaceSafely (s,v,x) = let val v_size = size v and
@ -179,7 +179,8 @@ fun buildTree (SOME line) = let fun getNode ("text",c) = (TextLeaf(c))::(buil
| buildTree NONE = []
fun codegen_env _ = getOpt(OS.Process.getEnv "CODEGEN_HOME",".")
fun codegen_home _ = getOpt(OS.Process.getEnv "CODEGEN_HOME",
library.su4sml_home()^"src/codegen")
(** calls the external cpp ( C PreProcessor).
* writes merged template to a file with extension .tmp instead of .tpl
@ -188,7 +189,7 @@ fun codegen_env _ = getOpt(OS.Process.getEnv "CODEGEN_HOME",".")
fun call_cpp file =
let (*val targetFile = String.substring (file,0,size file -4) ^".tmp";*)
val targetFile = OS.FileSys.tmpName ()
val _ = OS.Process.system ("cpp "^codegen_env()^"/"^file^" "^targetFile^" -P -C")
val _ = OS.Process.system ("cpp "^codegen_home()^"/"^file^" "^targetFile^" -P -C")
in
targetFile
end

View File

@ -28,6 +28,17 @@ infix |>
fun (x |> f) = f x;
(* HOLOCL_HOME resp. SU4SML_HOME should point to the top-level directory *)
(* of the corresponding library. The semantics of UML2CDL_HOME should *)
(* probably be fixed *)
fun su4sml_home () = case OS.Process.getEnv "HOLOCL_HOME" of
SOME p => p^"/lib/su4sml/src"
| NONE => (case OS.Process.getEnv "SU4SML_HOME" of
SOME p => p^"/src"
| NONE => getOpt(OS.Process.getEnv "UML2CDL_HOME",".")
)
fun filter (pred: 'a->bool) : 'a list -> 'a list =
let fun filt [] = []
| filt (x :: xs) = if pred x then x :: filt xs else filt xs

View File

@ -39,15 +39,6 @@ structure Parser = Parse (structure Dtd = Dtd
fun readFile filename =
let val currentDir = OS.FileSys.getDir()
(* HOLOCL_HOME resp. SU4SML_HOME should point to the top-level directory *)
(* of the corresponding library. The semantics of UML2CDL_HOME should *)
(* probably be fixed *)
fun su4sml_home () = case OS.Process.getEnv "HOLOCL_HOME" of
SOME p => p^"/lib/su4sml/src"
| NONE => (case OS.Process.getEnv "SU4SML_HOME" of
SOME p => p^"/src"
| NONE => getOpt(OS.Process.getEnv "UML2CDL_HOME",".")
)
(* how to do the following in a clean/portable way? *)
fun read_dtd dtd =
let val _ = OS.FileSys.chDir (su4sml_home())