Repository: flex-falcon Updated Branches: refs/heads/release0.8.0 61b228332 -> b36ee0336
fix issues with library projects in FB Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/b36ee033 Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/b36ee033 Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/b36ee033 Branch: refs/heads/release0.8.0 Commit: b36ee0336b9a0e0cd3be8114bd007d047f7213f0 Parents: 61b2283 Author: Alex Harui <aha...@apache.org> Authored: Wed May 17 16:32:15 2017 -0700 Committer: Alex Harui <aha...@apache.org> Committed: Wed May 17 16:36:27 2017 -0700 ---------------------------------------------------------------------- .../apache/flex/compiler/clients/COMPJSC.java | 3 ++ .../flex/compiler/clients/COMPJSCFlex.java | 38 +++++++++++++ .../apache/flex/compiler/clients/MXMLJSC.java | 4 +- .../src/main/java/flex2/tools/oem/Library.java | 57 +++++++++++++++++--- .../tools/oem/internal/OEMConfiguration.java | 15 ++++++ .../java/flex2/tools/oem/internal/OEMUtil.java | 40 ++++++++++++++ 6 files changed, 148 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/b36ee033/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 f13ee22..8b82cb8 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 @@ -202,6 +202,7 @@ public class COMPJSC extends MXMLJSC case SWF: System.out.println("COMPC"); COMPC compc = new COMPC(); + mxmlc = compc; compc.configurationClass = JSGoogCompcConfiguration.class; result = compc.mainNoExit(removeJSArgs(args)); if (result != 0) @@ -213,6 +214,7 @@ public class COMPJSC extends MXMLJSC case JS_FLEX: System.out.println("COMPCJSCFlex"); COMPJSCFlex flex = new COMPJSCFlex(); + lastCompiler = flex; result = flex.mainNoExit(removeASArgs(args), problems.getProblems(), false); if (result != 0) { @@ -221,6 +223,7 @@ public class COMPJSC extends MXMLJSC break; case JS_NATIVE: COMPJSCNative jsc = new COMPJSCNative(); + lastCompiler = jsc; result = jsc.mainNoExit(removeASArgs(args), problems.getProblems(), false); if (result != 0) { http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/b36ee033/compiler-jx/src/main/java/org/apache/flex/compiler/clients/COMPJSCFlex.java ---------------------------------------------------------------------- diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/clients/COMPJSCFlex.java b/compiler-jx/src/main/java/org/apache/flex/compiler/clients/COMPJSCFlex.java index c403bbc..3744a67 100644 --- a/compiler-jx/src/main/java/org/apache/flex/compiler/clients/COMPJSCFlex.java +++ b/compiler-jx/src/main/java/org/apache/flex/compiler/clients/COMPJSCFlex.java @@ -29,8 +29,10 @@ import java.io.InputStream; import java.util.ArrayList; import java.util.Collection; import java.util.Enumeration; +import java.util.LinkedList; import java.util.List; import java.util.Set; +import java.util.TreeSet; import java.util.zip.Deflater; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; @@ -64,6 +66,7 @@ import org.apache.flex.compiler.problems.UnableToBuildSWFProblem; import org.apache.flex.compiler.targets.ITarget.TargetType; import org.apache.flex.compiler.targets.ITargetSettings; import org.apache.flex.compiler.units.ICompilationUnit; +import org.apache.flex.compiler.units.ICompilationUnit.UnitType; import org.apache.flex.swc.io.SWCReader; /** @@ -525,4 +528,39 @@ public class COMPJSCFlex extends MXMLJSCFlex { return TargetType.SWC; } + + @Override + public List<String> getSourceList() + { + ArrayList<String> list = new ArrayList<String>(); + LinkedList<ICompilerProblem> problemList = new LinkedList<ICompilerProblem>(); + try + { + Collection<ICompilerProblem> errors = new ArrayList<ICompilerProblem>(); + Collection<ICompilationUnit> roots = ((FlexJSSWCTarget)target).getReachableCompilationUnits(errors); + Collection<ICompilationUnit> units = project.getReachableCompilationUnitsInSWFOrder(roots); + for (ICompilationUnit unit : units) + { + UnitType ut = unit.getCompilationUnitType(); + if (ut == UnitType.AS_UNIT || ut == UnitType.MXML_UNIT) + { + list.add(unit.getAbsoluteFilename()); + } + } + } + catch (InterruptedException e) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return list; + } + + @Override + public String getMainSource() + { + return null; + } + } http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/b36ee033/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 0916598..1f14259 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 @@ -261,8 +261,8 @@ public class MXMLJSC implements JSCompilerEntryPoint, ProblemQueryProvider, protected ITargetSettings targetSettings; protected IJSApplication jsTarget; private IJSPublisher jsPublisher; - private MXMLC mxmlc; - private JSCompilerEntryPoint lastCompiler; + protected MXMLC mxmlc; + protected JSCompilerEntryPoint lastCompiler; public boolean noLink; public OutputStream err; public Class<? extends Configuration> configurationClass = JSGoogConfiguration.class; http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/b36ee033/flex-compiler-oem/src/main/java/flex2/tools/oem/Library.java ---------------------------------------------------------------------- diff --git a/flex-compiler-oem/src/main/java/flex2/tools/oem/Library.java b/flex-compiler-oem/src/main/java/flex2/tools/oem/Library.java index bdcb3be..182c325 100644 --- a/flex-compiler-oem/src/main/java/flex2/tools/oem/Library.java +++ b/flex-compiler-oem/src/main/java/flex2/tools/oem/Library.java @@ -37,13 +37,16 @@ import java.util.TreeSet; import java.lang.annotation.Annotation; import java.net.URI; -import org.apache.flex.compiler.clients.COMPC; +import org.apache.flex.compiler.clients.COMPJSC; import org.apache.flex.compiler.clients.problems.ProblemFormatter; import org.apache.flex.compiler.clients.problems.ProblemQuery; import org.apache.flex.compiler.problems.CompilerProblemSeverity; import org.apache.flex.compiler.problems.ICompilerProblem; import org.apache.flex.compiler.problems.annotations.DefaultSeverity; +import flex2.compiler.CompilerException; +import flex2.compiler.Source; +import flex2.compiler.SourceList; import flex2.compiler.common.CompilerConfiguration; import flex2.compiler.config.ConfigurationException; import flex2.compiler.io.FileUtil; @@ -55,6 +58,9 @@ import flex2.compiler.util.CompilerMessage; import flex2.compiler.util.MimeMappings; import flex2.compiler.util.PerformanceData; import flex2.compiler.util.ThreadLocalToolkit; +import flex2.linker.SimpleMovie; +import flex2.tools.oem.internal.ApplicationCompilerConfiguration; +import flex2.tools.oem.internal.LibraryCompilerConfiguration; import flex2.tools.oem.internal.OEMConfiguration; import flex2.tools.oem.internal.OEMReport; import flex2.tools.oem.internal.OEMUtil; @@ -249,6 +255,10 @@ public class Library implements Builder, Cloneable private CompilerControl cc; private ApplicationCache applicationCache; private LibraryCache libraryCache; + + private List<Source> compiledSources; + private SourceList sourceList; + // clean() would null out the following variables //LibraryData data; @@ -746,10 +756,10 @@ public class Library implements Builder, Cloneable public Report getReport() { //OEMUtil.setupLocalizationManager(); - return new OEMReport(null, - null, + return new OEMReport(compiledSources, null, null, + sourceList, configurationReport, messages, files); } @@ -904,14 +914,47 @@ public class Library implements Builder, Cloneable true /* cleanConfig */, false /* cleanMessages */, false /* cleanThreadLocals */); - COMPC compc = new COMPC(); - int returnValue = compc.mainNoExit(constructCommandLine(oemConfiguration)); - if (returnValue == 0) + COMPJSC compc = new COMPJSC(); + int returnValue = compc.mainNoExit(constructCommandLine(oemConfiguration), null, true); + if (returnValue == 0 || returnValue == 2) returnValue = OK; else returnValue = FAIL; - convertMessages(compc.getProblems()); + LibraryCompilerConfiguration acc = ((LibraryCompilerConfiguration)tempOEMConfiguration.configuration); + VirtualFile[] sourcePaths = acc.getCompilerConfiguration().getSourcePath(); + + compiledSources = new ArrayList<Source>(); + List<String> sourceFiles = compc.getSourceList(); + String mainFile = compc.getMainSource(); + VirtualFile mainVirtualFile = null; + for (String sourceFile : sourceFiles) + { + for (VirtualFile sourcePath : sourcePaths) + { + String pathName = sourcePath.getName(); + if (sourceFile.indexOf(pathName) == 0) + { + String relPath = sourceFile.substring(pathName.length()); + int lastSep = relPath.lastIndexOf(File.separator); + String shortName = relPath.substring(lastSep + 1); + relPath = relPath.substring(0, lastSep); + boolean isRoot = sourceFile.equals(mainFile); + Source source = new Source(sourcePath, relPath, shortName, null, false, isRoot); + compiledSources.add(source); + if (mainFile != null && pathName.equals(mainFile)) + mainVirtualFile = sourcePath; + } + } + } + try { + sourceList = new SourceList(new ArrayList<VirtualFile>(), sourcePaths, mainVirtualFile, new String[0]); + } catch (CompilerException e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + + convertMessages(compc.getProblemQuery()); clean(returnValue != OK, false, false); return returnValue; http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/b36ee033/flex-compiler-oem/src/main/java/flex2/tools/oem/internal/OEMConfiguration.java ---------------------------------------------------------------------- diff --git a/flex-compiler-oem/src/main/java/flex2/tools/oem/internal/OEMConfiguration.java b/flex-compiler-oem/src/main/java/flex2/tools/oem/internal/OEMConfiguration.java index f141fd8..eef9c03 100644 --- a/flex-compiler-oem/src/main/java/flex2/tools/oem/internal/OEMConfiguration.java +++ b/flex-compiler-oem/src/main/java/flex2/tools/oem/internal/OEMConfiguration.java @@ -1163,6 +1163,21 @@ public class OEMConfiguration implements Configuration, ConfigurationConstants, * * @param paths an array of <code>java.io.File</code> (<code>File.isDirectory()</code> must return <code>true</code>). */ + public File[] getSourcePath() + { + if (args.containsKey(COMPILER_SOURCE_PATH)) + return (File[]) args.get(COMPILER_SOURCE_PATH); + if (more.containsKey(COMPILER_SOURCE_PATH)) + return (File[]) more.get(COMPILER_SOURCE_PATH); + return null; + } + + /** + * Sets a list of path elements that form the roots of ActionScript class hierarchies. + * This is equivalent to using <code>mxmlc/compc --compiler.source-path</code>. + * + * @param paths an array of <code>java.io.File</code> (<code>File.isDirectory()</code> must return <code>true</code>). + */ public void setSourcePath(File[] paths) { args.put(COMPILER_SOURCE_PATH, paths); http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/b36ee033/flex-compiler-oem/src/main/java/flex2/tools/oem/internal/OEMUtil.java ---------------------------------------------------------------------- diff --git a/flex-compiler-oem/src/main/java/flex2/tools/oem/internal/OEMUtil.java b/flex-compiler-oem/src/main/java/flex2/tools/oem/internal/OEMUtil.java index b6e1d5b..d791e10 100644 --- a/flex-compiler-oem/src/main/java/flex2/tools/oem/internal/OEMUtil.java +++ b/flex-compiler-oem/src/main/java/flex2/tools/oem/internal/OEMUtil.java @@ -243,6 +243,8 @@ public class OEMUtil private static LibraryCompilerConfiguration processCOMPCCConfiguration(org.apache.flex.compiler.config.Configuration config) { LibraryCompilerConfiguration acc = new LibraryCompilerConfiguration(); + ConfigurationPathResolver resolver = new ConfigurationPathResolver(); + acc.setConfigPathResolver(resolver); acc.setBackgroundColor(config.getDefaultBackgroundColor()); acc.setDebug(config.debug()); acc.setFrameRate(config.getDefaultFrameRate()); @@ -251,7 +253,45 @@ public class OEMUtil acc.setSwfVersion(config.getSwfVersion()); acc.setScriptRecursionLimit(config.getScriptRecursionLimit()); acc.setScriptTimeLimit(config.getScriptTimeLimit()); + CompilerConfiguration cc = acc.getCompilerConfiguration(); + List<String> externalLibraries = config.getCompilerExternalLibraryPath(); + String[] extlibs = new String[externalLibraries.size()]; + externalLibraries.toArray(extlibs); + try + { + cc.cfgExternalLibraryPath(null, extlibs); + } + catch (ConfigurationException e) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } + List<String> libraries = config.getCompilerLibraryPath(); + String[] libs = new String[libraries.size()]; + libraries.toArray(libs); + try + { + cc.cfgLibraryPath(null, libs); + } + catch (ConfigurationException e) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } + List<String> sources = config.getCompilerSourcePath(); + String[] srcs = new String[sources.size()]; + sources.toArray(srcs); + try + { + cc.cfgSourcePath(null, srcs); + } + catch (ConfigurationException e) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return acc; }