flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [40/42] git commit: [flex-falcon] [refs/heads/develop] - Uses now the config file provided by IntelliJ when -output is not provided
Date Thu, 04 Jun 2015 06:06:46 GMT
Uses now the config file provided by IntelliJ when -output is not provided


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

Branch: refs/heads/develop
Commit: d6162d04bfa310266b089fcf608fd797638469fd
Parents: 2a9b27c
Author: Frédéric THOMAS <webdoublefx@gmail.com>
Authored: Wed Jun 3 02:14:49 2015 +0100
Committer: Frédéric THOMAS <webdoublefx@gmail.com>
Committed: Wed Jun 3 02:14:49 2015 +0100

----------------------------------------------------------------------
 .../src/org/apache/flex/utils/ArgumentUtil.java | 15 ++--
 flex-compiler-oem/src/flex2/tools/Tool.java     | 82 ++++++++++++++++----
 2 files changed, 74 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/d6162d04/compiler/src/org/apache/flex/utils/ArgumentUtil.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/utils/ArgumentUtil.java b/compiler/src/org/apache/flex/utils/ArgumentUtil.java
index 8b5fe7a..6987cba 100644
--- a/compiler/src/org/apache/flex/utils/ArgumentUtil.java
+++ b/compiler/src/org/apache/flex/utils/ArgumentUtil.java
@@ -53,14 +53,15 @@ public class ArgumentUtil {
             }
         }
 
-        if (index < 0 || index >= length) {
-            throw new IndexOutOfBoundsException("Index: " + index + ", Length: " + length);
-        }
+        String[] newArgs = new String[length - 1];
 
