Community
Participate
Working Groups
Created attachment 206529 [details] Plug in project + EGL Project Take this code: public static void compileFile(File toCompile, ArrayList<File> eglPathDirectories, File outputDir){ String[] compileArgs = new String[7]; int i = 0; compileArgs[i++] = SOURCE_PATH; StringBuffer eglPath = new StringBuffer(); for (File file : eglPathDirectories) { eglPath.append(file.getAbsolutePath() + ";"); } compileArgs[i++] = eglPath.toString(); compileArgs[i++] = IR_OUTPUT_PATH; outputDir.mkdirs(); compileArgs[i++] = outputDir.getAbsolutePath(); compileArgs[i++] = IS_VAG_COMPATIBLE; compileArgs[i++] = CLEAN; compileArgs[i++] = toCompile.getAbsolutePath(); EGL2IR.main(compileArgs); } It is called like this: File tocompFile = new File("C:/Users/BVC/TestIndigo/JUnitEGLSimple_EDT/EGLSource/haha/abc.egl"); ArrayList<File> eglPathDirs = new ArrayList<File>(); eglPathDirs.add(new File("C:/Users/BVC/TestIndigo/JUnitEGLSimple_EDT/EGLSource")); File outputDir = new File("C:/Temp/EGL_Bin_Small_New"); Compile.compileFile(tocompFile, eglPathDirs, outputDir); The EGLIR.main() throws a NullPointerException that I'm unable to resolve. The stackTrace for the Exception is: Processing Part: abc Bootstrap initialize... org.eclipse.edt.compiler.internal.core.builder.BuildException: java.lang.NullPointerException at org.eclipse.edt.compiler.AbstractProcessingQueue.process(AbstractProcessingQueue.java:189) at org.eclipse.edt.compiler.AbstractProcessingQueue.process(AbstractProcessingQueue.java:154) at org.eclipse.edt.compiler.tools.EGLC.compile(EGLC.java:135) at org.eclipse.edt.compiler.tools.EGL2IR.compile(EGL2IR.java:89) at org.eclipse.edt.compiler.tools.EGL2IR.main(EGL2IR.java:54) at org.eclipse.edt.compiler.tools.EGL2IR.main(EGL2IR.java:47) at edtapi.Compile.compileFile(Compile.java:43) at edtapi.actions.SampleAction.run(SampleAction.java:44) at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:251) at org.eclipse.ui.internal.WWinPluginAction.runWithEvent(WWinPluginAction.java:229) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584) at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501) at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4165) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3754) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2696) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2660) at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2494) at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:674) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:667) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577) at org.eclipse.equinox.launcher.Main.run(Main.java:1410) at org.eclipse.equinox.launcher.Main.main(Main.java:1386) Caused by: java.lang.NullPointerException at org.eclipse.edt.compiler.internal.egl2mof.Egl2MofPart.handleVisitPart(Egl2MofPart.java:414) at org.eclipse.edt.compiler.internal.egl2mof.Egl2MofPart.defaultHandleVisitPart(Egl2MofPart.java:383) at org.eclipse.edt.compiler.internal.egl2mof.Egl2MofPart.visit(Egl2MofPart.java:216) at org.eclipse.edt.compiler.core.ast.Library.accept(Library.java:49) at org.eclipse.edt.compiler.internal.egl2mof.Egl2Mof.convert(Egl2Mof.java:160) at org.eclipse.edt.compiler.Processor.createIRFromBoundAST2(Processor.java:164) at org.eclipse.edt.compiler.Processor.level03Compile(Processor.java:120) at org.eclipse.edt.compiler.AbstractProcessingQueue.process(AbstractProcessingQueue.java:171) ... 37 more I'm attaching a projectInterchange with both the plug in project, and the EGL project. (Beware of hardcoded path in SampleAction.java)
I have managed to get your code to work with a few modifications. Since you are running the EGL2IR in the IDE, you will need to specify an IDE Compiler when you invoke it. One of the responsibilities of the compiler is to locate the system parts. EGL2IR defaults to using a compiler that is configured to find the system parts when running outside the IDE (in SDK mode). However, this default compiler cannot locate the .EGLAR and .MOFAR files if it is run inside the ide. So, you will need to invoke EGL2IR like this (in Compile.java): EGL2IR.main(compileArgs, new IDEEDTCompiler()); In order for this to compile, you will need to add the following plugins to your plugin dependencies: org.eclipse.edt.ide.compiler org.eclipse.edt.ide.core Finally, the default output format for the compile ir files is binary (so you will get files with the extension ".eglbin". If you would like to get the output in xml format (extension ".eglxml"), you can add the following argument when invoking EGL2IR: "-xmlout". The added line to Compile.java would look like this: compileArgs[i++] = "-xmlOut"; Of course, if you choose to do this, you will need to increase the size if the compileArgs array from 7 to 8.
Tried the changes that were proposed and they do fix the problem.