> This commit makes the 'release' version of Fred's excellent example work > (with warnings). Don't forget to rebuild the 'jquery' externs SWC, as it > needs to pick up the JS file.
I rebuilt falcon, the externs, the project and I still have Uncaught ReferenceError: Main is not defined with js-release, what did I miss ? Thanks, Frédéric THOMAS ---------------------------------------- > From: erikdebr...@apache.org > Date: Thu, 2 Jul 2015 15:19:13 +0200 > Subject: Re: [2/2] git commit: [flex-falcon] [refs/heads/develop] - GCC and > externs: add the 'externs.js' files to the SWCs; tell GCC to use those to > prevent renaming > To: dev@flex.apache.org > > This commit makes the 'release' version of Fred's excellent example work > (with warnings). Don't forget to rebuild the 'jquery' externs SWC, as it > needs to pick up the JS file. > > Looking further into those warnings. > > EdB > > > > On Thu, Jul 2, 2015 at 3:13 PM, <erikdebr...@apache.org> wrote: > >> GCC and externs: add the 'externs.js' files to the SWCs; tell GCC to use >> those to prevent renaming >> >> We've worked so hard to create AS classes from the Closure externs, let's >> not forget what these were originally intended for... and what we need them >> for: prevent renaming of externally declared functions. We needed to >> include the original extern files in their respective SWCs so we can later >> present them to the GCC. >> >> Signed-off-by: Erik de Bruin <e...@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/1f35e526 >> Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/1f35e526 >> Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/1f35e526 >> >> Branch: refs/heads/develop >> Commit: 1f35e5260e580b8b40f95551f383a362c2474edd >> Parents: e425a86 >> Author: Erik de Bruin <e...@ixsoftware.nl> >> Authored: Thu Jul 2 15:12:50 2015 +0200 >> Committer: Erik de Bruin <e...@ixsoftware.nl> >> Committed: Thu Jul 2 15:12:50 2015 +0200 >> >> ---------------------------------------------------------------------- >> .../mxml/flexjs/MXMLFlexJSPublisher.java | 43 +++++++++++++++++++- >> externs/jasmine/compile-config.xml | 5 +++ >> externs/jquery/compile-config.xml | 5 +++ >> 3 files changed, 51 insertions(+), 2 deletions(-) >> ---------------------------------------------------------------------- >> >> >> >> http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/1f35e526/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 1d6c7aa..cf3869b 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 >> @@ -22,7 +22,9 @@ import java.io.BufferedReader; >> import java.io.File; >> import java.io.FileInputStream; >> import java.io.IOException; >> +import java.io.InputStream; >> import java.io.InputStreamReader; >> +import java.io.OutputStream; >> import java.net.URL; >> import java.util.ArrayList; >> import java.util.Collection; >> @@ -49,6 +51,8 @@ import >> org.apache.flex.compiler.internal.driver.js.goog.JSGoogConfiguration; >> import org.apache.flex.compiler.internal.graph.GoogDepsWriter; >> import org.apache.flex.compiler.internal.projects.FlexJSProject; >> import org.apache.flex.compiler.utils.JSClosureCompilerWrapper; >> +import org.apache.flex.swc.ISWC; >> +import org.apache.flex.swc.ISWCFileEntry; >> >> public class MXMLFlexJSPublisher extends JSGoogPublisher implements >> IJSPublisher >> { >> @@ -57,6 +61,8 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher >> implements IJSPublisher >> public static final String FLEXJS_INTERMEDIATE_DIR_NAME = "js-debug"; >> public static final String FLEXJS_RELEASE_DIR_NAME = "js-release"; >> >> + private static final String FLEXJS_EXTERNS = "externs"; >> + >> class DependencyRecord >> { >> String path; >> @@ -278,8 +284,41 @@ public class MXMLFlexJSPublisher extends >> JSGoogPublisher implements IJSPublisher >> >> JSClosureCompilerWrapper compilerWrapper = new >> JSClosureCompilerWrapper(); >> >> - GoogDepsWriter gdw = new GoogDepsWriter(intermediateDir, >> projectName, (JSGoogConfiguration) configuration, >> - project.getLibraries()); >> + List<ISWC> swcs = project.getLibraries(); >> + >> + // (erikdebruin) We don't want to forget that we need to tell the >> GCC >> + // about them fancy externs we've been working so >> hard on >> + for (ISWC swc : swcs) >> + { >> + String srcName = swc.getSWCFile().getName().replace(".swc", >> ".js"); >> + String srcPath = FLEXJS_EXTERNS + File.separator + srcName; >> + >> + ISWCFileEntry fileEntry = swc.getFile(FLEXJS_EXTERNS + >> File.separator + srcName); >> + if (fileEntry != null) >> + { >> + File destFile = new File(intermediateDirPath + >> File.separator + srcPath); >> + >> + InputStream inStream = fileEntry.createInputStream(); >> + OutputStream outStream = >> FileUtils.openOutputStream(destFile); >> + byte[] b = new byte[1024 * 1024]; >> + int bytes_read; >> + while ((bytes_read = inStream.read(b)) != -1) >> + { >> + outStream.write(b, 0, bytes_read); >> + } >> + outStream.flush(); >> + outStream.close(); >> + inStream.close(); >> + >> + String destPath = destFile.getAbsolutePath(); >> + >> + System.out.println("using extern: " + destPath); >> + >> + compilerWrapper.addJSExternsFile(destPath); >> + } >> + } >> + >> + GoogDepsWriter gdw = new GoogDepsWriter(intermediateDir, >> projectName, (JSGoogConfiguration) configuration, swcs); >> StringBuilder depsFileData = new StringBuilder(); >> try >> { >> >> >> http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/1f35e526/externs/jasmine/compile-config.xml >> ---------------------------------------------------------------------- >> diff --git a/externs/jasmine/compile-config.xml >> b/externs/jasmine/compile-config.xml >> index abf867e..2af1e2a 100644 >> --- a/externs/jasmine/compile-config.xml >> +++ b/externs/jasmine/compile-config.xml >> @@ -67,6 +67,11 @@ >> <path-element>out/as/functions</path-element> >> </include-sources> >> >> + <include-file> >> + <name>externs/jasmine-2.0.js</name> >> + <path>externs/jasmine-2.0.js</path> >> + </include-file> >> + >> <!-- >> <include-file> >> <name>defaults.css</name> >> >> >> http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/1f35e526/externs/jquery/compile-config.xml >> ---------------------------------------------------------------------- >> diff --git a/externs/jquery/compile-config.xml >> b/externs/jquery/compile-config.xml >> index c0c7f34..3ff4f10 100644 >> --- a/externs/jquery/compile-config.xml >> +++ b/externs/jquery/compile-config.xml >> @@ -71,6 +71,11 @@ >> <path-element>out/as/functions</path-element> >> </include-sources> >> >> + <include-file> >> + <name>externs/jquery-1.9.js</name> >> + <path>externs/jquery-1.9.js</path> >> + </include-file> >> + >> <!-- >> <include-file> >> <name>defaults.css</name> >> >>