Repository: flex-falcon Updated Branches: refs/heads/dual f39e0fbc3 -> 0f02a8202
turn debug flag on by default for COMPC Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/0f02a820 Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/0f02a820 Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/0f02a820 Branch: refs/heads/dual Commit: 0f02a8202c4233694bb2cb93e784b6b1cdd29843 Parents: f39e0fb Author: Alex Harui <[email protected]> Authored: Fri Apr 21 09:32:54 2017 -0700 Committer: Alex Harui <[email protected]> Committed: Fri Apr 21 09:32:54 2017 -0700 ---------------------------------------------------------------------- .../apache/flex/compiler/clients/COMPJSC.java | 5 +- .../apache/flex/compiler/clients/MXMLJSC.java | 5 +- .../js/goog/JSGoogCompcConfiguration.java | 407 +++++++++++++++++++ 3 files changed, 413 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/0f02a820/compiler-jx/src/main/java/org/apache/flex/compiler/clients/COMPJSC.java ---------------------------------------------------------------------- diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/clients/COMPJSC.java b/compiler-jx/src/main/java/org/apache/flex/compiler/clients/COMPJSC.java index 614352b..f13ee22 100644 --- a/compiler-jx/src/main/java/org/apache/flex/compiler/clients/COMPJSC.java +++ b/compiler-jx/src/main/java/org/apache/flex/compiler/clients/COMPJSC.java @@ -52,7 +52,7 @@ import org.apache.flex.compiler.internal.codegen.js.JSWriter; import org.apache.flex.compiler.internal.driver.as.ASBackend; import org.apache.flex.compiler.internal.driver.js.amd.AMDBackend; import org.apache.flex.compiler.internal.driver.js.goog.GoogBackend; -import org.apache.flex.compiler.internal.driver.js.goog.JSGoogConfiguration; +import org.apache.flex.compiler.internal.driver.js.goog.JSGoogCompcConfiguration; import org.apache.flex.compiler.internal.driver.mxml.flexjs.MXMLFlexJSSWCBackend; import org.apache.flex.compiler.internal.driver.mxml.jsc.MXMLJSCJSSWCBackend; import org.apache.flex.compiler.internal.projects.CompilerProject; @@ -128,6 +128,7 @@ public class COMPJSC extends MXMLJSC long startTime = System.nanoTime(); final COMPJSC mxmlc = new COMPJSC(); + mxmlc.configurationClass = JSGoogCompcConfiguration.class; final List<ICompilerProblem> problems = new ArrayList<ICompilerProblem>(); final int exitCode = mxmlc.mainNoExit(args, problems, true); @@ -201,7 +202,7 @@ public class COMPJSC extends MXMLJSC case SWF: System.out.println("COMPC"); COMPC compc = new COMPC(); - compc.configurationClass = JSGoogConfiguration.class; + compc.configurationClass = JSGoogCompcConfiguration.class; result = compc.mainNoExit(removeJSArgs(args)); if (result != 0) { http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/0f02a820/compiler-jx/src/main/java/org/apache/flex/compiler/clients/MXMLJSC.java ---------------------------------------------------------------------- diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/clients/MXMLJSC.java b/compiler-jx/src/main/java/org/apache/flex/compiler/clients/MXMLJSC.java index b087fa5..795466e 100644 --- a/compiler-jx/src/main/java/org/apache/flex/compiler/clients/MXMLJSC.java +++ b/compiler-jx/src/main/java/org/apache/flex/compiler/clients/MXMLJSC.java @@ -264,6 +264,7 @@ public class MXMLJSC implements JSCompilerEntryPoint, ProblemQueryProvider, private JSCompilerEntryPoint lastCompiler; public boolean noLink; public OutputStream err; + public Class<? extends Configuration> configurationClass = JSGoogConfiguration.class; public MXMLJSC() { @@ -329,7 +330,7 @@ public class MXMLJSC implements JSCompilerEntryPoint, ProblemQueryProvider, { case SWF: mxmlc = new MXMLC(); - mxmlc.configurationClass = JSGoogConfiguration.class; + mxmlc.configurationClass = configurationClass; if (noLink) result = mxmlc.mainCompileOnly(removeJSArgs(args), err); else @@ -805,7 +806,7 @@ public class MXMLJSC implements JSCompilerEntryPoint, ProblemQueryProvider, */ public boolean configure(final String[] args) { - projectConfigurator = new Configurator(JSGoogConfiguration.class); + projectConfigurator = new Configurator(configurationClass); try { http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/0f02a820/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/goog/JSGoogCompcConfiguration.java ---------------------------------------------------------------------- diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/goog/JSGoogCompcConfiguration.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/goog/JSGoogCompcConfiguration.java new file mode 100644 index 0000000..ab690e4 --- /dev/null +++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/goog/JSGoogCompcConfiguration.java @@ -0,0 +1,407 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.flex.compiler.internal.driver.js.goog; + +import java.io.File; +import java.io.IOException; +import java.net.URLDecoder; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.apache.flex.compiler.clients.JSConfiguration; +import org.apache.flex.compiler.clients.MXMLJSC; +import org.apache.flex.compiler.config.ConfigurationValue; +import org.apache.flex.compiler.exceptions.ConfigurationException; +import org.apache.flex.compiler.internal.config.annotations.Arguments; +import org.apache.flex.compiler.internal.config.annotations.Config; +import org.apache.flex.compiler.internal.config.annotations.FlexOnly; +import org.apache.flex.compiler.internal.config.annotations.InfiniteArguments; +import org.apache.flex.compiler.internal.config.annotations.Mapping; + +/** + * The {@link JSGoogCompcConfiguration} class holds all compiler arguments needed for + * compiling ActionScript to JavaScript the 'goog' way. + * <p> + * Specific flags are implemented here for the configuration to be loaded by the + * configure() method of {@link MXMLJSC}. + * <p> + * This class inherits all compiler arguments from the MXMLC compiler. + * + * @author Erik de Bruin + */ +public class JSGoogCompcConfiguration extends JSConfiguration +{ + public JSGoogCompcConfiguration() + { + setDebug(true); + } + + // + // 'closure-lib' + // + + protected String closureLib = ""; + + public boolean isClosureLibSet() { + return !closureLib.isEmpty(); + } + + public String getClosureLib() + { + try + { + if (closureLib.equals("")) + { + return getAbsolutePathFromPathRelativeToMXMLC( + "../../js/lib/google/closure-library"); + } + } + catch (Exception e) { /* better to try and fail... */ } + + return closureLib; + } + + @Config + @Mapping("closure-lib") + public void setClosureLib(ConfigurationValue cv, String value) + throws ConfigurationException + { + if (value != null) + closureLib = value; + } + + // + // Override 'compiler.binding-value-change-event-type' + // + + private String bindingValueChangeEventType = "valueChange"; + + @Override + public String getBindingValueChangeEventType() + { + return bindingValueChangeEventType; + } + + @Override + @Config(advanced = true) + public void setCompilerBindingValueChangeEventType(ConfigurationValue cv, String b) + { + bindingValueChangeEventType = b; + } + + // + // Override 'compiler.mxml.children-as-data' + // + + private Boolean childrenAsData = true; + + @Override + public Boolean getCompilerMxmlChildrenAsData() + { + return childrenAsData; + } + + @Override + @Config + @Mapping({"compiler", "mxml", "children-as-data"}) + @FlexOnly + public void setCompilerMxmlChildrenAsData(ConfigurationValue cv, Boolean asData) throws ConfigurationException + { + childrenAsData = asData; + } + + // + // 'marmotinni' + // + + private String marmotinni; + + public String getMarmotinni() + { + return marmotinni; + } + + @Config + @Mapping("marmotinni") + public void setMarmotinni(ConfigurationValue cv, String value) + throws ConfigurationException + { + marmotinni = value; + } + + // + // 'sdk-js-lib' + // + + protected List<String> sdkJSLib = new ArrayList<String>(); + + public List<String> getSDKJSLib() + { + if (sdkJSLib.size() == 0) + { + try + { + String path = getAbsolutePathFromPathRelativeToMXMLC( + "../../frameworks/js/FlexJS/src"); + + sdkJSLib.add(path); + } + catch (Exception e) { /* better to try and fail... */ } + } + + return sdkJSLib; + } + + @Config(allowMultiple = true) + @Mapping("sdk-js-lib") + @Arguments(Arguments.PATH_ELEMENT) + @InfiniteArguments + public void setSDKJSLib(ConfigurationValue cv, List<String> value) + throws ConfigurationException + { + sdkJSLib.addAll(value); + } + + // + // 'external-js-lib' + // + + private List<String> externalJSLib = new ArrayList<String>(); + + public List<String> getExternalJSLib() + { + return externalJSLib; + } + + @Config(allowMultiple = true) + @Mapping("external-js-lib") + @Arguments(Arguments.PATH_ELEMENT) + @InfiniteArguments + public void setExternalJSLib(ConfigurationValue cv, List<String> value) + throws ConfigurationException + { + externalJSLib.addAll(value); + } + + // + // 'strict-publish' + // + + private boolean strictPublish = true; + + public boolean getStrictPublish() + { + return strictPublish; + } + + @Config + @Mapping("strict-publish") + public void setStrictPublish(ConfigurationValue cv, boolean value) + throws ConfigurationException + { + strictPublish = value; + } + + // + // 'keep-asdoc' + // + + private boolean keepASDoc = true; + + public boolean getKeepASDoc() + { + return keepASDoc; + } + + @Config + @Mapping("keep-asdoc") + public void setKeepASDoc(ConfigurationValue cv, boolean value) + throws ConfigurationException + { + keepASDoc = value; + } + + + + // + // 'remove-circulars' + // + + private boolean removeCirculars = false; + + public boolean getRemoveCirculars() + { + return removeCirculars; + } + + @Config + @Mapping("remove-circulars") + public void setRemoveCirculars(ConfigurationValue cv, boolean value) + throws ConfigurationException + { + removeCirculars = value; + } + + + // + // 'skip-transpile' + // + + private boolean skipTranspile = false; + + public boolean getSkipTranspile() + { + return skipTranspile; + } + + @Config + @Mapping("skip-transpile") + public void setSkipTranspile(ConfigurationValue cv, boolean value) + throws ConfigurationException + { + skipTranspile = value; + } + + + + protected String getAbsolutePathFromPathRelativeToMXMLC(String relativePath) + throws IOException + { + String mxmlcURL = MXMLJSC.class.getProtectionDomain().getCodeSource() + .getLocation().getPath(); + + File mxmlc = new File(URLDecoder.decode(mxmlcURL, "utf-8")); + + return new File(mxmlc.getParent() + File.separator + relativePath) + .getCanonicalPath(); + } + + // + // 'js-compiler-option' + // + + protected List<String> jsCompilerOptions = new ArrayList<String>(); + + public List<String> getJSCompilerOptions() + { + return jsCompilerOptions; + } + + @Config(allowMultiple = true) + @Mapping("js-compiler-option") + @Arguments("option") + @InfiniteArguments + public void setJSCompilerOptions(ConfigurationValue cv, List<String> value) + throws ConfigurationException + { + jsCompilerOptions.addAll(value); + } + + // + // 'js-output-optimization' + // + + protected List<String> jsOutputOptimizations = new ArrayList<String>(); + + public List<String> getJSOutputOptimizations() + { + return jsOutputOptimizations; + } + + @Config(allowMultiple = true) + @Mapping("js-output-optimization") + @Arguments("optimization") + @InfiniteArguments + public void setJSOutputOptimizations(ConfigurationValue cv, List<String> value) + throws ConfigurationException + { + jsOutputOptimizations.addAll(value); + } + + // 'html-template' option + // + + private String htmlTemplateFileName = null; + + public File getHtmlTemplate() + { + return htmlTemplateFileName != null ? new File(htmlTemplateFileName) : null; + } + + /** + * Specify an HTML template with tokens to replace with application-specific values. + * If not specified a standard template is generated. + */ + @Config(advanced = true) + @Mapping("html-template") + @Arguments("filename") + public void setHtmlTemplate(ConfigurationValue cv, String filename) + { + this.htmlTemplateFileName = getOutputPath(cv, filename); + } + + // 'html-output-filename' option + // + + private String htmlOutputFileName = "index.html"; + + public String getHtmlOutputFileName() + { + return htmlOutputFileName; + } + + /** + * Specify the name of the HTML file that goes in the output folder. Default is index.html. + */ + @Config(advanced = true) + @Mapping("html-output-filename") + @Arguments("filename") + public void setHtmlOutputFileName(ConfigurationValue cv, String filename) + { + this.htmlOutputFileName = filename; + } + + // + // 'compiler.keep-code-with-metadata' option + // + + private Set<String> keepCodeWithMetadata = null; + + public Set<String> getCompilerKeepCodeWithMetadata() + { + return keepCodeWithMetadata == null ? Collections.<String> emptySet() : keepCodeWithMetadata; + } + + @Config(advanced = true, allowMultiple = true) + @Mapping({ "compiler", "keep-code-with-metadata" }) + @Arguments("name") + @InfiniteArguments + public void setCompilerKeepCodeWithMetadata(ConfigurationValue cv, List<String> values) + { + if (keepCodeWithMetadata == null) + keepCodeWithMetadata = new HashSet<String>(); + keepCodeWithMetadata.addAll(values); + } + + +}
