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 2017/05/01 03:47:40 UTC

[14/38] git commit: [flex-falcon] [refs/heads/develop] - allow SWF compilers to use a JS config so that they don't complain when sharing -config.xml files

allow SWF compilers to use a JS config so that they don't complain when sharing -config.xml files


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

Branch: refs/heads/develop
Commit: 6ae2ed16a949632541c3e64f69e6cf6ce4ae46a1
Parents: 5c8ca85
Author: Alex Harui <ah...@apache.org>
Authored: Tue Feb 14 10:13:28 2017 -0800
Committer: Alex Harui <ah...@apache.org>
Committed: Tue Feb 14 10:13:28 2017 -0800

----------------------------------------------------------------------
 .../apache/flex/compiler/clients/COMPJSC.java   |  8 +++--
 .../flex/compiler/clients/JSConfiguration.java  | 18 +++++++++++
 .../apache/flex/compiler/clients/MXMLJSC.java   | 32 +++++++++++++++++---
 .../org/apache/flex/compiler/clients/COMPC.java |  2 +-
 .../org/apache/flex/compiler/clients/MXMLC.java |  5 +--
 5 files changed, 55 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6ae2ed16/compiler-jx/src/main/java/org/apache/flex/compiler/clients/COMPJSC.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/clients/COMPJSC.java b/compiler-jx/src/main/java/org/apache/flex/compiler/clients/COMPJSC.java
index 0eba441..467b333 100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/clients/COMPJSC.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/clients/COMPJSC.java
@@ -52,6 +52,7 @@ import org.apache.flex.compiler.internal.codegen.js.JSWriter;
 import org.apache.flex.compiler.internal.driver.as.ASBackend;
 import org.apache.flex.compiler.internal.driver.js.amd.AMDBackend;
 import org.apache.flex.compiler.internal.driver.js.goog.GoogBackend;
+import org.apache.flex.compiler.internal.driver.js.goog.JSGoogConfiguration;
 import org.apache.flex.compiler.internal.driver.mxml.flexjs.MXMLFlexJSSWCBackend;
 import org.apache.flex.compiler.internal.driver.mxml.jsc.MXMLJSCJSSWCBackend;
 import org.apache.flex.compiler.internal.projects.CompilerProject;
