README.md: add badges with links. minor tweaks.
[sdk] / epj2make / epj2make.ec
index 2d1b0c2..ab991be 100644 (file)
@@ -12,10 +12,24 @@ define pathListSep = ";";
 define pathListSep = ":";
 #endif
 
+#if defined(_DEBUG) && defined(__WIN32__)
+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;
-   byte * tokens[256];
+   char * tokens[256];
    int numTokens = TokenizeWith(string, sizeof(tokens) / sizeof(byte *), tokens, ";", false);
    list.Free();
    for(c = 0; c < numTokens; c++)
@@ -38,8 +52,6 @@ class epj2makeApp : GuiApplication
       int argc = 0;
       */
 
-      Platform targetPlatform = GetRuntimePlatform();
-
       Project project = null;
 
       CompilerConfig optionsCompiler { };
@@ -47,8 +59,8 @@ class epj2makeApp : GuiApplication
       bool noGlobalSettings = false;
       bool noResources = false;
       bool noWarnings = false;
-      char * overrideObjDir = null;
-      char * includemkPath = null;
+      const char * overrideObjDir = null;
+      const char * includemkPath = null;
 
       /*
       for(c = 0; c < this.argc; c++)
@@ -79,7 +91,7 @@ class epj2makeApp : GuiApplication
 
       for(c = 1; c < argc; c++)
       {
-         char * arg = argv[c];
+         const char * arg = argv[c];
          if(arg[0] == '-')
          {
             if(!strcmpi(arg+1, "make"))
@@ -163,8 +175,8 @@ class epj2makeApp : GuiApplication
             }
             else if(arg[1] == 't' && !arg[2])
             {
-               if(++c < argc)
-                  targetPlatform = argv[c];
+               // Obsolete target platform option
+               if(++c < argc);
                else
                   valid = false;
             }
@@ -182,14 +194,14 @@ class epj2makeApp : GuiApplication
             else if(arg[1] == 'i')
             {
                if(++c < argc)
-                  ParseDirList(argv[c], optionsCompiler.includeDirs);
+                  ParseDirList((char *)argv[c], optionsCompiler.includeDirs);
                else
                   valid = false;
             }
             else if(arg[1] == 'l')
             {
                if(++c < argc)
-                  ParseDirList(argv[c], optionsCompiler.libraryDirs);
+                  ParseDirList((char *)argv[c], optionsCompiler.libraryDirs);
                else
                   valid = false;
             }
@@ -221,27 +233,27 @@ class epj2makeApp : GuiApplication
       }
       if(!epjPath)
          valid = false;
-      
+
       if(!valid)
       {
-         printf($"Syntax:\n");
-         printf($"   epj2make [-t <target platform>] [-c <configuration>] [toolchain] [directories] [options] [-o <output>] <input>\n");
-         printf($"      toolchain:\n");
-         printf($"         [-make <make tool>]\n");
-         printf($"         [-cpp <c preprocessor>]\n");
-         printf($"         [-cc <c compiler>]\n");
-         printf($"         [-ecp <eC preprocessor>]\n");
-         printf($"         [-ecc <eC compiler>]\n");
-         printf($"         [-ecs <eC symbol generator>]\n");
-         printf($"         [-ear <Ecere Archiver>]\n");
-         printf($"      directories:\n");
-         printf($"         [-i <include dir[;inc dir[...]]>]\n");
-         printf($"         [-l <library dir[;lib dir[...]]>]\n");
-         printf($"      options:\n");
-         printf($"         [-noglobalsettings]\n");
-         printf($"         [-noresources]\n");
-         printf($"         [-d <intermediate objects directory>]\n");
-         printf($"         [-includemk <crossplatform.mk path>]\n");
+         printf("%s", $"Syntax:\n");
+         printf("%s", $"   epj2make [-t <target platform>] [-c <configuration>] [toolchain] [directories] [options] [-o <output>] <input>\n");
+         printf("%s", $"      toolchain:\n");
+         printf("%s", $"         [-make <make tool>]\n");
+         printf("%s", $"         [-cpp <c preprocessor>]\n");
+         printf("%s", $"         [-cc <c compiler>]\n");
+         printf("%s", $"         [-ecp <eC preprocessor>]\n");
+         printf("%s", $"         [-ecc <eC compiler>]\n");
+         printf("%s", $"         [-ecs <eC symbol generator>]\n");
+         printf("%s", $"         [-ear <Ecere Archiver>]\n");
+         printf("%s", $"      directories:\n");
+         printf("%s", $"         [-i <include dir[;inc dir[...]]>]\n");
+         printf("%s", $"         [-l <library dir[;lib dir[...]]>]\n");
+         printf("%s", $"      options:\n");
+         printf("%s", $"         [-noglobalsettings]\n");
+         printf("%s", $"         [-noresources]\n");
+         printf("%s", $"         [-d <intermediate objects directory>]\n");
+         printf("%s", $"         [-includemk <crossplatform.mk path>]\n");
       }
       else
       {
@@ -259,16 +271,18 @@ class epj2makeApp : GuiApplication
                }
                else
                {
-                  char * compiler = getenv("COMPILER");
+                  const char * compiler = getenv("COMPILER");
                   if(!compiler) compiler = "Default";
                   settingsContainer.Load();
+                  ideConfig.compilers.read(settingsContainer);
+
                   //incref ideSettings;
                   delete settingsContainer;
 
       // TODO: Command line option to choose between the two
-      // or a command line option to not use global settings 
+      // or a command line option to not use global settings
       //defaultCompiler = MakeDefaultCompiler();
-                  defaultCompiler = ideSettings.GetCompilerConfig(compiler);
+                  defaultCompiler = ideConfig.compilers.GetCompilerConfig(compiler);
       // possible TODO: use the workspace to select the active compiler
       // TODO: option to specify compiler name when using global settings
                }
@@ -294,7 +308,7 @@ class epj2makeApp : GuiApplication
                   defaultCompiler.libraryDirs.Add(dir);
                delete optionsCompiler;
 
-               project = LoadProject(epjPath);
+               project = LoadProject(epjPath, null);
                if(project)
                {
                   ProjectConfig defaultConfig = null;
@@ -355,8 +369,8 @@ class epj2makeApp : GuiApplication
                   }
                   if(valid)
                   {
-                     project.GenerateCompilerMk(defaultCompiler);
-                     project.GenerateCrossPlatformCf();
+                     project.GenerateCompilerCf(defaultCompiler, project.topNode.ContainsFilesWithExtension("ec", project.config));
+                     project.GenerateCrossPlatformMk(null);
                      if(project.GenerateMakefile(makePath, noResources, includemkPath, project.config))
                      {
                         if(makePath)
@@ -396,7 +410,7 @@ class epj2makeApp : GuiApplication
 
       // CheckMemory();
       delete ideSettings;
-#ifdef _DEBUG      
+#if defined(_DEBUG) && defined(__WIN32__)
       getch();
 #endif
    }