private void addLibs(final Element rootElement) { for (final JpsFlexDependencyEntry entry : myBC.getDependencies().getEntries()) { LinkageType linkageType = entry.getLinkageType(); if (linkageType == LinkageType.Test) { if (myFlexUnit) { linkageType = LinkageType.Merged; } else { continue; } } if (myCSS && linkageType == LinkageType.Include) linkageType = LinkageType.Merged; if (entry instanceof JpsFlexBCDependencyEntry) { if (linkageType == LinkageType.LoadInRuntime) continue; final JpsFlexBuildConfiguration dependencyBC = ((JpsFlexBCDependencyEntry) entry).getBC(); if (dependencyBC != null && FlexCommonUtils.checkDependencyType( myBC.getOutputType(), dependencyBC.getOutputType(), linkageType)) { addLib(rootElement, dependencyBC.getActualOutputFilePath(), linkageType); } } else if (entry instanceof JpsLibraryDependencyEntry) { final JpsLibrary library = ((JpsLibraryDependencyEntry) entry).getLibrary(); if (library != null) { addLibraryRoots(rootElement, library.getRootUrls(JpsOrderRootType.COMPILED), linkageType); } } } if (myFlexUnit) { final Collection<String> flexUnitLibNames = FlexCommonUtils.getFlexUnitSupportLibNames( myBC.getNature(), myBC.getDependencies().getComponentSet(), getPathToFlexUnitMainClass( myProjectDescriptor, myBC.getNature(), myBC.getMainClass())); for (String libName : flexUnitLibNames) { final String libPath = FlexCommonUtils.getPathToBundledJar(libName); final String flexUnitSwcUrl = JpsPathUtil.pathToUrl(FileUtil.toSystemIndependentName(libPath)); addLibraryRoots(rootElement, Collections.singletonList(flexUnitSwcUrl), LinkageType.Merged); } } }
private Pair<String, ValueSource> getValueAndSource(final CompilerOptionInfo info) { assert !info.isGroup() : info.DISPLAY_NAME; final String bcLevelValue = myBC.getCompilerOptions().getOption(info.ID); if (bcLevelValue != null) return Pair.create(bcLevelValue, ValueSource.BC); final String moduleLevelValue = myModuleLevelCompilerOptions.getOption(info.ID); if (moduleLevelValue != null) return Pair.create(moduleLevelValue, ValueSource.ModuleDefault); final String projectLevelValue = myProjectLevelCompilerOptions.getOption(info.ID); if (projectLevelValue != null) return Pair.create(projectLevelValue, ValueSource.ProjectDefault); return Pair.create( info.getDefaultValue( mySdk.getVersionString(), myBC.getNature(), myBC.getDependencies().getComponentSet()), ValueSource.GlobalDefault); }
private void addInputOutputPaths(final Element rootElement) throws IOException { if (myBC.getOutputType() == OutputType.Library) { addFilesIncludedInSwc(rootElement); if (!myFlexmojos) { addLibClasses(rootElement); } } else { final InfoFromConfigFile info = InfoFromConfigFile.getInfoFromConfigFile( myBC.getCompilerOptions().getAdditionalConfigFilePath()); final String pathToMainClassFile = myCSS ? myBC.getMainClass() : myFlexUnit ? getPathToFlexUnitMainClass( myProjectDescriptor, myBC.getNature(), myBC.getMainClass()) : FlexCommonUtils.getPathToMainClassFile(myBC.getMainClass(), myModule); if (pathToMainClassFile.isEmpty() && info.getMainClass(myModule) == null && !Utils.IS_TEST_MODE) { throw new IOException( FlexCommonBundle.message( "bc.incorrect.main.class", myBC.getMainClass(), myBC.getName(), myModule.getName())); } if (!pathToMainClassFile.isEmpty()) { addOption( rootElement, CompilerOptionInfo.MAIN_CLASS_INFO, FileUtil.toSystemIndependentName(pathToMainClassFile)); } } addOption(rootElement, CompilerOptionInfo.OUTPUT_PATH_INFO, myBC.getActualOutputFilePath()); }
private void addOption( final Element rootElement, final CompilerOptionInfo info, final String rawValue) { if (!info.isApplicable(mySdk.getVersionString(), myBC.getNature())) { return; } final String value = FlexCommonUtils.replacePathMacros( rawValue, myModule, myFlexmojos ? "" : mySdk.getHomePath()); final String pathInFlexConfig = info.ID.startsWith("compiler.debug") ? "compiler.debug" : info.ID; final List<String> elementNames = StringUtil.split(pathInFlexConfig, "."); Element parentElement = rootElement; for (int i1 = 0; i1 < elementNames.size() - 1; i1++) { parentElement = getOrCreateElement(parentElement, elementNames.get(i1)); } final String elementName = elementNames.get(elementNames.size() - 1); switch (info.TYPE) { case Boolean: case String: case Int: case File: final Element simpleElement = new Element(elementName, parentElement.getNamespace()); simpleElement.setText(value); parentElement.addContent(simpleElement); break; case List: if (info.LIST_ELEMENTS.length == 1) { final Element listHolderElement = getOrCreateElement(parentElement, elementName); for (final String listElementValue : StringUtil.split(value, CompilerOptionInfo.LIST_ENTRIES_SEPARATOR)) { final Element child = new Element(info.LIST_ELEMENTS[0].NAME, listHolderElement.getNamespace()); child.setText(listElementValue); listHolderElement.addContent(child); } } else { for (final String listEntry : StringUtil.split(value, String.valueOf(CompilerOptionInfo.LIST_ENTRIES_SEPARATOR))) { final Element repeatableListHolderElement = new Element(elementName, parentElement.getNamespace()); final List<String> values = StringUtil.split( listEntry, CompilerOptionInfo.LIST_ENTRY_PARTS_SEPARATOR, true, false); assert info.LIST_ELEMENTS.length == values.size() : info.ID + "=" + value; for (int i = 0; i < info.LIST_ELEMENTS.length; i++) { final Element child = new Element( info.LIST_ELEMENTS[i].NAME, repeatableListHolderElement.getNamespace()); child.setText(values.get(i)); repeatableListHolderElement.addContent(child); } parentElement.addContent(repeatableListHolderElement); } } break; default: assert false : info.DISPLAY_NAME; } }
private void addRootsFromSdk(final Element rootElement) { final CompilerOptionInfo localeInfo = CompilerOptionInfo.getOptionInfo("compiler.locale"); if (!getValueAndSource(localeInfo).first.isEmpty()) { addOption( rootElement, CompilerOptionInfo.LIBRARY_PATH_INFO, mySdk.getHomePath() + "/frameworks/locale/{locale}"); } final Map<String, String> libNameToRslInfo = new THashMap<String, String>(); for (final String swcUrl : mySdk.getParent().getRootUrls(JpsOrderRootType.COMPILED)) { final String swcPath = JpsPathUtil.urlToPath(swcUrl); if (!swcPath.toLowerCase().endsWith(".swc")) { Logger.getInstance(CompilerConfigGeneratorRt.class.getName()) .warn("Unexpected URL in Flex SDK classes: " + swcUrl); continue; } LinkageType linkageType = FlexCommonUtils.getSdkEntryLinkageType(swcPath, myBC); // check applicability if (linkageType == null) continue; // resolve default if (linkageType == LinkageType.Default) linkageType = myBC.getDependencies().getFrameworkLinkage(); if (linkageType == LinkageType.Default) { linkageType = FlexCommonUtils.getDefaultFrameworkLinkage(mySdk.getVersionString(), myBC.getNature()); } if (myCSS && linkageType == LinkageType.Include) linkageType = LinkageType.Merged; final CompilerOptionInfo info = linkageType == LinkageType.Merged ? CompilerOptionInfo.LIBRARY_PATH_INFO : linkageType == LinkageType.RSL ? CompilerOptionInfo.LIBRARY_PATH_INFO : linkageType == LinkageType.External ? CompilerOptionInfo.EXTERNAL_LIBRARY_INFO : linkageType == LinkageType.Include ? CompilerOptionInfo.INCLUDE_LIBRARY_INFO : null; assert info != null : swcPath + ": " + linkageType.getShortText(); addOption(rootElement, info, swcPath); if (linkageType == LinkageType.RSL) { final List<String> rslUrls = RslUtil.getRslUrls(mySdk.getHomePath(), swcPath); if (rslUrls.isEmpty()) continue; final StringBuilder rslBuilder = new StringBuilder(); final String firstUrl = rslUrls.get(0); rslBuilder .append(swcPath) .append(CompilerOptionInfo.LIST_ENTRY_PARTS_SEPARATOR) .append(firstUrl) .append(CompilerOptionInfo.LIST_ENTRY_PARTS_SEPARATOR); if (firstUrl.startsWith("http://")) { rslBuilder.append("http://fpdownload.adobe.com/pub/swz/crossdomain.xml"); } if (rslUrls.size() > 1) { final String secondUrl = rslUrls.get(1); rslBuilder .append(CompilerOptionInfo.LIST_ENTRY_PARTS_SEPARATOR) .append(secondUrl) .append(CompilerOptionInfo.LIST_ENTRY_PARTS_SEPARATOR); if (secondUrl.startsWith("http://")) { rslBuilder.append("http://fpdownload.adobe.com/pub/swz/crossdomain.xml"); } } final String swcName = PathUtilRt.getFileName(swcPath); final String libName = swcName.substring(0, swcName.length() - ".swc".length()); libNameToRslInfo.put(libName, rslBuilder.toString()); } } if (myBC.getNature().isLib()) { final String theme = getValueAndSource(CompilerOptionInfo.getOptionInfo("compiler.theme")).first; if (theme != null && theme.toLowerCase().endsWith(".swc")) { addOption(rootElement, CompilerOptionInfo.LIBRARY_PATH_INFO, theme); } } addRslInfo(rootElement, libNameToRslInfo); }
private void addMandatoryOptions(final Element rootElement) { if (!FlexCommonUtils.isRLMTemporaryBC(myBC) && !FlexCommonUtils.isRuntimeStyleSheetBC(myBC) && FlexCommonUtils.canHaveRLMsAndRuntimeStylesheets(myBC) && myBC.getRLMs().size() > 0) { addOption(rootElement, CompilerOptionInfo.LINK_REPORT_INFO, getLinkReportFilePath(myBC)); } if (FlexCommonUtils.isRLMTemporaryBC(myBC) && !myBC.getOptimizeFor().isEmpty()) { final String customLinkReportPath = getCustomLinkReportPath(myBC); final String linkReportPath = StringUtil.notNullize(customLinkReportPath, getLinkReportFilePath(myBC)); addOption(rootElement, CompilerOptionInfo.LOAD_EXTERNS_INFO, linkReportPath); } addOption(rootElement, CompilerOptionInfo.WARN_NO_CONSTRUCTOR_INFO, "false"); if (myFlexmojos) return; final BuildConfigurationNature nature = myBC.getNature(); final String targetPlayer = nature.isWebPlatform() ? myBC.getDependencies().getTargetPlayer() : FlexCommonUtils.getMaximumTargetPlayer(mySdk.getHomePath()); addOption(rootElement, CompilerOptionInfo.TARGET_PLAYER_INFO, targetPlayer); if (FlexCommonUtils.isAirSdkWithoutFlex(mySdk) || StringUtil.compareVersionNumbers(mySdk.getVersionString(), "4.5") >= 0) { final String swfVersion; if (nature.isWebPlatform()) { swfVersion = FlexCommonUtils.getSwfVersionForTargetPlayer(targetPlayer); } else { String airVersion = getAirVersionIfCustomDescriptor(myBC); if (airVersion == null) { airVersion = FlexCommonUtils.getAirVersion(mySdk.getHomePath(), mySdk.getVersionString()); } swfVersion = airVersion != null ? FlexCommonUtils.getSwfVersionForAirVersion(airVersion) : FlexCommonUtils.getSwfVersionForSdk_THE_WORST_WAY(mySdk.getVersionString()); } addOption(rootElement, CompilerOptionInfo.SWF_VERSION_INFO, swfVersion); } if (nature.isMobilePlatform()) { addOption(rootElement, CompilerOptionInfo.MOBILE_INFO, "true"); addOption(rootElement, CompilerOptionInfo.PRELOADER_INFO, "spark.preloaders.SplashScreen"); } if (!FlexCommonUtils.isAirSdkWithoutFlex(mySdk)) { final String accessible = nature.isMobilePlatform() ? "false" : StringUtil.compareVersionNumbers(mySdk.getVersionString(), "4") >= 0 ? "true" : "false"; addOption(rootElement, CompilerOptionInfo.ACCESSIBLE_INFO, accessible); final String fontManagers = StringUtil.compareVersionNumbers(mySdk.getVersionString(), "4") >= 0 ? "flash.fonts.JREFontManager" + CompilerOptionInfo.LIST_ENTRIES_SEPARATOR + "flash.fonts.BatikFontManager" + CompilerOptionInfo.LIST_ENTRIES_SEPARATOR + "flash.fonts.AFEFontManager" + CompilerOptionInfo.LIST_ENTRIES_SEPARATOR + "flash.fonts.CFFFontManager" : "flash.fonts.JREFontManager" + CompilerOptionInfo.LIST_ENTRIES_SEPARATOR + "flash.fonts.AFEFontManager" + CompilerOptionInfo.LIST_ENTRIES_SEPARATOR + "flash.fonts.BatikFontManager"; addOption(rootElement, CompilerOptionInfo.FONT_MANAGERS_INFO, fontManagers); addOption(rootElement, CompilerOptionInfo.STATIC_RSLS_INFO, "false"); } }