improved handling of SU4SML_HOME and unzip

git-svn-id: https://projects.brucker.ch/su4sml/svn/su4sml/trunk@8374 3260e6d1-4efc-4170-b0a7-36055960796d
This commit is contained in:
Achim D. Brucker 2009-01-04 18:04:16 +00:00
parent 450aa6f33c
commit 15fc0db2eb
8 changed files with 71 additions and 13 deletions

View File

@ -42,21 +42,56 @@
signature CONFIG =
sig
val su4sml_home : unit -> string
val su4sml_share : unit -> string
val umlocl_dtd : string
val unzip : string
val check_umlocl_dtd : unit -> bool
val check_unzip : unit -> bool
val check_argo_import : unit -> bool
val check_xmi_import : unit -> bool
end
structure Config:>CONFIG =
struct
val umlocl_dtd = "UML15OCL.xmi"
val unzip = "unzip"
(* 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"
fun su4sml_share () = case OS.Process.getEnv "HOLOCL_HOME" of
SOME p => p^"/lib/su4sml/share"
| NONE => (case OS.Process.getEnv "SU4SML_HOME" of
SOME p => p^"/src"
SOME p => p^"/share"
| NONE => (case OS.Process.getEnv "UML2CDL_HOME" of
SOME p => p^"../../../src"
SOME p => p^"../../../share"
| NONE => ".")
)
fun su4sml_home () = case OS.Process.getEnv "HOLOCL_HOME" of
SOME p => p^"/lib/su4sml"
| NONE => (case OS.Process.getEnv "SU4SML_HOME" of
SOME p => p
| NONE => (case OS.Process.getEnv "UML2CDL_HOME" of
SOME p => p^"../../.."
| NONE => ".")
)
fun check_umlocl_dtd () = (OS.FileSys.chDir (su4sml_share());OS.FileSys.access (umlocl_dtd,[]))
handle _ => false
fun check_unzip () = let
val tmpFile = OS.FileSys.tmpName ()
val result = (OS.Process.system (unzip^" > "^tmpFile) = OS.Process.success)
val _ = OS.FileSys.remove tmpFile
in
result
end
fun check_argo_import () = (check_umlocl_dtd ()) andalso (check_unzip ())
val check_xmi_import = check_umlocl_dtd
end

View File

@ -86,9 +86,10 @@ fun importArgoUMLUnNormalized file =
val base = if String.isSuffix ".zargo" file
then String.substring(file,0, (String.size file) -6)
else file
val _ = Logger.info ("*** Syscall: unzip -p -ca "^base^".zargo "^(basename base)^".xmi > "^tmpFile)
val _ = OS.Process.system ("unzip -p -ca "^base^".zargo "^(basename base)^".xmi > "^tmpFile)
val _ = Logger.debug1 ("*** Syscall: "^Config.unzip^" -p -ca "^base^".zargo "^(basename base)^".xmi > "^tmpFile)
val _ = OS.Process.system (Config.unzip^" -p -ca "^base^".zargo "^(basename base)^".xmi > "^tmpFile)
val model = readFileUnNormalized tmpFile
handle e => (OS.FileSys.remove tmpFile; raise e)
val _ = OS.FileSys.remove tmpFile

View File

@ -393,7 +393,7 @@ and generate_variables (Literal (paras)) path meth_name model = Literal (paras)
let
val _ = Logger.debug2 ("Preprocessor.generate_variables: AttributeCall\n")
val new_src = generate_variables src path meth_name model
val _ = List.app (print o (fn x => x^"\n") o string_of_path o name_of ) model
val _ = List.app (Logger.debug2 o (fn x => x^"\n") o string_of_path o name_of ) model
val classifier = class_of path (model,[])
val _ = Logger.debug4 "classifier found\n"
val meth = get_operation meth_name classifier (model,[])

View File

@ -730,9 +730,10 @@ fun importArgoUML file =
val base = if String.isSuffix ".zargo" file
then String.substring(file,0, (String.size file) -6)
else file
val _ = print ("*** Syscall: unzip -p -ca "^base^".zargo "^(basename base)^".xmi > "^tmpFile^"\n")
val _ = OS.Process.system ("unzip -p -ca "^base^".zargo "^(basename base)^".xmi > "^tmpFile)
val _ = Logger.debug1 ("*** Syscall: "^Config.unzip^" -p -ca "^base^".zargo "^(basename base)^".xmi > "^tmpFile^"\n")
val _ = OS.Process.system (Config.unzip^" -p -ca "^base^".zargo "^(basename base)^".xmi > "^tmpFile)
val model = readFile tmpFile
handle e => (OS.FileSys.remove tmpFile; raise e)
val _ = OS.FileSys.remove tmpFile
in

View File

@ -62,6 +62,26 @@ fun print_help name = let
val _ = print(" transform-model\n")
val _ = print(" typecheck\n")
val _ = print("\n")
val _ = print("Reading XMI or ArguUML files requires the file '"^Config.umlocl_dtd^"' which\n")
val _ = print("must be either located in the local directory or in '$SU4SML_HOME/share'.\n")
val _ = print("Current status: ")
val _ = print("SU4SML_HOME="^(Config.su4sml_home())^"\n")
val _ = print("\n")
val _ = print("Reading ArgoUML files requires the '"^Config.unzip^"' program.\n")
val _ = print("Current status: ")
val _ = print("The program '"^Config.unzip^"' was ")
val _ = if Config.check_unzip()
then print ""
else print "not"
val _ = print "found.\n"
val _ = print("\n")
val _ = if Config.check_argo_import ()
then print "Support for XMI and ArgoUML files enabled.\n"
else
if Config.check_xmi_import ()
then print "Support for XMI files enabled, support for ArgoUML files disabled.\n"
else print "Support for XMI and ArgoUML files disabled.\n"
val _ = print("\n")
val _ = print("Su4sml is a tool for working with UML/OCL and SecureUML/OCL models.\n")
val _ = print("For additional information, see http://projects.brucker.ch/projects/su4msl/\n")
in
@ -69,6 +89,7 @@ in
end
structure typecheck = struct
fun print_usage() = let

View File

@ -56,13 +56,13 @@ fun readFile filename =
(* how to do the following in a clean/portable way? *)
fun read_dtd dtd =
(OS.FileSys.chDir (Config.su4sml_home());
(OS.FileSys.chDir (Config.su4sml_share());
(* check to see if the DTD file exists. *)
if OS.FileSys.access ("UML15OCL.xmi",[]) then
if OS.FileSys.access (Config.umlocl_dtd,[]) then
(Parser.parseDocument
(SOME (Uri.String2Uri ("file:UML15OCL.xmi")))
(SOME (Uri.String2Uri ("file:"^(Config.umlocl_dtd))))
(SOME dtd) (dtd,nil,nil))
else Logger.error ("Error while reading file UML15OCL.xmi: "^
else Logger.error ("Error while reading UML/OCL DTD `"^(Config.umlocl_dtd)^"': "^
"no such file or directory");
OS.FileSys.chDir currentDir)