Commit 1ef6e7c7 authored by John van Groningen's avatar John van Groningen

Merge branch 'add-bytecode-options-to-cpm-cli' into 'master'

Add new settings to set command of cpm CLI

Closes #3

See merge request !17
parents a956a116 8561c5d4
Pipeline #23196 passed with stage
in 1 minute and 31 seconds
......@@ -23,6 +23,7 @@ from StdMaybe import :: Maybe
| SetRelativeRoot String
| SetTarget String
| SetExec String
| SetBytecode (Maybe String)
| SetProjectOptions [ProjectOption]
| ProjectHelp
......@@ -59,6 +60,11 @@ from StdMaybe import :: Maybe
| Output !Output
| LinkerGenerateSymbolsOn
| LinkerGenerateSymbolsOff
| PO_OptimiseABC !Bool
| PO_GenerateByteCode !Bool
| PO_StripByteCode !Bool
| PO_KeepByteCodeSymbols !Bool
| PO_PreLinkByteCode !Bool
:: ModuleAction
= CreateModule ModuleType
......
......@@ -153,6 +153,16 @@ doProjectAction cleanhome pwd pn (SetTarget target) world
doProjectAction cleanhome pwd pn (SetExec exec) world
= withProject pwd pn cleanhome (PR_SetExecPath exec) world
doProjectAction cleanhome pwd pn (SetBytecode Nothing) world
= withProject pwd pn cleanhome (\p->PR_SetByteCodePath (bytecode_path (PR_GetExecPath p)) p) world
where
bytecode_path exec_path
| exec_path % (size exec_path-4,size exec_path-1) == ".exe"
= exec_path % (0,size exec_path-4) +++ "bc"
= exec_path +++ ".bc"
doProjectAction cleanhome pwd pn (SetBytecode (Just bcfile)) world
= withProject pwd pn cleanhome (PR_SetByteCodePath bcfile) world
doProjectAction cleanhome pwd pn (SetProjectOptions project_options) world
= withProject pwd pn cleanhome (set_project_options project_options) world
where
......@@ -200,6 +210,16 @@ where
= PR_SetLinkOptions project {PR_GetLinkOptions project & generate_symbol_table=True}
set_project_option LinkerGenerateSymbolsOff project
= PR_SetLinkOptions project {PR_GetLinkOptions project & generate_symbol_table=False}
set_project_option (PO_OptimiseABC val) project
= PR_SetCodeGenOptions {PR_GetCodeGenOptions project & optimise_abc=val} project
set_project_option (PO_GenerateByteCode val) project
= PR_SetCodeGenOptions {PR_GetCodeGenOptions project & generate_bytecode=val} project
set_project_option (PO_StripByteCode val) project
= PR_SetLinkOptions project {PR_GetLinkOptions project & strip_bytecode=val}
set_project_option (PO_KeepByteCodeSymbols val) project
= PR_SetLinkOptions project {PR_GetLinkOptions project & keep_bytecode_symbols=val}
set_project_option (PO_PreLinkByteCode val) project
= PR_SetLinkOptions project {PR_GetLinkOptions project & prelink_bytecode=val}
doProjectAction _ _ _ _ world =
help "cpm project <projectfile> <action>"
......@@ -214,6 +234,7 @@ doProjectAction _ _ _ _ world =
, " : . is the same dir, .. the parent, ... the grandparent, etc."
, " target <env> : set target environment to <env>"
, " exec <execname> : set executable name to <execname>"
, " bytecode [bc] : set bytecode file to <bcfile> or <execname>.bc if no file given"
, " set <option> [<option>] : Set one or more of the following options:"
, " : -h SIZE"
, " : Change the heapsize (e.g. 2M)"
......@@ -238,6 +259,24 @@ doProjectAction _ _ _ _ world =
, " : Note that these are mutually exclusive and if you select multiple, the last one will take effect"
, " : -mp, -nmp"
, " : Enable or disable memory profiling"
, " : -optimiseabc, -noptimiseabc"
, " : Enable or disable ABC optimization for bytecode targets"
, " : -genbytecode, -ngenbytecode"
, " : Enable or disable bytecode generation"
, " : -stripbytecode, -nstripbytecode"
, " : Enable or disable bytecode stripping"
, " : -keepbytecodesymbols, -nkeepbytecodesymbols"
, " : Enable or disable bytecode symbol keeping"
, " : -prelinkbytecode, -nprelinkbytecode"
, " : Enable or disable bytecode prelinking"
, ""
, "Examples: "
, " - To create an iTasks project for module test, run:"
, " cpm project test create"
, " cpm project test bytecode"
, " cpm project test.prj target iTasks"
, " cpm project test.prj set -dynamics -h 200m -s 2m -descexl -optimiseabc -genbytecode -stripbytecode -keepbytecodesymbols -prelinkbytecode"
, " cpm project test.prj build"
] world
/**
......
......@@ -31,6 +31,8 @@ parse_Project ["root",s] project_name
= Project project_name (SetRelativeRoot s);
parse_Project ["target",s] project_name = Project project_name (SetTarget s);
parse_Project ["exec",s] project_name = Project project_name (SetExec s);
parse_Project ["bytecode",s] project_name = Project project_name (SetBytecode (Just s));
parse_Project ["bytecode"] project_name = Project project_name (SetBytecode Nothing);
parse_Project ["set":project_option_args] project_name
# (ok,project_options) = parse_Project_options project_option_args;
| ok
......@@ -149,6 +151,36 @@ parse_Project_options ["-mp":project_option_args]
parse_Project_options ["-nmp":project_option_args]
# (ok,project_options) = parse_Project_options project_option_args;
= (ok, [MemoryProfileOff:project_options]);
parse_Project_options ["-optimiseabc":project_option_args]
# (ok,project_options) = parse_Project_options project_option_args;
= (ok, [PO_OptimiseABC True:project_options]);
parse_Project_options ["-noptimiseabc":project_option_args]
# (ok,project_options) = parse_Project_options project_option_args;
= (ok, [PO_OptimiseABC False:project_options]);
parse_Project_options ["-genbytecode":project_option_args]
# (ok,project_options) = parse_Project_options project_option_args;
= (ok, [PO_GenerateByteCode True:project_options]);
parse_Project_options ["-ngenbytecode":project_option_args]
# (ok,project_options) = parse_Project_options project_option_args;
= (ok, [PO_GenerateByteCode False:project_options]);
parse_Project_options ["-stripbytecode":project_option_args]
# (ok,project_options) = parse_Project_options project_option_args;
= (ok, [PO_StripByteCode True:project_options]);
parse_Project_options ["-nstripbytecode":project_option_args]
# (ok,project_options) = parse_Project_options project_option_args;
= (ok, [PO_StripByteCode False:project_options]);
parse_Project_options ["-keepbytecodesymbols":project_option_args]
# (ok,project_options) = parse_Project_options project_option_args;
= (ok, [PO_KeepByteCodeSymbols True:project_options]);
parse_Project_options ["-nkeepbytecodesymbols":project_option_args]
# (ok,project_options) = parse_Project_options project_option_args;
= (ok, [PO_KeepByteCodeSymbols False:project_options]);
parse_Project_options ["-prelinkbytecode":project_option_args]
# (ok,project_options) = parse_Project_options project_option_args;
= (ok, [PO_PreLinkByteCode True:project_options]);
parse_Project_options ["-nprelinkbytecode":project_option_args]
# (ok,project_options) = parse_Project_options project_option_args;
= (ok, [PO_PreLinkByteCode False:project_options]);
parse_Project_options []
= (True,[]);
parse_Project_options _
......
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