You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ah...@apache.org on 2013/03/08 05:41:10 UTC
svn commit: r1454249 - in
/flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler:
clients/MXMLJSC.java internal/graph/GoogDepsWriter.java
Author: aharui
Date: Fri Mar 8 04:41:10 2013
New Revision: 1454249
URL: http://svn.apache.org/r1454249
Log:
Generate html wrappers (at least for now)
Modified:
flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/clients/MXMLJSC.java
flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/internal/graph/GoogDepsWriter.java
Modified: flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/clients/MXMLJSC.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/clients/MXMLJSC.java?rev=1454249&r1=1454248&r2=1454249&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/clients/MXMLJSC.java (original)
+++ flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/clients/MXMLJSC.java Fri Mar 8 04:41:10 2013
@@ -479,6 +479,11 @@ public class MXMLJSC
buildArtifact();
final File outputFile = new File(getOutputFilePath());
+ final File outputFolder = outputFile.getParentFile();
+ if (!outputFolder.exists())
+ {
+ outputFolder.mkdirs();
+ }
if (swfTarget != null)
{
@@ -500,7 +505,6 @@ public class MXMLJSC
if (JSSharedData.OUTPUT_ISOLATED)
{
- final File outputFolder = new File(outputFile.getParent());
List<ICompilationUnit> reachableCompilationUnits = project.getReachableCompilationUnitsInSWFOrder(ImmutableSet.of(mainCU));
for (final ICompilationUnit cu : reachableCompilationUnits)
{
@@ -1180,25 +1184,29 @@ public class MXMLJSC
BufferedOutputStream outputbuffer;
try {
String mainName = mainCU.getShortNames().get(0);
+ File outputFolder = outputFile.getParentFile();
outputbuffer = new BufferedOutputStream(new FileOutputStream(outputFile));
outputbuffer.write(optimizedCode.getBytes());
outputbuffer.flush();
outputbuffer.close();
- System.out.println("Assumptions:");
- System.out.println(" 1) Output folder has html file of the form:");
- System.out.println("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">");
- System.out.println("<html xmlns=\"http://www.w3.org/1999/xhtml\">");
- System.out.println("<head>");
- System.out.println("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />");
- System.out.println("<script type=\"text/javascript\" src=\"" + mainName + ".js" + "\" ></script>");
- System.out.println("<script type=\"text/javascript\">");
- System.out.println(" var app = new " + mainName + "();");
- System.out.println("</script>");
- System.out.println("<title>" + mainName + "</title>");
- System.out.println("</head>");
- System.out.println("<body onload=\"app.start()\">");
- System.out.println("</body>");
- System.out.println("</html>");
+ File htmlFile = new File(outputFolder.getAbsolutePath() + File.separator + mainName + ".example.html");
+ outputbuffer = new BufferedOutputStream(new FileOutputStream(htmlFile));
+ String html = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
+ html += "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n";
+ html += "<head>\n";
+ html += "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n";
+ html += "<script type=\"text/javascript\" src=\"" + mainName + ".js" + "\" ></script>\n";
+ html += "<script type=\"text/javascript\">\n";
+ html += " var app = new " + mainName + "();\n";
+ html += "</script>\n";
+ html += "<title>" + mainName + "</title>\n";
+ html += "</head>\n";
+ html += "<body onload=\"app.start()\">\n";
+ html += "</body>\n";
+ html += "</html>\n";
+ outputbuffer.write(html.getBytes());
+ outputbuffer.flush();
+ outputbuffer.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Modified: flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/internal/graph/GoogDepsWriter.java
URL: http://svn.apache.org/viewvc/flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/internal/graph/GoogDepsWriter.java?rev=1454249&r1=1454248&r2=1454249&view=diff
==============================================================================
--- flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/internal/graph/GoogDepsWriter.java (original)
+++ flex/falcon/trunk/compiler.js/src/org/apache/flex/compiler/internal/graph/GoogDepsWriter.java Fri Mar 8 04:41:10 2013
@@ -1,9 +1,11 @@
package org.apache.flex.compiler.internal.graph;
import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -47,7 +49,7 @@ public class GoogDepsWriter {
return files;
}
- public void writeToStream(OutputStream outputStream) throws InterruptedException
+ public void writeToStream(OutputStream outputStream) throws InterruptedException, FileNotFoundException
{
buildDB();
String mainName = mainCU.getShortNames().get(0);
@@ -96,8 +98,30 @@ public class GoogDepsWriter {
System.out.println("<body onload=\"app.start()\">");
System.out.println("</body>");
System.out.println("</html>");
+ File htmlFile = new File(outputFolderPath + File.separator + mainName + ".example.html");
+ BufferedOutputStream outputbuffer = new BufferedOutputStream(new FileOutputStream(htmlFile));
+ String html = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
+ html += "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n";
+ html += "<head>\n";
+ html += "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n";
+ html += "<script type=\"text/javascript\" src=\"goog/base.js\" ></script>\n";
+ html += "<script type=\"text/javascript\" src=\"" + mainName + "Deps.js" + "\" ></script>\n";
+ html += "<script type=\"text/javascript\">\n";
+ html += " goog.require('" + mainName + "')\n";
+ html += "</script>\n";
+ html += "<script type=\"text/javascript\">\n";
+ html += " var app = new " + mainName + "();\n";
+ html += "</script>\n";
+ html += "<title>" + mainName + "</title>\n";
+ html += "</head>\n";
+ html += "<body onload=\"app.start()\">\n";
+ html += "</body>\n";
+ html += "</html>\n";
try
{
+ outputbuffer.write(html.getBytes());
+ outputbuffer.flush();
+ outputbuffer.close();
outputStream.write(outString.getBytes());
}
catch (IOException e)
@@ -165,6 +189,7 @@ public class GoogDepsWriter {
String getFilePath(String className)
{
+ System.out.println("Finding file for class: " + className);
String classPath = className.replace(".", File.separator);
String fn = frameworkRoot + File.separator + classPath + ".js";
File f = new File(fn);