@@ -194,7 +195,8 @@ public class COMPJSC extends MXMLJSC
 	                {
 	                case SWF:
 	                    COMPC compc = new COMPC();
-	                    result = compc.mainNoExit(args);
+	                    compc.configurationClass = JSGoogConfiguration.class;
+	                    result = compc.mainNoExit(removeJSArgs(args));
 	                    if (result != 0)
 	                    {
 	                    	problems.addAll(compc.problems.getProblems());
@@ -203,7 +205,7 @@ public class COMPJSC extends MXMLJSC
 	                    break;
 	                case JS_FLEX:
 	                	COMPJSCFlex flex = new COMPJSCFlex();
-	                    result = flex.mainNoExit(args, problems.getProblems(), false);
+	                    result = flex.mainNoExit(removeASArgs(args), problems.getProblems(), false);
 	                    if (result != 0)
 	                    {
 	                    	break targetloop;
@@ -211,7 +213,7 @@ public class COMPJSC extends MXMLJSC
 	                    break;
 	                case JS_NATIVE:
 	                	COMPJSCNative jsc = new COMPJSCNative();
-	                    result = jsc.mainNoExit(args, problems.getProblems(), false);
+	                    result = jsc.mainNoExit(removeASArgs(args), problems.getProblems(), false);
 	                    if (result != 0)
 	                    {
 	                    	break targetloop;

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6ae2ed16/compiler-jx/src/main/java/org/apache/flex/compiler/clients/JSConfiguration.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/clients/JSConfiguration.java b/compiler-jx/src/main/java/org/apache/flex/compiler/clients/JSConfiguration.java
index 53a2f54..ae614bc 100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/clients/JSConfiguration.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/clients/JSConfiguration.java
@@ -28,6 +28,7 @@ import java.util.Map;
 import org.apache.flex.compiler.clients.MXMLJSC.JSOutputType;
 import org.apache.flex.compiler.clients.MXMLJSC.JSTargetType;
 import org.apache.flex.compiler.config.Configuration;
+import org.apache.flex.compiler.config.ConfigurationBuffer;
 import org.apache.flex.compiler.config.ConfigurationValue;
 import org.apache.flex.compiler.exceptions.ConfigurationException;
 import org.apache.flex.compiler.exceptions.ConfigurationException.CannotOpen;
@@ -296,4 +297,21 @@ public class JSConfiguration extends Configuration
     	return value;
     }
 
+    /**
+     * @return JS equivalent of -load-config
+     */
+    public String getJsLoadConfig()
+    {
+    	return null;
+    }
+
+    /**
+     * Placeholder.  MXMLJSC picks off these values and changes them to load-config for the JS compilers
+     */
+    @Config(allowMultiple = true)
+    @Arguments("filename")
+    public void setJsLoadConfig(ConfigurationValue cv, String filename) throws ConfigurationException
+    {
+        
+    }
 }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6ae2ed16/compiler-jx/src/main/java/org/apache/flex/compiler/clients/MXMLJSC.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/clients/MXMLJSC.java b/compiler-jx/src/main/java/org/apache/flex/compiler/clients/MXMLJSC.java
index 8ce5f4c..e2c6486 100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/clients/MXMLJSC.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/clients/MXMLJSC.java
@@ -328,7 +328,7 @@ public class MXMLJSC implements JSCompilerEntryPoint, ProblemQueryProvider,
 	                    break;
 	                case JS_FLEX:
 	                	MXMLJSCFlex flex = new MXMLJSCFlex();
-	                    result = flex.mainNoExit(args, problems.getProblems(), false);
+	                    result = flex.mainNoExit(removeASArgs(args), problems.getProblems(), false);
 	                    if (result != 0)
 	                    {
 	                    	break targetloop;
@@ -336,7 +336,7 @@ public class MXMLJSC implements JSCompilerEntryPoint, ProblemQueryProvider,
 	                    break;
 	                case JS_NODE:
 	                	MXMLJSCNode node = new MXMLJSCNode();
-	                    result = node.mainNoExit(args, problems.getProblems(), false);
+	                    result = node.mainNoExit(removeASArgs(args), problems.getProblems(), false);
 	                    if (result != 0)
 	                    {
 	                    	break targetloop;
@@ -344,7 +344,7 @@ public class MXMLJSC implements JSCompilerEntryPoint, ProblemQueryProvider,
 	                    break;
 	                case JS_NATIVE:
 	                	MXMLJSCNative jsc = new MXMLJSCNative();
-	                    result = jsc.mainNoExit(args, problems.getProblems(), false);
+	                    result = jsc.mainNoExit(removeASArgs(args), problems.getProblems(), false);
 	                    if (result != 0)
 	                    {
 	                    	break targetloop;
@@ -398,7 +398,7 @@ public class MXMLJSC implements JSCompilerEntryPoint, ProblemQueryProvider,
         return exitCode.code;
     }
     
-    private String[] removeJSArgs(String[] args)
+    protected String[] removeJSArgs(String[] args)
     {
     	ArrayList<String> list = new ArrayList<String>();
     	for (String arg : args)
@@ -410,12 +410,36 @@ public class MXMLJSC implements JSCompilerEntryPoint, ProblemQueryProvider,
     			  arg.startsWith("-compiler.js-library-path") ||
     			  arg.startsWith("-compiler.js-define") ||
     			  arg.startsWith("-js-output") ||
+    			  arg.startsWith("-js-load-config") ||
     			  arg.startsWith("-source-map")))
     			list.add(arg);						
     	}
     	return list.toArray(new String[0]);
     }
 
+    protected String[] removeASArgs(String[] args)
+    {
+    	ArrayList<String> list = new ArrayList<String>();
+    	boolean hasJSLoadConfig = false;
+    	for (String arg : args)
+    	{
+    		if (arg.startsWith("-js-load-config"))
+    			hasJSLoadConfig = true;
+    	}
+    	if (!hasJSLoadConfig)
+    		return args;
+    	for (String arg : args)
+    	{
+    		if (!arg.startsWith("-load-config"))
+    		{
+    			if (arg.startsWith("-js-load-config"))
+    				arg = arg.substring(3);
+    			list.add(arg);	
+    		}
+    	}
+    	return list.toArray(new String[0]);
+    }
+    
     /**
      * Main body of this program. This method is called from the public static
      * method's for this program.

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6ae2ed16/compiler/src/main/java/org/apache/flex/compiler/clients/COMPC.java
----------------------------------------------------------------------
diff --git a/compiler/src/main/java/org/apache/flex/compiler/clients/COMPC.java b/compiler/src/main/java/org/apache/flex/compiler/clients/COMPC.java
index 547f40f..0c7ac71 100644
--- a/compiler/src/main/java/org/apache/flex/compiler/clients/COMPC.java
+++ b/compiler/src/main/java/org/apache/flex/compiler/clients/COMPC.java
@@ -108,7 +108,7 @@ public class COMPC extends MXMLC implements FlexTool
     @Override
     protected Configurator createConfigurator()
     {
-        return new Configurator(COMPCConfiguration.class);
+        return new Configurator(configurationClass);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/6ae2ed16/compiler/src/main/java/org/apache/flex/compiler/clients/MXMLC.java
----------------------------------------------------------------------
diff --git a/compiler/src/main/java/org/apache/flex/compiler/clients/MXMLC.java b/compiler/src/main/java/org/apache/flex/compiler/clients/MXMLC.java
index 7a7bfdd..d77db73 100644
--- a/compiler/src/main/java/org/apache/flex/compiler/clients/MXMLC.java
+++ b/compiler/src/main/java/org/apache/flex/compiler/clients/MXMLC.java
@@ -399,6 +399,7 @@ public class MXMLC implements FlexTool
     public ProblemQuery problems;
     public ConfigurationBuffer configBuffer;
 
+	public Class<? extends Configuration> configurationClass = Configuration.class;
     protected Configurator projectConfigurator;
 
     protected ICompilationUnit mainCU;
@@ -449,9 +450,9 @@ public class MXMLC implements FlexTool
      * @return a new instance or subclass of {@link Configurator}. 
      * 
      */
-    protected Configurator createConfigurator()
+	protected Configurator createConfigurator()
     {
-        return new Configurator();
+        return new Configurator(configurationClass);
     }
     
     /**