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;
}
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;
}
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();
}
Aggregations