Commit 0986e3e0 authored by Mart Lubbers's avatar Mart Lubbers

Merge branch 'creat-main-module' into 'master'

Add support for editing the main module

See merge request !5
parents 995ce4d2 03601f65
Pipeline #13769 passed with stage
in 50 seconds
*.exe
*.out
*.prj
*.prp
*-data/
*-www/
*-sapl/
Clean System Files/
test:
before_script:
- install_clean_nightly.sh bundle-complete
- apt-get update -qq
- apt-get install -y -qq build-essential
image: "camilstaps/clean:nightly"
script:
- make -f Makefile.linux cpm/cpm
artifacts:
paths:
- "cpm/cpm"
definition module typeatt
update_type_window :: !Bool !String ![String] !*state -> *state
import IdeState
update_type_window :: !Bool !String ![String] !*GeneralSt -> *GeneralSt
implementation module typeatt
update_type_window :: !Bool !String ![String] !*state -> *state
update_type_window _ _ _ ps = ps
import StdList, StdFunc
import IdeState
update_type_window :: !Bool !String ![String] !*GeneralSt -> *GeneralSt
update_type_window interact name message ps = seq (map writeLog message) ps
This diff is collapsed.
.PHONY: cpm/cpm clean
cpm/cpm:
clm -nt -nr -h 67108864 -s 5242880\
-IL Platform/Deprecated/ArgEnv -IL Platform/Deprecated/StdLib \
-IL Directory -IL Platform -I Pm -I Unix -I Util -I BatchBuild \
-I Interfaces/LinkerInterface -I cpm/Posix -I cpm Cpm -o $@
CpmLinux.prj: cpm/cpm
yes n | cpm project $(basename $@) create
cpm project $@ set -h 67108864 -s 5242880 -nr
cpm project $@ path add "$$PWD/cpm"\
"$$PWD/cpm/Posix"\
"$$PWD/Pm"\
"$$PWD/Unix"\
"$$PWD/Util"\
"$$PWD/BatchBuild"\
"$$PWD/Interfaces/LinkerInterface"\
"$$CLEAN_HOME/lib/Directory"\
"$$CLEAN_HOME/lib/Platform"\
"$$CLEAN_HOME/lib/Platform/Deprecated/ArgEnv"\
"$$CLEAN_HOME/lib/Platform/Deprecated/StdLib"
cpm project $@ exec cpm/cpm
cpm project $@ main "$$PWD/cpm/Cpm"
# cpm
[linux64](https://gitlab.science.ru.nl/mlubbers/clean-ide/builds/artifacts/master/browse?job=test)
This diff is collapsed.
......@@ -102,4 +102,4 @@ free p = code {
}
FExists :: .a;
FExists = abort "FExists";
FExists = abort "FExists\n";
# bash completion for cpm
# Author: Mart Lubbers
# Date: 2018-07-17
#
# Todo
# - support --envs=filename
# - create completion for module
# - create completion for environment
# - test on non-linux
_set_opts="-generic_fusion -ngeneric_fusion -dynamics -ndynamics -descexl -ndescexl -b -nr -nc -sc"
_targets()
{
sed 's/EnvironmentName:[[:space:]]*//;t;d' | tr -d '\n'
}
_paths()
{
sed 's/\[\([[:digit:]]\)\].*/\1/;t;d' | tr -d '\n'
}
_cpm()
{
local arg cur prev words cword split
# Require bash completion
_init_completion || return
_get_first_arg
_get_comp_words_by_ref
# subcommand or project file
if [[ -z "${arg}" ]]
then
COMPREPLY=( $(compgen -W "environment project module make" -- ${cur}) )
_filedir prj
else
case "${arg}" in
*.prj)
COMPREPLY=( $(compgen -W "--force" -- ${cur}) )
;;
make)
;;
project)
# Not even a project file is selected
if [[ "$cword" = 2 ]]
then
_filedir prj
# A project file is selected
elif [[ "$cword" = 3 ]]
then
COMPREPLY=( $(compgen -W "create show build path root target exec set" -- ${cur}) )
# A project command is selected
elif [[ "$cword" -ge 4 ]]
then
case "${words[3]}" in
build)
COMPREPLY=( $(compgen -W "--force --envs" -- ${cur}) )
;;
path)
# No path command set yet
if [[ "$cword" = 4 ]]
then
COMPREPLY=( $(compgen -W "add list remove move" -- ${cur}) )
# Path command is set
elif [[ "$cword" -ge 5 ]]
then
case "${words[4]}" in
add)
_filedir -d
;;
list)
;;
remove)
COMPREPLY=( $(compgen -W "$("${words[0]}" project "${words[2]}" path list | _paths)" -- ${cur}) )
;;
move)
if [[ "$cword" = 5 ]]
then
COMPREPLY=( $(compgen -W "$("${words[0]}" project "${words[2]}" path list | _paths)" -- ${cur}) )
elif [[ "$cword" = 6 ]]
then
COMPREPLY=( $(compgen -W "up down top bottom" -- ${cur}) )
fi
;;
esac
fi
;;
root)
COMPREPLY=( $(compgen -W ". .. ... .... ....." -- ${cur}) )
;;
target)
COMPREPLY=( $(compgen -W "$(_targets < "$CLEAN_HOME/etc/IDEEnvs")" -- ${cur}) )
;;
set)
COMPREPLY=( $(compgen -W "$_set_opts" -- ${cur}) )
;;
exec)
;;
create)
;;
show)
;;
main)
_filedir
;;
esac
fi
;;
module)
;;
environment)
;;
esac
fi
} && complete -F _cpm cpm
......@@ -21,11 +21,12 @@ from PmTypes import :: Output
| SetRelativeRoot String
| SetTarget String
| SetExec String
| SetMain String
| SetProjectOptions [ProjectOption]
| ProjectHelp
:: PathAction
= AddPathAction String
= AddPathAction [String]
| RemovePathAction Int
| ListPathsAction
| MovePathAction Int PathDirection
......
......@@ -80,7 +80,9 @@ doProjectAction cleanhome pwd pn CreateProject 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
# world = showLines ["Please make sure to create the main module or change it before compiling!"] world
= mkProject world
| otherwise = mkProject world
where
basefilename = dropExtension pn
......@@ -98,6 +100,9 @@ doProjectAction cleanhome pwd pn CreateProject world
# projectfile = addExtension basefilename "prj"
= saveProject cleanhome pwd project projectfile world
doProjectAction cleanhome pwd pn (SetMain mainmod) world
= withProject pwd pn cleanhome (PR_SetRoot mainmod {eo={newlines=NewlineConventionUnix},pos_size=NoWindowPosAndSize} compilerOptions) world
doProjectAction cleanhome pwd pn ShowProject world
# (proj_path, project, ok, world) = openProject pwd pn cleanhome world
| not ok
......@@ -106,9 +111,14 @@ doProjectAction cleanhome pwd pn ShowProject world
, "ProjectRoot..: " +++ PR_GetRelativeRootDir project
, "Target.......: " +++ PR_GetTarget project
, "Executable...: " +++ PR_GetExecPath project
, "Main module..: " +++ get_main_module project
, "Paths........:"
: showPaths project
] world
where
get_main_module project
# (mad, project) = PR_GetRootModuleDirAndName project
= mad.mdn_name +++ " (in " +++ mad.mdn_dir +++ ")"
doProjectAction cleanhome pwd pn (BuildProject force ideenvs) world
# (envs, world) = readIDEEnvs cleanhome ideenvs world
......@@ -170,13 +180,13 @@ where
set_project_option RTSFlagsOn project
= PR_SetApplicationOptions {PR_GetApplicationOptions project & disable_rts_flags=False} project
set_project_option TimeProfileOff project
= PR_SetApplicationOptions {PR_GetApplicationOptions project & profiling=False} project
= PR_SetApplicationOptions {PR_GetApplicationOptions project & profiling=False, stack_traces=False} project
set_project_option TimeProfileOn project
= PR_SetApplicationOptions {PR_GetApplicationOptions project & profiling=True} project
= PR_SetApplicationOptions {PR_GetApplicationOptions project & profiling=True, stack_traces=False} project
set_project_option StackTraceOff project
= PR_SetApplicationOptions {PR_GetApplicationOptions project & stack_traces=False} project
= PR_SetApplicationOptions {PR_GetApplicationOptions project & profiling=False, stack_traces=False} project
set_project_option StackTraceOn project
= PR_SetApplicationOptions {PR_GetApplicationOptions project & stack_traces=True} project
= PR_SetApplicationOptions {PR_GetApplicationOptions project & profiling=True, stack_traces=True} project
set_project_option MemoryProfileOff project
= PR_SetApplicationOptions {PR_GetApplicationOptions project & memoryProfiling=False} project
set_project_option MemoryProfileOn project
......@@ -190,6 +200,7 @@ doProjectAction _ _ _ _ world =
help "cpm project <projectfile> <action>"
[ "Where <action> is one of the following"
, " create : create a new project"
, " main <module> : set the main module, <module> should be a path to a module"
, " show : show project information"
, " build [--force] [--envs=filename] : build the project. Optionally force build (default: 'false')"
, " Optionally specify the environments file (default: 'IDEEnvs')"
......@@ -205,7 +216,7 @@ doProjectAction _ _ _ _ world =
, " : Enable or disable application stripping"
, " : -dynamics,-ndynamics"
, " : Enable or disable dynamics"
, " : -descexl,-descexl"
, " : -descexl,-ndescexl"
, " : Enable or disable descriptor generation and label exporting"
, " : This translates to passing -desc and -exl to cocl"
, " : -rtsopts,-nrtsopts"
......@@ -213,10 +224,9 @@ doProjectAction _ _ _ _ world =
, " : -b,-nr,-nc,-sc"
, " : Set the output option to BasicValuesOnly, NoReturnType,"
, " : NoConsole or ShowConstructors respectively"
, " : -tst, -ntst"
, " : Enable or disable stack tracing"
, " : -pt, -npt"
, " : Enable or disable time profiling"
, " : -pt, -npt, -tst, ntst"
, " : Enable or disable time profiling and stack tracing"
, " : Note that these are mutually exclusive and if you select multiple, the last one will take effect"
, " : -mp, -nmp"
, " : Enable or disable memory profiling"
] world
......@@ -262,8 +272,8 @@ withProject pwd pn cleanhome f world
* Execute path-related project actions
*/
doProjectPathAction :: String String String Project PathAction *World -> *World
doProjectPathAction cleanhome pwd pn project (AddPathAction path) world
= doModPaths cleanhome pwd pn project ((:!) (GetLongPathName path)) world
doProjectPathAction cleanhome pwd pn project (AddPathAction paths) world
= doModPaths cleanhome pwd pn project (Concat [! GetLongPathName path\\path<-paths !]) world
doProjectPathAction cleanhome pwd pn project (RemovePathAction i) world
= doModPaths cleanhome pwd pn project (rmStrictListIdx i) world
......@@ -277,10 +287,11 @@ doProjectPathAction cleanhome pwd pn project (MovePathAction i pdir) world
doProjectPathAction _ _ _ _ _ world
= help "cpm project <projectname.prj> path <action>"
[ "Where <action> is one of the following"
, " add <path> : add a path to the project"
, " list : list all project paths and their index"
, " remove <i> : remove path <i> from the list of projects"
, " move <i> <up|down> : move path <i> up or down one position" ] world
, " add <path> : add a path to the project"
, " list : list all project paths and their index"
, " remove <i> : remove path <i> from the list of projects"
, " move <i> <up|down|top|bottom> : move path <i>"
] world
/**
* Collect all project paths in a list with an index prefixed
......@@ -398,7 +409,7 @@ doModuleAction _ _ _ world =
*/
error :: !String !*World -> *World
error message world
# stderr = fwrites message stderr
# stderr = stderr <<< message <<< "\n"
# (ok,world) = fclose stderr world
= set_return_code_world (-1) world
......
......@@ -20,6 +20,7 @@ parse_CpmLogic _ = CpmHelp;
parse_Project :: ![String] !String -> CpmAction;
parse_Project ["create"] project_name = Project project_name CreateProject;
parse_Project ["show"] project_name = Project project_name ShowProject;
parse_Project ["main",mainmod] project_name = Project project_name (SetMain mainmod);
parse_Project ["build":project_build_args] project_name
= parse_Project_build_args project_build_args False EnvsFileName project_name (Project "" ProjectHelp);
parse_Project ["path":project_path_args] project_name = parse_Project_path_args project_path_args project_name;
......@@ -48,8 +49,8 @@ parse_Project_build_args _ _ _ _ error_cpm_action
= error_cpm_action;
parse_Project_path_args :: ![String] !String -> CpmAction;
parse_Project_path_args ["add",path] project_name
= Project project_name (ProjectPath (AddPathAction path));
parse_Project_path_args ["add":path] project_name
| length path <> 0 = Project project_name (ProjectPath (AddPathAction path));
parse_Project_path_args ["remove",i] project_name
| size i>0 && only_digits_in_string 0 i
= Project project_name (ProjectPath (RemovePathAction (toInt i)));
......
File added
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