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 2015/04/21 06:39:44 UTC

git commit: [flex-falcon] [refs/heads/develop] - pull JS files from the SWCs

Repository: flex-falcon
Updated Branches:
  refs/heads/develop 4d0fb41f1 -> 9d294a9ef


pull JS files from the SWCs


Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/9d294a9e
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/9d294a9e
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/9d294a9e

Branch: refs/heads/develop
Commit: 9d294a9ef58f1837bfb8cf8668045177b9774e9c
Parents: 4d0fb41
Author: Alex Harui <ah...@apache.org>
Authored: Mon Apr 20 21:39:36 2015 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Mon Apr 20 21:39:36 2015 -0700

----------------------------------------------------------------------
 .../codegen/js/flexjs/JSFlexJSEmitter.java      |  1 +
 .../mxml/flexjs/MXMLFlexJSPublisher.java        |  3 +-
 .../compiler/internal/graph/GoogDepsWriter.java | 67 +++++++++++++++++++-
 3 files changed, 69 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/9d294a9e/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
index 5ca8a61..d709929 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
@@ -396,6 +396,7 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
         	ignorable = ignorable.substring(0, endIndex);
         	ignorable = ignorable.trim();
     		ignoreList.add(ignorable);
+    		System.out.println("Found ignorable: " + ignorable);
     		index = doc.indexOf(ignoreToken, index + endIndex);
     	}
     	this.getDocEmitter();

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/9d294a9e/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.java
index 1d1b542..af11b15 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.java
@@ -266,7 +266,8 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements
         
         JSClosureCompilerWrapper compilerWrapper = new JSClosureCompilerWrapper();
 
-        GoogDepsWriter gdw = new GoogDepsWriter(intermediateDir, projectName, (JSGoogConfiguration) configuration);
+        GoogDepsWriter gdw = new GoogDepsWriter(intermediateDir, projectName, 
+        		(JSGoogConfiguration) configuration, project.getLibraries());
         StringBuilder depsFileData = new StringBuilder();
         try
         {

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/9d294a9e/compiler.jx/src/org/apache/flex/compiler/internal/graph/GoogDepsWriter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/graph/GoogDepsWriter.java b/compiler.jx/src/org/apache/flex/compiler/internal/graph/GoogDepsWriter.java
index e185535..2c89d98 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/graph/GoogDepsWriter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/graph/GoogDepsWriter.java
@@ -23,35 +23,43 @@ import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.FileWriter;
 import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
 import java.io.PrintWriter;
 import java.nio.charset.Charset;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.Scanner;
+import java.util.Set;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.flex.compiler.clients.problems.ProblemQuery;
 import org.apache.flex.compiler.internal.codegen.js.goog.JSGoogEmitterTokens;
 import org.apache.flex.compiler.internal.driver.js.goog.JSGoogConfiguration;
 import org.apache.flex.compiler.problems.FileNotFoundProblem;
+import org.apache.flex.swc.ISWC;
+import org.apache.flex.swc.ISWCFileEntry;
 
 import com.google.common.io.Files;
 
 public class GoogDepsWriter {
 
-	public GoogDepsWriter(File outputFolder, String mainClassName, JSGoogConfiguration config)
+	public GoogDepsWriter(File outputFolder, String mainClassName, JSGoogConfiguration config, List<ISWC> swcs)
 	{
 		this.outputFolderPath = outputFolder.getAbsolutePath();
 		this.mainName = mainClassName;
 		otherPaths = config.getSDKJSLib();
 		otherPaths.add(new File(outputFolder.getParent(), "flexjs/FlexJS/src").getPath());
+		this.swcs = swcs;
 	}
 	
 	private ProblemQuery problems;
 	private String outputFolderPath;
 	private String mainName;
 	private List<String> otherPaths;
+	private List<ISWC> swcs;
 	private boolean problemsFound = false;
 	private ArrayList<GoogDep> dps;
 	
@@ -425,6 +433,63 @@ public class GoogDepsWriter {
     		}
         }
         
+        for (ISWC swc : swcs)
+        {
+        	ISWCFileEntry fileEntry =  swc.getFile("js/src/" + classPath + ".js");
+        	if (fileEntry == null)
+        		fileEntry = swc.getFile("js/out/" + classPath + ".js");
+    		if (fileEntry != null)
+    		{
+    			fn = outputFolderPath + File.separator + classPath + ".js";
+    			destFile = new File(fn);
+    			// copy source to output
+    			try {
+    				InputStream inStream = fileEntry.createInputStream();
+    				OutputStream outStream = FileUtils.openOutputStream(destFile);
+    				byte[] b = new byte[1024 * 1024];
+    				int bytes_read;
+    				while ((bytes_read = inStream.read(b)) != -1)
+    				{
+        				outStream.write(b, 0, bytes_read);
+    				}
+    				outStream.flush();
+    				outStream.close();    					
+    				inStream.close();
+
+    				// (erikdebruin) copy class assets files
+    				if (className.contains("org_apache_flex"))
+    				{
+    					Map<String, ISWCFileEntry> includedfiles = swc.getFiles();
+    					Set<String> includedList = includedfiles.keySet();
+    					for (String included : includedList)
+    					{
+    						if (included.contains(".png") ||
+    							included.contains(".gif") ||
+    							included.contains(".jpg") ||
+    							included.contains(".json"))
+    						{
+    							fileEntry = includedfiles.get(included);
+    			    			String assetName = outputFolderPath + File.separator + included;
+    			    			File assetFile = new File(assetName);
+    		    				inStream = fileEntry.createInputStream();
+    		    				outStream = FileUtils.openOutputStream(assetFile);
+    		    				b = new byte[inStream.available()];
+    		    				inStream.read(b);
+    		    				outStream.write(b);
+    		    				inStream.close();
+    		    				outStream.flush();
+    		    				outStream.close();
+						        System.out.println("Copied asset " + assetName);
+    						}
+    					}
+    				}
+    			} catch (IOException e) {
+    				System.out.println("Error copying file for class: " + className);
+    			}
+    			return fn;
+    		}
+        }
+        
 		System.out.println("Could not find file for class: " + className);
 		problems.add(new FileNotFoundProblem(className));
 		problemsFound = true;