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 2019/07/08 17:01:32 UTC

[royale-compiler] branch develop updated: improved commit 66ef1643b2139778e579b8b3ef342a5bc5b08571 that avoids writing source maps for externs

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 eecd387  improved commit 66ef1643b2139778e579b8b3ef342a5bc5b08571 that avoids writing source maps for externs
eecd387 is described below

commit eecd3876159c39b06573f78cb8d286618b893021
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Mon Jul 8 10:01:27 2019 -0700

    improved commit 66ef1643b2139778e579b8b3ef342a5bc5b08571 that avoids writing source maps for externs
    
    1) moved the logic earlier, where it checks if source maps have been requested
    2) applied the same fix to other compc classes that also need it
---
 .../apache/royale/compiler/clients/COMPJSC.java    | 11 ++--
 .../royale/compiler/clients/COMPJSCNative.java     | 11 ++--
 .../royale/compiler/clients/COMPJSCRoyale.java     | 62 ++++++++++------------
 3 files changed, 42 insertions(+), 42 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 501a734..4625a41 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
@@ -476,15 +476,18 @@ public class COMPJSC extends MXMLJSC
 	                        problems.addAll(errors);
 	                        ByteArrayOutputStream temp = new ByteArrayOutputStream();
                             ByteArrayOutputStream sourceMapTemp = null;
-	                        if (project.config.getSourceMap())
+
+                            boolean isExterns = false;
+	                        if (writer instanceof JSWriter)
+	                        	isExterns = ((JSWriter)writer).isExterns();
+
+                            // if the file is @externs DON'T create source map file
+                            if (project.config.getSourceMap() && !isExterns)
 	                        {
                                 sourceMapTemp = new ByteArrayOutputStream();
 	                        }
                             writer.writeTo(temp, sourceMapTemp, null);
 
-                            boolean isExterns = false;
-	                        if (writer instanceof JSWriter)
-	                        	isExterns = ((JSWriter)writer).isExterns();
                     		String outputClassFile = getOutputClassFile(
                                     cu.getQualifiedNames().get(0),
                                     isExterns ? externsOut : jsOut,
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 b38270a..e77bc1f 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
@@ -330,15 +330,18 @@ public class COMPJSCNative extends MXMLJSCNative
 
                             ByteArrayOutputStream temp = new ByteArrayOutputStream();
                             ByteArrayOutputStream sourceMapTemp = null;
-	                        if (project.config.getSourceMap())
+                            
+                            boolean isExterns = false;
+	                        if (writer instanceof JSWriter)
+	                        	isExterns = ((JSWriter)writer).isExterns();
+
+                            // if the file is @externs DON'T create source map file
+	                        if (project.config.getSourceMap() && !isExterns)
 	                        {
                                 sourceMapTemp = new ByteArrayOutputStream();
 	                        }
                             writer.writeTo(temp, sourceMapTemp, null);
 
-                            boolean isExterns = false;
-	                        if (writer instanceof JSWriter)
-	                        	isExterns = ((JSWriter)writer).isExterns();
                     		String outputClassFile = getOutputClassFile(
                                     cu.getQualifiedNames().get(0),
                                     isExterns ? externsOut : jsOut,
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 e531df9..a83aae9 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
@@ -375,7 +375,8 @@ public class COMPJSCRoyale extends MXMLJSCRoyale
 	                        if (writer instanceof JSWriter)
 	                        	isExterns = ((JSWriter)writer).isExterns();
 	                        
-                            if (project.config.getSourceMap())
+                            // if the file is @externs DON'T create source map file
+                            if (project.config.getSourceMap() && !isExterns)
 	                        {
                                 sourceMapTemp = new ByteArrayOutputStream();
 	                        }
@@ -441,41 +442,34 @@ public class COMPJSCRoyale extends MXMLJSCRoyale
                             zipOutputStream.closeEntry();
                             fileList.append("        <file path=\"" + outputClassFile + "\" mod=\"" + fileDate + "\"/>\n");
                             
-                            // if the file is @externs DON'T create source map file
-                            boolean createSourceMapFile = false;
-                            if (writer instanceof JSWriter)
-                                createSourceMapFile = !((JSWriter)writer).isExterns();
-                            if(createSourceMapFile)
-                            { 
-                                if(sourceMapTemp != null)
+                            if(sourceMapTemp != null)
+                            {
+                                String sourceMapFile = getOutputSourceMapFile(
+                                                                                cu.getQualifiedNames().get(0),
+                                                                                isExterns ? externsOut : jsOut,
+                                                                                false).getPath();
+                                if (config.isVerbose())
                                 {
-                                    String sourceMapFile = getOutputSourceMapFile(
-                                                                                  cu.getQualifiedNames().get(0),
-                                                                                  isExterns ? externsOut : jsOut,
-                                                                                  false).getPath();
-                                    if (config.isVerbose())
-                                    {
-                                        System.out.println("Writing file: " + sourceMapFile);
-                                    }
-                                    ze = new ZipEntry(sourceMapFile);
-                                    ze.setTime(zipFileDate);
-                                    ze.setMethod(ZipEntry.STORED);
-                                    
-                                    baos = new ByteArrayOutputStream();
-                                    sourceMapTemp.writeTo(baos);
-                                    ze.setSize(baos.size());
-                                    ze.setCompressedSize(baos.size());
-                                    crc = new CRC32();
-                                    crc.reset();
-                                    crc.update(baos.toByteArray());
-                                    ze.setCrc(crc.getValue());
-                                    
-                                    zipOutputStream.putNextEntry(ze);
-                                    baos.writeTo(zipOutputStream);
-                                    zipOutputStream.flush();
-                                    zipOutputStream.closeEntry();
-                                    fileList.append("        <file path=\"" + sourceMapFile + "\" mod=\"" + fileDate + "\"/>\n");
+                                    System.out.println("Writing file: " + sourceMapFile);
                                 }
+                                ze = new ZipEntry(sourceMapFile);
+                                ze.setTime(zipFileDate);
+                                ze.setMethod(ZipEntry.STORED);
+                                
+                                baos = new ByteArrayOutputStream();
+                                sourceMapTemp.writeTo(baos);
+                                ze.setSize(baos.size());
+                                ze.setCompressedSize(baos.size());
+                                crc = new CRC32();
+                                crc.reset();
+                                crc.update(baos.toByteArray());
+                                ze.setCrc(crc.getValue());
+                                
+                                zipOutputStream.putNextEntry(ze);
+                                baos.writeTo(zipOutputStream);
+                                zipOutputStream.flush();
+                                zipOutputStream.closeEntry();
+                                fileList.append("        <file path=\"" + sourceMapFile + "\" mod=\"" + fileDate + "\"/>\n");
                             }
 	                        writer.close();
                     	}