use of com.intellij.execution.configurations.GeneralCommandLine in project clion-embedded-arm by elmot.
the class OpenOcdComponent method startOpenOcd.
@SuppressWarnings("WeakerAccess")
public Future<STATUS> startOpenOcd(Project project, @Nullable File fileToLoad, @Nullable String additionalCommand) throws ConfigurationException {
if (project == null)
return new FutureResult<>(STATUS.FLASH_ERROR);
GeneralCommandLine commandLine = createOcdCommandLine(project, fileToLoad, additionalCommand, false);
if (process != null && !process.isProcessTerminated()) {
LOG.info("openOcd is already run");
return new FutureResult<>(STATUS.FLASH_ERROR);
}
try {
process = new OSProcessHandler(commandLine) {
@Override
public boolean isSilentlyDestroyOnClose() {
return true;
}
};
DownloadFollower downloadFollower = new DownloadFollower();
process.addProcessListener(downloadFollower);
RunContentExecutor openOCDConsole = new RunContentExecutor(project, process).withTitle("OpenOCD console").withActivateToolWindow(true).withFilter(new ErrorFilter(project)).withStop(process::destroyProcess, () -> !process.isProcessTerminated() && !process.isProcessTerminating());
openOCDConsole.run();
return downloadFollower;
} catch (ExecutionException e) {
ExecutionErrorDialog.show(e, "OpenOCD start failed", project);
return new FutureResult<>(STATUS.FLASH_ERROR);
}
}
use of com.intellij.execution.configurations.GeneralCommandLine in project moe-ide-integration by multi-os-engine.
the class MOERunProfileState method createProcessHandler.
@NotNull
private OSProcessHandler createProcessHandler() throws ExecutionException {
if (runConfiguration.configuration() == null) {
throw new ExecutionException("Invalid build configuration for " + runConfiguration.getClass().getName());
} else if (runConfiguration.architecture() == null) {
throw new ExecutionException("Invalid architecture for " + runConfiguration.getClass().getName());
}
final MOEGradleRunner gradleRunner = new MOEGradleRunner(runConfiguration);
final boolean isDebug = runConfiguration.getActionType().equals("Debug");
final GeneralCommandLine commandLine = gradleRunner.construct(isDebug, true);
final OSProcessHandler handler = new MOEOSProcessHandler(commandLine);
handler.setShouldDestroyProcessRecursively(true);
final MOETestResultParser parser = new MOETestResultParser(new MOETestListener(this));
final boolean isTest = runConfiguration.runJUnitTests();
handler.addProcessListener(new ProcessListener() {
@Override
public void startNotified(ProcessEvent event) {
}
@Override
public void processTerminated(ProcessEvent event) {
}
@Override
public void processWillTerminate(ProcessEvent event, boolean willBeDestroyed) {
}
@Override
public void onTextAvailable(ProcessEvent event, Key outputType) {
String text = event.getText();
if (isTest) {
parser.addOutput(text);
}
if (text.contains("ApplicationVerificationFailed")) {
MOEToolWindow.getInstance(project).balloon(MessageType.ERROR, "Application installation failed. Please check log for details...");
MOEToolWindow.getInstance(project).log("Application installation failed. Please make sure you have correct bundle id in your Info.plist file.");
}
}
});
return handler;
}
use of com.intellij.execution.configurations.GeneralCommandLine in project moe-ide-integration by multi-os-engine.
the class MOEGradleRunner method buildProject.
private void buildProject(MOEGradleInvocationResult result) {
final Stopwatch stopwatch = Stopwatch.createUnstarted();
stopwatch.start();
String errorMessage = null;
try {
LOG.debug("Start build process");
final org.moe.idea.compiler.MOEGradleRunner gradleRunner = new org.moe.idea.compiler.MOEGradleRunner(runConfig);
final boolean isDebug = runConfig.getActionType().equals("Debug");
boolean isMaven = ModuleUtils.isMOEMavenModule(runConfig.module());
final MOEToolWindow toolWindow = MOEToolWindow.getInstance(runConfig.getProject());
if (!isMaven) {
final GeneralCommandLine commandLine = gradleRunner.construct(isDebug, false);
final OSProcessHandler handler = new OSProcessHandler(commandLine);
handler.setShouldDestroyProcessRecursively(true);
handler.addProcessListener(new ProcessAdapter() {
@Override
public void onTextAvailable(ProcessEvent event, Key outputType) {
if (ProcessOutputTypes.STDERR.equals(outputType)) {
toolWindow.error(event.getText());
} else if (ProcessOutputTypes.STDOUT.equals(outputType)) {
toolWindow.log(event.getText());
}
}
});
handler.startNotify();
// Start and wait
handler.waitFor();
int returnCode = handler.getProcess().exitValue();
// Show on failure
if (returnCode != 0) {
toolWindow.balloon(MessageType.ERROR, "BUILD FAILED");
errorMessage = "Multi-OS Engine module build failed";
}
} else {
MOEMavenBuildTask mavenTask = new MOEMavenBuildTask(runConfig, "Building " + runConfig.moduleName(), true);
boolean res = mavenTask.runTask();
if (!res) {
toolWindow.balloon(MessageType.ERROR, "BUILD FAILED");
errorMessage = "Multi-OS Engine module build failed";
}
}
if (errorMessage == null) {
result.setBuildSuccessful(true);
} else {
result.setBuildSuccessful(false);
result.setErrorMessage(errorMessage);
}
} catch (Exception e) {
result.setBuildSuccessful(false);
result.setErrorMessage(String.format("Error while building %s .%n", e.getMessage()));
} finally {
stopwatch.stop();
}
}
use of com.intellij.execution.configurations.GeneralCommandLine in project moe-ide-integration by multi-os-engine.
the class MOEGenerateActionsAndOutletsAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
final DataContext dataContext = e.getDataContext();
final Module module = (Module) dataContext.getData(LangDataKeys.MODULE.getName());
if (module == null) {
Messages.showErrorDialog("Failed to locate module", "Actions and Outlets Generation Error");
return;
}
boolean isMaven = ModuleUtils.isMOEMavenModule(module);
if (!isMaven) {
ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
@Override
public void run() {
ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
if (progress == null) {
progress = new EmptyProgressIndicator();
}
progress.pushState();
try {
progress.setText(ACTION_PROGRESS_LABEL);
runInternal();
} catch (final Throwable t) {
t.printStackTrace(System.err);
UIUtil.invokeLaterIfNeeded(new Runnable() {
@Override
public void run() {
String message = t.getMessage();
if (message == null || message.length() == 0) {
message = "Unknown error";
}
Messages.showErrorDialog(message, "Actions and Outlets Generation Error");
final MOEToolWindow toolWindow = MOEToolWindow.getInstance(module.getProject());
toolWindow.show();
}
});
} finally {
progress.popState();
}
}
private void runInternal() throws IOException, ExecutionException {
final GeneralCommandLine commandLine = MOEGradleRunner.construct(module, "moeGenerateUIObjCInterfaces");
final OSProcessHandler handler = new OSProcessHandler(commandLine);
handler.setShouldDestroyProcessRecursively(true);
// Configure output
final MOEToolWindow toolWindow = MOEToolWindow.getInstance(module.getProject());
toolWindow.clear();
handler.addProcessListener(new ProcessAdapter() {
@Override
public void onTextAvailable(ProcessEvent event, Key outputType) {
if (ProcessOutputTypes.STDERR.equals(outputType)) {
toolWindow.error(event.getText());
} else if (ProcessOutputTypes.STDOUT.equals(outputType)) {
toolWindow.log(event.getText());
}
}
});
handler.startNotify();
// Start and wait
handler.waitFor();
final int exitValue = handler.getProcess().exitValue();
if (exitValue != 0) {
throw new IOException(ACTION_TITLE + " finished with non-zero exit value (" + exitValue + ")");
}
}
}, ACTION_TITLE, true, module.getProject());
} else {
CompilerTask compilerTask = new CompilerTask(module.getProject(), "", false, true, true, true);
compilerTask.start(new Runnable() {
@Override
public void run() {
MOEMavenTask task = new MOEMavenTask(module, ACTION_TITLE, false);
task.setGoal("moe:generateUIObjCInterfaces");
if (!task.runTask()) {
ModuleUtils.runInDispatchedThread(new Runnable() {
@Override
public void run() {
Messages.showErrorDialog("Unable run generation", "Actions and Outlets Generation Error");
}
});
}
}
}, null);
ModuleUtils.runInDispatchedThread(new Runnable() {
@Override
public void run() {
MOEMavenTask task = new MOEMavenTask(module, ACTION_TITLE, false);
task.setGoal("moe:generateUIObjCInterfaces");
if (!task.runTask()) {
Messages.showErrorDialog("Unable run generation", "Actions and Outlets Generation Error");
}
}
});
}
}
use of com.intellij.execution.configurations.GeneralCommandLine in project moe-ide-integration by multi-os-engine.
the class MOEGradleRunner method construct.
public static GeneralCommandLine construct(Module module, String... args) {
final List<String> cmdargs = new ArrayList<String>();
// Get Gradle
File workingDir = new File(ModuleUtils.getModulePath(module));
GradleExec exec = new GradleExec(workingDir);
cmdargs.add(exec.getExecPath());
for (String arg : args) {
cmdargs.add(arg);
}
return new GeneralCommandLine(cmdargs).withWorkDirectory(workingDir);
}
Aggregations