You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by er...@apache.org on 2013/04/10 19:23:29 UTC

git commit: FLEX-33482: [FalconJX] dep.'s paths on Windows

Updated Branches:
  refs/heads/develop c050380d9 -> d3ca933f1


FLEX-33482: [FalconJX] dep.'s paths on Windows

FalconJX now creates correct deps.js paths on Windows as well as OS X.

Signed-off-by: Erik de Bruin <er...@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/d3ca933f
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/d3ca933f
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/d3ca933f

Branch: refs/heads/develop
Commit: d3ca933f192202900cd11100afa27066cb7c0d54
Parents: c050380
Author: Erik de Bruin <er...@ixsoftware.nl>
Authored: Wed Apr 10 19:23:11 2013 +0200
Committer: Erik de Bruin <er...@ixsoftware.nl>
Committed: Wed Apr 10 19:23:11 2013 +0200

----------------------------------------------------------------------
 .../codegen/mxml/flexjs/MXMLFlexJSPublisher.java   |   63 +++++++++++++--
 1 files changed, 55 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/d3ca933f/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 8c29a3f..d41f606 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
@@ -1,7 +1,10 @@
 package org.apache.flex.compiler.internal.codegen.mxml.flexjs;
 
+import java.io.BufferedReader;
 import java.io.File;
+import java.io.FileInputStream;
 import java.io.IOException;
+import java.io.InputStreamReader;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
@@ -65,6 +68,7 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements
                 + "/closure/goog/";
         final String closureGoogTgtLibDirPath = intermediateDirPath
                 + "/library/closure/goog";
+        final String closureGoogTgtLibDirRelPath = "./library/closure/goog";
         final String closureTPSrcLibDirPath = closureLibDirPath
                 + "/third_party/closure/goog/";
         final String closureTPTgtLibDirPath = intermediateDirPath
@@ -85,6 +89,8 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements
 
         copyFile(sdkJSLibSrcDirPath, sdkJSLibTgtDirPath);
 
+        boolean isWindows = System.getProperty("os.name").indexOf("Mac") == -1;
+
         List<SourceFile> inputs = new ArrayList<SourceFile>();
         Collection<File> files = org.apache.commons.io.FileUtils.listFiles(
                 new File(intermediateDirPath),
@@ -92,7 +98,20 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements
                 DirectoryFileFilter.DIRECTORY);
         for (File file : files)
         {
-            inputs.add(SourceFile.fromFile(file));
+            if (isWindows)
+            {
+                // TODO (erikdebruin) maybe fix the 'manual' relative path prefix?
+                String filePath = "../../../"
+                        + new File(intermediateDirPath).toURI()
+                                .relativize(file.toURI()).getPath();
+
+                inputs.add(SourceFile.fromCode(filePath, filePath,
+                        readCode(file)));
+            }
+            else
+            {
+                inputs.add(SourceFile.fromFile(file));
+            }
         }
 
         copyFile(closureGoogSrcLibDirPath, closureGoogTgtLibDirPath);
@@ -105,15 +124,12 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements
 
         ErrorManager errorManager = new JSGoogErrorManager();
         DepsGenerator depsGenerator = new DepsGenerator(deps, inputs,
-                InclusionStrategy.ALWAYS, closureGoogTgtLibDirPath,
-                errorManager);
+                InclusionStrategy.ALWAYS,
+                (isWindows) ? closureGoogTgtLibDirRelPath
+                        : closureGoogTgtLibDirPath, errorManager);
         writeFile(depsTgtFilePath, depsGenerator.computeDependencyCalls(),
                 false);
 
-        org.apache.commons.io.FileUtils.deleteQuietly(srcDeps);
-        org.apache.commons.io.FileUtils.moveFile(new File(depsTgtFilePath),
-                srcDeps);
-
         writeHTML("intermediate", projectName, intermediateDirPath);
         writeHTML("release", projectName, releaseDirPath);
 
@@ -143,6 +159,10 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements
 
         appendSourceMapLocation(projectReleaseJSFilePath, projectName);
 
+        org.apache.commons.io.FileUtils.deleteQuietly(srcDeps);
+        org.apache.commons.io.FileUtils.moveFile(new File(depsTgtFilePath),
+                srcDeps);
+
         System.out.println("The project '"
                 + projectName
                 + "' has been successfully compiled and optimized.");
@@ -162,6 +182,33 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements
         writeFile(path, appendString.toString(), true);
     }
 
+    protected String readCode(File file)
+    {
+        String code = "";
+        try
+        {
+            BufferedReader in = new BufferedReader(new InputStreamReader(
+                    new FileInputStream(file), "UTF8"));
+
+            String line = in.readLine();
+
+            while (line != null)
+            {
+                code += line + "\n";
+                line = in.readLine();
+            }
+            code = code.substring(0, code.length() - 1);
+
+            in.close();
+        }
+        catch (Exception e)
+        {
+            // nothing to see, move along...
+        }
+
+        return code;
+    }
+
     private void writeHTML(String type, String projectName, String dirPath)
             throws IOException
     {
@@ -197,7 +244,7 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements
         htmlFile.append("\t\t\treturn true;\n");
         htmlFile.append("\t\t};\n");
         htmlFile.append("\t\t\n");
-        
+
         htmlFile.append("\t\tnew ");
         htmlFile.append(projectName);
         htmlFile.append("()");