ide; documentor; epj2make; installer: Moved IDE dependency out of IDESettings
authorJerome St-Louis <jerome@ecere.com>
Wed, 3 Aug 2016 23:39:32 +0000 (19:39 -0400)
committerJerome St-Louis <jerome@ecere.com>
Thu, 4 Aug 2016 00:25:11 +0000 (20:25 -0400)
- epj2make: Fixed loading configurations
- installer: Updated for split compiler configurations

documentor/src/Documentor.ec
epj2make/epj2make.ec
ide/src/IDESettings.ec
ide/src/debugger/process.ec
ide/src/dialogs/GlobalSettingsDialog.ec
ide/src/ide.ec
ide/src/project/Project.ec
ide/src/project/ProjectConfig.ec
installer/src/installer.ec

index c3e6212..7f22013 100644 (file)
@@ -5,6 +5,14 @@ import "HTMLView"
 import "IDESettings"
 import "SettingsDialog"
 
+IDESettings ideSettings;
+
+IDESettingsContainer settingsContainer
+{
+   dataOwner = &ideSettings;
+   dataClass = class(IDESettings);
+};
+
 static Context globalContext { };
 static OldList defines { };
 static OldList imports { };
index 53792c1..ab991be 100644 (file)
@@ -16,6 +16,16 @@ define pathListSep = ":";
 extern int getch(void);
 #endif
 
+IDESettings ideSettings;
+
+IDESettingsContainer settingsContainer
+{
+   dataOwner = &ideSettings;
+   dataClass = class(IDESettings);
+};
+
+IDEConfigHolder ideConfig { };
+
 void ParseDirList(char * string, Container<String> list)
 {
    int c;
@@ -264,6 +274,8 @@ class epj2makeApp : GuiApplication
                   const char * compiler = getenv("COMPILER");
                   if(!compiler) compiler = "Default";
                   settingsContainer.Load();
+                  ideConfig.compilers.read(settingsContainer);
+
                   //incref ideSettings;
                   delete settingsContainer;
 
index be46617..f9c9695 100644 (file)
@@ -20,21 +20,16 @@ import "StringsBox"
 
 import "OldIDESettings"
 
-#if !defined(ECERE_DOCUMENTOR) && !defined(ECERE_EPJ2MAKE)
-import "ide"
-import "process"
+#ifdef __WIN32__
+#define WIN32_LEAN_AND_MEAN
+#define Sleep _Sleep
+#include <windows.h>
+#undef MoveFileEx
+#undef Sleep
+#undef MessageBox
+#undef GetObject
 #endif
 
-IDEConfigHolder ideConfig { };
-
-IDESettings ideSettings;
-
-IDESettingsContainer settingsContainer
-{
-   dataOwner = &ideSettings;
-   dataClass = class(IDESettings);
-};
-
 define MaxRecent = 9;
 
 enum DirTypes { includes, libraries, executables };
@@ -297,20 +292,28 @@ class IDEConfigHolder
 
 class IDESettingsContainer : GlobalSettings
 {
+   virtual void onLoadCompilerConfigs();
+   virtual void onLoadRecentFiles();
+   virtual void onLoadRecentProjects();
+
+   CompilerConfigs compilerConfigs;
+   RecentFiles recentFiles;
+   RecentWorkspaces recentProjects;
+
    property bool useNewConfigurationFiles
    {
       set
       {
          if(value)
          {
-            settingsContainer.driver = "ECON";
+            driver = "ECON";
             settingsName = "config";
             settingsExtension = "econ";
             settingsDirectory = settingsDir;
          }
          else
          {
-            settingsContainer.driver = "JSON";
+            driver = "JSON";
             settingsName = ideSettingsName;
             settingsExtension = null;
             settingsDirectory = null;
@@ -334,7 +337,7 @@ class IDESettingsContainer : GlobalSettings
             int c;
             bool locked;
             for(c = 0; c < 10 && !(locked = f.Lock(shared, 0, 0, false)); c++) ecere::sys::Sleep(0.01);
-            RecentFiles::read();
+            recentFiles.read(this);
             f.Unlock(0,0,true);
             delete f;
          }
@@ -356,7 +359,7 @@ class IDESettingsContainer : GlobalSettings
             int c;
             bool locked;
             for(c = 0; c < 10 && !(locked = f.Lock(shared, 0, 0, false)); c++) ecere::sys::Sleep(0.01);
-            RecentWorkspaces::read();
+            recentProjects.read(this);
             f.Unlock(0,0,true);
             delete f;
          }
@@ -364,6 +367,30 @@ class IDESettingsContainer : GlobalSettings
       }
    };
 
+   static void getConfigFilePath(char * path, Class _class, char * dir, const char * configName)
+   {
+      if(dir) *dir = 0;
+      strcpy(path, settingsFilePath);
+      StripLastDirectory(path, path);
+      if(oldConfig)
+         PathCatSlash(path, settingsDir);
+      if(_class == class(CompilerConfig))
+      {
+         PathCatSlash(path, "compilerConfigs");
+         if(dir)
+            strcpy(dir, path);
+         if(configName)
+         {
+            PathCatSlash(path, configName);
+            strcat(path, ".econ");
+         }
+      }
+      else if(_class == class(RecentFilesData))
+         PathCatSlash(path, "recentFiles.econ");
+      else if(_class == class(RecentWorkspacesData))
+         PathCatSlash(path, "recentWorkspaces.econ");
+   }
+
 private:
    bool oldConfig;
    FileSize settingsFileSize;
@@ -515,21 +542,17 @@ private:
       if(oldConfig)
       {
          data.compilerConfigs.ensureDefaults();
-         data.compilerConfigs.write(null);
+         data.compilerConfigs.write(this, null);
          data.compilerConfigs.Free();
 
-         data.recentFiles.write();
+         data.recentFiles.write(this);
          data.recentFiles.Free();
 
-         data.recentProjects.write();
+         data.recentProjects.write(this);
          data.recentProjects.Free();
 
          Save();
       }
-
-#if !defined(ECERE_DOCUMENTOR) && !defined(ECERE_EPJ2MAKE)
-      globalSettingsDialog.ideSettings = data;
-#endif
       return result;
    }
 
