Search in sources :

Example 1 with AirDesktopPackagingOptions

use of com.intellij.lang.javascript.flex.projectStructure.model.AirDesktopPackagingOptions in project intellij-plugins by JetBrains.

the class FlexBaseRunner method createAdlCommandLine.

public static GeneralCommandLine createAdlCommandLine(final Project project, final BCBasedRunnerParameters params, final FlexBuildConfiguration bc, @Nullable String airRuntimePath) throws CantRunException {
    assert params instanceof FlashRunnerParameters || params instanceof FlexUnitRunnerParameters : params;
    assert bc.getTargetPlatform() == TargetPlatform.Desktop || bc.getTargetPlatform() == TargetPlatform.Mobile;
    final Module module = ModuleManager.getInstance(project).findModuleByName(params.getModuleName());
    final Sdk sdk = bc.getSdk();
    if (module == null) {
        throw new CantRunException(FlexBundle.message("module.not.found", params.getModuleName()));
    }
    if (sdk == null) {
        throw new CantRunException(FlexCommonBundle.message("sdk.not.set.for.bc.0.of.module.1", bc.getName(), params.getModuleName()));
    }
    final GeneralCommandLine commandLine = new GeneralCommandLine();
    commandLine.setExePath(FileUtil.toSystemDependentName(FlexSdkUtils.getAdlPath(sdk)));
    String adlOptions;
    if (params instanceof FlashRunnerParameters) {
        adlOptions = bc.getTargetPlatform() == TargetPlatform.Desktop ? ((FlashRunnerParameters) params).getAdlOptions() : ((FlashRunnerParameters) params).getEmulatorAdlOptions();
    } else {
        adlOptions = bc.getTargetPlatform() == TargetPlatform.Desktop ? "" : ((FlexUnitRunnerParameters) params).getEmulatorAdlOptions();
    }
    final List<String> runtimePath = FlexCommonUtils.getOptionValues(adlOptions, "runtime");
    if (!runtimePath.isEmpty()) {
        adlOptions = FlexCommonUtils.removeOptions(adlOptions, "runtime");
        airRuntimePath = runtimePath.get(0);
    }
    if (airRuntimePath != null) {
        commandLine.addParameter("-runtime");
        commandLine.addParameter(airRuntimePath);
    }
    final Collection<VirtualFile> aneFiles = FlexCompilationUtils.getANEFiles(ModuleRootManager.getInstance(module), bc.getDependencies());
    if (!aneFiles.isEmpty()) {
        ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> {
            final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
            if (indicator != null)
                indicator.setIndeterminate(true);
            FlexCompilationUtils.unzipANEFiles(aneFiles, indicator);
        }, "Unzipping ANE files", true, project);
    }
    if (bc.getNature().isDesktopPlatform()) {
        final AirDesktopPackagingOptions packagingOptions = bc.getAirDesktopPackagingOptions();
        final String descriptorPath = getAirDescriptorPath(bc, packagingOptions);
        if ((FlexSdkUtils.isAirSdkWithoutFlex(sdk) || StringUtil.compareVersionNumbers(sdk.getVersionString(), "4.1") >= 0) && FlexCommonUtils.getOptionValues(adlOptions, "profile").isEmpty()) {
            final String profiles = getSupportedProfiles(descriptorPath);
            if (profiles == null || profiles.contains("extendedDesktop")) {
                commandLine.addParameter("-profile");
                commandLine.addParameter("extendedDesktop");
            }
        }
        if (!StringUtil.isEmptyOrSpaces(adlOptions)) {
            for (StringTokenizer tokenizer = new CommandLineTokenizer(adlOptions); tokenizer.hasMoreTokens(); ) {
                commandLine.addParameter(tokenizer.nextToken());
            }
        }
        if (!aneFiles.isEmpty()) {
            commandLine.addParameter("-extdir");
            commandLine.addParameter(FlexCompilationUtils.getPathToUnzipANE());
        }
        commandLine.addParameter(FileUtil.toSystemDependentName(descriptorPath));
        commandLine.addParameter(FileUtil.toSystemDependentName(PathUtil.getParentPath(bc.getActualOutputFilePath())));
        final String programParameters = params instanceof FlashRunnerParameters ? ((FlashRunnerParameters) params).getAirProgramParameters() : "";
        if (!StringUtil.isEmptyOrSpaces(programParameters)) {
            commandLine.addParameter("--");
            for (StringTokenizer tokenizer = new CommandLineTokenizer(programParameters); tokenizer.hasMoreTokens(); ) {
                commandLine.addParameter(tokenizer.nextToken());
            }
        }
    } else {
        final AppDescriptorForEmulator descriptorForEmulator = params instanceof FlashRunnerParameters ? ((FlashRunnerParameters) params).getAppDescriptorForEmulator() : ((FlexUnitRunnerParameters) params).getAppDescriptorForEmulator();
        final String descriptorPath = getDescriptorForEmulatorPath(bc, descriptorForEmulator);
        if (params instanceof FlashRunnerParameters) {
            final FlashRunnerParameters.AirMobileRunTarget mobileRunTarget = ((FlashRunnerParameters) params).getMobileRunTarget();
            assert mobileRunTarget == FlashRunnerParameters.AirMobileRunTarget.Emulator : mobileRunTarget;
        }
        if (FlexCommonUtils.getOptionValues(adlOptions, "profile").isEmpty()) {
            final String profiles = getSupportedProfiles(descriptorPath);
            if (profiles == null || profiles.contains("extendedMobileDevice")) {
                commandLine.addParameter("-profile");
                commandLine.addParameter("extendedMobileDevice");
            }
        }
        final FlashRunnerParameters.Emulator emulator = params instanceof FlashRunnerParameters ? ((FlashRunnerParameters) params).getEmulator() : FlashRunnerParameters.Emulator.NexusOne;
        final boolean customSize = emulator.adlAlias == null;
        commandLine.addParameter("-screensize");
        if (customSize) {
            assert params instanceof FlashRunnerParameters;
            final FlashRunnerParameters flashParams = (FlashRunnerParameters) params;
            commandLine.addParameter(flashParams.getScreenWidth() + "x" + flashParams.getScreenHeight() + ":" + flashParams.getFullScreenWidth() + "x" + flashParams.getFullScreenHeight());
        } else {
            commandLine.addParameter(emulator.adlAlias);
        }
        if (FlexCommonUtils.getOptionValues(adlOptions, "XscreenDPI").isEmpty()) {
            if (customSize && ((FlashRunnerParameters) params).getScreenDpi() > 0) {
                commandLine.addParameter("-XscreenDPI");
                commandLine.addParameter(String.valueOf(((FlashRunnerParameters) params).getScreenDpi()));
            } else if (!customSize && emulator.screenDPI > 0) {
                commandLine.addParameter("-XscreenDPI");
                commandLine.addParameter(String.valueOf(emulator.screenDPI));
            }
        }
        if (FlexCommonUtils.getOptionValues(adlOptions, "XversionPlatform").isEmpty() && emulator.versionPlatform != null) {
            commandLine.addParameter("-XversionPlatform");
            commandLine.addParameter(emulator.versionPlatform);
        }
        if (!StringUtil.isEmptyOrSpaces(adlOptions)) {
            for (StringTokenizer tokenizer = new CommandLineTokenizer(adlOptions); tokenizer.hasMoreTokens(); ) {
                commandLine.addParameter(tokenizer.nextToken());
            }
        }
        if (!aneFiles.isEmpty()) {
            commandLine.addParameter("-extdir");
            commandLine.addParameter(FlexCompilationUtils.getPathToUnzipANE());
        }
        commandLine.addParameter(FileUtil.toSystemDependentName(descriptorPath));
        commandLine.addParameter(FileUtil.toSystemDependentName(PathUtil.getParentPath(bc.getActualOutputFilePath())));
    }
    return commandLine;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) AppDescriptorForEmulator(com.intellij.lang.javascript.flex.run.FlashRunnerParameters.AppDescriptorForEmulator) StringTokenizer(java.util.StringTokenizer) FlexUnitRunnerParameters(com.intellij.lang.javascript.flex.flexunit.FlexUnitRunnerParameters) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) AirDesktopPackagingOptions(com.intellij.lang.javascript.flex.projectStructure.model.AirDesktopPackagingOptions) Sdk(com.intellij.openapi.projectRoots.Sdk) Module(com.intellij.openapi.module.Module)

Aggregations

FlexUnitRunnerParameters (com.intellij.lang.javascript.flex.flexunit.FlexUnitRunnerParameters)1 AirDesktopPackagingOptions (com.intellij.lang.javascript.flex.projectStructure.model.AirDesktopPackagingOptions)1 AppDescriptorForEmulator (com.intellij.lang.javascript.flex.run.FlashRunnerParameters.AppDescriptorForEmulator)1 Module (com.intellij.openapi.module.Module)1 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1 Sdk (com.intellij.openapi.projectRoots.Sdk)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 StringTokenizer (java.util.StringTokenizer)1