ide: fix specifying all file extensions (output file extension for emscripten) inside...
authorRejean Loyer <redj@ecere.com>
Sun, 3 Jul 2016 20:59:35 +0000 (16:59 -0400)
committerJerome St-Louis <jerome@ecere.com>
Thu, 28 Jul 2016 22:23:37 +0000 (18:23 -0400)
 - add static and shared library file extensions to compiler config
 - add executable file extension to compiler config
 - fix ar and ld fields are not being disabled for default compiler in global settings dialog, compilers tab, toolchain tab.

default.cf
ide/src/IDESettings.ec
ide/src/dialogs/GlobalSettingsDialog.ec
ide/src/project/Project.ec
ide/src/project/ProjectView.ec

index aa3d8aa..e1a1756 100644 (file)
@@ -7,8 +7,23 @@ ifdef WINDOWS_HOST
  endif
 endif
 
-# EXTENSIONS
-OUT := $(if $(STATIC_LIBRARY_TARGET),$(A),$(if $(SHARED_LIBRARY_TARGET),$(SO)$(VER),$(if $(EXECUTABLE_TARGET),$(E),.x)))
+# PREFIXES AND EXTENSIONS
+EC := .ec
+S := .sym
+I := .imp
+B := .bowl
+C := .c
+ifndef O
+O := .o
+endif
+A := .a
+E := $(if $(WINDOWS_TARGET),.exe,)
+SO := $(if $(WINDOWS_TARGET),.dll,$(if $(OSX_TARGET),.dylib,.so))
+LP := $(if $(WINDOWS_TARGET),$(if $(STATIC_LIBRARY_TARGET),lib,),lib)
+HOST_E := $(if $(WINDOWS_HOST),.exe,)
+HOST_SO := $(if $(WINDOWS_HOST),.dll,$(if $(OSX_HOST),.dylib,.so))
+HOST_LP := $(if $(WINDOWS_HOST),$(if $(STATIC_LIBRARY_TARGET),lib,),lib)
+.SUFFIXES: .c .ec .sym .imp .bowl $(O) $(A)
 
 # TOOLCHAIN
 export CC      = $(CCACHE_COMPILE)$(DISTCC_COMPILE)$(GCC_PREFIX)gcc$(_SYSROOT)$(if $(GCC_CC_FLAGS),$(space)$(GCC_CC_FLAGS),)
index af82e81..5659cc1 100644 (file)
@@ -1244,11 +1244,23 @@ public:
       get { return objectFileExt && objectFileExt[0] ? objectFileExt : objectDefaultFileExt ; }
       isset { return objectFileExt && objectFileExt[0] && strcmp(objectFileExt, objectDefaultFileExt); }
    }
-   property const char * outputFileExt
+   property const char * staticLibFileExt
+   {
+      set { delete staticLibFileExt; if(value && value[0]) staticLibFileExt = CopyString(value); }
+      get { return staticLibFileExt; }
+      isset { return staticLibFileExt && staticLibFileExt[0]; }
+   }
+   property const char * sharedLibFileExt
    {
-      set { delete outputFileExt; if(value && value[0]) outputFileExt = CopyString(value); }
-      get { return outputFileExt; }
-      isset { return outputFileExt && outputFileExt[0]; }
+      set { delete sharedLibFileExt; if(value && value[0]) sharedLibFileExt = CopyString(value); }
+      get { return sharedLibFileExt; }
+      isset { return sharedLibFileExt && sharedLibFileExt[0]; }
+   }
+   property const char * executableFileExt
+   {
+      set { delete executableFileExt; if(value && value[0]) executableFileExt = CopyString(value); }
+      get { return executableFileExt; }
+      isset { return executableFileExt && executableFileExt[0]; }
    }
    property const char * executableLauncher
    {
@@ -1281,6 +1293,7 @@ public:
       isset { return sysroot && sysroot[0]; }
    }
    bool resourcesDotEar;
