You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by jo...@apache.org on 2018/11/06 19:18:07 UTC

[royale-compiler] branch develop updated: compiler-jx: fixed issue where compc incorrectly created empty js/out directory in project when packing a SWC

This is an automated email from the ASF dual-hosted git repository.

joshtynjala pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git


The following commit(s) were added to refs/heads/develop by this push:
     new ec18b6f  compiler-jx: fixed issue where compc incorrectly created empty js/out directory in project when packing a SWC
ec18b6f is described below

commit ec18b6f22ecf45ca573af5877461c16321ecebe3
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Tue Nov 6 11:16:08 2018 -0800

    compiler-jx: fixed issue where compc incorrectly created empty js/out directory in project when packing a SWC
---
 .../apache/royale/compiler/clients/COMPJSC.java    | 40 +++++++++++++++-------
 .../royale/compiler/clients/COMPJSCNative.java     | 40 +++++++++++++++-------
 .../royale/compiler/clients/COMPJSCRoyale.java     | 40 +++++++++++++++-------
 3 files changed, 81 insertions(+), 39 deletions(-)

diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSC.java b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSC.java
index 21df1b0..f4201e2 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSC.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSC.java
@@ -393,7 +393,7 @@ public class COMPJSC extends MXMLJSC
                     	if (!packingSWC)
                     	{
 	                        final File outputClassFile = getOutputClassFile(
-	                                cu.getQualifiedNames().get(0), outputFolder);
+	                                cu.getQualifiedNames().get(0), outputFolder, true);
 	
 	                        System.out.println("Compiling file: " + outputClassFile);
 	
@@ -421,7 +421,7 @@ public class COMPJSC extends MXMLJSC
                             if (project.config.getSourceMap())
                             {
                                 outputSourceMapFile = getOutputSourceMapFile(
-                                        cu.getQualifiedNames().get(0), outputFolder);
+                                        cu.getQualifiedNames().get(0), outputFolder, true);
                                 sourceMapOut = new BufferedOutputStream(
                                     new FileOutputStream(outputSourceMapFile));
                             }
@@ -467,7 +467,9 @@ public class COMPJSC extends MXMLJSC
 	                        if (writer instanceof JSWriter)
 	                        	isExterns = ((JSWriter)writer).isExterns();
                     		String outputClassFile = getOutputClassFile(
-	                                cu.getQualifiedNames().get(0), isExterns ? externsOut : jsOut).getPath();
+                                    cu.getQualifiedNames().get(0),
+                                    isExterns ? externsOut : jsOut,
+                                    false).getPath();
 	                        System.out.println("Writing file: " + outputClassFile);     	
 	                        zipOutputStream.putNextEntry(new ZipEntry(outputClassFile));
 	                        temp.writeTo(zipOutputStream);
@@ -477,7 +479,9 @@ public class COMPJSC extends MXMLJSC
                             if(sourceMapTemp != null)
                             {
                                 String sourceMapFile = getOutputSourceMapFile(
-                                    cu.getQualifiedNames().get(0), isExterns ? externsOut : jsOut).getPath();
+                                    cu.getQualifiedNames().get(0),
+                                    isExterns ? externsOut : jsOut,
+                                    false).getPath();
                                 System.out.println("Writing file: " + sourceMapFile);     	
                                 zipOutputStream.putNextEntry(new ZipEntry(sourceMapFile));
                                 sourceMapTemp.writeTo(zipOutputStream);
@@ -600,14 +604,15 @@ public class COMPJSC extends MXMLJSC
     /**
      * Get the output class file. This includes the (sub)directory in which the
      * original class file lives. If the directory structure doesn't exist, it
-     * is created.
+     * is created, if specified.
      * 
      * @author Erik de Bruin
      * @param qname
      * @param outputFolder
+     * @param createDirs
      * @return output class file path
      */
-    private File getOutputClassFile(String qname, File outputFolder)
+    private File getOutputClassFile(String qname, File outputFolder, boolean createDirs)
     {
         String[] cname = qname.split("\\.");
         String sdirPath = outputFolder + File.separator;
@@ -618,9 +623,12 @@ public class COMPJSC extends MXMLJSC
                 sdirPath += cname[i] + File.separator;
             }
 
-            File sdir = new File(sdirPath);
-            if (!sdir.exists())
-                sdir.mkdirs();
+            if (createDirs)
+            {
+                File sdir = new File(sdirPath);
+                if (!sdir.exists())
+                    sdir.mkdirs();
+            }
 
             qname = cname[cname.length - 1];
         }
@@ -629,11 +637,14 @@ public class COMPJSC extends MXMLJSC
     }
 
     /**
+     * Similar to getOutputClassFile, but for the source map file.
+     * 
      * @param qname
      * @param outputFolder
+     * @param createDirs
      * @return output source map file path
      */
-    private File getOutputSourceMapFile(String qname, File outputFolder)
+    private File getOutputSourceMapFile(String qname, File outputFolder, boolean createDirs)
     {
         String[] cname = qname.split("\\.");
         String sdirPath = outputFolder + File.separator;
@@ -644,9 +655,12 @@ public class COMPJSC extends MXMLJSC
                 sdirPath += cname[i] + File.separator;
             }
 
-            File sdir = new File(sdirPath);
-            if (!sdir.exists())
-                sdir.mkdirs();
+            if (createDirs)
+            {
+                File sdir = new File(sdirPath);
+                if (!sdir.exists())
+                    sdir.mkdirs();
+            }
 
             qname = cname[cname.length - 1];
         }
diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSCNative.java b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSCNative.java
index 6f57322..8a13875 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSCNative.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSCNative.java
@@ -256,7 +256,7 @@ public class COMPJSCNative extends MXMLJSCNative
                     	if (!packingSWC)
                     	{
 	                        final File outputClassFile = getOutputClassFile(
-	                                cu.getQualifiedNames().get(0), outputFolder);
+	                                cu.getQualifiedNames().get(0), outputFolder, true);
 	
 	                        System.out.println("Compiling file: " + outputClassFile);
 	
@@ -284,7 +284,7 @@ public class COMPJSCNative extends MXMLJSCNative
                             if (project.config.getSourceMap())
                             {
 	                            outputSourceMapFile = getOutputSourceMapFile(
-                                        cu.getQualifiedNames().get(0), outputFolder);
+                                        cu.getQualifiedNames().get(0), outputFolder, true);
                                 sourceMapOut = new BufferedOutputStream(
                                     new FileOutputStream(outputSourceMapFile));
                             }
@@ -331,7 +331,9 @@ public class COMPJSCNative extends MXMLJSCNative
 	                        if (writer instanceof JSWriter)
 	                        	isExterns = ((JSWriter)writer).isExterns();
                     		String outputClassFile = getOutputClassFile(
-	                                cu.getQualifiedNames().get(0), isExterns ? externsOut : jsOut).getPath();
+                                    cu.getQualifiedNames().get(0),
+                                    isExterns ? externsOut : jsOut,
+                                    false).getPath();
 	                        System.out.println("Writing file: " + outputClassFile);     	
 	                        zipOutputStream.putNextEntry(new ZipEntry(outputClassFile));
 	                        temp.writeTo(zipOutputStream);
@@ -341,7 +343,9 @@ public class COMPJSCNative extends MXMLJSCNative
                             if(sourceMapTemp != null)
                             {
                                 String sourceMapFile = getOutputSourceMapFile(
-                                    cu.getQualifiedNames().get(0), isExterns ? externsOut : jsOut).getPath();
+                                    cu.getQualifiedNames().get(0),
+                                    isExterns ? externsOut : jsOut,
+                                    false).getPath();
                                 System.out.println("Writing file: " + sourceMapFile);     	
                                 zipOutputStream.putNextEntry(new ZipEntry(sourceMapFile));
                                 sourceMapTemp.writeTo(zipOutputStream);
@@ -464,14 +468,15 @@ public class COMPJSCNative extends MXMLJSCNative
     /**
      * Get the output class file. This includes the (sub)directory in which the
      * original class file lives. If the directory structure doesn't exist, it
-     * is created.
+     * is created, if specified.
      * 
      * @author Erik de Bruin
      * @param qname
      * @param outputFolder
+     * @param createDirs
      * @return output class file path
      */
-    private File getOutputClassFile(String qname, File outputFolder)
+    private File getOutputClassFile(String qname, File outputFolder, boolean createDirs)
     {
         String[] cname = qname.split("\\.");
         String sdirPath = outputFolder + File.separator;
@@ -482,9 +487,12 @@ public class COMPJSCNative extends MXMLJSCNative
                 sdirPath += cname[i] + File.separator;
             }
 
-            File sdir = new File(sdirPath);
-            if (!sdir.exists())
-                sdir.mkdirs();
+            if (createDirs)
+            {
+                File sdir = new File(sdirPath);
+                if (!sdir.exists())
+                    sdir.mkdirs();
+            }
 
             qname = cname[cname.length - 1];
         }
@@ -493,11 +501,14 @@ public class COMPJSCNative extends MXMLJSCNative
     }
 
     /**
+     * Similar to getOutputClassFile, but for the source map file.
+     * 
      * @param qname
      * @param outputFolder
+     * @param createDirs
      * @return output source map file path
      */
-    private File getOutputSourceMapFile(String qname, File outputFolder)
+    private File getOutputSourceMapFile(String qname, File outputFolder, boolean createDirs)
     {
         String[] cname = qname.split("\\.");
         String sdirPath = outputFolder + File.separator;
@@ -508,9 +519,12 @@ public class COMPJSCNative extends MXMLJSCNative
                 sdirPath += cname[i] + File.separator;
             }
 