-        String[] newArgs = new String[args.length - 1];
-        System.arraycopy(args, 0, newArgs, 0, index);
-        if (index < length - 1) {
-            System.arraycopy(args, index + 1, newArgs, index, length - index - 1);
+        if (index < 0 || index >= length) {
+            System.arraycopy(args, 0, newArgs, 0, length - 1);
+        } else  {
+            System.arraycopy(args, 0, newArgs, 0, index);
+            if (index < length - 1) {
+                System.arraycopy(args, index + 1, newArgs, index, length - index - 1);
+            }
         }
 
         return newArgs;

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/d6162d04/flex-compiler-oem/src/flex2/tools/Tool.java
----------------------------------------------------------------------
diff --git a/flex-compiler-oem/src/flex2/tools/Tool.java b/flex-compiler-oem/src/flex2/tools/Tool.java
index a41c1f4..b77dd8f 100644
--- a/flex-compiler-oem/src/flex2/tools/Tool.java
+++ b/flex-compiler-oem/src/flex2/tools/Tool.java
@@ -31,6 +31,11 @@ import org.apache.flex.compiler.clients.MXMLC;
 import org.apache.flex.compiler.clients.MXMLJSC.JSOutputType;
 import org.apache.flex.compiler.clients.problems.ProblemQuery;
 import org.apache.flex.compiler.clients.problems.ProblemQueryProvider;
+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.filespecs.FileSpecification;
+import org.apache.flex.compiler.internal.config.FileConfigurator;
 import org.apache.flex.compiler.problems.CompilerProblemSeverity;
 import org.apache.flex.compiler.problems.ICompilerProblem;
 import org.apache.flex.compiler.problems.annotations.DefaultSeverity;
@@ -41,10 +46,7 @@ import java.io.FileInputStream;
 import java.io.IOException;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.InvocationTargetException;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
+import java.util.*;
 
 import static org.apache.flex.compiler.clients.MXMLJSC.JSOutputType.FLEXJS_DUAL;
 
@@ -81,26 +83,36 @@ public class Tool {
         return exitCode;
     }
 
-    protected static class ArgumentBag {
-        public String[] args;
+    protected static ArgumentBag preparePhase1(ArgumentBag bag) {
+        bag.isCommandLineOutput = true;
 
-        public String oldOutputPath;
-        public String newOutputPath;
+        bag.oldOutputPath = ArgumentUtil.getValue(bag.args, "-output");
 
-        public ArgumentBag(String[] args) {
-            this.args = args;
-        }
-    }
+        if (bag.oldOutputPath == null) {
+            bag.isCommandLineOutput = false;
+            ConfigurationBuffer flexConfig = null;
 
-    protected static ArgumentBag preparePhase1(ArgumentBag bag) {
-        bag.oldOutputPath = ArgumentUtil.getValue(bag.args, "-output");
+            try {
+                flexConfig = loadConfig(bag.args);
+            } catch (org.apache.flex.compiler.exceptions.ConfigurationException ignored)
{
+            }
+
+            final List<ConfigurationValue> output = flexConfig != null ? flexConfig.getVar("output")
: null;
+            final ConfigurationValue configurationValue = output != null ? output.get(0)
: null;
+            bag.oldOutputPath = configurationValue != null ? configurationValue.getArgs().get(0)
: null;
+        }
 
         if (bag.oldOutputPath != null) {
             final int lastIndexOf = Math.max(bag.oldOutputPath.lastIndexOf("/"), bag.oldOutputPath.lastIndexOf("\\"));
 
             if (lastIndexOf > -1) {
                 bag.newOutputPath = bag.oldOutputPath.substring(0, lastIndexOf) + File.separator
+ "js" + File.separator + "out";
-                ArgumentUtil.setValue(bag.args, "-output", bag.newOutputPath);
+
+                if (bag.isCommandLineOutput) {
+                    ArgumentUtil.setValue(bag.args, "-output", bag.newOutputPath);
+                } else {
+                    bag.args = ArgumentUtil.addValueAt(bag.args, "-output", bag.newOutputPath,
bag.args.length - 1);
+                }
             }
         }
 
@@ -111,7 +123,11 @@ public class Tool {
         bag.args = ArgumentUtil.removeElement(bag.args, "-js-output-type");
 
         if (bag.oldOutputPath != null) {
-            ArgumentUtil.setValue(bag.args, "-output", bag.oldOutputPath);
+            if (bag.isCommandLineOutput) {
+                ArgumentUtil.setValue(bag.args, "-output", bag.oldOutputPath);
+            } else {
+                bag.args = ArgumentUtil.removeElement(bag.args, "-output");
+            }
         }
 
         if (COMPILER.getName().equals(COMPC.class.getName())) {
@@ -121,6 +137,28 @@ public class Tool {
         return bag;
     }
 
+    private static ConfigurationBuffer loadConfig(String[] args) throws org.apache.flex.compiler.exceptions.ConfigurationException
{
+        final String configFilePath = ArgumentUtil.getValue(args, "-load-config");
+        final File configFile = new File(configFilePath);
+        final FileSpecification fileSpecification = new FileSpecification(configFile.getAbsolutePath());
+        final ConfigurationBuffer cfgbuf = createConfigurationBuffer(Configuration.class);
+
+        FileConfigurator.load(
+                cfgbuf,
+                fileSpecification,
+                new File(configFile.getPath()).getParent(),
+                "flex-config",
+                false);
+
+        return cfgbuf;
+    }
+
+    private static ConfigurationBuffer createConfigurationBuffer(
+            Class<? extends Configuration> configurationClass) {
+        return new ConfigurationBuffer(
+                configurationClass, Configuration.getAliases());
+    }
+
     protected static int flexCompile(String[] args) throws NoSuchMethodException, InstantiationException,
IllegalAccessException, InvocationTargetException {
         int exitCode;
 
@@ -263,4 +301,16 @@ public class Tool {
             return mxmlc.getProblems();
         }
     }
+
+    protected static class ArgumentBag {
+        public String[] args;
+
+        public String oldOutputPath;
+        public String newOutputPath;
+        public boolean isCommandLineOutput;
+
+        public ArgumentBag(String[] args) {
+            this.args = args;
+        }
+    }
 }


Mime
View raw message