Repository: flex-falcon
Updated Branches:
  refs/heads/develop 1c96ccd6a -> ab582dd17


add compiler.exclude-defaults-css-files option to exclude certain kinds of CSS 
output.  The entries should be paths to files or can reference the defaults.css 
in HTML.swc via HTML.swc:defaults.css


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

Branch: refs/heads/develop
Commit: ab582dd1761e3877d26717ea1544941257e2e718
Parents: 9345ae4
Author: Alex Harui <aha...@apache.org>
Authored: Sun Oct 23 23:42:49 2016 -0700
Committer: Alex Harui <aha...@apache.org>
Committed: Sun Oct 23 23:42:59 2016 -0700

----------------------------------------------------------------------
 .../compiler/internal/targets/FlexJSTarget.java |  1 +
 .../org/apache/flex/compiler/clients/ASC.java   |  6 ++
 .../flex/compiler/config/Configuration.java     | 59 ++++++++++++++++++--
 .../internal/config/TargetSettings.java         |  6 ++
 .../css/codegen/CSSCompilationSession.java      | 19 +++++++
 .../internal/targets/FlexAppSWFTarget.java      |  1 +
 .../flex/compiler/targets/ITargetSettings.java  |  5 ++
 7 files changed, 91 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/ab582dd1/compiler-jx/src/main/java/org/apache/flex/compiler/internal/targets/FlexJSTarget.java
----------------------------------------------------------------------
diff --git 
a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/targets/FlexJSTarget.java
 
b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/targets/FlexJSTarget.java
index 89ad4ff..01c24f1 100644
--- 
a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/targets/FlexJSTarget.java
+++ 
b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/targets/FlexJSTarget.java
@@ -148,6 +148,7 @@ public class FlexJSTarget extends JSTarget implements 
IJSTarget
     {
         JSCSSCompilationSession cssCompilationSession = 
(JSCSSCompilationSession) flexProject.getCSSCompilationSession();
         
cssCompilationSession.setKeepAllTypeSelectors(targetSettings.keepAllTypeSelectors());
+        
cssCompilationSession.setExcludeDefaultsCSSFiles(targetSettings.getExcludeDefaultsCSSFiles());
         
         // Performance heuristic: let's start compilation on all of the 
compilation
         // units we know about up front. This is particularly useful on SWC 
projects where 

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/ab582dd1/compiler/src/main/java/org/apache/flex/compiler/clients/ASC.java
----------------------------------------------------------------------
diff --git a/compiler/src/main/java/org/apache/flex/compiler/clients/ASC.java 
b/compiler/src/main/java/org/apache/flex/compiler/clients/ASC.java
index 432a445..a13c85a 100644
--- a/compiler/src/main/java/org/apache/flex/compiler/clients/ASC.java
+++ b/compiler/src/main/java/org/apache/flex/compiler/clients/ASC.java
@@ -426,6 +426,12 @@ public class ASC
         }
         
         @Override
+        public List<String> getExcludeDefaultsCSSFiles()
+        {
+            return ImmutableList.of();
+        }
+        
+        @Override
         public File getLinkReport()
         {
             return null;

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/ab582dd1/compiler/src/main/java/org/apache/flex/compiler/config/Configuration.java
----------------------------------------------------------------------
diff --git 
a/compiler/src/main/java/org/apache/flex/compiler/config/Configuration.java 
b/compiler/src/main/java/org/apache/flex/compiler/config/Configuration.java
index 79e555d..ea1e879 100644
--- a/compiler/src/main/java/org/apache/flex/compiler/config/Configuration.java
+++ b/compiler/src/main/java/org/apache/flex/compiler/config/Configuration.java
@@ -2986,6 +2986,49 @@ public class Configuration
         }
     }
 
+    //
+    // 'compiler.exclude-defaults-css-files' option
+    //
+
+    private Deque<String> excludeDefaultsCSSFiles = new ArrayDeque<String>();
+
+    /**
+     * List of filenames to exclude from list of defaults style stylesheets 
(css only).
+     * For defaults.css files in a SWC, use HTML.swc:defaults.css where HTML 
is the
+     * name of a SWC.
+     * <p>
+     * <b>For example:</b><br>
+     * <code>-exclude-defaults-css-files=[A, B, C]</code><br>
+     * Then, 'A' should have precedence over 'B', then 'C', then SWCs 
defaultsCssFiles should have the order: SWCS, C,
+     * B, A
+     * 
+     * @see #setExcludeDefaultsCSSFiles
+     */
+    public Deque<String> getExcludeDefaultsCSSFiles()
+    {
+        return excludeDefaultsCSSFiles;
+    }
+
+    /**
+     * Excludes CSS files from the output.
+     * <p>
+     * This option takes one or more files. The precedence for multiple CSS 
files included with this option is from
+     * first to last.
+     */
+    @Config(allowMultiple = true, advanced = true)
+    @Mapping({ "compiler", "exclude-defaults-css-files" })
+    @Arguments("filename")
+    @InfiniteArguments
+    @FlexOnly
+    public void setExcludeDefaultsCSSFiles(ConfigurationValue cv, List<String> 
paths) throws CannotOpen
+    {
+        final ImmutableList<String> resolved = 
resolvePathsStrict(ImmutableList.copyOf(paths), cv, true);
+        for (final String path : resolved)
+        {
+            excludeDefaultsCSSFiles.addFirst(path);
+        }
+    }
+
     /**
      * Location of theme style stylesheets (css only, configured via 
themefiles above).
      */
@@ -4132,14 +4175,18 @@ public class Configuration
                 if (c != -1)
                     processedPath = processedPath.substring(0, c);
             }