-            File sdir = new File(sdirPath);
-            if (!sdir.exists())
-                sdir.mkdirs();
+            if (createDirs)
+            {
+                File sdir = new File(sdirPath);
+                if (!sdir.exists())
+                    sdir.mkdirs();
+            }
 
             qname = cname[cname.length - 1];
         }
diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSCRoyale.java b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSCRoyale.java
index b2568ff..b22e526 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSCRoyale.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSCRoyale.java
@@ -257,7 +257,7 @@ public class COMPJSCRoyale extends MXMLJSCRoyale
                     	if (!packingSWC)
                     	{
 	                        final File outputClassFile = getOutputClassFile(
-	                                cu.getQualifiedNames().get(0), outputFolder);
+	                                cu.getQualifiedNames().get(0), outputFolder, true);
 	
 	                        System.out.println("Compiling file: " + outputClassFile);
 	
@@ -285,7 +285,7 @@ public class COMPJSCRoyale extends MXMLJSCRoyale
                             if (project.config.getSourceMap())
                             {
 	                            outputSourceMapFile = getOutputSourceMapFile(
-                                        cu.getQualifiedNames().get(0), outputFolder);
+                                        cu.getQualifiedNames().get(0), outputFolder, true);
                                 sourceMapOut = new BufferedOutputStream(
                                     new FileOutputStream(outputSourceMapFile));
                             }
@@ -332,7 +332,9 @@ public class COMPJSCRoyale extends MXMLJSCRoyale
 	                        if (writer instanceof JSWriter)
 	                        	isExterns = ((JSWriter)writer).isExterns();
                     		String outputClassFile = getOutputClassFile(
-	                                cu.getQualifiedNames().get(0), isExterns ? externsOut : jsOut).getPath();
+                                    cu.getQualifiedNames().get(0),
+                                    isExterns ? externsOut : jsOut,
+                                    false).getPath();
 	                        System.out.println("Writing file: " + outputClassFile);     	
 	                        zipOutputStream.putNextEntry(new ZipEntry(outputClassFile));
 	                        temp.writeTo(zipOutputStream);
@@ -342,7 +344,9 @@ public class COMPJSCRoyale extends MXMLJSCRoyale
                             if(sourceMapTemp != null)
                             {
                                 String sourceMapFile = getOutputSourceMapFile(
-                                    cu.getQualifiedNames().get(0), isExterns ? externsOut : jsOut).getPath();
+                                    cu.getQualifiedNames().get(0),
+                                    isExterns ? externsOut : jsOut,
+                                    false).getPath();
                                 System.out.println("Writing file: " + sourceMapFile);     	
                                 zipOutputStream.putNextEntry(new ZipEntry(sourceMapFile));
                                 sourceMapTemp.writeTo(zipOutputStream);
@@ -465,14 +469,15 @@ public class COMPJSCRoyale extends MXMLJSCRoyale
     /**
      * Get the output class file. This includes the (sub)directory in which the
      * original class file lives. If the directory structure doesn't exist, it
-     * is created.
+     * is created if specified.
      * 
      * @author Erik de Bruin
      * @param qname
      * @param outputFolder
+     * @param createDirs
      * @return output class file path
      */
-    private File getOutputClassFile(String qname, File outputFolder)
+    private File getOutputClassFile(String qname, File outputFolder, boolean createDirs)
     {
         String[] cname = qname.split("\\.");
         String sdirPath = outputFolder + File.separator;
@@ -483,9 +488,12 @@ public class COMPJSCRoyale extends MXMLJSCRoyale
                 sdirPath += cname[i] + File.separator;
             }
 
-            File sdir = new File(sdirPath);
-            if (!sdir.exists())
-                sdir.mkdirs();
+            if (createDirs)
+            {
+                File sdir = new File(sdirPath);
+                if (!sdir.exists())
+                    sdir.mkdirs();
+            }
 
             qname = cname[cname.length - 1];
         }
@@ -494,11 +502,14 @@ public class COMPJSCRoyale extends MXMLJSCRoyale
     }
 
     /**
+     * Similar to getOutputClassFile, but for the source map file.
+     * 
      * @param qname
      * @param outputFolder
+     * @param createDirs
      * @return output source map file path
      */
-    private File getOutputSourceMapFile(String qname, File outputFolder)
+    private File getOutputSourceMapFile(String qname, File outputFolder, boolean createDirs)
     {
         String[] cname = qname.split("\\.");
         String sdirPath = outputFolder + File.separator;
@@ -509,9 +520,12 @@ public class COMPJSCRoyale extends MXMLJSCRoyale
                 sdirPath += cname[i] + File.separator;
             }
 
-            File sdir = new File(sdirPath);
-            if (!sdir.exists())
-                sdir.mkdirs();
+            if (createDirs)
+            {
+                File sdir = new File(sdirPath);
+                if (!sdir.exists())
+                    sdir.mkdirs();
+            }
 
             qname = cname[cname.length - 1];
         }