use of com.intellij.flex.model.bc.JpsFlexBuildConfiguration in project intellij-plugins by JetBrains.
the class FlexBuilder method createCssBC.
private static JpsFlexBuildConfiguration createCssBC(final JpsFlexBuildConfiguration mainBC, final String cssPath) {
final JpsFlexBuildConfiguration cssBC = mainBC.getModule().getProperties().createTemporaryCopyForCompilation(mainBC);
cssBC.setOutputType(OutputType.Application);
cssBC.setMainClass(cssPath);
cssBC.setOutputFileName(FileUtil.getNameWithoutExtension(PathUtilRt.getFileName(cssPath)) + ".swf");
final String cssDirPath = PathUtilRt.getParentPath(cssPath);
String relativeToRoot = FlexCommonUtils.getPathRelativeToSourceRoot(mainBC.getModule(), cssDirPath);
if (relativeToRoot == null) {
relativeToRoot = FlexCommonUtils.getPathRelativeToContentRoot(mainBC.getModule(), cssDirPath);
}
if (!StringUtil.isEmpty(relativeToRoot)) {
final String outputFolder = PathUtilRt.getParentPath(mainBC.getActualOutputFilePath());
cssBC.setOutputFolder(outputFolder + "/" + relativeToRoot);
}
cssBC.setUseHtmlWrapper(false);
cssBC.setRLMs(Collections.emptyList());
cssBC.setCssFilesToCompile(Collections.emptyList());
final JpsFlexCompilerOptions compilerOptions = cssBC.getCompilerOptions();
compilerOptions.setResourceFilesMode(JpsFlexCompilerOptions.ResourceFilesMode.None);
String additionalOptions = compilerOptions.getAdditionalOptions();
additionalOptions = FlexCommonUtils.removeOptions(additionalOptions, "link-report");
additionalOptions = FlexCommonUtils.fixSizeReportOption(additionalOptions, FileUtil.getNameWithoutExtension(PathUtilRt.getFileName(cssPath)));
compilerOptions.setAdditionalOptions(additionalOptions);
return cssBC;
}
use of com.intellij.flex.model.bc.JpsFlexBuildConfiguration in project intellij-plugins by JetBrains.
the class FlexBuilder method createRlmBC.
private static JpsFlexBuildConfiguration createRlmBC(final JpsFlexBuildConfiguration mainBC, final JpsFlexBuildConfiguration.RLMInfo rlm) {
final JpsFlexBuildConfiguration rlmBC = mainBC.getModule().getProperties().createTemporaryCopyForCompilation(mainBC);
rlmBC.setOutputType(OutputType.RuntimeLoadedModule);
// any not empty string means that need to optimize
rlmBC.setOptimizeFor(rlm.OPTIMIZE ? mainBC.getName() : "");
final String subdir = PathUtilRt.getParentPath(rlm.OUTPUT_FILE);
final String outputFileName = PathUtilRt.getFileName(rlm.OUTPUT_FILE);
rlmBC.setMainClass(rlm.MAIN_CLASS);
rlmBC.setOutputFileName(outputFileName);
if (!subdir.isEmpty()) {
final String outputFolder = PathUtilRt.getParentPath(mainBC.getActualOutputFilePath());
rlmBC.setOutputFolder(outputFolder + "/" + subdir);
}
rlmBC.setUseHtmlWrapper(false);
rlmBC.setRLMs(Collections.emptyList());
rlmBC.setCssFilesToCompile(Collections.emptyList());
final JpsFlexCompilerOptions compilerOptions = rlmBC.getCompilerOptions();
compilerOptions.setResourceFilesMode(JpsFlexCompilerOptions.ResourceFilesMode.None);
String additionalOptions = compilerOptions.getAdditionalOptions();
additionalOptions = FlexCommonUtils.removeOptions(additionalOptions, "link-report");
additionalOptions = FlexCommonUtils.fixSizeReportOption(additionalOptions, StringUtil.getShortName(rlmBC.getMainClass()));
compilerOptions.setAdditionalOptions(additionalOptions);
return rlmBC;
}
use of com.intellij.flex.model.bc.JpsFlexBuildConfiguration in project intellij-plugins by JetBrains.
the class FlexBuildTargetType method computeAllTargets.
@NotNull
public List<FlexBuildTarget> computeAllTargets(@NotNull final JpsModel model) {
final List<FlexBuildTarget> result = new ArrayList<>();
final JpsProject project = model.getProject();
for (JpsTypedRunConfiguration<JpsFlashRunnerParameters> runConfig : project.getRunConfigurations(JpsFlashRunConfigurationType.INSTANCE)) {
ContainerUtilRt.addIfNotNull(result, FlexBuildTarget.create(project, runConfig.getType(), runConfig.getName()));
}
for (JpsTypedRunConfiguration<JpsFlexUnitRunnerParameters> runConfig : project.getRunConfigurations(JpsFlexUnitRunConfigurationType.INSTANCE)) {
ContainerUtilRt.addIfNotNull(result, FlexBuildTarget.create(project, runConfig.getType(), runConfig.getName()));
}
for (JpsTypedModule<JpsFlexBuildConfigurationManager> module : project.getModules(JpsFlexModuleType.INSTANCE)) {
for (JpsFlexBuildConfiguration bc : module.getProperties().getBuildConfigurations()) {
result.add(FlexBuildTarget.create(bc, null));
final BuildConfigurationNature nature = bc.getNature();
if (nature.isApp() && (nature.isDesktopPlatform() || nature.isMobilePlatform())) {
result.add(FlexBuildTarget.create(bc, Boolean.TRUE));
result.add(FlexBuildTarget.create(bc, Boolean.FALSE));
}
}
}
return result;
}
use of com.intellij.flex.model.bc.JpsFlexBuildConfiguration in project intellij-plugins by JetBrains.
the class FlexResourceBuildTarget method writeConfiguration.
@Override
public void writeConfiguration(ProjectDescriptor pd, final PrintWriter out) {
out.println("Module: " + getModule().getName());
for (JpsFlexBuildConfiguration bc : getModule().getProperties().getBuildConfigurations()) {
if (!bc.isSkipCompile() && FlexCommonUtils.canHaveResourceFiles(bc.getNature()) && bc.getCompilerOptions().getResourceFilesMode() != JpsFlexCompilerOptions.ResourceFilesMode.None) {
out.print("BC: " + bc.getName());
out.print(", output folder: " + PathUtilRt.getParentPath(bc.getActualOutputFilePath()));
out.print(", mode: " + bc.getCompilerOptions().getResourceFilesMode());
if (bc.getCompilerOptions().getResourceFilesMode() == JpsFlexCompilerOptions.ResourceFilesMode.ResourcePatterns) {
final JpsJavaCompilerConfiguration c = JpsJavaExtensionService.getInstance().getCompilerConfiguration(getModule().getProject());
if (c != null) {
out.print(", patterns: " + StringUtil.join(c.getResourcePatterns(), " "));
}
}
out.println();
}
}
}
use of com.intellij.flex.model.bc.JpsFlexBuildConfiguration in project intellij-plugins by JetBrains.
the class FlexResourceBuilder method build.
public void build(@NotNull final FlexResourceBuildTarget target, @NotNull final DirtyFilesHolder<BuildRootDescriptor, FlexResourceBuildTarget> holder, @NotNull final BuildOutputConsumer outputConsumer, @NotNull final CompileContext context) throws ProjectBuildException, IOException {
final JpsJavaCompilerConfiguration configuration = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(target.getModule().getProject());
final JpsCompilerExcludes excludes = configuration.getCompilerExcludes();
try {
holder.processDirtyFiles(new FileProcessor<BuildRootDescriptor, FlexResourceBuildTarget>() {
public boolean apply(final FlexResourceBuildTarget target, final File file, final BuildRootDescriptor root) throws IOException {
if (excludes.isExcluded(file))
return true;
final String relativePath = FileUtil.toSystemIndependentName(FileUtil.getRelativePath(root.getRootFile(), file));
if (target.isTests()) {
if (!FlexCommonUtils.isSourceFile(file.getName())) {
final String outputRootUrl = JpsJavaExtensionService.getInstance().getOutputUrl(target.getModule(), target.isTests());
if (outputRootUrl == null)
return true;
final String targetPath = JpsPathUtil.urlToPath(outputRootUrl) + '/' + relativePath;
context.processMessage(new ProgressMessage("Copying " + file.getPath()));
copyResource(context, file, Collections.singleton(targetPath), outputConsumer);
}
} else {
final Collection<String> targetPaths = new ArrayList<>();
for (JpsFlexBuildConfiguration bc : target.getModule().getProperties().getBuildConfigurations()) {
if (bc.isSkipCompile() || !FlexCommonUtils.canHaveResourceFiles(bc.getNature()) || bc.getCompilerOptions().getResourceFilesMode() == JpsFlexCompilerOptions.ResourceFilesMode.None) {
continue;
}
final JpsFlexCompilerOptions.ResourceFilesMode mode = bc.getCompilerOptions().getResourceFilesMode();
if (mode == JpsFlexCompilerOptions.ResourceFilesMode.All && !FlexCommonUtils.isSourceFile(file.getName()) || mode == JpsFlexCompilerOptions.ResourceFilesMode.ResourcePatterns && configuration.isResourceFile(file, root.getRootFile())) {
final String outputFolder = PathUtilRt.getParentPath(bc.getActualOutputFilePath());
targetPaths.add(outputFolder + "/" + relativePath);
}
}
if (!targetPaths.isEmpty()) {
context.processMessage(new ProgressMessage("Copying " + file.getPath()));
copyResource(context, file, targetPaths, outputConsumer);
}
}
return true;
}
});
} catch (Exception e) {
throw new ProjectBuildException(e.getMessage(), e);
}
}
Aggregations