+   bool noStripTarget;
    property Array<String> includeDirs
    {
       set
@@ -1434,6 +1447,23 @@ public:
       get { return executableLauncher; }
       isset { return false; }
    }
+   property const char * outputFileExt
+   {
+      set { delete executableFileExt; if(value && value[0]) executableFileExt = CopyString(value); }
+      get { return executableFileExt; }
+      isset { return false; }
+   }
+   // utility
+   property bool hasDocumentOutput
+   {
+      get
+      {
+         bool result = executableFileExt && executableFileExt[0] &&
+               (!strcmpi(executableFileExt, "htm") || !strcmpi(executableFileExt, "html"));
+         return result;
+      }
+      isset { return false; }
+   }
 private:
    Array<String> includeDirs { };
    Array<String> libraryDirs { };
@@ -1459,7 +1489,9 @@ private:
    char * ldCommand;
    char * arCommand;
    char * objectFileExt;
-   char * outputFileExt;
+   char * staticLibFileExt;
+   char * sharedLibFileExt;
+   char * executableFileExt;
    char * executableLauncher;
    char * distccHosts;
    char * gnuToolchainPrefix;
@@ -1483,7 +1515,9 @@ private:
       delete ldCommand;
       delete arCommand;
       delete objectFileExt;
-      delete outputFileExt;
+      delete staticLibFileExt;
+      delete sharedLibFileExt;
+      delete executableFileExt;
       delete makeCommand;
       delete executableLauncher;
       delete distccHosts;
@@ -1560,7 +1594,9 @@ public:
          arCommand,
          ldCommand,
          objectFileExt,
-         outputFileExt,
+         staticLibFileExt,
+         sharedLibFileExt,
+         executableFileExt,
          executableLauncher,
          ccacheEnabled,
          distccEnabled,
@@ -1568,7 +1604,8 @@ public:
          distccHosts,
          gnuToolchainPrefix,
          sysroot,
-         resourcesDotEar
+         resourcesDotEar,
+         noStripTarget
       };
       for(s : includeDirs) copy.includeDirs.Add(CopyString(s));
       for(s : libraryDirs) copy.libraryDirs.Add(CopyString(s));
@@ -1648,8 +1685,12 @@ class CompilerConfigs : List<CompilerConfig>
                ccfg.arCommand = arDefaultCommand;
             if(!ccfg.objectFileExt || !ccfg.objectFileExt[0])
                ccfg.objectFileExt = objectDefaultFileExt;
-            /*if(!ccfg.outputFileExt || !ccfg.outputFileExt[0])
-               ccfg.outputFileExt = outputDefaultFileExt;*/
+            /*if(!ccfg.staticLibFileExt || !ccfg.staticLibFileExt[0])
+               ccfg.staticLibFileExt = staticLibDefaultFileExt;*/
+            /*if(!ccfg.sharedLibFileExt || !ccfg.sharedLibFileExt[0])
+               ccfg.sharedLibFileExt = sharedLibDefaultFileExt;*/
+            /*if(!ccfg.executableFileExt || !ccfg.executableFileExt[0])
+               ccfg.executableFileExt = outputDefaultFileExt;*/
             if(!ccfg._refCount) incref ccfg;
          }
       }
index 921fddc..b6c5392 100644 (file)
@@ -864,7 +864,8 @@ class CompilerToolchainTab : CompilersSubTab
          cppLabel.disabled = cpp.disabled = isVC || disabled;
          cxxLabel.disabled = cxx.disabled = isVC || disabled;
          ccLabel.disabled = cc.disabled = isVC || disabled;
-         ldLabel.disabled = cxx.disabled = isVC || disabled;
+         ldLabel.disabled = ld.disabled = isVC || disabled;
+         arLabel.disabled = ar.disabled = isVC || disabled;
          makeLabel.disabled = make.disabled = disabled;
          executableLauncherLabel.disabled = executableLauncher.disabled = disabled;
          gnuToolchainPrefixLabel.disabled = gnuToolchainPrefix.disabled = disabled;
