Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
clean-and-itasks
clean-ide
Commits
2576e211
Commit
2576e211
authored
May 16, 2019
by
Mart Lubbers
Browse files
add create from template to parser, abssyn and implement rudimentary
parent
1ef6e7c7
Pipeline
#23208
passed with stage
in 56 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
cpm/AbsSyn.dcl
View file @
2576e211
...
...
@@ -15,7 +15,7 @@ from StdMaybe import :: Maybe
|
CpmHelp
::
ProjectAction
=
CreateProject
=
CreateProject
(
Maybe
FilePath
)
|
ShowProject
|
BuildProject
Bool
FilePath
|
Compile
[
String
]
...
...
cpm/CpmLogic.icl
View file @
2576e211
...
...
@@ -74,29 +74,45 @@ getLine world
* Execute project-specific actions
*/
doProjectAction
::
String
String
String
ProjectAction
*
World
->
*
World
doProjectAction
cleanhome
pwd
pn
CreateProject
world
//Check if main module exists
#
(
exists
,
world
)
=
accFiles
(
FExists
mainmodule
)
world
|
not
exists
// = error ("Main module " +++ mainmodule +++ " does not exist.") world
#
world
=
showLines
[
"Main module "
+++
mainmodule
+++
" does not exist. Create it? [y/n]"
]
world
#
(
line
,
world
)
=
getLine
world
|
line
.[
0
]
==
'y'
=
mkMainAndProject
world
|
otherwise
=
error
(
"Failed to create project. Need "
+++
mainmodule
)
world
|
otherwise
=
mkProject
world
where
mainmodule
=
MakeImpPathname
pn
mkMainAndProject
world
#
world
=
doModuleAction
""
mainmodule
(
CreateModule
ApplicationModule
)
world
=
mkProject
world
mkProject
world
#
edit_options
=
{
eo
={
newlines
=
NewlineConventionUnix
},
pos_size
=
NoWindowPosAndSize
}
//Create project file using the Clean IDE libraries
#
prj
=
PR_NewProject
mainmodule
edit_options
compilerOptions
DefCodeGenOptions
DefApplicationOptions
[!!]
DefaultLinkOptions
#
project
=
PR_SetRoot
mainmodule
edit_options
compilerOptions
prj
#
projectfile
=
MakeProjectPathname
pn
=
saveProject
cleanhome
pwd
project
projectfile
world
doProjectAction
cleanhome
pwd
pn
(
CreateProject
mbTemplate
)
world
//Check if main module exists
#
(
exists
,
world
)
=
accFiles
(
FExists
mainmodule
)
world
|
not
exists
#
world
=
showLines
[
"Main module "
+++
mainmodule
+++
" does not exist. Create it? [y/n]"
]
world
#
(
line
,
world
)
=
getLine
world
|
line
.[
0
]
==
'y'
=
mkMainAndProject
world
|
otherwise
=
error
(
"Failed to create project. Need "
+++
mainmodule
)
world
|
otherwise
=
mkProject
world
where
mainmodule
=
MakeImpPathname
pn
mkMainAndProject
world
#
world
=
doModuleAction
""
mainmodule
(
CreateModule
ApplicationModule
)
world
=
mkProject
world
mkProject
world
#
edit_options
=
{
eo
={
newlines
=
NewlineConventionUnix
},
pos_size
=
NoWindowPosAndSize
}
#
projectfile
=
MakeProjectPathname
pn
|
isNothing
mbTemplate
// no template, create from scratch
//Create project file using the Clean IDE libraries
#
prj
=
PR_NewProject
mainmodule
edit_options
compilerOptions
DefCodeGenOptions
DefApplicationOptions
[!!]
DefaultLinkOptions
#
project
=
PR_SetRoot
mainmodule
edit_options
compilerOptions
prj
=
saveProject
cleanhome
pwd
project
projectfile
world
// a template, create from template
#
templatefile
=
prtExtension
(
fromJust
mbTemplate
)
#
((
ok
,
prj
,
err
),
world
)
=
accFiles
(
read_project_template_file
templatefile
pwd
)
world
#
((
ok
,
prj
,
err
),
world
)
=
if
(
not
ok
)
(
accFiles
(
read_project_template_file
(
cleanhome
+++
DirSeparatorString
+++
"etc"
+++
DirSeparatorString
+++
templatefile
)
pwd
)
world
)
((
ok
,
prj
,
err
),
world
)
|
not
ok
=
error
(
"Failed to open template: "
+++
err
)
world
//TODO if ProjectRoot is deeper
// # prj = PR_SetRoot (pwd+++DirSeparatorString+++mainmodule) edit_options compilerOptions prj
#
prj
=
PR_SetExecPath
(
"{Project}"
+++
DirSeparatorString
+++
MakeExecPathname
mainmodule
)
prj
=
saveProject
cleanhome
pwd
prj
projectfile
world
prtExtension
fn
|
equal_suffix
".prt"
fn
=
fn
=
fn
+++
".prt"
doProjectAction
cleanhome
pwd
pn
ShowProject
world
#
(
proj_path
,
project
,
ok
,
world
)
=
openProject
pwd
pn
cleanhome
world
...
...
@@ -224,7 +240,7 @@ where
doProjectAction
_
_
_
_
world
=
help
"cpm project <projectfile> <action>"
[
"Where <action> is one of the following"
,
" create
: create a new project"
,
" create
[template]
: create a new project"
,
" compile <modulename> [..] : compile the given modules"
,
" show : show project information"
,
" build [--force] [--envs=filename] : build the project. Optionally force build (default: 'false')"
...
...
cpm/Parser.icl
View file @
2576e211
...
...
@@ -19,7 +19,8 @@ parse_CpmLogic [project_name:project_build_args] = parse_Project_build_args proj
parse_CpmLogic
_
=
CpmHelp
;
parse_Project
::
![
String
]
!
String
->
CpmAction
;
parse_Project
[
"create"
]
project_name
=
Project
project_name
CreateProject
;
parse_Project
[
"create"
]
project_name
=
Project
project_name
(
CreateProject
Nothing
);
parse_Project
[
"create"
,
s
]
project_name
=
Project
project_name
(
CreateProject
(
Just
s
));
parse_Project
[
"show"
]
project_name
=
Project
project_name
ShowProject
;
parse_Project
[
"build"
:
project_build_args
]
project_name
=
parse_Project_build_args
project_build_args
False
EnvsFileName
project_name
(
Project
""
ProjectHelp
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment