flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erikdebr...@apache.org
Subject [1/4] git commit: [FalconJX] improved output file management
Date Fri, 12 Apr 2013 13:05:25 GMT
Updated Branches:
  refs/heads/develop 1b5195a6b -> 31da8f27b


[FalconJX] improved output file management

The responsibility for file management (i.e. output directory cleanup and creation) is moved
to the Publishers. In anticipation of "marmotinni", a bypass for the file management is added
so the test framework can take care of this.

Signed-off-by: Erik de Bruin <erik@ixsoftware.nl>


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

Branch: refs/heads/develop
Commit: 92adca358f934fe16a82dbc3e8386c00ef2528c4
Parents: 7d9a461
Author: Erik de Bruin <erik@ixsoftware.nl>
Authored: Thu Apr 11 12:29:50 2013 +0200
Committer: Erik de Bruin <erik@ixsoftware.nl>
Committed: Fri Apr 12 09:16:10 2013 +0200

----------------------------------------------------------------------
 .../org/apache/flex/compiler/clients/MXMLJSC.java  |   23 ++--------
 .../compiler/internal/codegen/js/JSPublisher.java  |   36 ++++++++++++++-
 .../internal/codegen/js/goog/JSGoogPublisher.java  |   31 +++++++-----
 .../codegen/mxml/flexjs/MXMLFlexJSPublisher.java   |   32 +++++++++-----
 4 files changed, 78 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/92adca35/compiler.jx/src/org/apache/flex/compiler/clients/MXMLJSC.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/clients/MXMLJSC.java b/compiler.jx/src/org/apache/flex/compiler/clients/MXMLJSC.java
index 7bfd437..cd956d5 100644
--- a/compiler.jx/src/org/apache/flex/compiler/clients/MXMLJSC.java
+++ b/compiler.jx/src/org/apache/flex/compiler/clients/MXMLJSC.java
@@ -329,44 +329,29 @@ public class MXMLJSC
                         return false;
                 }
 
-                File outputFolder = new File(getOutputFilePath());
-                if (!outputFolder.isDirectory())
-                    outputFolder = outputFolder.getParentFile();
-
                 // output type specific pre-compile actions
                 switch (jsOutputType)
                 {
-                case AMD: {
-                    //
-
-                    break;
-                }
-
                 case FLEXJS: {
                     jsPublisher = new MXMLFlexJSPublisher(config);
 
-                    outputFolder = jsPublisher.getOutputFolder();
-
                     break;
                 }
 
                 case GOOG: {
                     jsPublisher = new JSGoogPublisher(config);
 
-                    outputFolder = jsPublisher.getOutputFolder();
-
                     break;
                 }
+                case AMD:
                 default: {
                     jsPublisher = new JSPublisher(config);
+
+                    break;
                 }
                 }
 
-                if (outputFolder.exists())
-                    org.apache.commons.io.FileUtils.deleteQuietly(outputFolder);
-
-                if (!outputFolder.exists())
-                    outputFolder.mkdirs();
+                File outputFolder = jsPublisher.getOutputFolder();
 
                 List<ICompilationUnit> reachableCompilationUnits = project
                         .getReachableCompilationUnitsInSWFOrder(ImmutableSet

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/92adca35/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/JSPublisher.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/JSPublisher.java
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/JSPublisher.java
index 7e548d0..468485d 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/JSPublisher.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/JSPublisher.java
@@ -22,6 +22,7 @@ package org.apache.flex.compiler.internal.codegen.js;
 import java.io.File;
 import java.io.IOException;
 
+import org.apache.commons.io.FilenameUtils;
 import org.apache.flex.compiler.codegen.js.IJSPublisher;
 import org.apache.flex.compiler.config.Configuration;
 
@@ -33,11 +34,44 @@ public class JSPublisher implements IJSPublisher
         this.configuration = config;
     }
 
+    protected File outputFolder;
+    protected File outputParentFolder;
+
+
     protected Configuration configuration;
 
     public File getOutputFolder()
     {
-        return null;
+        outputFolder = new File(getOutputFilePath());
+        if (!outputFolder.isDirectory())
+            outputFolder = outputFolder.getParentFile();
+
+        outputParentFolder = outputFolder;
+
+        setupOutputFolder();
+
+        return outputFolder;
+    }
+
+    protected void setupOutputFolder()
+    {
+        if (outputParentFolder.exists())
+            org.apache.commons.io.FileUtils.deleteQuietly(outputParentFolder);
+
+        if (!outputFolder.exists())
+            outputFolder.mkdirs();
+    }
+
+    private String getOutputFilePath()
+    {
+        if (configuration.getOutput() == null)
+        {
+            final String extension = "." + JSSharedData.OUTPUT_EXTENSION;
+            return FilenameUtils.removeExtension(configuration.getTargetFile())
+                    .concat(extension);
+        }
+        else
+            return configuration.getOutput();
     }
 
     public void publish() throws IOException

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/92adca35/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/goog/JSGoogPublisher.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/goog/JSGoogPublisher.java
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/goog/JSGoogPublisher.java
index 3f46334..ba022e6 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/goog/JSGoogPublisher.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/goog/JSGoogPublisher.java
@@ -38,11 +38,13 @@ public class JSGoogPublisher extends JSPublisher implements IJSPublisher
 
     public File getOutputFolder()
     {
-        File outputFolder = new File(configuration.getTargetFileDirectory())
+        outputParentFolder = new File(configuration.getTargetFileDirectory())
                 .getParentFile();
-        outputFolder = new File(outputFolder,
+        outputFolder = new File(outputParentFolder,
                 JSGoogPublisher.GOOG_INTERMEDIATE_DIR_NAME);
 
+        setupOutputFolder();
+
         return outputFolder;
     }
 
@@ -52,8 +54,8 @@ public class JSGoogPublisher extends JSPublisher implements IJSPublisher
 
         final String projectName = FilenameUtils.getBaseName(configuration
                 .getTargetFile());
-        final String outputFileName = projectName + "."
-                + JSSharedData.OUTPUT_EXTENSION;
+        final String outputFileName = projectName
+                + "." + JSSharedData.OUTPUT_EXTENSION;
 
         File releaseDir = new File(
                 new File(intermediateDirPath).getParentFile(),
@@ -83,8 +85,8 @@ public class JSGoogPublisher extends JSPublisher implements IJSPublisher
         final String depsTgtFilePath = intermediateDirPath + "/deps.js";
         final String projectIntermediateJSFilePath = intermediateDirPath
                 + File.separator + outputFileName;
-        final String projectReleaseJSFilePath = releaseDirPath + File.separator
-                + outputFileName;
+        final String projectReleaseJSFilePath = releaseDirPath
+                + File.separator + outputFileName;
 
         appendExportSymbol(projectIntermediateJSFilePath, projectName);
 
@@ -136,10 +138,10 @@ public class JSGoogPublisher extends JSPublisher implements IJSPublisher
         optionList.add("--only_closure_dependencies");
         optionList.add("--compilation_level=ADVANCED_OPTIMIZATIONS");
         optionList.add("--js_output_file=" + projectReleaseJSFilePath);
-        optionList.add("--output_manifest=" + releaseDirPath + File.separator
-                + "manifest.txt");
-        optionList.add("--create_source_map=" + projectReleaseJSFilePath
-                + ".map");
+        optionList.add("--output_manifest="
+                + releaseDirPath + File.separator + "manifest.txt");
+        optionList.add("--create_source_map="
+                + projectReleaseJSFilePath + ".map");
         optionList.add("--source_map_format=" + SourceMap.Format.V3);
 
         String[] options = (String[]) optionList.toArray(new String[0]);
@@ -148,7 +150,8 @@ public class JSGoogPublisher extends JSPublisher implements IJSPublisher
 
         appendSourceMapLocation(projectReleaseJSFilePath, projectName);
 
-        System.out.println("The project '" + projectName
+        System.out.println("The project '"
+                + projectName
                 + "' has been successfully compiled and optimized.");
     }
 
@@ -166,10 +169,12 @@ public class JSGoogPublisher extends JSPublisher implements IJSPublisher
         writeFile(path, appendString.toString(), true);
     }
 
-    protected void appendSourceMapLocation(String path, String projectName) throws IOException
+    protected void appendSourceMapLocation(String path, String projectName)
+            throws IOException
     {
         StringBuilder appendString = new StringBuilder();
-        appendString.append("\n//@ sourceMappingURL=./" + projectName + ".js.map");
+        appendString.append("\n//@ sourceMappingURL=./"
+                + projectName + ".js.map");
         writeFile(path, appendString.toString(), true);
     }
 

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/92adca35/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 4681acf..b5e0bf0 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
@@ -29,10 +29,9 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements
         IJSPublisher
 {
 
-    public static final String FLEXJS_INTERMEDIATE_DIR_NAME = "bin/js-debug";
-    public static final String FLEXJS_RELEASE_DIR_NAME = "bin/js-release";
-
-    private File outputParentFolder;
+    public static final String FLEXJS_OUTPUT_DIR_NAME = "bin";
+    public static final String FLEXJS_INTERMEDIATE_DIR_NAME = "js-debug";
+    public static final String FLEXJS_RELEASE_DIR_NAME = "js-release";
 
     public MXMLFlexJSPublisher(Configuration config)
     {
@@ -43,25 +42,36 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements
     public File getOutputFolder()
     {
         // (erikdebruin) If there is a -marmotinni switch, we want
-        // the output redirected to the directory it specifies.
+        //               the output redirected to the directory it specifies.
         JSGoogConfiguration jsGoogConfig = (JSGoogConfiguration) configuration;
         if (jsGoogConfig.getMarmotinni() != null)
         {
-            this.outputParentFolder = new File(jsGoogConfig.getMarmotinni());
+            outputParentFolder = new File(jsGoogConfig.getMarmotinni());
         }
         else
         {
-            this.outputParentFolder = new File(configuration.getTargetFileDirectory())
-                    .getParentFile();
+            outputParentFolder = new File(
+                    configuration.getTargetFileDirectory()).getParentFile();
         }
-        
-        return new File(this.outputParentFolder, FLEXJS_INTERMEDIATE_DIR_NAME);
+
+        outputParentFolder = new File(outputParentFolder,
+                FLEXJS_OUTPUT_DIR_NAME);
+
+        outputFolder = new File(outputParentFolder, File.separator
+                + FLEXJS_INTERMEDIATE_DIR_NAME);
+
+        // (erikdebruin) Marmotinni handles file management, so we 
+        //               bypass the setup.
+        if (jsGoogConfig.getMarmotinni() == null)
+            setupOutputFolder();
+
+        return outputFolder;
     }
 
     @Override
     public void publish() throws IOException
     {
-        final String intermediateDirPath = getOutputFolder().getPath();
+        final String intermediateDirPath = outputFolder.getPath();
 
         final String projectName = FilenameUtils.getBaseName(configuration
                 .getTargetFile());


Mime
View raw message