ide,ecere: <wip> fix ear support for emscripten.
authorRejean Loyer <redj@ecere.com>
Sun, 7 Dec 2014 01:46:12 +0000 (20:46 -0500)
committerRejean Loyer <redj@ecere.com>
Mon, 16 Mar 2015 05:31:59 +0000 (01:31 -0400)
ecere/src/sys/EARArchive.ec
ide/src/project/Project.ec
ide/src/project/ProjectNode.ec
ide/src/project/ProjectView.ec

index d9fd49a..9e28be7 100644 (file)
@@ -46,13 +46,18 @@ static File EAROpenArchive(const char * archive, EARHeader header)
    {
       char moduleName[MAX_LOCATION];
       const char * name = archive + 1;
-#if defined(__ANDROID__)
+#if defined(__ANDROID__) || defined(__EMSCRIPTEN__)
       if(!name[0])
          name = ((SubModule)__thisModule.application.modules.first).next.module.name;
 #endif
-
+#if defined(__EMSCRIPTEN__)
+      //sprintf(moduleName, "__%s.ear", name);
+      sprintf(moduleName, "__%s.ear", "HelloForm");
+      f = FileOpen(moduleName, read);
+#else
       if(LocateModule(name, moduleName))
          f = FileOpen(moduleName, read);
+#endif
    }
    else
       f = FileOpen(archive, read);
index 37aff11..bc2c2e6 100644 (file)
@@ -2697,11 +2697,12 @@ private:
       return result;
    }
 
-   bool GenerateMakefile(const char * altMakefilePath, bool noResources, const char * includemkPath, ProjectConfig config, const char * ldCommand)
+   bool GenerateMakefile(const char * altMakefilePath, bool noResources, const char * includemkPath, ProjectConfig config, CompilerConfig compiler)
    {
       bool result = false;
       char filePath[MAX_LOCATION];
       char makeFile[MAX_LOCATION];
+      const char * ldCommand = compiler.ldCommand;
       // PathBackup pathBackup { };
       // char oldDirectory[MAX_LOCATION];
       File f = null;
@@ -2917,6 +2918,10 @@ private:
             }
          }
          f.Puts("\n");
+         if(!strcmp(compiler.name, "em"))
+            f.Printf("EAR_TARGET = __%s.ear\n", fixedModuleName);
+         else
+            f.Printf("EAR_TARGET = $(TARGET)\n");
 
          // Use something fixed here, to not cause Makefile differences across compilers...
          varStringLenDiffs["$(OBJ)"] = 30; // strlen("obj/memoryGuard.android.gcc-4.6.2") - 6;
@@ -3401,7 +3406,10 @@ private:
 
          f.Puts("ifndef STATIC_LIBRARY_TARGET\n");
 
-         f.Printf("\t$(%s) $(OFLAGS) @$(OBJ)objects.lst $(LIBS) -o $(TARGET) $(INSTALLNAME)\n", ldCommand && ldCommand[0] ? "LD" : containsCXX ? "CXX" : "CC");
+         f.Printf("\t$(%s) $(OFLAGS) @$(OBJ)objects.lst $(LIBS)%s -o $(TARGET) $(INSTALLNAME)\n",
+               ldCommand && ldCommand[0] ? "LD" : containsCXX ? "CXX" : "CC",
+               //strcmp(compiler.name, "em") == 0 ? " --preload-file __HelloForm.ear" : "");
+               strcmp(compiler.name, "em") == 0 ? " --embed-file __HelloForm.ear" : "");
          if(!GetDebug(config))
          {
             f.Puts("ifndef NOSTRIP\n");
index 5ec1a39..4de2484 100644 (file)
@@ -2146,7 +2146,7 @@ private:
 
                // $(EAR) aw%s --- /*quiet ? "q" : */""
                if(count == 0)
-                  f.Printf("\t%s$(EAR) aw$(EARFLAGS) $(TARGET)", ts.a);
+                  f.Printf("\t%s$(EAR) aw$(EARFLAGS) $(EAR_TARGET)", ts.a);
 
                tempPath[0] = '\0';
                if(eString_PathInsideOfMore(child.path, resourcesPath, tempPath))
index 65d261a..c94ea22 100644 (file)
@@ -737,7 +737,7 @@ class ProjectView : Window
             //logBox.Logf("%s\n", makefileName);
             logBox.Logf($"%s - %s%smakefile for %s config...\n", makefileName, reason, action, GetConfigName(config));
 
-            if(!project.GenerateMakefile(null, false, null, config, compiler.ldCommand))
+            if(!project.GenerateMakefile(null, false, null, config, compiler))
                ide.outputView.buildBox.Logf($"Error generating makefile (Is the project directory writable?)\n");
 
             ide.statusBar.text = null;