-            final File fileSpec = pathResolver.resolve(processedPath);
-            if (!returnMissingFiles && !fileSpec.exists())
+            if (!processedPath.contains(".swc:"))
             {
-                throw new 
CannotOpen(FilenameNormalization.normalize(processedPath), cv.getVar(), 
cv.getSource(),
-                        cv.getLine());
+                   final File fileSpec = pathResolver.resolve(processedPath);
+                   if (!returnMissingFiles && !fileSpec.exists())
+                   {
+                       throw new 
CannotOpen(FilenameNormalization.normalize(processedPath), cv.getVar(), 
cv.getSource(),
+                               cv.getLine());
+                   }
+                   resolvedPathsBuilder.add(fileSpec.getAbsolutePath());
             }
-
-            resolvedPathsBuilder.add(fileSpec.getAbsolutePath());
+            else
+                resolvedPathsBuilder.add(processedPath);
         }
         return resolvedPathsBuilder.build();
     }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/ab582dd1/compiler/src/main/java/org/apache/flex/compiler/internal/config/TargetSettings.java
----------------------------------------------------------------------
diff --git 
a/compiler/src/main/java/org/apache/flex/compiler/internal/config/TargetSettings.java
 
b/compiler/src/main/java/org/apache/flex/compiler/internal/config/TargetSettings.java
index 03ba470..aad8301 100644
--- 
a/compiler/src/main/java/org/apache/flex/compiler/internal/config/TargetSettings.java
+++ 
b/compiler/src/main/java/org/apache/flex/compiler/internal/config/TargetSettings.java
@@ -545,6 +545,12 @@ public class TargetSettings implements ITargetSettings
     }
 
     @Override
+    public List<String> getExcludeDefaultsCSSFiles()
+    {
+        return 
ImmutableList.copyOf(configuration.getExcludeDefaultsCSSFiles());
+    }
+
+    @Override
     public File getLinkReport()
     {
         return configuration.getLinkReport();

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/ab582dd1/compiler/src/main/java/org/apache/flex/compiler/internal/css/codegen/CSSCompilationSession.java
----------------------------------------------------------------------
diff --git 
a/compiler/src/main/java/org/apache/flex/compiler/internal/css/codegen/CSSCompilationSession.java
 
b/compiler/src/main/java/org/apache/flex/compiler/internal/css/codegen/CSSCompilationSession.java
index ae98028..c6e7560 100644
--- 
a/compiler/src/main/java/org/apache/flex/compiler/internal/css/codegen/CSSCompilationSession.java
+++ 
b/compiler/src/main/java/org/apache/flex/compiler/internal/css/codegen/CSSCompilationSession.java
@@ -166,6 +166,11 @@ public class CSSCompilationSession
     private boolean keepAllTypeSelectors;
 
     /**
+     * Excluded CSS files.
+     */
+    private List<String> excludedCSSFiles;
+
+    /**
      * Determine if a rule should be in the output
      * 
      * @return true if rule should be in the output
@@ -189,6 +194,9 @@ public class CSSCompilationSession
         
         for (final ICSSDocument cssDocument : cssDocuments)
         {
+               if (excludedCSSFiles.contains(cssDocument.getSourcePath()))
+                       continue;
+                               
             for (final ICSSRule newRule : cssDocument.getRules())
             {
                 if (keepRule(newRule))
@@ -414,4 +422,15 @@ public class CSSCompilationSession
     {
         this.keepAllTypeSelectors = keepAllTypeSelectors;
     }
+
+    /**
+     * Set whether to keep all type selectors for linking.
+     * 
+     * @param keepAllTypeSelectors value
+     */
+    public void setExcludeDefaultsCSSFiles(List<String> excludes)
+    {
+        this.excludedCSSFiles = excludes;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/ab582dd1/compiler/src/main/java/org/apache/flex/compiler/internal/targets/FlexAppSWFTarget.java
----------------------------------------------------------------------
diff --git 
a/compiler/src/main/java/org/apache/flex/compiler/internal/targets/FlexAppSWFTarget.java
 
b/compiler/src/main/java/org/apache/flex/compiler/internal/targets/FlexAppSWFTarget.java
index bed094c..50cd567 100644
--- 
a/compiler/src/main/java/org/apache/flex/compiler/internal/targets/FlexAppSWFTarget.java
+++ 
b/compiler/src/main/java/org/apache/flex/compiler/internal/targets/FlexAppSWFTarget.java
@@ -839,6 +839,7 @@ public class FlexAppSWFTarget extends AppSWFTarget
             
             this.cssCompilationSession = new CSSCompilationSession();
             
this.cssCompilationSession.setKeepAllTypeSelectors(targetSettings.keepAllTypeSelectors());
+            
this.cssCompilationSession.setExcludeDefaultsCSSFiles(targetSettings.getExcludeDefaultsCSSFiles());
         }
         
         private final IClassDefinition mainApplicationClassDefinition;

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/ab582dd1/compiler/src/main/java/org/apache/flex/compiler/targets/ITargetSettings.java
----------------------------------------------------------------------
diff --git 
a/compiler/src/main/java/org/apache/flex/compiler/targets/ITargetSettings.java 
b/compiler/src/main/java/org/apache/flex/compiler/targets/ITargetSettings.java
index f223f50..a27eb38 100644
--- 
a/compiler/src/main/java/org/apache/flex/compiler/targets/ITargetSettings.java
+++ 
b/compiler/src/main/java/org/apache/flex/compiler/targets/ITargetSettings.java
@@ -103,6 +103,11 @@ public interface ITargetSettings
     List<String> getDefaultsCSSFiles();
     
     /**
+     * @return Normalized paths in {@code exclude-defaults-css-files} 
configuration option.
+     */
+    List<String> getExcludeDefaultsCSSFiles();
+    
+    /**
      * Returns the default background color.
      * 
      * @return the default background color.

Reply via email to