Search in sources :

Example 6 with FlexUnitRunnerParameters

use of com.intellij.lang.javascript.flex.flexunit.FlexUnitRunnerParameters in project intellij-plugins by JetBrains.

the class FlexBaseRunner method doExecute.

@Override
@Nullable
protected RunContentDescriptor doExecute(@NotNull final RunProfileState state, @NotNull final ExecutionEnvironment env) throws ExecutionException {
    FileDocumentManager.getInstance().saveAllDocuments();
    final RunProfile runProfile = env.getRunProfile();
    final boolean isDebug = this instanceof FlexDebugRunner;
    try {
        if (runProfile instanceof RunProfileWithCompileBeforeLaunchOption) {
            checkMakeBeforeRunEnabled(env.getProject(), runProfile);
        }
        if (runProfile instanceof RemoteFlashRunConfiguration) {
            final RemoteFlashRunnerParameters params = ((RemoteFlashRunConfiguration) runProfile).getRunnerParameters();
            final Pair<Module, FlexBuildConfiguration> moduleAndBC = params.checkAndGetModuleAndBC(env.getProject());
            if (params.getDebugTransport() == FlashRunnerParameters.AirMobileDebugTransport.USB) {
                final Sdk sdk = moduleAndBC.second.getSdk();
                assert sdk != null;
                if (params.getRemoteDebugTarget() == RemoteDebugTarget.AndroidDevice) {
                    if (!AirPackageUtil.startAdbServer(env.getProject(), sdk) || !AirPackageUtil.scanAndroidDevices(env.getProject(), sdk, params) || !AirPackageUtil.androidForwardTcpPort(env.getProject(), sdk, params.getDeviceInfo(), params.getUsbDebugPort())) {
                        return null;
                    }
                } else if (params.getRemoteDebugTarget() == RemoteDebugTarget.iOSDevice) {
                    final String adtVersion = AirPackageUtil.getAdtVersion(env.getProject(), sdk);
                    if (!AirPackageUtil.checkAdtVersionForPackaging(env.getProject(), adtVersion, "3.4", sdk.getName(), FlexBundle.message("air.ios.debug.via.usb.requires.3.4"))) {
                        return null;
                    }
                    if (!AirPackageUtil.scanIosDevices(env.getProject(), sdk, params)) {
                        return null;
                    }
                    final DeviceInfo device = params.getDeviceInfo();
                    final int deviceHandle = device == null ? -1 : device.IOS_HANDLE;
                    if (deviceHandle < 0) {
                        return null;
                    }
                    if (!AirPackageUtil.iosForwardTcpPort(env.getProject(), sdk, params.getUsbDebugPort(), deviceHandle)) {
                        return null;
                    }
                }
            }
            return launchDebugProcess(moduleAndBC.first, moduleAndBC.second, params, env);
        }
        if (runProfile instanceof FlexUnitRunConfiguration) {
            final FlexUnitRunnerParameters params = ((FlexUnitRunConfiguration) runProfile).getRunnerParameters();
            final Pair<Module, FlexBuildConfiguration> moduleAndConfig = params.checkAndGetModuleAndBC(env.getProject());
            final Module module = moduleAndConfig.first;
            final FlexBuildConfiguration bc = moduleAndConfig.second;
            if (bc.getTargetPlatform() == TargetPlatform.Web) {
                FlashPlayerTrustUtil.updateTrustedStatus(module, bc, isDebug, params.isTrusted());
                return launchWebFlexUnit(env.getProject(), env.getContentToReuse(), env, params, bc.getActualOutputFilePath());
            } else {
                return launchAirFlexUnit(env.getProject(), state, env.getContentToReuse(), env, params);
            }
        }
        if (runProfile instanceof FlashRunConfiguration) {
            final FlashRunnerParameters params = ((FlashRunConfiguration) runProfile).getRunnerParameters();
            params.setDeviceInfo(null);
            final Pair<Module, FlexBuildConfiguration> moduleAndConfig = params.checkAndGetModuleAndBC(env.getProject());
            final Module module = moduleAndConfig.first;
            final FlexBuildConfiguration bc = moduleAndConfig.second;
            if (bc.isSkipCompile()) {
                showBCCompilationSkippedWarning(module, bc);
            }
            if (isDebug && SystemInfo.isMac && bc.getTargetPlatform() == TargetPlatform.Web) {
                checkDebuggerFromSdk4(env.getProject(), runProfile, params, bc);
            }
            if (bc.getTargetPlatform() == TargetPlatform.Web && !params.isLaunchUrl()) {
                FlashPlayerTrustUtil.updateTrustedStatus(module, bc, isDebug, params.isRunTrusted());
            }
            return launchFlexConfig(module, bc, params, state, env.getContentToReuse(), env);
        }
    } catch (RuntimeConfigurationError e) {
        throw new ExecutionException(e.getMessage());
    }
    return null;
}
Also used : FlexDebugRunner(com.intellij.lang.javascript.flex.debug.FlexDebugRunner) FlexUnitRunConfiguration(com.intellij.lang.javascript.flex.flexunit.FlexUnitRunConfiguration) FlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration) FlexUnitRunnerParameters(com.intellij.lang.javascript.flex.flexunit.FlexUnitRunnerParameters) DeviceInfo(com.intellij.lang.javascript.flex.actions.airpackage.DeviceInfo) Sdk(com.intellij.openapi.projectRoots.Sdk) Module(com.intellij.openapi.module.Module) Nullable(org.jetbrains.annotations.Nullable)

