if (module == null) {
throw new ExecutionException(HaxeBundle.message("no.module.for.run.configuration", configuration.getName()));
}
final HaxeModuleSettings settings = HaxeModuleSettings.getInstance(module);
if (settings.isUseNmmlToBuild()) {
final NMERunningState nmeRunningState = new NMERunningState(env, module, false);
return super.doExecute(project, nmeRunningState, contentToReuse, env);
}
if (settings.isUseOpenFLToBuild()) {
final OpenFLRunningState openflRunningState = new OpenFLRunningState(env, module, true);
return super.doExecute(project, openflRunningState, contentToReuse, env);
}
if (configuration.isCustomFileToLaunch() && FileUtilRt.extensionEquals(configuration.getCustomFileToLaunchPath(), "n")) {
final NekoRunningState nekoRunningState = new NekoRunningState(env, module, configuration.getCustomFileToLaunchPath());
return super.doExecute(project, nekoRunningState, contentToReuse, env);
}
if (configuration.isCustomExecutable()) {
final String filePath = configuration.isCustomFileToLaunch()
? configuration.getCustomFileToLaunchPath()
: getOutputFilePath(module, settings);
return super.doExecute(project, new CommandLineState(env) {
@NotNull
@Override
protected ProcessHandler startProcess() throws ExecutionException {
final GeneralCommandLine commandLine = new GeneralCommandLine();
commandLine.setWorkDirectory(PathUtil.getParentPath(module.getModuleFilePath()));
commandLine.setExePath(configuration.getCustomExecutablePath());
commandLine.addParameter(filePath);
final TextConsoleBuilder consoleBuilder = TextConsoleBuilderFactory.getInstance().createBuilder(module.getProject());
setConsoleBuilder(consoleBuilder);
return new OSProcessHandler(commandLine.createProcess(), commandLine.getCommandLineString());
}
}, contentToReuse, env);
}
if (configuration.isCustomFileToLaunch()) {
BrowserUtil.open(configuration.getCustomFileToLaunchPath());
return null;
}
if (settings.getHaxeTarget() == HaxeTarget.FLASH) {
BrowserUtil.open(getOutputFilePath(module, settings));
return null;
}
if (settings.getHaxeTarget() != HaxeTarget.NEKO) {
throw new ExecutionException(HaxeBundle.message("haxe.run.wrong.target", settings.getHaxeTarget()));
}
final NekoRunningState nekoRunningState = new NekoRunningState(env, module, null);
return super.doExecute(project, nekoRunningState, contentToReuse, env);
}