Commit 4c9d88d3 authored by Mart Lubbers's avatar Mart Lubbers

implement environment import/export .. for cpm

parent 412ff028
Pipeline #21004 passed with stage
in 56 seconds
......@@ -35,6 +35,7 @@ EnvsFileName :== "IDEEnvs"
getEnvironments :: !String !String !*env -> *([Target],*env) | FileSystem, FileEnv env
openEnvironments :: !String !String !*env -> *([Target],*env) | FileEnv env
openEnvironment :: !String *a -> *(([Target],.Bool,{#Char}),*a) | FileSystem a
saveEnvironments :: !String ![Target] !*env -> *(Bool,*env) | FileEnv env
t_StdEnv :: Target
......@@ -72,7 +72,7 @@ from PmTypes import ::Pathname,::Output
| ImportEnvironment FilePath
| RemoveEnvironment String
| ShowEnvironment String
| ExportEnvironment String
| ExportEnvironment String FilePath
| CreateEnvironment String
| RenameEnvironment String String
| SetEnvironmentCompiler String String
......
......@@ -247,7 +247,12 @@ doEnvironmentAction :: String String EnvironmentAction *World -> *World
doEnvironmentAction cleanhome pwd ListEnvironments world
= withEnvironments cleanhome (\ts w->(Nothing, showLines [t.target_name\\t<-ts] w)) world
doEnvironmentAction cleanhome pwd (ImportEnvironment ef) world
= error "Not implemented" world
= withEnvironments cleanhome importEnvironment world
where
importEnvironment ts world
# ((ts`, ok, err), world) = openEnvironment ef world
| not ok = (Nothing, error err world)
= (Just (ts ++ ts`), world)
doEnvironmentAction cleanhome pwd (RemoveEnvironment en) world
= withEnvironment cleanhome en (\_ w->(Just [], w)) world
doEnvironmentAction cleanhome pwd (ShowEnvironment en) world
......@@ -277,7 +282,13 @@ where
CompilePers = "pers"
, "Processor: " +++ toString e.target_proc
]
doEnvironmentAction cleanhome pwd (ExportEnvironment en) world = error ("Not implemented") world
doEnvironmentAction cleanhome pwd (ExportEnvironment en fp) world
= withEnvironment cleanhome en exportEnvironment world
where
exportEnvironment t world
# (ok, world) = saveEnvironments fp [t] world
| not ok = (Nothing, error "Error saving environment" world)
= (Nothing, world)
doEnvironmentAction cleanhome pwd (CreateEnvironment en) world = error ("Not implemented") world
doEnvironmentAction cleanhome pwd (RenameEnvironment en en`) world
= withEnvironment cleanhome en (\t w->(Just [{t & target_name=en`}], w)) world
......@@ -291,7 +302,7 @@ doEnvironmentAction _ _ _ world =
, " create <envname> : create a new environment with name <envname>"
, " remove <envname> : remove evironment <envname>"
, " show <envname> : show environment <envname>"
, " export <envname> : export environment <envname>"
, " export <envname> <filepath> : export environment <envname> to <filepath>"
, " rename <envname> <envname`> : rename environment <envname> to <envname`>"
, " setcompiler <envname> <compilername> : set compiler for <envname> to <compilername>"
, " setcodegen <envname> <codegenname> : set codegen for <envname> to <codegenname>"
......
......@@ -181,7 +181,7 @@ parse_Environment ["import",s] = Environment (ImportEnvironment s);
parse_Environment ["create",s] = Environment (CreateEnvironment s);
parse_Environment ["remove",s] = Environment (RemoveEnvironment s);
parse_Environment ["show",s] = Environment (ShowEnvironment s);
parse_Environment ["export",s] = Environment (ExportEnvironment s);
parse_Environment ["export",s1,s2] = Environment (ExportEnvironment s1 s2);
parse_Environment ["rename",s1,s2] = Environment (RenameEnvironment s1 s2);
parse_Environment ["setcompiler",s1,s2] = Environment (SetEnvironmentCompiler s1 s2);
parse_Environment ["setcodegen",s1,s2] = Environment (SetEnvironmentCodeGen s1 s2);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment