Commit 1c572fd2 authored by Jurrien Stutterheim's avatar Jurrien Stutterheim
Browse files

Try --cleanhome or CLEAN_HOME before defaulting to pwd

parent e1c2ce36
......@@ -31,48 +31,53 @@ from UtilIO import GetFullApplicationPath,GetLongPathName
derive gEq BBArg
Start :: *World -> *World
Start world
# commandline = getCommandLine
# cleanhome = case getEnvironmentVariable "CLEAN_HOME" of
(EnvironmentVariable ch) -> ch
_ -> "."
cl = intersperse " " (tl [arg \\ arg <-: commandline])
argsrec = startPBB (concat [fromString c \\ c <- cl])
# (pwd, world) = accFiles GetFullApplicationPath world // TODO: Do we replace this with cleanhome somewhere?
# cleanhome = case getStringArg "cleanhome" argsrec.args of
(Just nm) -> nm
Nothing -> case getEnvironmentVariable "CLEAN_HOME" of
(EnvironmentVariable ch) -> ch
_ -> pwd
| isNothing argsrec.filename = showUsage world
= case getStringArg "action" argsrec.args of
(Just "create") -> createProject world argsrec.filename cleanhome
(Just "show") -> showProject world argsrec.filename cleanhome
//(Just "addpath") -> addPath world argsrec.filename cleanhome
//(Just "removepath") -> removePath world argsrec cleanhome
_ -> buildProject world argsrec
_ -> buildProject world argsrec cleanhome
showUsage :: !*World -> *World
showUsage world = show
[ "BatchBuild"
, "Usage: BatchBuild [--force] filename [--action=ARG] [--envsfile=ARG]"
, " --action : Execute a specific action. Possible actions:"
, " build : Build a project (default)."
, " create : Create a basic project file for a module."
, " show : Summarize the contents of a project file."
, " --envsfile : Specify an environments file (defaults to 'IDEEnvs')"
, "Usage: BatchBuild [--force] filename [--action=ARG] [--envsfile=ARG] [--cleanhome=ARG]"
, " --action : Execute a specific action. Possible actions:"
, " build : Build a project (default)."
, " create : Create a basic project file for a module."
, " show : Summarize the contents of a project file."
, " --envsfile : Specify an environments file (defaults to 'IDEEnvs')"
, " --cleanhome : Specify the Clean directory (defaults to '.')."
, " Alternatively, specify $CLEAN_HOME in your environment."
] world
buildProject :: *World BBArgs -> *World
buildProject world {force_rebuild=force_rebuild, filename=filename, args=args}
# (startup,world) = accFiles GetFullApplicationPath world
# envsfile = case getStringArg "envsfile" args of
(Just p) -> application_path p
_ -> application_path EnvsFileName
# (envs,world) = openEnvironments startup envsfile world
# ((proj,ok,err),world) = accFiles (ReadProjectFile (fromJust filename) startup) world
| not ok || err <> "" = wAbort ("BatchBuild failed while opening project: "+++.err+++."\n") world
# (ok,logfile,world) = openLogfile (fromJust filename) world
| not ok = wAbort ("BatchBuild failed while opening logfile.\n") world
# default_compiler_options = DefaultCompilerOptions
# iniGeneral = initGeneral True default_compiler_options startup (fromJust filename) proj envs logfile
# ps = {ls=iniGeneral,gst_world=world,gst_continue_or_stop=False}
# {ls,gst_world} = pinit (force_rebuild || hasFlag "force" args) ps
buildProject :: *World BBArgs String -> *World
buildProject world {force_rebuild=force_rebuild, filename=filename, args=args} cleanhome
# envsfile = case getStringArg "envsfile" args of
(Just p) -> application_path p
_ -> application_path EnvsFileName
# (envs, world) = openEnvironments cleanhome envsfile world
# ((proj, ok, err), world) = accFiles (ReadProjectFile (fromJust filename) cleanhome) world
| not ok || err <> "" = wAbort ("BatchBuild failed while opening project: "+++.err+++."\n") world
# (ok, logfile, world) = openLogfile (fromJust filename) world
| not ok = wAbort ("BatchBuild failed while opening logfile.\n") world
# default_compiler_options = DefaultCompilerOptions
# iniGeneral = initGeneral True default_compiler_options cleanhome (fromJust filename) proj envs logfile
# ps = {ls=iniGeneral,gst_world=world,gst_continue_or_stop=False}
# {ls, gst_world} = pinit (force_rebuild || hasFlag "force" args) ps
= finish gst_world
createProject :: *World (Maybe String) String -> *World
......@@ -188,22 +193,26 @@ pNotSpace = sp (<+> (satisfy (not o isWhite)))
pBoolLongOpt :: String -> CParser Char BBArg a
pBoolLongOpt long = pLongOpt long <@ const (BBBool long)
//pBoolShortOpt short = pShortOpt short <@ const (BBBool short)
pBoolShortOpt :: String -> CParser Char BBArg a
pBoolShortOpt short = pShortOpt short <@ const (BBBool short)
pIntLongOpt :: String -> CParser Char BBArg a
pIntLongOpt long = pLongOpt long &> sp int <@ BBInt long
//pIntShortOpt short = pShortOpt short &> sp int <@ BBInt short
pIntShortOpt :: String -> CParser Char BBArg a
pIntShortOpt short = pShortOpt short &> sp int <@ BBInt short
pStringLongOpt :: String -> CParser Char BBArg a
pStringLongOpt long = pLongOpt long &> sp pNotSpace <@ \s -> BBString long (toString s)
pStringLongOpt long = pLongOpt long &> sp pNotSpace <@ BBString long o toString
//pStringShortOpt short = pShortOpt short &> sp pNotSpace <@ BBString short o toString
pStringShortOpt :: String -> CParser Char BBArg a
pStringShortOpt short = pShortOpt short &> sp pNotSpace <@ BBString short o toString
pLongOpt :: String -> CParser Char [Char] a
pLongOpt long = sptoken (fromString "--") &> token (fromString long) <& (<?> (spsymbol '='))
//pShortOpt short = spsymbol '-' &> token (fromString short) <& (<?> (spsymbol '='))
pShortOpt :: String -> CParser Char [Char] a
pShortOpt short = spsymbol '-' &> token (fromString short) <& (<?> (spsymbol '='))
pinit :: .Bool *GeneralSt -> *GeneralSt
......
Supports Markdown
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