Commit 7ebbd243 authored by John van Groningen's avatar John van Groningen

store editor options in .prp file instead of .prj file,

sort modules in .prj and .prp files
parent bbc8e5a5
......@@ -158,8 +158,8 @@ ed_open_cont pathName cont ps
# optional_window_pos_and_size = if (isJust inf)
(if isDefMod
(fromJust inf).defeo.pos_size
(fromJust inf).impeo.pos_size)
(fromJust inf).mod_edit_options.defeo.pos_size
(fromJust inf).mod_edit_options.impeo.pos_size)
NoWindowPosAndSize
# ps = openEditWindow mn_und (if readOnly title` title) pathName text font tabs margin syncols windowId (
[ WindowClose (noLS (ed_close windowId))
......@@ -247,11 +247,13 @@ where
lengths = size s
firsts = lengths - 4
lasts = dec lengths
dofrag (SCons (str) SNil)
| CleanModId str
= Just str
= Nothing
dofrag _ = Nothing
handlefrag (Just str) mIds
=
[(mIds.mn_odm,"Open "+++(MakeDefPathname str))
......@@ -443,9 +445,9 @@ ed_common_close update_in_project win ps
# modname = GetModuleName nam
# isDefmod = IsDefPathname nam
# pos_size = WindowPosAndSize {posx = pos.vx,posy=pos.vy,sizex=siz.w,sizey=siz.Size.h}
# update = \inf=:{defeo,impeo} -> if isDefmod
{inf & defeo = {defeo & pos_size = pos_size}, defopen = not update_in_project}
{inf & impeo = {impeo & pos_size = pos_size}, impopen = not update_in_project}
# update = \inf=:{mod_edit_options=mod_edit_options=:{defeo,impeo}} -> if isDefmod
{inf & mod_edit_options={mod_edit_options & defeo = {defeo & pos_size = pos_size}, defopen = not update_in_project}}
{inf & mod_edit_options={mod_edit_options & impeo = {impeo & pos_size = pos_size}, impopen = not update_in_project}}
# ps = appProject (\p -> PR_UpdateModule modname update p) ps
= closeEditWindow win ps
......
......@@ -645,7 +645,7 @@ pm_set ps
# info = PR_GetModuleInfo (GetModuleName path) project
| isJust info
# info = fromJust info
# eo = info.impeo
# eo = info.mod_edit_options.impeo
# co = info.compilerOptions
# project = PR_SetRoot path eo co project
# ps = appProject (const project) ps
......
implementation module PmDriver
import StdArray, StdBool, StdList, StdMisc, StdEnum, StdStrictLists
import StdArray,StdBool,StdList,StdMisc,StdEnum,StdStrictLists
import UtilNewlinesFile, UtilIO
......@@ -13,13 +13,9 @@ from projwin import pm_update_project_window
import PmCallBack
import PmCleanSystem
import PmPath
import PmProject
import PmCleanSystem,PmPath,PmProject
from PmDialogues import doPathsDialog
import PmAbcMagic
import PmFileInfo
import PmDirCache
import PmAbcMagic,PmFileInfo,PmDirCache
import Platform
from StdLibMisc import :: Date{..}, :: Time{..}
......@@ -150,7 +146,6 @@ BringProjectUptoDate force continuation ps
# ps = showInfo (Level1 "Bring up to date...") ps
# ps = ClearCompilerCache` ps
ini_step = DInit force project cleanup
= start ini_step step ps
where
......@@ -170,7 +165,7 @@ where
| isJust postlink
# (Just post_link) = postlink
# (prj_path,ps) = getProjectFilePath ps
# prj_dir_path = RemoveFilename prj_path
# prj_dir_path = PR_GetRootDir project
# (app_path,ps) = getStup ps
# post_link = fulPath app_path prj_dir_path post_link
# ps = showInfo (Level1 "Postlink...") ps
......@@ -360,13 +355,11 @@ step intr (DComp force dircache compinfo=:(Pers _) (next :! rest) ds) ps
| isProjLibraryModule modname ds.libsinfo
// instead of testing explicitly put libmodules in done <= conflicts with other administration
= step intr (DComp force dircache compinfo rest ds) ps
# ps = trace_n ("update",next) ps
# (ps,dircache,ok,newpaths`,rest,compinfo,ds,_)
= UpdateDependencies force next rest compinfo dircache ds ps
# ds = {ds & newpaths = ds.newpaths || newpaths`, ok = ok}
| not ok
# (Pers inf) = compinfo
# (_,ps) = trace_n "exit compiler!" ExitCleanCompiler (inf,ps)
# (paths,ds) = ds!modpaths
= step intr (DGene paths SyncCodeGeneration ds) ps
# ds = {ds & modpaths = next :! ds.modpaths}
......@@ -861,6 +854,7 @@ step intr (DLink ds=:{ok, newpaths, fileinfo, libsinfo, modpaths, abccache, proj
# prj_path` = RemoveFilename prj_path
# execpath = PR_GetExecPath project
# prj_path` = PR_GetRootDir project
# execpath = fulPath app_path prj_path` execpath
# ps = showInfo (Level2 ("Linking '" +++ RemovePath execpath +++ "'")) ps
......@@ -935,29 +929,12 @@ step intr (DLink ds=:{ok, newpaths, fileinfo, libsinfo, modpaths, abccache, proj
= continue False newpaths False fileinfo libsinfo modpaths project intr (abccache, ps)
// project objects and dynamic libs
/* full paths again...
# (loobjsOk,ofiles,abcPathsCache)
= GetPathNames lo.extraObjectModules ofiles abcPathsCache
# (lolibsOk,lfiles,_)
= GetPathNames lo.libraries lfiles abcPathsCache
*/
# loobjsOk = True
# lolibsOk = True
# extraObjectModules = lo.extraObjectModules
# extraObjectModules = Map (append_object_file_extension_if_dot_at_end tp use_64_bit_processor) extraObjectModules
# ofiles = Concat extraObjectModules ofiles
# ofiles` = Concat extraObjectModules ofiles`
# lfiles = Concat lo.libraries lfiles
| not loobjsOk
# line = Level3 ["Link error: File: '" +++ (Head ofiles) +++ "' not found."]
# ps = showInfo line ps
= continue False newpaths False fileinfo libsinfo modpaths project intr (abccache, ps)
| not lolibsOk
# line = Level3 ["Link error: File: '" +++ (Head lfiles) +++ "' not found."]
# ps = showInfo line ps
= continue False newpaths False fileinfo libsinfo modpaths project intr (abccache, ps)
# (env_static_libs,ps) = getCurrentSlibs ps
#! sfiles = Concat (SL_Libs libsinfo) env_static_libs // only if really used?
#! ofiles = Reverse ofiles
......@@ -1393,8 +1370,7 @@ where
set defp ao ps
# (prj,ps) = getProject ps
# prj = PR_SetPaths False defp ao prj
# ps = setProject prj ps
= ps
= setProject prj ps
ProcessCompilerMsg cstate _ _ path abcpath SyntaxError fileinfo dircache abccache project ps
= (cstate,(ps, fileinfo, dircache,abccache,project, False, False, abcpath,Nil))
......
......@@ -8,12 +8,12 @@ import PmCompilerOptions
import PmTypes
ProjectTable :: OptionsTable ProjectGlobalOptions
project_table :: OptionsTable ProjectGlobalOptions
edit_options_table :: OptionsTable ProjectGlobalOptions
CompilerOptionsTable :: OptionsTable CompilerOptions
CodeGenOptionsTable :: OptionsTable CodeGenOptions
LinkOptionsTable :: OptionsTable LinkOptions
ApplicationOptionsTable :: OptionsTable ApplicationOptions
//ProjectOptionsTable :: OptionsTable ProjectOptions
ProjectFileVersion :== "1.4"
......
......@@ -70,28 +70,36 @@ EmptyUndefModule =
}
project_root_option = SimpleOption "ProjectRoot" (\a->a.pg_root_directory) (\v a->{a & pg_root_directory = v})
target_option = SimpleOption "Target" (\a->a.pg_target) (\v a->{a & pg_target=v})
code_gen_option = GroupedOption "CodeGen" CodeGenOptionsTable (\a->a.pg_codegen) (\v a->{a & pg_codegen=v})
application_option = GroupedOption "Application" ApplicationOptionsTable (\a->a.pg_application) (\v a->{a & pg_application=v})
link_option = GroupedOption "Link" LinkOptionsTable (\a->a.pg_link) (\v a->{a & pg_link=v})
paths_option = ListOption "Paths" PathName "" (\a->a.pg_projectPaths) (\v a->{a & pg_projectPaths=v})
static_option = GroupedOption "Static" StaticLibsInfoTable (\a->a.pg_staticLibInfo) (\v a->{a & pg_staticLibInfo=v})
precompile_option = SimpleOption "Precompile" (\a->unwrap a.pg_precompile)(\v a->{a & pg_precompile = wrap v})
postlink_option = SimpleOption "Postlink" (\a->unwrap a.pg_postlink) (\v a->{a & pg_postlink = wrap v})
// Making Precompile & Postlink 'List' options is probably prettier...
unwrap Nothing = ""
unwrap (Just s) = s
wrap "" = Nothing
wrap s = Just s
ProjectGlobalOptionsTable :: OptionsTable ProjectGlobalOptions
ProjectGlobalOptionsTable =
{ project_root_option
, SimpleOption "Built" (\a->a.pg_built) (\v a->{a & pg_built=v})
, SimpleOption "Target" (\a->a.pg_target) (\v a->{a & pg_target=v})
, target_option
, SimpleWithStringConversionOption convert_exec_path_separators_and_extension "Exec" (\a->a.pg_execpath) (\v a->{a & pg_execpath=v})
, GroupedOption "CodeGen" CodeGenOptionsTable (\a->a.pg_codegen) (\v a->{a & pg_codegen=v})
, GroupedOption "Application" ApplicationOptionsTable (\a->a.pg_application) (\v a->{a & pg_application=v})
, GroupedOption "Link" LinkOptionsTable (\a->a.pg_link) (\v a->{a & pg_link=v})
, ListOption "Paths" PathName "" (\a->a.pg_projectPaths) (\v a->{a & pg_projectPaths=v})
, GroupedOption "Static" StaticLibsInfoTable (\a->a.pg_staticLibInfo) (\v a->{a & pg_staticLibInfo=v})
, SimpleOption "Precompile" (\a->unwrap a.pg_precompile)(\v a->{a & pg_precompile = wrap v})
, SimpleOption "Postlink" (\a->unwrap a.pg_postlink) (\v a->{a & pg_postlink = wrap v})
, code_gen_option
, application_option
, link_option
, paths_option
, static_option
, precompile_option
, postlink_option
}
where
// Making Precompile & Postlink 'List' options is probably prettier...
unwrap Nothing = ""
unwrap (Just s) = s
wrap "" = Nothing
wrap s = Just s
instance fromString Bool
where
......@@ -100,41 +108,83 @@ where
fromString _
= True
name_option = SimpleOption "Name" (\a->a.name) (\v a->{a & name=v})
dir_option = SimpleWithStringConversionOption convert_path_separators "Dir" (\a->a.info.dir) (\v a->{a & info.dir=v})
compiler_option = GroupedOption "Compiler" CompilerOptionsTable (\a->a.info.compilerOptions)(\v a->{a & info.compilerOptions=v})
needed_obj_files_option = ListOption "NeededObjFiles" ObjectFile "" (\a->a.info.abcLinkInfo.linkObjFileNames)
(\v a->{a & info.abcLinkInfo.linkObjFileNames=v})
needed_libraries_option = ListOption "NeededLibraries" Library "" (\a->a.info.abcLinkInfo.linkLibraryNames)
(\v a->{a & info.abcLinkInfo.linkLibraryNames=v})
dcl_option = GroupedOption "Dcl" EditWdOptionsTable (\a->a.info.mod_edit_options.defeo) (\v a->{a & info.mod_edit_options.defeo=v})
dcl_open_option = SimpleOption "DclOpen" (\a->a.info.mod_edit_options.defopen) (\v a->{a & info.mod_edit_options.defopen=v})
icl_option = GroupedOption "Icl" EditWdOptionsTable (\a->a.info.mod_edit_options.impeo) (\v a->{a & info.mod_edit_options.impeo=v})
icl_open_option = SimpleOption "IclOpen" (\a->a.info.mod_edit_options.impopen) (\v a->{a & info.mod_edit_options.impopen=v})
ModInfoAndNameTable :: OptionsTable ModInfoAndName
ModInfoAndNameTable =
{ SimpleOption "Name" (\a->a.name) (\v a->{a & name=v})
, SimpleWithStringConversionOption convert_path_separators "Dir" (\a->a.info.dir) (\v a->{a & info.dir=v})
, GroupedOption "Compiler" CompilerOptionsTable (\a->a.info.compilerOptions)(\v a->{a & info.compilerOptions=v})
, GroupedOption "Dcl" EditWdOptionsTable (\a->a.info.defeo) (\v a->{a & info.defeo=v})
, SimpleOption "DclOpen" (\a->a.info.defopen) (\v a->{a & info.defopen=v})
, GroupedOption "Icl" EditWdOptionsTable (\a->a.info.impeo) (\v a->{a & info.impeo=v})
, SimpleOption "IclOpen" (\a->a.info.impopen) (\v a->{a & info.impopen=v})
, ListOption "NeededObjFiles" ObjectFile "" (\a->a.info.abcLinkInfo.linkObjFileNames)
(\v a->{a & info.abcLinkInfo.linkObjFileNames=v})
, ListOption "NeededLibraries" Library "" (\a->a.info.abcLinkInfo.linkLibraryNames)
(\v a->{a & info.abcLinkInfo.linkLibraryNames=v})
{ name_option
, dir_option
, compiler_option
, dcl_option
, dcl_open_option
, icl_option
, icl_open_option
, needed_obj_files_option
, needed_libraries_option
}
ModInfoAndNameEntry =
GroupedOption "Module" ModInfoAndNameTable id const
ModInfoAndNameEntry = GroupedOption "Module" ModInfoAndNameTable id const
prj_mod_info_and_name_table :: OptionsTable ModInfoAndName
prj_mod_info_and_name_table
= { name_option, dir_option, compiler_option, needed_obj_files_option, needed_libraries_option }
prj_mod_info_and_name_entry = GroupedOption "Module" prj_mod_info_and_name_table id const
prp_mod_info_and_name_table :: OptionsTable ModInfoAndName
prp_mod_info_and_name_table
= { name_option, dir_option, dcl_option, dcl_open_option, icl_option, icl_open_option }
prp_mod_info_and_name_entry = GroupedOption "Module" prp_mod_info_and_name_table id const
ProjectTable :: OptionsTable ProjectGlobalOptions
ProjectTable = // +++ order is important here
{ GroupedOption "Global" ProjectGlobalOptionsTable id const
, GroupedOption "MainModule" ModInfoAndNameTable (\a->a.pg_mainModuleInfo) (\v a->{a & pg_mainModuleInfo=v})
, ListOption "OtherModules" ModInfoAndNameEntry {info=EmptyModInfo,name=""} (\a->a.pg_otherModules) (\v a->{a & pg_otherModules=v})
ProjectTable
# main_module_option = GroupedOption "MainModule" ModInfoAndNameTable (\a->a.pg_mainModuleInfo) (\v a->{a & pg_mainModuleInfo=v})
# other_modules_option = ListOption "OtherModules" ModInfoAndNameEntry {info=EmptyModInfo,name=""} (\a->a.pg_otherModules) (\v a->{a & pg_otherModules=v})
= make_project_table main_module_option other_modules_option
project_table :: OptionsTable ProjectGlobalOptions
project_table
# main_module_option = GroupedOption "MainModule" prj_mod_info_and_name_table (\a->a.pg_mainModuleInfo) (\v a->{a & pg_mainModuleInfo=v})
# other_modules_option = ListOption "OtherModules" prj_mod_info_and_name_entry {info=EmptyModInfo,name=""} (\a->a.pg_otherModules) (\v a->{a & pg_otherModules=v})
= make_project_table main_module_option other_modules_option
edit_options_table :: OptionsTable ProjectGlobalOptions
edit_options_table
# main_module_option = GroupedOption "MainModule" prp_mod_info_and_name_table (\a->a.pg_mainModuleInfo) (\v a->{a & pg_mainModuleInfo=v})
# other_modules_option = ListOption "OtherModules" prp_mod_info_and_name_entry {info=EmptyModInfo,name=""} (\a->a.pg_otherModules) (\v a->{a & pg_otherModules=v})
= { main_module_option, other_modules_option }
make_project_table :: !(OptionsTableEntry ProjectGlobalOptions) !(OptionsTableEntry ProjectGlobalOptions) -> OptionsTable ProjectGlobalOptions
make_project_table main_module_option other_modules_option
= // +++ order is important here
{ GroupedOption "Global" ProjectGlobalOptionsTable id const
, main_module_option
, other_modules_option
, GroupedOption "Dynamic" DynamicInfoTable (\a->a.pg_dynamic) (\v a->{a & pg_dynamic=v})
}
EmptyModInfo :: ModInfo
EmptyModInfo
# defaultEditWdOptions = {eo=DefaultEditOptions,pos_size=NoWindowPosAndSize}
# mod_edit_options = {defeo=defaultEditWdOptions,impeo=defaultEditWdOptions,
defopen=False,impopen=False}
= { dir = EmptyPathname,
compilerOptions = DefaultCompilerOptions,
mod_edit_options = mod_edit_options,
abcLinkInfo = {linkObjFileNames = Nil, linkLibraryNames = Nil} }
where
EmptyModInfo :: ModInfo
EmptyModInfo = { dir = EmptyPathname,
compilerOptions = DefaultCompilerOptions,
defeo = {eo=DefaultEditOptions,pos_size=NoWindowPosAndSize},
impeo = {eo=DefaultEditOptions,pos_size=NoWindowPosAndSize},
defopen = False,
impopen = False,
abcLinkInfo = {linkObjFileNames = Nil, linkLibraryNames = Nil} }
DefaultEditOptions :: EditOptions;
DefaultEditOptions =
{ newlines = HostNativeNewlineConvention
......
implementation module PmProject
import StdClass,StdBool, StdInt, StdString,StdArray, StdFunc, StdTuple, StdList
import StdClass,StdBool,StdInt,StdString,StdArray,StdFunc,StdTuple,StdList,StdStrictLists
import StdMaybe
from StdOverloadedList import ++|,Hd
import PmPath, UtilStrictLists
from UtilDate import NoDate, :: DATE
import UtilNewlinesFile
......@@ -110,11 +111,8 @@ PR_NewProject main_module_file_name eo compilerOptions cgo ao prjpaths linkOptio
, inflist =
{ mn = modname
, info = { dir = "{Project}"//dirname
, defeo = eo
, impeo = eo
, compilerOptions = compilerOptions
, defopen = False
, impopen = True
, mod_edit_options = {defeo=eo,impeo=eo,defopen=False,impopen=True}
, abcLinkInfo = {linkObjFileNames = Nil, linkLibraryNames = Nil}
}
, src = True
......@@ -177,15 +175,13 @@ where
where
TryInsertImporter :: !InfList !InfList -> InfList
TryInsertImporter Nil list
# default_edit_options = {pos_size = NoWindowPosAndSize, eo = {newlines= HostNativeNewlineConvention}}
# item =
{ mn = importermn,
info = { dir = importerdir,
compilerOptions
= compilerOptions,
defeo = defeo,
impeo = impeo,
defopen = False,
impopen = False,
compilerOptions = compilerOptions,
mod_edit_options = {defeo = default_edit_options,impeo = default_edit_options,
defopen = False, impopen = False},
abcLinkInfo = {linkObjFileNames = Nil, linkLibraryNames = Nil} },
src = True,
abc = True }
......@@ -212,11 +208,11 @@ PR_SetRoot newroot eo compilerOptions project=:{prjpaths}
exec = False,
inflist = { mn = modname,
info = { dir = dirname,
defeo = eo,
impeo = eo,
compilerOptions = compilerOptions,
defopen = False, /* nonsense, we don't know this! */
impopen = True,
mod_edit_options = {defeo = eo,impeo = eo,
impopen = True,
defopen = False /* nonsense, we don't know this! */
},
abcLinkInfo = {linkObjFileNames = Nil, linkLibraryNames = Nil} },
src = True,
abc = True
......@@ -421,7 +417,7 @@ where
modnames = MapR GetModulenames inflist
GetModulenames :: !InfListItem -> List String
GetModulenames {mn,info={dir,defopen,impopen}}
GetModulenames {mn,info={dir,mod_edit_options={defopen,impopen}}}
| defopen && impopen = defname :! impname :! Nil
| defopen = defname :! Nil
| impopen = impname :! Nil
......@@ -523,14 +519,14 @@ where
unchanged = eqInfo info info`;
eqInfo :: !ModInfo !ModInfo -> Bool
eqInfo info1 info2
= info1.defeo.eo == info2.defeo.eo &&
info1.impeo.eo == info2.impeo.eo &&
eqInfo info1=:{mod_edit_options=mod_edit_options1} info2=:{mod_edit_options=mod_edit_options2}
= mod_edit_options1.defeo.eo == mod_edit_options2.defeo.eo &&
mod_edit_options1.impeo.eo == mod_edit_options2.impeo.eo &&
eqCO info1.compilerOptions info2.compilerOptions &&
info1.defeo.pos_size == info2.defeo.pos_size &&
info1.impeo.pos_size == info2.impeo.pos_size &&
info1.defopen == info2.defopen &&
info1.impopen == info2.impopen
mod_edit_options1.defeo.pos_size == mod_edit_options2.defeo.pos_size &&
mod_edit_options1.impeo.pos_size == mod_edit_options2.impeo.pos_size &&
mod_edit_options1.defopen == mod_edit_options2.defopen &&
mod_edit_options1.impopen == mod_edit_options2.impopen
eqCO :: !CompilerOptions !CompilerOptions -> Bool
eqCO co1 co2
......@@ -639,15 +635,14 @@ where
defaultModInfo :: ModInfo
defaultModInfo =
{ dir = EmptyPathname
, compilerOptions = DefaultCompilerOptions
, defeo = {eo=DefaultEditOptions,pos_size=NoWindowPosAndSize}
, impeo = {eo=DefaultEditOptions,pos_size=NoWindowPosAndSize}
, defopen = False
, impopen = False
{ dir = EmptyPathname
, compilerOptions = DefaultCompilerOptions
, mod_edit_options = { defeo = defaultEditWdOptions,impeo = defaultEditWdOptions,
defopen = False,impopen = False}
, abcLinkInfo = {linkObjFileNames = Nil, linkLibraryNames = Nil}
}
where
defaultEditWdOptions = {eo=DefaultEditOptions,pos_size=NoWindowPosAndSize}
DefaultEditOptions =
{ newlines = HostNativeNewlineConvention}
/* { tabs = 4
......@@ -781,13 +776,109 @@ SL_SetDeps lp sl = {sl & sDeps = lp}
SaveProjectFile :: !String !Project !String !*Files -> (!Bool, !*Files);
SaveProjectFile projectPath project applicationDir files
# (opened, file, files) = fopen projectPath FWriteText files
# (opened, prj_file, files) = fopen projectPath FWriteText files
| not opened
= (False, files)
#! projectGO = GetProject applicationDir project
#! options = PutOptions ProjectTable projectGO
#! file = WriteOptionsFile ProjectFileVersion options file
= fclose file files
# prp_path = RemoveSuffix` projectPath +++ ".prp"
# (opened, prp_file, files) = fopen prp_path FWriteText files
| not opened
# (_,files) = fclose prj_file files
= (False, files)
#! projectGO = GetProject applicationDir project
# projectGO = sort_modules projectGO
# prj_file = WriteOptionsFile ProjectFileVersion (PutOptions project_table projectGO) prj_file
# prp_file = WriteOptionsFile ProjectFileVersion (PutOptions edit_options_table projectGO) prp_file
#! (prj_ok, files) = fclose prj_file files
#! (prp_ok, files) = fclose prp_file files
= (prj_ok && prp_ok, files)
sort_modules :: !ProjectGlobalOptions -> ProjectGlobalOptions
sort_modules projectGO=:{pg_projectPaths,pg_otherModules}
# project_paths = {project_path \\ project_path<|-pg_projectPaths}
# n_project_paths = size project_paths
# (project_modules,other_modules) = collect_project_modules pg_otherModules (createArray n_project_paths [!!]) project_paths
# pg_otherModules = append_project_modules 0 project_modules other_modules
= {projectGO & pg_otherModules=pg_otherModules}
where
collect_project_modules :: ![!ModInfoAndName!] !*{![!ModInfoAndName!]} !{#Pathname} -> (!*{![!ModInfoAndName!]},![!ModInfoAndName!])
collect_project_modules [!mod=:{ModInfoAndName|info={dir}}:mods!] project_modules project_paths
# path_index = find_path dir 0 project_paths
| path_index>=0
# (modules_in_dir,project_modules) = project_modules![path_index]
# project_modules = {project_modules & [path_index] = [!mod:modules_in_dir!]}
= collect_project_modules mods project_modules project_paths
# (project_modules,other_modules) = collect_project_modules mods project_modules project_paths
= (project_modules,[!mod:other_modules!])
collect_project_modules [!!] project_modules project_paths
= (project_modules,[!!])
find_path :: !{#Char} !Int !{#{#Char}} -> Int
find_path dir i project_paths
| i<size project_paths
| project_paths.[i]==dir
= i
= find_path dir (i+1) project_paths
= -1
append_project_modules :: !Int !{![!ModInfoAndName!]} [!ModInfoAndName!] -> [!ModInfoAndName!]
append_project_modules i project_modules other_modules
| i<size project_modules
= sort_by_name project_modules.[i] ++| append_project_modules (i+1) project_modules other_modules
= sort_by_dir_and_name other_modules
sort_by_name :: !u:[!ModInfoAndName!] -> u:[!ModInfoAndName!]
sort_by_name l = Hd (msort (pair l)) // mergesort
where
pair [|x1,x2:xs]
| x2.name < x1.name
= [[|x2,x1]:pair xs];
= [[|x1,x2]:pair xs];
pair x = [|x];
msort [|x1,x2:xs] = msort (merge_stage [|x1,x2:xs]);
msort x = x;
merge_stage [|xs1,xs2:xxs] = [|merge xs1 xs2 : merge_stage xxs];
merge_stage x = x;
merge :: !u:[!ModInfoAndName!] !v:[!ModInfoAndName!] -> w:[!ModInfoAndName!], [u v <= w];
merge [|] y = y
merge f=:[|x:xs] [|] = f
merge f=:[|x:xs] s=:[|y:ys]
| y.name < x.name
= [|y:merge f ys]
= [|x:merge xs s]
sort_by_dir_and_name :: !u:[!ModInfoAndName!] -> u:[!ModInfoAndName!]
sort_by_dir_and_name l = Hd (msort (pair l)) // mergesort
where
pair [|x1,x2:xs]
| x2.ModInfoAndName.info.dir == x1.ModInfoAndName.info.dir
| x2.name < x1.name
= [[|x2,x1]:pair xs];
= [[|x1,x2]:pair xs];
| x2.ModInfoAndName.info.dir < x1.ModInfoAndName.info.dir
= [[|x2,x1]:pair xs];
= [[|x1,x2]:pair xs];
pair x = [|x];
msort [|x1,x2:xs] = msort (merge_stage [|x1,x2:xs]);
msort x = x;
merge_stage [|xs1,xs2:xxs] = [|merge xs1 xs2 : merge_stage xxs];
merge_stage x = x;
merge :: !u:[!ModInfoAndName!] !v:[!ModInfoAndName!] -> w:[!ModInfoAndName!], [u v <= w];
merge [|] y = y
merge f=:[|x:xs] [|] = f
merge f=:[|x:xs] s=:[|y:ys]
| y.ModInfoAndName.info.dir == x.ModInfoAndName.info.dir
| y.name < x.name
= [|y:merge f ys]
= [|x:merge xs s]
| y.ModInfoAndName.info.dir < x.ModInfoAndName.info.dir
= [|y:merge f ys]
= [|x:merge xs s]
ReadProjectFile :: !String !String !*Files -> (!(!Project, !Bool, !{#Char}),!*Files)
ReadProjectFile projectPath applicationDir files
......@@ -802,8 +893,10 @@ ReadProjectFile projectPath applicationDir files
# (_, files) = fclose file files
= ((emptyProject,False,"The file \"" +++ projectName +++ "\" is an old project and could not be opened."),files)
#! (options, file) = ReadOptionsFile file
projectGO = GetProject applicationDir emptyProject
projectGO = GetOptions ProjectTable options projectGO
empty_projectGO = GetProject applicationDir emptyProject
projectGO = GetOptions ProjectTable options empty_projectGO
(projectGO,files)
= add_edit_options_from_prp_file (RemoveSuffix` projectPath +++ ".prp") projectGO empty_projectGO files
projectGO = (if (version == "1.3")
(\p->{p&pg_target="StdEnv"})
(id)
......@@ -819,6 +912,49 @@ ReadProjectFile projectPath applicationDir files
= ((project, True,"The file \"" +++ projectName +++ "\" could not be closed."), files)
= ((project, True,""), files)
add_edit_options_from_prp_file :: !String !ProjectGlobalOptions !ProjectGlobalOptions !*Files -> (!ProjectGlobalOptions, !*Files)
add_edit_options_from_prp_file prp_path projectGO empty_projectGO files
# (opened, prp_file, files) = fopen prp_path FReadData files
| not opened
= (projectGO, files)
# (version, prp_file) = ReadVersion prp_file
| size version==0
= (projectGO, files)
# (options,prp_file) = ReadOptionsFile prp_file
#! edit_projectGO = GetOptions ProjectTable options empty_projectGO
# (closed, files) = fclose prp_file files
| not closed
= (projectGO, files)
# projectGO = add_edit_options edit_projectGO projectGO