@@ -602,30 +625,6 @@ static Map<String, CompilerConfig> getCompilerConfigsByName(const char * path)
    return map;
 }
 
-static void getConfigFilePath(char * path, Class _class, char * dir, const char * configName)
-{
-   if(dir) *dir = 0;
-   strcpy(path, settingsContainer.settingsFilePath);
-   StripLastDirectory(path, path);
-   if(settingsContainer.oldConfig)
-      PathCatSlash(path, settingsDir);
-   if(_class == class(CompilerConfig))
-   {
-      PathCatSlash(path, "compilerConfigs");
-      if(dir)
-         strcpy(dir, path);
-      if(configName)
-      {
-         PathCatSlash(path, configName);
-         strcat(path, ".econ");
-      }
-   }
-   else if(_class == class(RecentFilesData))
-      PathCatSlash(path, "recentFiles.econ");
-   else if(_class == class(RecentWorkspacesData))
-      PathCatSlash(path, "recentWorkspaces.econ");
-}
-
 static SettingsIOResult writeConfigFile(const char * path, Class dataType, void * data)
 {
    SettingsIOResult result = error;
@@ -804,7 +803,7 @@ class IDESettings : GlobalSettingsData
 public:
    property CompilerConfigs compilerConfigs
    {
-      set { if(settingsContainer.oldConfig) { if(compilerConfigs) compilerConfigs.Free(); delete compilerConfigs; if(value) compilerConfigs = value; } }
+      set { /*if(settingsContainer.oldConfig)*/ { if(compilerConfigs) compilerConfigs.Free(); delete compilerConfigs; if(value) compilerConfigs = value; } }
       get { return compilerConfigs; }
       isset { return false; }
    }
@@ -1061,37 +1060,31 @@ private:
 
 class RecentFiles : RecentPaths
 {
-   void onAdd()
-   {
-      write();
-   }
-
-   void ::read()
+   void read(IDESettingsContainer settingsContainer)
    {
       char path[MAX_LOCATION];
       RecentFilesData d = null;
       Class _class = class(RecentFilesData);
-      getConfigFilePath(path, _class, null, null);
+      settingsContainer.getConfigFilePath(path, _class, null, null);
       readConfigFile(path, _class, &d);
       if(d && d.recentFiles && d.recentFiles.count)
       {
-         ideConfig.recentFiles = d.recentFiles;
-         d.recentFiles = null;
-#if !defined(ECERE_DOCUMENTOR) && !defined(ECERE_EPJ2MAKE)
-         ide.updateRecentFilesMenu();
-#endif
+         Free();
+         Copy((void *)d.recentFiles);
+         settingsContainer.recentFiles = this; // Merge IDEConfigHolder / IDESettingsContainer?
       }
       delete d;
       settingsContainer.recentFilesMonitor.fileName = path;
       settingsContainer.recentFilesMonitor.StartMonitoring();
+      settingsContainer.onLoadRecentFiles();
    }
 
-   void write()
+   void write(IDESettingsContainer settingsContainer)
    {
       char path[MAX_LOCATION];
       RecentFilesData d { };
       Class _class = class(RecentFilesData);
-      getConfigFilePath(path, _class, null, null);
+      settingsContainer.getConfigFilePath(path, _class, null, null);
       d.recentFiles = this;
       writeConfigFile(path, _class, d);
       d.recentFiles = null;
@@ -1101,37 +1094,31 @@ class RecentFiles : RecentPaths
 
 class RecentWorkspaces : RecentPaths
 {
-   void onAdd()
-   {
-      write();
-   }
-
-   void ::read()
+   void read(IDESettingsContainer settingsContainer)
    {
       char path[MAX_LOCATION];
       RecentWorkspacesData d = null;
       Class _class = class(RecentWorkspacesData);
-      getConfigFilePath(path, _class, null, null);
+      settingsContainer.getConfigFilePath(path, _class, null, null);
       readConfigFile(path, _class, &d);
       if(d && d.recentWorkspaces && d.recentWorkspaces.count)
       {
-         ideConfig.recentProjects = d.recentWorkspaces;
-         d.recentWorkspaces = null;
-#if !defined(ECERE_DOCUMENTOR) && !defined(ECERE_EPJ2MAKE)
-         ide.updateRecentProjectsMenu();
-#endif
+         Free();
+         Copy((void *)d.recentWorkspaces);
+         settingsContainer.recentProjects = this; // Merge IDEConfigHolder / IDESettingsContainer?
       }
+      delete d;
       settingsContainer.recentProjectsMonitor.fileName = path;
       settingsContainer.recentProjectsMonitor.StartMonitoring();
-      delete d;
+      settingsContainer.onLoadRecentProjects();
    }
 
-   void write()
+   void write(IDESettingsContainer settingsContainer)
    {
       char path[MAX_LOCATION];
       RecentWorkspacesData d { };
       Class _class = class(RecentWorkspacesData);
-      getConfigFilePath(path, _class, null, null);
+      settingsContainer.getConfigFilePath(path, _class, null, null);
       d.recentWorkspaces = this;
       writeConfigFile(path, _class, d);
       d.recentWorkspaces = null;
@@ -1141,8 +1128,6 @@ class RecentWorkspaces : RecentPaths
 
 class RecentPaths : Array<String>
 {
-   virtual void onAdd();
-
    IteratorPointer Add(T value)
    {
       int c;
@@ -1176,7 +1161,6 @@ class RecentPaths : Array<String>
       while(count >= MaxRecent)
          Delete(GetLast());
       ip = Insert(null, filePath);
-      onAdd();
       return ip;
    }
 
@@ -1739,12 +1723,12 @@ public:
       return d;
    }
 
-   void write()
+   void write(IDESettingsContainer settingsContainer)
    {
       char dir[MAX_LOCATION];
       char path[MAX_LOCATION];
       const char * settingsFilePath = settingsContainer.settingsFilePath;
-      getConfigFilePath(path, _class, dir, name);
+      settingsContainer.getConfigFilePath(path, _class, dir, name);
       if(FileExists(settingsFilePath) && !FileExists(dir))
       {
          MakeDir(dir);
@@ -1843,19 +1827,21 @@ class CompilerConfigs : List<CompilerConfig>
       return list;
    }
 
-   void read()
+   bool read(IDESettingsContainer settingsContainer)
    {
       if(settingsContainer.settingsFilePath)
       {
          char dir[MAX_LOCATION];
          char path[MAX_LOCATION];
          Class _class = class(CompilerConfig);
-         getConfigFilePath(path, _class, dir, null);
+         settingsContainer.getConfigFilePath(path, _class, dir, null);
          if(dir[0])
          {
             AVLTree<const String> addedConfigs { };
             Map<String, CompilerConfig> compilerConfigsByName = getCompilerConfigsByName(dir);
             MapIterator<const String, CompilerConfig> it { map = compilerConfigsByName };
+            Free();
+            settingsContainer.compilerConfigs = this; // Merge IDEConfigHolder / IDESettingsContainer?
             if(it.Index("Default", false))
             {
                CompilerConfig ccfg = it.data;
@@ -1870,30 +1856,23 @@ class CompilerConfigs : List<CompilerConfig>
                   addedConfigs.Add(ccfg.name);
                }
             }
-            /*
-            for(ccfg : this)
-            {
-               if(!addedConfigs.Find(ccfg.name))
-                  Add(ccfg.Copy());
-            }
-            */
             delete addedConfigs;
             ensureDefaults();
             compilerConfigsByName.Free();
             delete compilerConfigsByName;
-#if !defined(ECERE_DOCUMENTOR) && !defined(ECERE_EPJ2MAKE)
-            ide.UpdateCompilerConfigs(true);
-#endif
+            settingsContainer.onLoadCompilerConfigs();
+            return true;
          }
       }
+      return false;
    }
 
-   void write(AVLTree<String> cfgsToWrite)
+   void write(IDESettingsContainer settingsContainer, AVLTree<String> cfgsToWrite)
    {
       char dir[MAX_LOCATION];
       char path[MAX_LOCATION];
       Map<String, String> paths;
-      getConfigFilePath(path, class(CompilerConfig), dir, null);
+      settingsContainer.getConfigFilePath(path, class(CompilerConfig), dir, null);
       paths = getCompilerConfigFilePathsByName(dir);
       {
          MapIterator<String, String> it { map = paths };
@@ -1901,7 +1880,7 @@ class CompilerConfigs : List<CompilerConfig>
          {
             CompilerConfig ccfg = c;
             if(!cfgsToWrite || cfgsToWrite.Find(ccfg.name))
-               ccfg.write();
+               ccfg.write(settingsContainer);
             if(it.Index(ccfg.name, false))
             {
                delete it.data;
@@ -1985,6 +1964,24 @@ const String GetLanguageString()
    return language;
 }
 
+void setEcereLanguageInWinRegEnvironment(const char * languageCode)
+{
+#ifdef __WIN32__
+   HKEY key = null;
+   uint16 wLanguage[256];
+   DWORD status;
+   wLanguage[0] = 0;
+
+   RegCreateKeyEx(HKEY_CURRENT_USER, "Environment", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, null, &key, &status);
+   if(key)
+   {
+      UTF8toUTF16Buffer(languageCode, wLanguage, sizeof(wLanguage) / sizeof(uint16));
+      RegSetValueExW(key, L"ECERE_LANGUAGE", 0, REG_EXPAND_SZ, (byte *)wLanguage, (uint)(wcslen(wLanguage)+1) * 2);
+      RegCloseKey(key);
+   }
+#endif
+}
+
 bool LanguageRestart(const char * code, Application app, IDESettings settings, IDESettingsContainer settingsContainer, Window ide, Window projectView, bool wait)
 {
    bool restart = true;
index 8c6481e..9db7779 100644 (file)
@@ -355,21 +355,3 @@ int Process_GetChildExeProcessId(const int parentProcessId, const char * exeFile
    return pid;
 #endif
 }
-
-void setEcereLanguageInWinRegEnvironment(const char * languageCode)
-{
-#ifdef __WIN32__
-   HKEY key = null;
-   uint16 wLanguage[256];
-   DWORD status;
-   wLanguage[0] = 0;
-
-   RegCreateKeyEx(HKEY_CURRENT_USER, "Environment", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, null, &key, &status);
-   if(key)
-   {
-      UTF8toUTF16Buffer(languageCode, wLanguage, sizeof(wLanguage) / sizeof(uint16));
-      RegSetValueExW(key, L"ECERE_LANGUAGE", 0, REG_EXPAND_SZ, (byte *)wLanguage, (uint)(wcslen(wLanguage)+1) * 2);
-      RegCloseKey(key);
-   }
-#endif
-}
index 07e8291..1644ebc 100644 (file)
@@ -19,8 +19,6 @@ class GlobalSettingsDialog : Window
    minClientSize = { 560, 542 };
    nativeDecorations = true;
 
-   IDESettings ideSettings;
-   IDESettingsContainer settingsContainer;
    String workspaceActiveCompiler;
 
    TabControl tabControl { this, background = formColor, anchor = { left = 8, top = 8, right = 8, bottom = 40 } };
@@ -129,7 +127,7 @@ class GlobalSettingsDialog : Window
 
             if(compilerSettingsChanged)
             {
-               ideConfig.compilers.write(cfgsToWrite);
+               ideConfig.compilers.write(settingsContainer, cfgsToWrite);
                OnGlobalSettingChange(GlobalSettingsChange::compilerSettings);
                cfgsToWrite.Free();
                delete cfgsToWrite;
@@ -1397,14 +1395,14 @@ class WorkspaceOptionsTab : GlobalSettingsSubTab
    bool OnCreate()
    {
       GlobalSettingsDialog dialog = this.dialog;
-      if(dialog && dialog.compilersTab.compilerConfigs && dialog.ideSettings)
+      if(dialog && dialog.compilersTab.compilerConfigs && ideSettings)
       {
          DataRow row;
          for(compiler : ideConfig.compilers)
          {
             row = defaultCompilerDropBox.AddString(compiler.name);
-            if(dialog.ideSettings.defaultCompiler && dialog.ideSettings.defaultCompiler[0] &&
-                  !strcmp(compiler.name, dialog.ideSettings.defaultCompiler))
+            if(ideSettings.defaultCompiler && ideSettings.defaultCompiler[0] &&
+                  !strcmp(compiler.name, ideSettings.defaultCompiler))
                defaultCompilerDropBox.currentRow = row;
          }
          if(!defaultCompilerDropBox.currentRow && defaultCompilerDropBox)
index 51eda16..0832c18 100644 (file)
@@ -59,6 +59,20 @@ define pathListSep = ";";
 define pathListSep = ":";
 #endif
 
+IDEConfigHolder ideConfig { };
+
+IDESettings ideSettings;
+
+IDESettingsContainer settingsContainer
+{
+   dataOwner = &ideSettings;
+   dataClass = class(IDESettings);
+
+   void onLoadCompilerConfigs()     { ide.UpdateCompilerConfigs(true); }
+   void onLoadRecentFiles()         { ide.updateRecentFilesMenu(); }
+   void onLoadRecentProjects()      { ide.updateRecentProjectsMenu(); }
+};
+
 define maxPathLen = 65 * MAX_LOCATION;
 
 class PathBackup : struct
@@ -151,9 +165,6 @@ FileDialog ideProjectFileDialog
 
 GlobalSettingsDialog globalSettingsDialog
 {
-   ideSettings = ideSettings;
-   settingsContainer = settingsContainer;
-
    void OnGlobalSettingChange(GlobalSettingsChange globalSettingsChange)
    {
       switch(globalSettingsChange)
@@ -727,8 +738,7 @@ class IDEWorkSpace : Window
          bool NotifySelect(MenuItem selection, Modifiers mods)
          {
             // Reload configs here until we setup a configs directory monitor
-            ideConfig.compilers.Free();
-            ideConfig.compilers.read();
+            ideConfig.compilers.read(settingsContainer);
 
             globalSettingsDialog.master = this;
             if(ide.workspace && ide.workspace.activeCompiler)
@@ -829,6 +839,7 @@ class IDEWorkSpace : Window
                      if(projectView)
                      {
                         ideConfig.recentWorkspaces.addRecent(projectView.fileName);
+                        ideConfig.recentWorkspaces.write(settingsContainer);
                         ide.updateRecentProjectsMenu();
                      }
                   }
@@ -1829,6 +1840,7 @@ class IDEWorkSpace : Window
    void DocumentSaved(Window document, const char * fileName)
    {
       ideConfig.recentFiles.addRecent(fileName);
+      ideConfig.recentFiles.write(settingsContainer);
       ide.updateRecentFilesMenu();
       ide.AdjustFileMenus();
    }
@@ -2575,12 +2587,16 @@ class IDEWorkSpace : Window
          if(isProject)
          {
             ideConfig.recentWorkspaces.addRecent(document.fileName);
+            ideConfig.recentWorkspaces.write(settingsContainer);
             ide.updateRecentProjectsMenu();
          }
          else if(workspace)
             workspace.recentFiles.addRecent(document.fileName);
          else
+         {
             ideConfig.recentFiles.addRecent(document.fileName);
+            ideConfig.recentFiles.write(settingsContainer);
+         }
          ide.updateRecentFilesMenu();
          ide.AdjustFileMenus();
          return document;
@@ -3177,6 +3193,7 @@ class IDEWorkSpace : Window
                   if(projectView)
                   {
                      ideConfig.recentWorkspaces.addRecent(projectView.fileName);
+                     ideConfig.recentWorkspaces.write(settingsContainer);
                      ide.updateRecentMenus();
                   }
                   delete newProjectDialog;
@@ -3672,9 +3689,9 @@ class IDEApp : GuiApplication
          }
       }
 
-      ideConfig.compilers.read();
-      ideConfig.recentFiles.read();
-      ideConfig.recentWorkspaces.read();
+      ideConfig.compilers.read(settingsContainer);
+      ideConfig.recentFiles.read(settingsContainer);
+      ideConfig.recentWorkspaces.read(settingsContainer);
 
       // First count files arg to decide whether to maximize
       {
@@ -3738,8 +3755,6 @@ class IDEApp : GuiApplication
       }
       */
 
-      globalSettingsDialog.settingsContainer = settingsContainer;
-
       // Default to language specified by environment if no language selected
       if(!ideSettings.language)
       {
index c223749..ee82b70 100644 (file)
@@ -6,7 +6,9 @@ public import "ecere"
 
 import "DynamicString"
 
-#if !defined(ECERE_DOCUMENTOR) && !defined(ECERE_EPJ2MAKE)
+#if defined(ECERE_EPJ2MAKE)
+import "epj2make"
+#else
 import "ide"
 // We should have the .sln/.vcproj generation even on other platforms
 // e.g. detect from an environment variable pointing to a Windows drive
index 2bf6a64..2e604dc 100644 (file)
@@ -1,7 +1,3 @@
-#if !defined(ECERE_DOCUMENTOR) && !defined(ECERE_EPJ2MAKE)
-import "ide"
-#endif
-
 import "Project"
 
 enum DirExpressionType { unknown, targetDir, intermediateObjectsDir };  // "type" is not right
@@ -40,10 +36,10 @@ class DirExpression : struct
       {
          if(ideSettings)
          {
-         if(type == targetDir)
-            expr = ideSettings.projectDefaultTargetDir;
-         else if(type == intermediateObjectsDir)
-            expr = ideSettings.projectDefaultIntermediateObjDir;
+            if(type == targetDir)
+               expr = ideSettings.projectDefaultTargetDir;
+            else if(type == intermediateObjectsDir)
+               expr = ideSettings.projectDefaultIntermediateObjDir;
          }
          if(!expr || !expr[0])
             expr = defaultObjDirExpression;
index 7d611ce..d4c68e0 100644 (file)
@@ -1428,6 +1428,7 @@ class InstallThread : Thread
 
          // Configure IDE
          IDESettings settings = null; // Don't instantiate yet so we can pick up old settings
+         CompilerConfigs configs { };
 
          IDESettingsContainer settingsContainer
          {
@@ -1442,7 +1443,9 @@ class InstallThread : Thread
          ((GuiApplication)__thisModule).SignalEvent();
 
          settingsContainer.Load();
-         compiler = settings.GetCompilerConfig(defaultCompilerName);
+         configs.read(settingsContainer);
+
+         compiler = configs.GetCompilerConfig(defaultCompilerName);
          if(compiler)
          {
             {
@@ -1537,8 +1540,14 @@ class InstallThread : Thread
          }
 
          settingsContainer.Save();
+         {
+            AVLTree<String> cfgsToWrite { [ compiler.name ] };
+            configs.write(settingsContainer, cfgsToWrite);
+            delete cfgsToWrite;
+         }
          delete settingsContainer;
          delete settings;
+         delete configs;
 
          // Set up Uninstaller
          ((GuiApplication)__thisModule).Lock();