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/06/20 09:07:51 UTC

[5/5] git commit: [flex-falcon] [refs/heads/develop] - get CLI working for EXTERNC

get CLI working for EXTERNC


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

Branch: refs/heads/develop
Commit: 0c8ab8d51450e767d08d2371a108747c2889ec8e
Parents: f489326
Author: Alex Harui <ah...@apache.org>
Authored: Fri Jun 19 23:13:41 2015 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Sat Jun 20 00:06:17 2015 -0700

----------------------------------------------------------------------
 .../apache/flex/compiler/clients/EXTERNC.java   | 37 +++++++++-
 .../compiler/clients/ExternCConfiguration.java  | 74 ++++++++++++++++++--
 2 files changed, 103 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/0c8ab8d5/compiler.jx/src/org/apache/flex/compiler/clients/EXTERNC.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/clients/EXTERNC.java b/compiler.jx/src/org/apache/flex/compiler/clients/EXTERNC.java
index 7bb9b42..8a632db 100644
--- a/compiler.jx/src/org/apache/flex/compiler/clients/EXTERNC.java
+++ b/compiler.jx/src/org/apache/flex/compiler/clients/EXTERNC.java
@@ -24,11 +24,14 @@ import java.util.HashSet;
 import java.util.Set;
 
 import org.apache.commons.io.FileUtils;
+import org.apache.flex.compiler.config.Configurator;
+import org.apache.flex.compiler.config.ICompilerSettingsConstants;
 import org.apache.flex.compiler.internal.codegen.externals.emit.ReferenceEmitter;
 import org.apache.flex.compiler.internal.codegen.externals.pass.ReferenceCompiler;
 import org.apache.flex.compiler.internal.codegen.externals.reference.ReferenceModel;
 import org.apache.flex.compiler.internal.codegen.js.JSSharedData;
 import org.apache.flex.compiler.problems.ICompilerProblem;
+import org.apache.flex.compiler.targets.ITarget.TargetType;
 
 import com.google.javascript.jscomp.Result;
 
@@ -53,6 +56,7 @@ public class EXTERNC
         final int code;
     }
 
+    protected Configurator projectConfigurator;
     private ExternCConfiguration configuration;
     private ReferenceModel model;
     private ReferenceCompiler compiler;
@@ -73,8 +77,26 @@ public class EXTERNC
         return emitter;
     }
 
