buildsystem, epj2make, ide: support Emscripten compiler.
[sdk] / ide / src / project / Workspace.ec
index a534a5f..6f126a0 100644 (file)
@@ -1,8 +1,6 @@
 import "ide"
 
-//bool eString_PathInsideOf(char * path, char * of);
-
-static void ParseListValue(List<String> list, char * equal)
+/*static void ParseListValue(List<String> list, char * equal)
 {
    char * start, * comma;
    char * string;
@@ -21,9 +19,32 @@ static void ParseListValue(List<String> list, char * equal)
       start = comma;
    }
    delete string;
-}
+}*/
 
 enum OpenedFileState { unknown, opened, closed };
+enum ValgrindLeakCheck
+{
+   no, summary, yes, full;
+
+   property const char *
+   {
+      get { return OnGetString(null, null, null); }
+   }
+
+   const char * OnGetString(char * tempString, void * fieldData, bool * needClass)
+   {
+      if(this >= no && this <= full)
+      {
+         if(tempString)
+            strcpy(tempString, valgrindLeakCheckNames[this]);
+         return valgrindLeakCheckNames[this];
+      }
+      if(tempString && tempString[0])
+         tempString[0] = '\0';
+      return null;
+   }
+};
+static const char * valgrindLeakCheckNames[ValgrindLeakCheck] = { "no", "summary", "yes", "full" };
 
 class OpenedFileInfo
 {
@@ -60,7 +81,7 @@ class OpenedFileInfo
          ide.workspace.modified = true;
       }
    }
-   
+
    void Activate()
    {
       if(trackingAllowed)
@@ -71,9 +92,13 @@ class OpenedFileInfo
          {
             files.Move(it.pointer, files.GetPrev(files.GetLast()));
             ide.workspace.modified = true;
-         } 
+         }
       }
    }
+   ~OpenedFileInfo()
+   {
+      delete path;
+   }
 };
 
 class Workspace
@@ -83,13 +108,13 @@ public:
    char * workspaceFile;
    char * workspaceDir;
    char * commandLineArgs;
-   property char * commandLineArgs { set { delete commandLineArgs; if(value) commandLineArgs = CopyString(value); } }
+   property const char * commandLineArgs { set { delete commandLineArgs; if(value) commandLineArgs = CopyString(value); } }
    char * debugDir;
-   property char * debugDir { set { delete debugDir; if(value) debugDir = CopyString(value); } }
+   property const char * debugDir { set { delete debugDir; if(value) debugDir = CopyString(value); } }
 
    int bpCount;
 
-   property char * compiler
+   property const char * compiler
    {
       set { delete compiler; if(value && value[0]) compiler = CopyString(value); }
       get { return compiler && compiler[0] ? compiler : null; }
@@ -118,7 +143,7 @@ public:
       }
    };
 
