From e2105c68d09ac51010b321576f14cffb8725a837 Mon Sep 17 00:00:00 2001 From: Jurrien Stutterheim Date: Wed, 18 Nov 2015 07:51:40 +0000 Subject: [PATCH] CPM: Deal with different paths on Windows --- CpmLinux.prj | 1 + CpmMacOSX.prj | 156 +++++++++++++++++++++------------------ CpmWin.prj | 1 + cpm/CpmLogic.icl | 122 +++++++++++++++--------------- cpm/Posix/CpmPaths.dcl | 6 ++ cpm/Posix/CpmPaths.icl | 8 ++ cpm/Windows/CpmPaths.dcl | 6 ++ cpm/Windows/CpmPaths.icl | 8 ++ 8 files changed, 179 insertions(+), 129 deletions(-) create mode 100644 cpm/Posix/CpmPaths.dcl create mode 100644 cpm/Posix/CpmPaths.icl create mode 100644 cpm/Windows/CpmPaths.dcl create mode 100644 cpm/Windows/CpmPaths.icl diff --git a/CpmLinux.prj b/CpmLinux.prj index f61cc98..d10f218 100644 --- a/CpmLinux.prj +++ b/CpmLinux.prj @@ -37,6 +37,7 @@ Global ExportedNames: Paths Path: {Project}/cpm + Path: {Project}/cpm/Posix Path: {Application}/lib/ArgEnv Path: {Application}/lib/Directory Path: {Application}/lib/Generics diff --git a/CpmMacOSX.prj b/CpmMacOSX.prj index 431f188..84aacbb 100644 --- a/CpmMacOSX.prj +++ b/CpmMacOSX.prj @@ -16,6 +16,7 @@ Global ShowGC: False ShowStackSize: False MarkingCollector: False + DisableRTSFlags: False StandardRuntimeEnv: True Profile Memory: False @@ -37,13 +38,14 @@ Global ExportedNames: Paths Path: {Project}/cpm + Path: {Project}/cpm/Posix + Path: {Project}/BatchBuild Path: {Application}/lib/ArgEnv Path: {Application}/lib/Directory Path: {Application}/lib/Generics Path: {Project}/Pm Path: {Project}/MacOSX Path: {Project}/Util - Path: {Project}/BatchBuild Path: {Project}/Interfaces/LinkerInterface Path: {Application}/lib/clean-platform/OS-Independent Path: {Application}/lib/clean-platform/OS-Independent/Deprecated/StdLib @@ -109,8 +111,8 @@ OtherModules ReuseUniqueNodes: True Fusion: False Module - Name: Directory - Dir: {Application}/lib/Directory + Name: CpmPaths + Dir: {Project}/cpm/Posix Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -122,11 +124,9 @@ OtherModules ReadableABC: False ReuseUniqueNodes: True Fusion: False - NeededObjFiles - ObjectFile: cDirectory. Module - Name: GenEq - Dir: {Application}/lib/Generics + Name: IdeState + Dir: {Project}/BatchBuild Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -139,8 +139,8 @@ OtherModules ReuseUniqueNodes: True Fusion: False Module - Name: PmAbcMagic - Dir: {Project}/Pm + Name: PmCallBack + Dir: {Project}/BatchBuild Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -153,8 +153,8 @@ OtherModules ReuseUniqueNodes: True Fusion: False Module - Name: PmCompilerOptions - Dir: {Project}/Pm + Name: PmDialogues + Dir: {Project}/BatchBuild Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -167,8 +167,8 @@ OtherModules ReuseUniqueNodes: True Fusion: False Module - Name: PmDirCache - Dir: {Project}/Pm + Name: errwin + Dir: {Project}/BatchBuild Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -181,8 +181,8 @@ OtherModules ReuseUniqueNodes: True Fusion: False Module - Name: PmDriver - Dir: {Project}/Pm + Name: messwin + Dir: {Project}/BatchBuild Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -195,8 +195,8 @@ OtherModules ReuseUniqueNodes: True Fusion: False Module - Name: PmEnvironment - Dir: {Project}/Pm + Name: projwin + Dir: {Project}/BatchBuild Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -209,8 +209,8 @@ OtherModules ReuseUniqueNodes: True Fusion: False Module - Name: PmFileInfo - Dir: {Project}/Pm + Name: typeatt + Dir: {Project}/BatchBuild Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -223,8 +223,8 @@ OtherModules ReuseUniqueNodes: True Fusion: False Module - Name: PmFiles - Dir: {Project}/Pm + Name: typewin + Dir: {Project}/BatchBuild Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -237,8 +237,8 @@ OtherModules ReuseUniqueNodes: True Fusion: False Module - Name: PmParse - Dir: {Project}/Pm + Name: Directory + Dir: {Application}/lib/Directory Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -250,8 +250,24 @@ OtherModules ReadableABC: False ReuseUniqueNodes: True Fusion: False + NeededObjFiles + ObjectFile: cDirectory. Module - Name: PmPath + Name: GenEq + Dir: {Application}/lib/Generics + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False + Module + Name: PmAbcMagic Dir: {Project}/Pm Compiler NeverMemoryProfile: False @@ -265,7 +281,7 @@ OtherModules ReuseUniqueNodes: True Fusion: False Module - Name: PmProject + Name: PmCompilerOptions Dir: {Project}/Pm Compiler NeverMemoryProfile: False @@ -279,7 +295,7 @@ OtherModules ReuseUniqueNodes: True Fusion: False Module - Name: PmTypes + Name: PmDirCache Dir: {Project}/Pm Compiler NeverMemoryProfile: False @@ -293,8 +309,8 @@ OtherModules ReuseUniqueNodes: True Fusion: False Module - Name: Platform - Dir: {Project}/MacOSX + Name: PmDriver + Dir: {Project}/Pm Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -307,8 +323,8 @@ OtherModules ReuseUniqueNodes: True Fusion: False Module - Name: PmCleanSystem - Dir: {Project}/MacOSX + Name: PmEnvironment + Dir: {Project}/Pm Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -321,8 +337,8 @@ OtherModules ReuseUniqueNodes: True Fusion: False Module - Name: UtilIO - Dir: {Project}/MacOSX + Name: PmFileInfo + Dir: {Project}/Pm Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -335,8 +351,8 @@ OtherModules ReuseUniqueNodes: True Fusion: False Module - Name: UtilNewlinesFile - Dir: {Project}/MacOSX + Name: PmFiles + Dir: {Project}/Pm Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -349,8 +365,8 @@ OtherModules ReuseUniqueNodes: True Fusion: False Module - Name: set_return_code - Dir: {Project}/MacOSX + Name: PmParse + Dir: {Project}/Pm Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -363,8 +379,8 @@ OtherModules ReuseUniqueNodes: True Fusion: False Module - Name: StdPathname - Dir: {Project}/Util + Name: PmPath + Dir: {Project}/Pm Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -377,8 +393,8 @@ OtherModules ReuseUniqueNodes: True Fusion: False Module - Name: UtilDate - Dir: {Project}/Util + Name: PmProject + Dir: {Project}/Pm Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -391,8 +407,8 @@ OtherModules ReuseUniqueNodes: True Fusion: False Module - Name: UtilOptions - Dir: {Project}/Util + Name: PmTypes + Dir: {Project}/Pm Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -405,8 +421,8 @@ OtherModules ReuseUniqueNodes: True Fusion: False Module - Name: UtilStrictLists - Dir: {Project}/Util + Name: Platform + Dir: {Project}/MacOSX Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -419,8 +435,8 @@ OtherModules ReuseUniqueNodes: True Fusion: False Module - Name: logfile - Dir: {Project}/Util + Name: PmCleanSystem + Dir: {Project}/MacOSX Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -433,8 +449,8 @@ OtherModules ReuseUniqueNodes: True Fusion: False Module - Name: IdeState - Dir: {Project}/BatchBuild + Name: UtilIO + Dir: {Project}/MacOSX Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -447,8 +463,8 @@ OtherModules ReuseUniqueNodes: True Fusion: False Module - Name: PmCallBack - Dir: {Project}/BatchBuild + Name: UtilNewlinesFile + Dir: {Project}/MacOSX Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -461,8 +477,8 @@ OtherModules ReuseUniqueNodes: True Fusion: False Module - Name: PmDialogues - Dir: {Project}/BatchBuild + Name: set_return_code + Dir: {Project}/MacOSX Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -475,8 +491,8 @@ OtherModules ReuseUniqueNodes: True Fusion: False Module - Name: errwin - Dir: {Project}/BatchBuild + Name: StdPathname + Dir: {Project}/Util Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -489,8 +505,8 @@ OtherModules ReuseUniqueNodes: True Fusion: False Module - Name: messwin - Dir: {Project}/BatchBuild + Name: UtilDate + Dir: {Project}/Util Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -503,8 +519,8 @@ OtherModules ReuseUniqueNodes: True Fusion: False Module - Name: projwin - Dir: {Project}/BatchBuild + Name: UtilOptions + Dir: {Project}/Util Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -517,8 +533,8 @@ OtherModules ReuseUniqueNodes: True Fusion: False Module - Name: typeatt - Dir: {Project}/BatchBuild + Name: UtilStrictLists + Dir: {Project}/Util Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -531,8 +547,8 @@ OtherModules ReuseUniqueNodes: True Fusion: False Module - Name: typewin - Dir: {Project}/BatchBuild + Name: logfile + Dir: {Project}/Util Compiler NeverMemoryProfile: False NeverTimeProfile: False @@ -643,7 +659,7 @@ OtherModules ReuseUniqueNodes: True Fusion: False Module - Name: Data.IO + Name: Data.List Dir: {Application}/lib/clean-platform/OS-Independent Compiler NeverMemoryProfile: False @@ -657,7 +673,7 @@ OtherModules ReuseUniqueNodes: True Fusion: False Module - Name: Data.List + Name: Data.Maybe Dir: {Application}/lib/clean-platform/OS-Independent Compiler NeverMemoryProfile: False @@ -671,7 +687,7 @@ OtherModules ReuseUniqueNodes: True Fusion: False Module - Name: Data.Maybe + Name: Data.Monoid Dir: {Application}/lib/clean-platform/OS-Independent Compiler NeverMemoryProfile: False @@ -685,7 +701,7 @@ OtherModules ReuseUniqueNodes: True Fusion: False Module - Name: Data.Monoid + Name: Data.Tuple Dir: {Application}/lib/clean-platform/OS-Independent Compiler NeverMemoryProfile: False @@ -699,7 +715,7 @@ OtherModules ReuseUniqueNodes: True Fusion: False Module - Name: Data.Tuple + Name: Data.Void Dir: {Application}/lib/clean-platform/OS-Independent Compiler NeverMemoryProfile: False @@ -713,7 +729,7 @@ OtherModules ReuseUniqueNodes: True Fusion: False Module - Name: Data.Void + Name: System.CommandLine Dir: {Application}/lib/clean-platform/OS-Independent Compiler NeverMemoryProfile: False @@ -727,7 +743,7 @@ OtherModules ReuseUniqueNodes: True Fusion: False Module - Name: System.CommandLine + Name: System.FilePath Dir: {Application}/lib/clean-platform/OS-Independent Compiler NeverMemoryProfile: False @@ -741,7 +757,7 @@ OtherModules ReuseUniqueNodes: True Fusion: False Module - Name: System.FilePath + Name: System.IO Dir: {Application}/lib/clean-platform/OS-Independent Compiler NeverMemoryProfile: False diff --git a/CpmWin.prj b/CpmWin.prj index c8238a5..491e538 100644 --- a/CpmWin.prj +++ b/CpmWin.prj @@ -37,6 +37,7 @@ Global ExportedNames: Paths Path: {Project}\cpm + Path: {Project}\cpm\Windows Path: {Application}\Libraries\ArgEnv Path: {Application}\Libraries\Directory Path: {Application}\Libraries\Generics diff --git a/cpm/CpmLogic.icl b/cpm/CpmLogic.icl index 554f0c9..11112d5 100644 --- a/cpm/CpmLogic.icl +++ b/cpm/CpmLogic.icl @@ -3,7 +3,7 @@ implementation module CpmLogic /** * CPM imports */ -import AbsSyn +import AbsSyn, CpmPaths /** * CleanIDE imports @@ -76,27 +76,28 @@ getLine world doProjectAction :: String String String ProjectAction *World -> *World doProjectAction cleanhome pwd pn CreateProject world //Check if main module exists - # (exists,world) = fileExists 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 + # (exists,world) = fileExists 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 = if (line.[0] == 'y') (mkMainAndProject world) (error ("Failed to create project. Need " +++ mainmodule) world) - = mkProject world + | otherwise = mkProject world where - basefilename = dropExtension pn - mainmodule = addExtension basefilename "icl" - projectfile = mkProjectFile basefilename //addExtension basefilename "prj" - edit_options = {eo={newlines=NewlineConventionUnix},pos_size=NoWindowPosAndSize} - project = PR_SetRoot mainmodule edit_options compilerOptions prj - //Create project file using the Clean IDE libraries - where prj = PR_NewProject mainmodule edit_options compilerOptions DefCodeGenOptions - DefApplicationOptions [!!] DefaultLinkOptions + basefilename = dropExtension pn + mainmodule = addExtension basefilename "icl" + mkMainAndProject world # world = doModuleAction "" mainmodule (CreateModule ApplicationModule) world = mkProject world mkProject world - # (prjok, world) = accFiles (SaveProjectFile projectfile project cleanhome) world - | not prjok = error ("Could not create project file " +++ projectfile) 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 = mkProjectFile basefilename //addExtension basefilename "prj" + # (prjok, world) = accFiles (SaveProjectFile projectfile project cleanhome) world + | not prjok = error ("Could not create project file " +++ projectfile) world = world doProjectAction cleanhome pwd pn ShowProject world @@ -111,16 +112,17 @@ doProjectAction cleanhome pwd pn ShowProject world ] world doProjectAction cleanhome pwd pn (BuildProject force ideenvs) world - # (envs, world) = openEnvironments cleanhome (cleanhome "etc" ideenvs) world - # ((proj, ok, err), world) = accFiles (ReadProjectFile proj_path cleanhome) world - | not ok || err <> "" = error ("CPM failed while opening project: " +++ err +++ "\n") world - # (console, world) = stdio world - # iniGeneral = initGeneral True compilerOptions cleanhome proj_path proj envs console - # {ls, gst_world} = pinit force {ls=iniGeneral,gst_world=world,gst_continue_or_stop=False} + # (envs, world) = readIDEEnvs cleanhome ideenvs world + # proj_path = GetLongPathName pn + # ((proj, ok, err), world) = accFiles (ReadProjectFile proj_path cleanhome) world + | not ok || err <> "" = error ("CPM failed while opening project: " +++ err +++ "\n") world + # (console, world) = stdio world + # iniGeneral = initGeneral True compilerOptions cleanhome proj_path proj envs console + # {ls, gst_world} = pinit force {ls=iniGeneral,gst_world=world,gst_continue_or_stop=False} = gst_world - where proj_path = GetLongPathName pn - pinit force_rebuild gst = BringProjectUptoDate force_rebuild cleanup gst - cleanup exepath bool1 bool2 ps = abortLog False "" ps + where + pinit force_rebuild gst = BringProjectUptoDate force_rebuild cleanup gst + cleanup exepath bool1 bool2 ps = abortLog False "" ps doProjectAction cleanhome _ pn (ProjectPath pa) world # projectfile = mkProjectFile pn @@ -186,8 +188,8 @@ mkProjectFile pn = addExtension (dropExtension pn) "prj" */ withProject :: !String !String (Project -> Project) *World -> *World withProject cleanhome pn f world - # projectfile = mkProjectFile pn - # (project, world) = openProject cleanhome projectfile world + # projectfile = mkProjectFile pn + # (project, world) = openProject cleanhome projectfile world = saveProject cleanhome (f project) projectfile world /** @@ -227,10 +229,10 @@ showPaths project = map f (zip2 [0..] (StrictListToList (PR_GetPaths project))) */ doModPaths :: !String !String !Project ([!String!] -> [!String!]) *World -> *World doModPaths cleanhome pn project f world - # world = saveProject cleanhome prj pn world + # paths = PR_GetPaths project + # prj = PR_SetPaths False paths (f paths) project + # world = saveProject cleanhome prj pn world = showLines ["Successfully modified project paths"] world - where paths = PR_GetPaths project - prj = PR_SetPaths False paths (f paths) project /** * Open a project file @@ -238,8 +240,8 @@ doModPaths cleanhome pn project f world openProject :: !FilePath !FilePath !*World -> (!Project, !*World) openProject cleanhome projectfile world # ((prj, ok, err), world) = accFiles (ReadProjectFile projectfile cleanhome) world - | ok = (prj, world) - = (prj, error err world) + | ok = (prj, world) + | otherwise = (prj, error err world) /** * Save a project back to its project file @@ -247,8 +249,8 @@ openProject cleanhome projectfile world saveProject :: !FilePath !Project !FilePath !*World -> *World saveProject cleanhome prj projectfile world # (ok, world) = accFiles (SaveProjectFile projectfile prj cleanhome) world - | not ok = error "Error saving project" world - = world + | not ok = error "Error saving project" world + | otherwise = world /** * Remove an item from a strict list at a given index. Abort execution if the @@ -288,28 +290,29 @@ doModuleAction _ mn (CreateModule mt) world # (iclexists, world) = fileExists iclnm world | iclexists = error ("Implementation module '" +++ iclnm +++ "' already exists.") world = writeMods mt world - where basenm = dropExtension mn - dclnm = addExtension basenm "dcl" - iclnm = addExtension basenm "icl" + where + basenm = dropExtension mn + dclnm = addExtension basenm "dcl" + iclnm = addExtension basenm "icl" - mkmod mty = mty +++ "module " +++ basenm + mkmod mty = mty +++ "module " +++ basenm - writeMods ApplicationModule world = writeicl ApplicationModule world - writeMods LibraryModule world - # world = writeicl ApplicationModule world - = writedcl world + writeMods ApplicationModule world = writeicl ApplicationModule world + writeMods LibraryModule world + # world = writeicl ApplicationModule world + = writedcl world - writeicl ApplicationModule world = writeicl` "" world - writeicl LibraryModule world = writeicl` "implementation " world + writeicl ApplicationModule world = writeicl` "" world + writeicl LibraryModule world = writeicl` "implementation " world - writeicl` pref world = writemod iclnm pref ("Failed to write implementation module '" +++ basenm +++ "'") world + writeicl` pref world = writemod iclnm pref ("Failed to write implementation module '" +++ basenm +++ "'") world - writedcl world = writemod dclnm "definition " ("Failed to write definition module '" +++ basenm +++ "'") world + writedcl world = writemod dclnm "definition " ("Failed to write definition module '" +++ basenm +++ "'") world - writemod nm pref errmsg world - # (me, world) = writeFile nm (mkmod pref) world - | isError me = error errmsg world - = world + writemod nm pref errmsg world + # (me, world) = writeFile nm (mkmod pref) world + | isError me = error errmsg world + = world doModuleAction _ _ _ world = help "cpm module " @@ -324,19 +327,20 @@ doModuleAction _ _ _ world = */ error :: !String !*World -> *World error message world - # stderr = fwrites message stderr - # (ok,world) = fclose stderr world + # stderr = fwrites message stderr + # (ok,world) = fclose stderr world = set_return_code_world (-1) world /** * Show a help message */ help :: !String ![String] !*World -> *World -help cmd lines world = showLines lines` world - where lines` = [ "CPM: Clean Project Manager" - : "" - : "Usage: " +++ cmd - : lines] +help cmd lines world + # lines` = [ "CPM: Clean Project Manager" + : "" + : "Usage: " +++ cmd + : lines] + = showLines lines` world /** * Given a list of strings, concatenate them to a single string with newlines @@ -344,6 +348,6 @@ help cmd lines world = showLines lines` world */ showLines :: ![String] !*World -> *World showLines lines world - # (console, world) = stdio world - # console = seqSt (\s -> fwrites (s +++ "\n")) lines console + # (console, world) = stdio world + # console = seqSt (\s -> fwrites (s +++ "\n")) lines console = snd $ fclose console world diff --git a/cpm/Posix/CpmPaths.dcl b/cpm/Posix/CpmPaths.dcl new file mode 100644 index 0000000..3c5eba2 --- /dev/null +++ b/cpm/Posix/CpmPaths.dcl @@ -0,0 +1,6 @@ +definition module CpmPaths + +import PmEnvironment + +readIDEEnvs :: !String !String !*World -> *([Target], *World) + diff --git a/cpm/Posix/CpmPaths.icl b/cpm/Posix/CpmPaths.icl new file mode 100644 index 0000000..3c224fc --- /dev/null +++ b/cpm/Posix/CpmPaths.icl @@ -0,0 +1,8 @@ +implementation module CpmPaths + +import PmEnvironment +import System.FilePath + +readIDEEnvs :: !String !String !*World -> *([Target], *World) +readIDEEnvs cleanhome ideenvs world = openEnvironments cleanhome (cleanhome "etc" ideenvs) world + diff --git a/cpm/Windows/CpmPaths.dcl b/cpm/Windows/CpmPaths.dcl new file mode 100644 index 0000000..3c5eba2 --- /dev/null +++ b/cpm/Windows/CpmPaths.dcl @@ -0,0 +1,6 @@ +definition module CpmPaths + +import PmEnvironment + +readIDEEnvs :: !String !String !*World -> *([Target], *World) + diff --git a/cpm/Windows/CpmPaths.icl b/cpm/Windows/CpmPaths.icl new file mode 100644 index 0000000..1922e8c --- /dev/null +++ b/cpm/Windows/CpmPaths.icl @@ -0,0 +1,8 @@ +implementation module CpmPaths + +import PmEnvironment +import System.FilePath + +readIDEEnvs :: !String !String !*World -> *([Target], *World) +readIDEEnvs cleanhome ideenvs world = openEnvironments cleanhome (cleanhome "Config" ideenvs) world + -- GitLab