public ProcessHandler createProcess(SNode file) throws ExecutionException { if ((myGccLocation_String == null || myGccLocation_String.length() == 0) || !(new File(myGccLocation_String).exists())) { throw new ExecutionException("Could not find gcc by path " + myGccLocation_String); } IFile sourceFile = Gcc_Command.getSourceFile(file); if (!((sourceFile.exists()))) { throw new ExecutionException( "Source file " + sourceFile + " does not exist. Can't compile it."); } final IFile executableFile = Gcc_Command.getExecutableFile(file); ThreadUtils.runInUIThreadAndWait( new Runnable() { public void run() { ModelAccess.instance() .requireWrite( new Runnable() { public void run() { executableFile.getParent().mkdirs(); } }); } }); // -xc -- specifies source language (c) // -g -- save debug information return new Exec_Command() .setWorkingDirectory_File(new File(sourceFile.getParent().getAbsolutePath())) .setProgramParameters_String( "-xc" + " " + "-g" + " " + Gcc_Command.protect(sourceFile.getAbsolutePath()) + " " + "-o " + Gcc_Command.protect(executableFile.getAbsolutePath())) .createProcess(new File(myGccLocation_String)); }
public static IFile getSourceFile(final SNode file) { final Wrappers._T<IModule> module = new Wrappers._T<IModule>(); final Wrappers._T<String> sourceName = new Wrappers._T<String>(); final Wrappers._T<String> packageName = new Wrappers._T<String>(); ModelAccess.instance() .runReadAction( new Runnable() { public void run() { module.value = SNodeOperations.getModel(file).getModelDescriptor().getModule(); sourceName.value = TraceInfoUtil.getUnitName(file); packageName.value = SNodeOperations.getModel(file).getLongName().replace(".", "/"); } }); return FileSystem.getInstance() .getFileByPath(module.value.getGeneratorOutputPath()) .getDescendant(packageName.value) .getDescendant(sourceName.value + Gcc_Command.getSourceExtension()); }
public static IFile getExecutableFile(final SNode file) { final Wrappers._T<IModule> module = new Wrappers._T<IModule>(); final Wrappers._T<String> sourceName = new Wrappers._T<String>(); final Wrappers._T<String> packageName = new Wrappers._T<String>(); ModelAccess.instance() .runReadAction( new Runnable() { public void run() { module.value = SNodeOperations.getModel(file).getModelDescriptor().getModule(); sourceName.value = TraceDown.anyUnitName(file); packageName.value = SNodeOperations.getModel(file).getLongName().replace(".", "/"); } }); return module .value .getClassesGen() .getDescendant(packageName.value) .getDescendant(sourceName.value + Gcc_Command.getOutputExtension()); }