+    public EXTERNC()
+    {
+    }
+    
     public EXTERNC(ExternCConfiguration configuration)
     {
+    	configure(configuration);
+    }
+
+    public void configure(String[] args)
+    {
+        projectConfigurator = createConfigurator();    
+        projectConfigurator.setConfiguration(args,
+                "external", false);
+        projectConfigurator.getTargetSettings(TargetType.SWC);
+        configure((ExternCConfiguration)projectConfigurator.getConfiguration());
+    }
+    
+    public void configure(ExternCConfiguration configuration)
+    {
         this.configuration = configuration;
 
         model = new ReferenceModel(configuration);
@@ -83,6 +105,17 @@ public class EXTERNC
     }
 
     /**
+     * Create a new Configurator. This method may be overridden to allow
+     * Configurator subclasses to be created that have custom configurations.
+     * 
+     * @return a new instance or subclass of {@link Configurator}.
+     */
+    protected Configurator createConfigurator()
+    {
+    	return new Configurator(ExternCConfiguration.class);
+    }
+    
+    /**
      * Java program entry point.
      * 
      * @param args command line arguments
@@ -103,8 +136,8 @@ public class EXTERNC
     {
         long startTime = System.nanoTime();
 
-        ExternCConfiguration config = new ExternCConfiguration(args);
-        final EXTERNC compiler = new EXTERNC(config);
+        final EXTERNC compiler = new EXTERNC();
+        compiler.configure(args);
         final Set<ICompilerProblem> problems = new HashSet<ICompilerProblem>();
         final int exitCode = compiler.mainNoExit(args, problems, true);
 

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/0c8ab8d5/compiler.jx/src/org/apache/flex/compiler/clients/ExternCConfiguration.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/clients/ExternCConfiguration.java b/compiler.jx/src/org/apache/flex/compiler/clients/ExternCConfiguration.java
index 44d27f4..0a620eb 100644
--- a/compiler.jx/src/org/apache/flex/compiler/clients/ExternCConfiguration.java
+++ b/compiler.jx/src/org/apache/flex/compiler/clients/ExternCConfiguration.java
@@ -25,13 +25,21 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
+import org.apache.flex.compiler.config.Configuration;
+import org.apache.flex.compiler.config.ConfigurationValue;
+import org.apache.flex.compiler.exceptions.ConfigurationException.CannotOpen;
+import org.apache.flex.compiler.exceptions.ConfigurationException.IncorrectArgumentCount;
 import org.apache.flex.compiler.internal.codegen.externals.pass.ReferenceCompiler.ExternalFile;
 import org.apache.flex.compiler.internal.codegen.externals.reference.ClassReference;
 import org.apache.flex.compiler.internal.codegen.externals.reference.FieldReference;
 import org.apache.flex.compiler.internal.codegen.externals.reference.MemberReference;
+import org.apache.flex.compiler.internal.config.annotations.Arguments;
+import org.apache.flex.compiler.internal.config.annotations.Config;
+import org.apache.flex.compiler.internal.config.annotations.InfiniteArguments;
+import org.apache.flex.compiler.internal.config.annotations.Mapping;
 import org.apache.flex.utils.FilenameNormalization;
 
-public class ExternCConfiguration
+public class ExternCConfiguration extends Configuration
 {
     private File asRoot;
 
@@ -52,16 +60,18 @@ public class ExternCConfiguration
     {
     }
 
-    public ExternCConfiguration(String[] args)
-    {
-        // TODO (mschmalle) implement argument digesting
-    }
-
     public File getAsRoot()
     {
         return asRoot;
     }
 
+    @Config
+    @Mapping("as-root")
+    public void setASRoot(ConfigurationValue cfgval, String filename) throws CannotOpen
+    {
+    	setASRoot(new File(FilenameNormalization.normalize(getOutputPath(cfgval, filename))));
+    }
+    
     public void setASRoot(File file)
     {
         this.asRoot = file;
@@ -125,6 +135,16 @@ public class ExternCConfiguration
         addExternal(new File(FilenameNormalization.normalize(externalFile)));
     }
 
+    @Config(allowMultiple = true, isPath = true)
+    @Mapping("external")
+    @Arguments(Arguments.PATH_ELEMENT)
+    @InfiniteArguments
+    public void setExternal(ConfigurationValue cfgval, String[] vals) throws IOException, CannotOpen
+    {
+    	for (String val : vals)
+    		addExternal(resolvePathStrict(val, cfgval));
+    }
+    
     public ExcludedMemeber isExcludedClass(ClassReference classReference)
     {
         for (ExcludedMemeber memeber : excludesClass)
@@ -154,6 +174,23 @@ public class ExternCConfiguration
         return null;
     }
 
+    @Config(allowMultiple = true)
+    @Mapping("exclude")
+    @Arguments({"class", "name"})
+    public void setExcludes(ConfigurationValue cfgval, List<String> values) throws IncorrectArgumentCount
+    {
+        final int size = values.size();
+        if (size % 2 != 0)
+            throw new IncorrectArgumentCount(size + 1, size, cfgval.getVar(), cfgval.getSource(), cfgval.getLine());
+
+        for (int nameIndex = 0; nameIndex < size - 1; nameIndex += 2)
+        {
+            final String className = values.get(nameIndex);
+            final String name = values.get(nameIndex + 1);
+        	addExclude(className, name);
+        }
+    }
+    
     public void addExclude(String className, String name)
     {
         excludes.add(new ExcludedMemeber(className, name));
@@ -164,11 +201,36 @@ public class ExternCConfiguration
         excludes.add(new ExcludedMemeber(className, name, description));
     }
 
+    @Config(allowMultiple = true)
+    @Mapping("field-exclude")
+    @Arguments({"class", "field"})
+    public void setFieldExcludes(ConfigurationValue cfgval, List<String> values) throws IncorrectArgumentCount
+    {
+        final int size = values.size();
+        if (size % 2 != 0)
+            throw new IncorrectArgumentCount(size + 1, size, cfgval.getVar(), cfgval.getSource(), cfgval.getLine());
+
+        for (int nameIndex = 0; nameIndex < size - 1; nameIndex += 2)
+        {
+            final String className = values.get(nameIndex);
+            final String fieldName = values.get(nameIndex + 1);
+        	addFieldExclude(className, fieldName);
+        }
+    }
+    
     public void addFieldExclude(String className, String fieldName)
     {
         excludesField.add(new ExcludedMemeber(className, fieldName, ""));
     }
 
+    @Config(allowMultiple = true)
+    @Mapping("class-exclude")
+    @Arguments("class")
+    public void setClassExcludes(ConfigurationValue cfgval, List<String> values)
+    {
+    	for (String className : values)
+    		addClassExclude(className);
+    }
     public void addClassExclude(String className)
     {
         excludesClass.add(new ExcludedMemeber(className, null, ""));