-   property char * workspaceFile
+   property const char * workspaceFile
    {
       set
       {
@@ -132,7 +157,7 @@ public:
       get { return workspaceFile; }
    }
 
-   property char * projectDir
+   property const char * projectDir
    {
       get
       {
@@ -157,7 +182,7 @@ public:
          if(project)
          {
             projectDir = CopyString(project.topNode.path);
-            
+
             if(!project.config && activeConfig && activeConfig[0])
             {
                ProjectConfig cfg;
@@ -175,13 +200,22 @@ public:
 
 private:
    String compiler;
+   int bitDepth;
+   // TODO: save these new settings when json format is ready
+   bool useValgrind;
+   ValgrindLeakCheck vgLeakCheck;
+   bool vgTrackOrigins;
+   int vgRedzoneSize;
+
+   vgRedzoneSize = -1;
+   vgLeakCheck = summary;
 
 public:
    void Save()
    {
       bool bkpts = false;
       File file;
-      
+
       file = FileOpen(workspaceFile, write);
       if(file)
       {
@@ -196,16 +230,16 @@ public:
                   file.Printf("Breakpoint=0,%d,%s,%s\n", bp.line, bp.absoluteFilePath, bp.relativeFilePath);
             }
          }
-         
+
          for(wh : watches)
             file.Printf("Watch=%s\n", wh.expression);
-         
+
          for(dir : sourceDirs)
             file.Printf("SourceDir=%s\n", dir);
 
          if(debugDir && debugDir[0])
             file.Printf("DebugDir=%s\n", debugDir);
-         
+
          if(commandLineArgs && commandLineArgs[0])
             file.Printf("CommandLineArgs=%s\n", commandLineArgs);
          */
@@ -218,7 +252,8 @@ public:
          file.Printf("\nVersion 0.02\n");
          file.Printf("\nWorkspace\n");
          file.Printf("\n   Active Compiler = %s\n", compiler ? compiler : defaultCompilerName);
-         
+         file.Printf("\n   Active Bit Depth = %d\n", bitDepth);
+
          if(projects.first)
          {
             file.Printf("\n   Projects\n\n");
@@ -231,7 +266,7 @@ public:
                //strcat(location, ".epj");
 
                file.Printf("    %s %s\n", "-", location);
-               
+
                if(prj.config)
                   file.Printf("         Active Configuration = %s\n", prj.config.name);
                for(cfg : prj.configurations)
@@ -243,8 +278,30 @@ public:
                }
             }
          }
-         
+
+         file.Printf("\n   Execution Data\n");
+         if(commandLineArgs && commandLineArgs[0])
+         {
+            file.Printf("\n      Command Line Arguments = ");
+            file.Puts(commandLineArgs);
+            file.Printf("\n");
+         }
+
+         if(environmentVars.count)
+         {
+            file.Printf("\n      Environment Variables\n\n");
+            for(v : environmentVars)
+            {
+               file.Printf("       ~ ");
+               file.Puts(v.name);
+               file.Printf(" = ");
+               file.Puts(v.string);
+               file.Printf("\n");
+            }
+         }
+
          file.Printf("\n   Debugger Data\n");
+         // This really belonged in Execution Data...
          if(debugDir && debugDir[0])
             file.Printf("\n      Debug Working Directory = %s\n", debugDir);
          if(sourceDirs.count)
@@ -282,7 +339,7 @@ public:
                char * location;
                char chr[2];
                char relativePath[MAX_LOCATION];
-               if(eString_PathInsideOf(ofi.path, workspaceDir))
+               if(IsPathInsideOf(ofi.path, workspaceDir))
                {
                   MakePathRelative(ofi.path, workspaceDir, relativePath);
                   MakeSlashPath(relativePath);
@@ -301,16 +358,17 @@ public:
       }
    }
 
-   char * GetAbsolutePathFromRelative(char * relative)
+   char * CopyAbsolutePathFromRelative(const char * relative)
    {
       char name[MAX_LOCATION];
       char absolute[MAX_LOCATION];
       Project prj = null;
+      ProjectNode node = null;
 
       GetLastDirectory(relative, name);
       for(p : projects)
       {
-         if(p.topNode.Find(name, false))
+         if((node = p.topNode.Find(name, false)))
          {
             prj = p;
             break;
@@ -318,8 +376,7 @@ public:
       }
       if(prj)
       {
-         strcpy(absolute, prj.topNode.path);
-         PathCatSlash(absolute, relative);
+         node.GetFullFilePath(absolute);
          return CopyString(absolute);
       }
 
@@ -351,13 +408,13 @@ public:
                return CopyString(absolute);
          }
       }
-      
+
       return null;
    }
 
-   char * GetPathWorkspaceRelativeOrAbsolute(char * path)
+   char * CopyUnixPathWorkspaceRelativeOrAbsolute(const char * path)
    {
-      if(eString_PathInsideOf(path, workspaceDir))
+      if(IsPathInsideOf(path, workspaceDir))
       {
          char relativePath[MAX_LOCATION];
          MakePathRelative(path, workspaceDir, relativePath);
@@ -367,7 +424,125 @@ public:
          return CopyUnixPath(path);
    }
 
-   OpenedFileInfo UpdateOpenedFileInfo(char * fileName, OpenedFileState state)
+   char * MakeRelativePath(char * buffer, const char * path)
+   {
+      char * result = null;
+      if(buffer && path)
+      {
+         MakePathRelative(path, workspaceDir, buffer);
+         MakeSlashPath(buffer);
+         result = buffer;
+      }
+      return result;
+   }
+
+   char * GetRelativePathForProject(char * buffer, Project project)
+   {
+      char * result = null;
+      if(buffer && project && project.topNode.path)
+      {
+         MakePathRelative(project.topNode.path, workspaceDir, buffer);
+         MakeSlashPath(buffer);
+         PathCatSlash(buffer, project.topNode.name);
+         result = buffer;
+      }
+      return result;
+   }
+
+   Array<ProjectNode> GetAllProjectNodes(const char *fullPath, bool skipExcluded)
+   {
+      Array<ProjectNode> nodes = null;
+      for(project : projects)
+      {
+         ProjectNode node;
+         if((node = project.topNode.FindByFullPath(fullPath, false)))
+         {
+            if(!skipExcluded || !node.GetIsExcluded(project.config))
+            {
+               if(!nodes) nodes = { };
+               nodes.Add(node);
+            }
+         }
+      }
+      return nodes;
+   }
+
+   Project GetFileOwner(const char * absolutePath, const char * objectFileExt)
+   {
+      Project owner = null;
+      for(prj : projects)
+      {
+         if(prj.topNode.FindByFullPath(absolutePath, false))
+         {
+            owner = prj;
+            break;
+         }
+      }
+      if(!owner)
+         GetObjectFileNode(absolutePath, &owner, null, objectFileExt);
+      return owner;
+   }
+
+   void GetRelativePath(const char * absolutePath, char * relativePath, Project * owner, const char * objectFileExt)
+   {
+      Project prj = GetFileOwner(absolutePath, objectFileExt);
+      if(owner)
+         *owner = prj;
+      if(!prj)
+         prj = projects.firstIterator.data;
+      if(prj)
+      {
+         MakePathRelative(absolutePath, prj.topNode.path, relativePath);
+         MakeSlashPath(relativePath);
+      }
+      else
+         relativePath[0] = '\0';
+   }
+
+   ProjectNode GetObjectFileNode(const char * filePath, Project * project, char * fullPath, const char * objectFileExt)
+   {
+      ProjectNode node = null;
+      char ext[MAX_EXTENSION];
+      GetExtension(filePath, ext);
+      if(ext[0])
+      {
+         IntermediateFileType type = IntermediateFileType::FromExtension(ext);
+         if(type)
+         {
+            char fileName[MAX_FILENAME];
+            GetLastDirectory(filePath, fileName);
+            if(fileName[0])
+            {
+               DotMain dotMain = DotMain::FromFileName(fileName);
+               for(prj : ide.workspace.projects)
+               {
+                  if((node = prj.FindNodeByObjectFileName(fileName, type, dotMain, null, objectFileExt)))
+                  {
+                     if(project)
+                        *project = prj;
+                     if(fullPath)
+                     {
+                        const char * cfgName = prj.config ? prj.config.name : "";
+                        char name[MAX_FILENAME];
+                        CompilerConfig compiler = ideSettings.GetCompilerConfig(prj.lastBuildCompilerName);
+                        DirExpression objDir = prj.GetObjDir(compiler, prj.config, bitDepth);
+                        strcpy(fullPath, prj.topNode.path);
+                        PathCatSlash(fullPath, objDir.dir);
+                        node.GetObjectFileName(name, prj.configsNameCollisions[cfgName], type, dotMain, objectFileExt);
+                        PathCatSlash(fullPath, name);
+                        delete objDir;
+                        delete compiler;
+                     }
+                     break;
+                  }
+               }
+            }
+         }
+      }
+      return node;
+   }
+
+   OpenedFileInfo UpdateOpenedFileInfo(const char * fileName, OpenedFileState state)
    {
       char filePath[MAX_LOCATION];
       OpenedFileInfo ofi = null;
@@ -404,34 +579,58 @@ public:
 
    void UpdateSourceDirsArray(Array<String> dirs)
    {
-      byte * tokens[256];
-      int c, numTokens;
-
       sourceDirs.Free();
-      
+
       for(s : dirs)
          sourceDirs.Add(CopyString(s));
-      
-      DropInvalidBreakpoints();
+
+      DropInvalidBreakpoints(null);
 
       delete dirs;
    }
-   
+
    void RemoveProject(Project project)
    {
       Iterator<Project> it { projects };
       if(it.Find(project))
          it.Remove();
 
-      DropInvalidBreakpoints();
+      for(bp : breakpoints)
+      DropInvalidBreakpoints(project);
       modified = true;
       ide.findInFilesDialog.RemoveProjectItem(project);
+      ide.UpdateToolBarActiveConfigs(false);
       Save();
 
       delete project;
    }
 
-   bool FindPath(ProjectNode node, char * path)
+   void SelectActiveConfig(const char * configName)
+   {
+      bool change = false;
+      for(prj : ide.workspace.projects)
+      {
+         for(cfg : prj.configurations)
+         {
+            if(cfg.name && !strcmp(cfg.name, configName))
+            {
+               prj.config = cfg;
+               change = true;
+               break;
+            }
+         }
+      }
+      if(change)
+      {
+         modified = true;
+         ide.UpdateToolBarActiveConfigs(true);
+         ide.projectView.Update(null);
+         Save();
+      }
+      ide.AdjustDebugMenus();
+   }
+
+   bool FindPath(ProjectNode node, const char * path)
    {
       if(node.type == file)
       {
@@ -455,18 +654,23 @@ public:
       return false;
    }
 
-   void ChangeBreakpoint(DataRow row, char * location)
+   void ChangeBreakpoint(DataRow row, const char * location)
    {
-      Breakpoint bp = (Breakpoint)row.tag;
+      Breakpoint bp = (Breakpoint)(intptr)row.tag;
       if(bp)
       {
-         char * currentLoc = bp.LocationToString();
+         char * currentLoc = bp.CopyUserLocationString();
          if(strcmp(location, currentLoc))
          {
-            // todo, parse location
-            //  if good, make changes to breakpoint, according to execution state delete and place breakpoint
-            ide.breakpointsView.UpdateBreakpoint(row); // this is the else
-            //Save();
+            char * newLoc;
+            bp.location = location;
+            bp.ParseLocation();
+            newLoc = bp.CopyUserLocationString();
+            if(strcmp(newLoc, currentLoc))
+            {
+               ide.breakpointsView.UpdateBreakpoint(row);
+               Save();
+            }
          }
          delete currentLoc;
       }
@@ -478,7 +682,7 @@ public:
          //  else
          //     ...
          //bp = Breakpoint { };
-         //row.tag = (int)bp;
+         //row.tag = (int64)bp;
          //breakpoints.Add(bp);
          //bp.row = row;
          Save();
@@ -487,7 +691,7 @@ public:
 
    void ChangeBreakpointIgnore(DataRow row, int ignore)
    {
-      Breakpoint bp = (Breakpoint)row.tag;
+      Breakpoint bp = (Breakpoint)(intptr)row.tag;
       if(bp)
       {
          bp.ignore = ignore;
@@ -497,7 +701,7 @@ public:
 
    void ChangeBreakpointLevel(DataRow row, int level)
    {
-      Breakpoint bp = (Breakpoint)row.tag;
+      Breakpoint bp = (Breakpoint)(intptr)row.tag;
       if(bp)
       {
          bp.level = level;
@@ -505,9 +709,9 @@ public:
       }
    }
 
-   void ChangeBreakpointCondition(DataRow row, char * condition)
+   void ChangeBreakpointCondition(DataRow row, const char * condition)
    {
-      Breakpoint bp = (Breakpoint)row.tag;
+      Breakpoint bp = (Breakpoint)(intptr)row.tag;
       if(bp && !(!bp.condition && !(condition && condition[0])))
       {
          if(!bp.condition)
@@ -546,11 +750,11 @@ public:
          Window document;
          for(document = ide.firstChild; document; document = document.next)
          {
-            char * fileName = document.fileName;
+            const char * fileName = document.fileName;
             if(document.isDocument && fileName && document.created)
             {
                char winFilePath[MAX_LOCATION];
-               char * slashPath = GetSlashPathBuffer(winFilePath, fileName);
+               const char * slashPath = GetSlashPathBuffer(winFilePath, fileName);
 
                if(!fstrcmp(slashPath, bp.absoluteFilePath))
                {
@@ -567,40 +771,76 @@ public:
       delete bp;
    }
 
-   void DropInvalidBreakpoints()
+   void ParseLoadedBreakpoints()
+   {
+      for(bp : breakpoints; bp.location)
+      {
+         bp.ParseLocation();
+         ide.breakpointsView.UpdateBreakpoint(bp.row);
+      }
+   }
+
+   void DropInvalidBreakpoints(Project removedProject)
    {
       Link bpLink, next;
       for(bpLink = breakpoints.first; bpLink; bpLink = next)
       {
-         Breakpoint bp = (Breakpoint)bpLink.data;
+         Breakpoint bp = (Breakpoint)(intptr)bpLink.data;
          next = bpLink.next;
 
          if(bp.type == user)
          {
-            Project project = null;
-            for(p : projects)
+            if(removedProject)
             {
-               if(FindPath(p.topNode, bp.absoluteFilePath))
+               if(bp.project == removedProject)
                {
-                  project = p;
-                  break;
+                  ide.breakpointsView.RemoveBreakpoint(bp);
+                  RemoveBreakpoint(bp);
                }
             }
-            if(!project)
+            else
             {
-               bool found = false;
-               for(dir : sourceDirs)
+               Project project = bp.project;
+               if(!project)
                {
-                  if(eString_PathInsideOf(bp.absoluteFilePath, dir))
+                  for(p : projects)
                   {
-                     found = true;
-                     break;
+                     if(FindPath(p.topNode, bp.absoluteFilePath))
+                     {
+                        project = p;
+                        break;
+                     }
+                     // Handle symbol loader modules:
+                     {
+                        char moduleName[MAX_FILENAME];
+                        char * sl;
+                        GetLastDirectory(bp.absoluteFilePath, moduleName);
+                        // Tweak for automatically resolving symbol loader modules
+                        sl = strstr(moduleName, ".main.ec");
+                        if(sl && (*sl = 0, !strcmpi(moduleName, p.name)))
+                        {
+                           project = p;
+                           break;
+                        }
+                     }
                   }
                }
-               if(!found)
+               if(!project)
                {
-                  ide.breakpointsView.RemoveBreakpoint(bp);
-                  RemoveBreakpoint(bp);
+                  bool found = false;
+                  for(dir : sourceDirs)
+                  {
+                     if(IsPathInsideOf(bp.absoluteFilePath, dir))
+                     {
+                        found = true;
+                        break;
+                     }
+                  }
+                  if(!found)
+                  {
+                     ide.breakpointsView.RemoveBreakpoint(bp);
+                     RemoveBreakpoint(bp);
+                  }
                }
             }
          }
@@ -614,7 +854,7 @@ public:
       delete workspaceDir;
       delete commandLineArgs;
       delete debugDir;
-      
+
       //project = null;
 
       projects.Free();
@@ -632,12 +872,13 @@ public:
       ide.breakpointsView.Clear();
 
       property::debugDir = "";
-      
+
       SetSourceDirs(sourceDirs);
    }
 
    ~Workspace()
    {
+      Save();
       timer.Stop();
 
       sourceDirs.Free();
@@ -650,7 +891,7 @@ public:
 
 }
 
-Workspace LoadWorkspace(char * filePath, char * fromProjectFile)
+Workspace LoadWorkspace(const char * filePath, const char * fromProjectFile)
 {
    File file;
    Workspace workspace = null;
@@ -659,6 +900,9 @@ Workspace LoadWorkspace(char * filePath, char * fromProjectFile)
    if(file)
    {
       OldList openedFilesNotFound { };
+      double version = 0;
+      char section[128];
+      char subSection[128];
 
       workspace = Workspace { compiler = ideSettings.defaultCompiler, workspaceFile = filePath };
 
@@ -666,16 +910,11 @@ Workspace LoadWorkspace(char * filePath, char * fromProjectFile)
       while(!file.Eof())
       {
          char buffer[65536];
-         char section[128];
-         char subSection[128];
-         //char version[16];
-         float version;
          char * equal;
-         int len;
-         
+
          Watch wh;
-         Breakpoint bp;
-         
+         Breakpoint bp = null;
+
          file.GetLine(buffer, 65536 - 1);
          TrimLSpaces(buffer, buffer);
          TrimRSpaces(buffer, buffer);
@@ -701,6 +940,18 @@ Workspace LoadWorkspace(char * filePath, char * fromProjectFile)
                      bp.condition = wh;
                   }
                }
+               else if(!strcmpi(section, "Execution Data") && !strcmpi(subSection, "Environment Variables"))
+               {
+                  String value = strchr(equal, '=');
+                  if(value)
+                  {
+                     *value = 0;
+                     value++;
+                     TrimRSpaces(equal, equal);
+                     TrimLSpaces(value, value);
+                     workspace.environmentVars.Add({ equal, value });
+                  }
+               }
             }
             else if(buffer[0] == '*')
             {
@@ -714,7 +965,7 @@ Workspace LoadWorkspace(char * filePath, char * fromProjectFile)
                   char * strLevel = null;
                   char * strLine = null;
                   char * strFile = null;
-                  
+
                   strEnabled = equal;
                   if(strEnabled && strEnabled[0])
                   {
@@ -740,7 +991,7 @@ Workspace LoadWorkspace(char * filePath, char * fromProjectFile)
                      strFile[0] = '\0';
                      strFile++;
                   }
-                  if(strEnabled && strEnabled[0] && strIgnore && strIgnore[0] && 
+                  if(strEnabled && strEnabled[0] && strIgnore && strIgnore[0] &&
                         strLevel && strLevel[0] && strLine && strLine[0] && strFile && strFile[0])
                   {
                      bool enabled;
@@ -766,10 +1017,7 @@ Workspace LoadWorkspace(char * filePath, char * fromProjectFile)
 
                      bp = { type = user, enabled = enabled, ignore = ignore, level = level, line = line };
                      workspace.breakpoints.Add(bp);
-                     bp.relativeFilePath = CopyString(strFile);
-                     bp.absoluteFilePath = workspace.GetAbsolutePathFromRelative(strFile);
-                     if(!bp.absoluteFilePath)
-                        bp.absoluteFilePath = CopyString("");
+                     bp.location = strFile;
                   }
                }
             }
@@ -788,7 +1036,7 @@ Workspace LoadWorkspace(char * filePath, char * fromProjectFile)
                   Point scroll { };
                   char absolutePath[MAX_LOCATION];
                   strcpy(absolutePath, workspace.workspaceDir);
-                  if(version == 0.01f)
+                  if(version == 0.01)
                   {
                      char * comma = strchr(equal, ',');
                      if(comma)
@@ -798,7 +1046,7 @@ Workspace LoadWorkspace(char * filePath, char * fromProjectFile)
                         equal = comma + 1;
                      }
                   }
-                  else if(version >= 0.02f)
+                  else if(version >= 0.02)
                   {
                      char * column = strchr(equal, ':');
                      if(column)
@@ -843,7 +1091,7 @@ Workspace LoadWorkspace(char * filePath, char * fromProjectFile)
                      }
                   }
                   PathCatSlash(absolutePath, equal);
-                     
+
                   if(state == closed || FileExists(absolutePath))
                      workspace.openedFiles.Add(OpenedFileInfo { path = CopyString(absolutePath), state = state, lineNumber = lineNumber, position = position, scroll = scroll });
                   else
@@ -855,9 +1103,12 @@ Workspace LoadWorkspace(char * filePath, char * fromProjectFile)
                   Project newProject;
                   strcpy(projectFilePath, workspace.workspaceDir);
                   PathCatSlash(projectFilePath, equal);
-                  newProject = LoadProject(projectFilePath);
+                  newProject = LoadProject(projectFilePath, null);
                   if(newProject)
+                  {
                      workspace.projects.Add(newProject);
+                     newProject.StartMonitoring();
+                  }
                   else if(workspace.projects.count == 0)
                   {
                      delete workspace;
@@ -872,7 +1123,7 @@ Workspace LoadWorkspace(char * filePath, char * fromProjectFile)
             }
             else if(!strcmpi(buffer, "ECERE Workspace File"));
             else if(!strcmpi(buffer, "Version 0a"))
-               version = 0.0f;
+               version = 0;
             else if(!strncmp(buffer, "Version ", 8))
                version = atof(&buffer[8]);
             else if(!strcmpi(buffer, "Workspace"))
@@ -889,6 +1140,8 @@ Workspace LoadWorkspace(char * filePath, char * fromProjectFile)
                strcpy(subSection, buffer);
             else if(!strcmpi(buffer, "Watches"))
                strcpy(subSection, buffer);
+            else if(!strcmpi(buffer, "Environment Variables"))
+               strcpy(subSection, buffer);
             else if(!strcmpi(buffer, "Opened Files"))
                strcpy(section, buffer);
             else if(!strcmpi(buffer, ""))      // | These two lines were commented out
@@ -913,6 +1166,14 @@ Workspace LoadWorkspace(char * filePath, char * fromProjectFile)
                            workspace.compiler = equal;
                         delete compiler;
                      }
+                     if(!strcmpi(buffer, "Active Bit Depth"))
+                     {
+                        int bitDepth = atoi(equal);
+                        if(!(bitDepth == 32 || bitDepth == 64))
+                           bitDepth = 0;
+                        workspace.bitDepth = bitDepth;
+                        ide.toolBar.activeBitDepth.SelectRow(ide.toolBar.activeBitDepth.FindRow(bitDepth));
+                     }
                   }
                   else if(!strcmpi(section, "Execution Data"))
                   {
@@ -922,6 +1183,14 @@ Workspace LoadWorkspace(char * filePath, char * fromProjectFile)
                      TrimLSpaces(equal, equal);
                      if(!strcmpi(buffer, "Command Line Arguments"))
                         workspace.commandLineArgs = equal;
+
+                     if(!strcmpi(buffer, "Environment Variables"))
+                     {
+                        workspace.environmentVars.Free();
+                        delete workspace.environmentVars;
+                        workspace.environmentVars = { };
+                     }
+
                   }
                   else if(!strcmpi(section, "Debugger Data"))
                   {
@@ -1006,10 +1275,7 @@ Workspace LoadWorkspace(char * filePath, char * fromProjectFile)
                                           bp = { type = user, enabled = enabled, level = -1 };
                                           workspace.breakpoints.Add(bp);
                                           bp.line = atoi(lineNum);
-                                          bp.relativeFilePath = CopyString(relPath);
-                                          bp.absoluteFilePath = workspace.GetAbsolutePathFromRelative(relPath);
-                                          if(!bp.absoluteFilePath)
-                                             bp.absoluteFilePath = CopyString("");
+                                          bp.location = relPath;
                                        }
                                     }
                                  }
@@ -1045,22 +1311,23 @@ Workspace LoadWorkspace(char * filePath, char * fromProjectFile)
          {
             Project project;
             if(fromProjectFile)
-               project = LoadProject(fromProjectFile /*projectFilePath*/);
+               project = LoadProject(fromProjectFile /*projectFilePath*/, null);
             else
             {
                char projectFilePath[MAX_LOCATION];
                strcpy(projectFilePath, workspace.workspaceFile);
                ChangeExtension(projectFilePath, ProjectExtension, projectFilePath);
-               project = LoadProject(projectFilePath);
+               project = LoadProject(projectFilePath, null);
             }
             if(project)
             {
+               project.StartMonitoring();
                workspace.projects.Add(project);
                workspace.name = CopyString(project.name);
             }
             else
             {
-               MessageBox { type = ok, master = ide, contents = "Workspace load file failed", text = "Workspace Load File Error" }.Modal();
+               MessageBox { type = ok, master = ide, contents = $"Workspace load file failed", text = $"Workspace Load File Error" }.Modal();
                delete workspace;
                return null;
             }
@@ -1070,16 +1337,16 @@ Workspace LoadWorkspace(char * filePath, char * fromProjectFile)
          {
             int c = 0;
             char s[2] = "";
-            char files[MAX_LOCATION * 16] = "\n";
+            String files = new char[MAX_LOCATION * 16];
             char title[512];
-            char msg[MAX_LOCATION * 16 + 2048];
-
+            String msg = new char[MAX_LOCATION * 16 + 2048];
             NamedItem item;
+            strcpy(files,"\n");
 
             item = openedFilesNotFound.first;
             if(item.next)
                strcpy(s, "s");
-            
+
             for(item = openedFilesNotFound.first; item; item = item.next)
             {
                c++;
@@ -1092,10 +1359,13 @@ Workspace LoadWorkspace(char * filePath, char * fromProjectFile)
                strcat(files, item.name);
             }
 
-            sprintf(title, "File%s not found", s);
-            sprintf(msg, "The following file%s could not be re-opened.%s", s, files);
-            
+            sprintf(title, $"File%s not found", s);
+            sprintf(msg, $"The following file%s could not be re-opened.%s", s, files);
+
             MessageBox { type = ok, master = ide, contents = msg, text = title }.Modal();
+
+            delete files;
+            delete msg;
          }
          openedFilesNotFound.Free(OldLink::Free);
       }
@@ -1105,23 +1375,23 @@ Workspace LoadWorkspace(char * filePath, char * fromProjectFile)
    else if(fromProjectFile)
    {
       //MessageBox { type = Ok, master = ide, contents = "Worspace load file failed", text = "Worspace Load File Error" }.Modal();
-      
-      char projectFile[MAX_LOCATION];
+      //char projectFile[MAX_LOCATION];
       Project newProject;
-      
+
       //strcpy(projectFile, filePath);
       //ChangeExtension(projectFile, ProjectExtension, projectFile);
-      newProject = LoadProject(fromProjectFile /*projectFile*/);
+      newProject = LoadProject(fromProjectFile /*projectFile*/, null);
 
       if(newProject)
       {
+         newProject.StartMonitoring();
          workspace = Workspace { workspaceFile = filePath };
 
          workspace.projects.Add(newProject);
          workspace.Save();
       }
    }
-   
+
    if(workspace)
    {
       ide.ChangeFileDialogsDirectory(workspace.workspaceDir, false);
@@ -1129,6 +1399,5 @@ Workspace LoadWorkspace(char * filePath, char * fromProjectFile)
       if(!workspace.compiler || !workspace.compiler[0])
          workspace.compiler = defaultCompilerName;
    }
-
    return workspace;
 }