@@ -1167,10 +1168,10 @@ class CompilerOptionsTab : CompilersSubTab
       }
    };
 
-   Label outputFileExtLabel { this, position = { 8, 306 }, labeledWindow = outputFileExt };
-   EditBox outputFileExt
+   Label staticLibFileExtLabel { this, position = { 8, 306 }, labeledWindow = staticLibFileExt };
+   EditBox staticLibFileExt
    {
-      this, text = $"Output file extension";//, hotKey = altH;
+      this, text = $"Output (a, so, exe) file extension";//, hotKey = altH;
       position = { 168, 304 }, size = { 80, 22 };
 
       bool NotifyModified(EditBox editBox)
@@ -1178,7 +1179,59 @@ class CompilerOptionsTab : CompilersSubTab
          CompilerConfig compiler = loadedCompiler;
          if(compiler)
          {
-            compiler.outputFileExt = editBox.contents;
+            compiler.staticLibFileExt = editBox.contents;
+            modifiedDocument = true;
+            compilersTab.modifiedDocument = true;
+         }
+         return true;
+      }
+   };
+   EditBox sharedLibFileExt
+   {
+      this;
+      position = { 256, 304 }, size = { 80, 22 };
+
+      bool NotifyModified(EditBox editBox)
+      {
+         CompilerConfig compiler = loadedCompiler;
+         if(compiler)
+         {
+            compiler.sharedLibFileExt = editBox.contents;
+            modifiedDocument = true;
+            compilersTab.modifiedDocument = true;
+         }
+         return true;
+      }
+   };
+   EditBox executableFileExt
+   {
+      this;
+      position = { 344, 304 }, size = { 80, 22 };
+
+      bool NotifyModified(EditBox editBox)
+      {
+         CompilerConfig compiler = loadedCompiler;
+         if(compiler)
+         {
+            compiler.executableFileExt = editBox.contents;
+            modifiedDocument = true;
+            compilersTab.modifiedDocument = true;
+         }
+         return true;
+      }
+   };
+
+   Button stripTarget
+   {
+      this, text = $"Strip target", hotKey = altC, position = { 168, 332 };
+      isCheckbox = true;
+
+      bool NotifyClicked(Button button, int x, int y, Modifiers mods)
+      {
+         CompilerConfig compiler = loadedCompiler;
+         if(compiler)
+         {
+            compiler.noStripTarget = !button.checked;
             modifiedDocument = true;
             compilersTab.modifiedDocument = true;
          }
@@ -1188,7 +1241,7 @@ class CompilerOptionsTab : CompilersSubTab
 
    Button resourcesDotEar
    {
-      this, text = $"Use resources.ear", position = { 300, 308 };
+      this, text = $"Use resources.ear", position = { 308, 332 };
       isCheckbox = true;
 
       bool NotifyClicked(Button button, int x, int y, Modifiers mods)
@@ -1236,7 +1289,10 @@ class CompilerOptionsTab : CompilersSubTab
          cxxFlags.strings = compiler.cxxFlags;
          linkerFlags.strings = compiler.linkerFlags;
          objectFileExt.contents = compiler.objectFileExt;
-         outputFileExt.contents = compiler.outputFileExt;
+         staticLibFileExt.contents = compiler.staticLibFileExt;
+         sharedLibFileExt.contents = compiler.sharedLibFileExt;
+         executableFileExt.contents = compiler.executableFileExt;
+         stripTarget.checked = !compiler.noStripTarget;
          resourcesDotEar.checked = compiler.resourcesDotEar;
 
          labelTargetPlatform.disabled = disabled;
index 15983f9..9953d65 100644 (file)
@@ -1243,11 +1243,21 @@ private:
       switch(targetType)
       {
          case executable:
-            if(compiler.targetPlatform == win32)
+            if(compiler.executableFileExt)
+            {
+               strcat(string, ".");
+               strcat(string, compiler.executableFileExt);
+            }
+            else if(compiler.targetPlatform == win32)
                strcat(string, ".exe");
             break;
          case sharedLibrary:
-            if(compiler.targetPlatform == win32)
+            if(compiler.sharedLibFileExt)
+            {
+               strcat(string, ".");
+               strcat(string, compiler.sharedLibFileExt);
+            }
+            else if(compiler.targetPlatform == win32)
                strcat(string, ".dll");
             else if(compiler.targetPlatform == apple)
                strcat(string, ".dylib");
@@ -1260,7 +1270,13 @@ private:
             }
             break;
          case staticLibrary:
-            strcat(string, ".a");
+            if(compiler.staticLibFileExt)
+            {
+               strcat(string, ".");
+               strcat(string, compiler.staticLibFileExt);
+            }
+            else
+               strcat(string, ".a");
             break;
       }
    }
@@ -1546,8 +1562,8 @@ private:
       cc.concatx((String)prefix, compiler.ccCommand,  " ");
       cxx.concatx((String)prefix, compiler.cxxCommand, " ");
 
+      ar.concatx((String)gnuToolchainPrefix, compiler.arCommand,  " ");
       strip.concatx(gnuToolchainPrefix, "strip ");
-      ar.concatx(gnuToolchainPrefix, "ar rcs");
       windres.concatx(gnuToolchainPrefix, "windres ");
 
       testLen = Max(testLen, ecp.size);
@@ -2090,7 +2106,6 @@ private:
       char command[MAX_F_STRING*4];
       char * compilerName = CopyString(compiler.name);
       Map<String, NameCollisionInfo> cfgNameCollisions;
-      const char * objFileExt = strcmp(compiler.objectFileExt, objectDefaultFileExt) != 0 ? compiler.objectFileExt : null;
 
       delete lastBuildConfigName;
       lastBuildConfigName = CopyString(config ? config.name : "Common");
@@ -2129,15 +2144,13 @@ private:
             // Create object dir if it does not exist already
             if(!FileExists(objDirExp.dir).isDirectory)
             {
-               sprintf(command, "%s CF_DIR=\"%s\"%s%s%s%s%s COMPILER=%s%s%s objdir -C \"%s\"%s%s -f \"%s\"",
+               sprintf(command, "%s CF_DIR=\"%s\"%s%s%s%s%s COMPILER=%s objdir -C \"%s\"%s%s -f \"%s\"",
                      compiler.makeCommand, cfDir,
                      crossCompiling ? " TARGET_PLATFORM=" : "",
                      targetPlatform,
                      bitDepth ? " ARCH=" : "", bitDepth == 32 ? "32" : bitDepth == 64 ? "64" : "",
                      /*(bitDepth == 64 && compiler.targetPlatform == win32) ? " GCC_PREFIX=x86_64-w64-mingw32-" : (bitDepth == 32 && compiler.targetPlatform == win32) ? " GCC_PREFIX=i686-w64-mingw32-" : */"",
-
                      compilerName,
-                     objFileExt ? " O=." : "", objFileExt ? objFileExt : "",
                      topNode.path, outputMode == verbose ? " V=1" : "", outputMode == justPrint ? " -n" : "", makeFilePath);
                if(outputMode != normal)
                   ide.outputView.buildBox.Logf("%s\n", command);
@@ -2189,7 +2202,7 @@ private:
          GccVersionInfo cxxVersion = GetGccVersionInfo(compiler, compiler.cxxCommand);
          char cfDir[MAX_LOCATION];
          GetIDECompilerConfigsDir(cfDir, true, true);
-         sprintf(command, "%s%s %sCF_DIR=\"%s\"%s%s%s%s%s%s COMPILER=%s%s%s %s%s%s-j%d %s%s%s -C \"%s\"%s%s -f \"%s\"",
+         sprintf(command, "%s%s %sCF_DIR=\"%s\"%s%s%s%s%s%s COMPILER=%s%s %s%s%s-j%d %s%s%s -C \"%s\"%s%s -f \"%s\"",
 #if defined(__WIN32__)
                "",
 #else
@@ -2205,7 +2218,7 @@ private:
                ide.workspace.useValgrind ? " DISABLED_POOLING=1" : "",
                /*(bitDepth == 64 && compiler.targetPlatform == win32) ? " GCC_PREFIX=x86_64-w64-mingw32-" : (bitDepth == 32 && compiler.targetPlatform == win32) ? " GCC_PREFIX=i686-w64-mingw32-" :*/ "",
                compilerName,
-               objFileExt ? " O=." : "", objFileExt ? objFileExt : "",
+               compiler.noStripTarget ? " NOSTRIP=y" : "",
                eC_Debug ? "--always-make " : "",
                ccVersion == post4_8 ? "GCC_CC_FLAGS=-fno-diagnostics-show-caret " : "",
                cxxVersion == post4_8 ? "GCC_CXX_FLAGS=-fno-diagnostics-show-caret " : "",
@@ -2283,7 +2296,6 @@ private:
       PathBackup pathBackup { };
       bool crossCompiling = (compiler.targetPlatform != __runtimePlatform);
       const char * targetPlatform = crossCompiling ? (char *)compiler.targetPlatform : "";
-      const char * objFileExt = strcmp(compiler.objectFileExt, objectDefaultFileExt) ? compiler.objectFileExt : null;
 
       compilerName = CopyString(compiler.name);
       CamelCase(compilerName);
@@ -2318,12 +2330,11 @@ private:
       {
          char cfDir[MAX_LOCATION];
          GetIDECompilerConfigsDir(cfDir, true, true);
-         sprintf(command, "%s CF_DIR=\"%s\"%s%s%s%s COMPILER=%s%s%s %sclean%s -C \"%s\"%s%s -f \"%s\"",
+         sprintf(command, "%s CF_DIR=\"%s\"%s%s%s%s COMPILER=%s %sclean%s -C \"%s\"%s%s -f \"%s\"",
                compiler.makeCommand, cfDir,
                crossCompiling ? " TARGET_PLATFORM=" : "", targetPlatform,
                bitDepth ? " ARCH=" : "", bitDepth == 32 ? "32" : bitDepth == 64 ? "64" : "",
                compilerName,
-               objFileExt ? " O=." : "", objFileExt ? objFileExt : "",
                cleanType == realClean ? "real" : "", cleanType == cleanTarget ? "target" : "",
                topNode.path, outputMode == verbose ? " V=1" : "", outputMode == justPrint ? " -n": "", makeFilePath);
          if(outputMode != normal)
@@ -2348,7 +2359,7 @@ private:
       delete compilerName;
    }
 
-   void Run(const char * args, CompilerConfig compiler, ProjectConfig config, int bitDepth)
+   void Run(const char * args, CompilerConfig compiler, ProjectConfig config, int bitDepth, bool shellOpen)
    {
       String target = new char[maxPathLen];
       char oldDirectory[MAX_LOCATION];
@@ -2361,7 +2372,8 @@ private:
       strcpy(target, topNode.path);
       PathCatSlash(target, targetDirExp.dir);
       CatTargetFileName(target, compiler, config);
-      sprintf(target, "%s %s", target, args);
+      if(args[0] && (executableLauncher || !shellOpen))
+         sprintf(target, "%s %s", target, args);
       GetWorkingDir(oldDirectory, MAX_LOCATION);
 
       if(ide.workspace.debugDir && strlen(ide.workspace.debugDir))
@@ -2384,6 +2396,8 @@ private:
          Execute(prefixedTarget);
          delete prefixedTarget;
       }
+      else if(shellOpen)
+         ShellOpen(target);
       else
          Execute(target);
 
@@ -2508,6 +2522,24 @@ private:
                f.Puts("\n");
             }
 
+            f.Puts("# PREFIXES AND EXTENSIONS\n");
+            f.Puts("EC := .ec\n");
+            f.Puts("S := .sym\n");
+            f.Puts("I := .imp\n");
+            f.Puts("B := .bowl\n");
+            f.Puts("C := .c\n");
+            f.Printf("O := .%s\n", compiler.objectFileExt ? compiler.objectFileExt  : "o");
+            f.Printf("A := .%s\n", compiler.staticLibFileExt ? compiler.staticLibFileExt  : "a");
+            f.Printf("SO := .%s\n", compiler.sharedLibFileExt ? compiler.sharedLibFileExt : "$(if $(WINDOWS_TARGET),dll,$(if $(OSX_TARGET),dylib,so))");
+            f.Printf("E := %s%s\n", compiler.executableFileExt ? "." : "",
+                  compiler.executableFileExt ? compiler.executableFileExt : "$(if $(WINDOWS_TARGET),.exe,)");
+            f.Puts("OUT := $(if $(STATIC_LIBRARY_TARGET),$(A),$(if $(SHARED_LIBRARY_TARGET),$(SO)$(VER),$(if $(EXECUTABLE_TARGET),$(E),.x)))\n");
+            f.Puts("LP := $(if $(WINDOWS_TARGET),$(if $(STATIC_LIBRARY_TARGET),lib,),lib)\n");
+            f.Puts("HOST_E := $(if $(WINDOWS_HOST),.exe,)\n");
+            f.Puts("HOST_SO := $(if $(WINDOWS_HOST),.dll,$(if $(OSX_HOST),.dylib,.so))\n");
+            f.Puts("HOST_LP := $(if $(WINDOWS_HOST),$(if $(STATIC_LIBRARY_TARGET),lib,),lib)\n");
+            f.Puts(".SUFFIXES: .c .ec .sym .imp .bowl $(O) $(A)\n");
+
             f.Puts("# TOOLCHAIN\n");
             f.Puts("\n");
 
@@ -2518,6 +2550,9 @@ private:
                f.Puts("   USE_RESOURCES_EAR := defined\n");
                f.Puts("endif\n");
             }
+            if(compiler.noStripTarget)
+               f.Puts("NOSTRIP := defined");
+
             f.Puts("\n");
 
             f.Puts("# EXTENSIONS\n");
index f59d62d..6abf32e 100644 (file)
@@ -1612,17 +1612,18 @@ class ProjectView : Window
       CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.activeCompiler);
       ProjectConfig config = project.config;
       int bitDepth = ide.workspace.bitDepth;
+      bool shellOpen = compiler.hasDocumentOutput;
       String args = new char[maxPathLen];
       args[0] = '\0';
       if(ide.workspace.commandLineArgs)
          //ide.debugger.GetCommandLineArgs(args);
          strcpy(args, ide.workspace.commandLineArgs);
       if(ide.debugger.isActive)
-         project.Run(args, compiler, config, bitDepth);
+         project.Run(args, compiler, config, bitDepth, shellOpen);
       /*else if(config.targetType == sharedLibrary || config.targetType == staticLibrary)
          MessageBox { master = ide, type = ok, text = "Run", contents = "Shared and static libraries cannot be run like executables." }.Modal();*/
       else if(BuildInterrim(project, run, compiler, config, bitDepth, normal))
-         project.Run(args, compiler, config, bitDepth);
+         project.Run(args, compiler, config, bitDepth, shellOpen);
       delete args;
       delete compiler;
       return true;
@@ -1663,6 +1664,10 @@ class ProjectView : Window
 
                delete pathBackup;
             }
+            else if(compiler.hasDocumentOutput)
+            {
+               project.Run("", compiler, config, bitDepth, true);
+            }
             else
             {
                ide.debugger.Start(compiler, config, bitDepth, useValgrind);