Example 7 with FlexUnitRunnerParameters

use of com.intellij.lang.javascript.flex.flexunit.FlexUnitRunnerParameters 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)

Example 8 with FlexUnitRunnerParameters

use of com.intellij.lang.javascript.flex.flexunit.FlexUnitRunnerParameters in project intellij-plugins by JetBrains.

the class FlexBaseRunner method launchDebugProcess.

protected RunContentDescriptor launchDebugProcess(final Module module, final FlexBuildConfiguration bc, final BCBasedRunnerParameters params, final ExecutionEnvironment env) throws ExecutionException {
    final XDebugSession debugSession = XDebuggerManager.getInstance(module.getProject()).startSession(env, new XDebugProcessStarter() {

        @Override
        @NotNull
        public XDebugProcess start(@NotNull final XDebugSession session) throws ExecutionException {
            try {
                if (params instanceof FlexUnitRunnerParameters) {
                    return new FlexDebugProcess(session, bc, params) {

                        @NotNull
                        @Override
                        public ExecutionConsole createConsole() {
                            try {
                                return createFlexUnitRunnerConsole(session.getProject(), env, getProcessHandler());
                            } catch (ExecutionException e) {
                                Logger.getInstance(FlexBaseRunner.class.getName()).error(e);
                            }
                            return super.createConsole();
                        }
                    };
                }
                return new FlexDebugProcess(session, bc, params);
            } catch (IOException e) {
                iosStopForwardTcpPortIfNeeded(bc, params);
                throw new ExecutionException(e.getMessage(), e);
            }
        }
    });
    debugSession.addSessionListener(new XDebugSessionListener() {

        @Override
        public void sessionStopped() {
            iosStopForwardTcpPortIfNeeded(bc, params);
        }
    });
    return debugSession.getRunContentDescriptor();
}
Also used : FlexUnitRunnerParameters(com.intellij.lang.javascript.flex.flexunit.FlexUnitRunnerParameters) FlexDebugProcess(com.intellij.lang.javascript.flex.debug.FlexDebugProcess) ExecutionConsole(com.intellij.execution.ui.ExecutionConsole) IOException(java.io.IOException) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

FlexUnitRunnerParameters (com.intellij.lang.javascript.flex.flexunit.FlexUnitRunnerParameters)8 FlexUnitRunConfiguration (com.intellij.lang.javascript.flex.flexunit.FlexUnitRunConfiguration)6 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)3 Sdk (com.intellij.openapi.projectRoots.Sdk)3 ExecutionConsole (com.intellij.execution.ui.ExecutionConsole)2 Module (com.intellij.openapi.module.Module)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 IOException (java.io.IOException)2 Map (java.util.Map)2 NotNull (org.jetbrains.annotations.NotNull)2 Nullable (org.jetbrains.annotations.Nullable)2 CodeInsightTestCase (com.intellij.codeInsight.CodeInsightTestCase)1 Executor (com.intellij.execution.Executor)1 RunManager (com.intellij.execution.RunManager)1 ConfigurationFromContext (com.intellij.execution.actions.ConfigurationFromContext)1 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)1 DefaultDebugExecutor (com.intellij.execution.executors.DefaultDebugExecutor)1 DefaultRunExecutor (com.intellij.execution.executors.DefaultRunExecutor)1 HyperlinkInfo (com.intellij.execution.filters.HyperlinkInfo)1 ProcessEvent (com.intellij.execution.process.ProcessEvent)1