|
|
|
|
|
|
|
Re: Building from source - Setting up the workbench [message #659254 is a reply to message #659043] |
Fri, 11 March 2011 11:58   |
Eclipse User |
|
|
|
Its not the most elegant thing at this point. But this bit of code will inspect eclipse projects, find EGLSource folders, force an EGL to EGLXML compile into a project local directory. It then builds a list of all parts in the compile folder. From there it iterates across each part and prints some interesting stuff to the screen (this is taken from one of the provided samples)
package com.clearblade.edt.egl.doc;
import java.io.File;
import java.io.PrintStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.edt.mof.egl.Part;
import org.eclipse.edt.mof.egl.compiler.EGL2IR;
import org.eclipse.edt.mof.egl.utils.IRLoader;
import org.eclipse.edt.mof.egl.utils.LoadPartException;
import org.eclipse.edt.mof.serialization.Serializer;
import org.eclipse.edt.mof.serialization.xml.XMLSerializer;
public class EGLDocManager {
private class IRLoaderInfo {
String rootDir;
String partName;
}
public EGLDocManager(List<IProject> selectedProjects) {
try {
for (Iterator<IProject> iterator = selectedProjects.iterator(); iterator.hasNext();) {
IProject iProject = (IProject) iterator.next();
if (iProject.exists()){
forceCompile(iProject);
iProject.getProject().refreshLocal(1, new NullProgressMonitor());
List<IRLoaderInfo> IRLoaderInfoList = getIRLoaderInfoForProject(iProject);
processParts(IRLoaderInfoList);
System.out.println("stop here");
//cleanup the IR xml
//deleteDir(file)
iProject.getProject().refreshLocal(1, new NullProgressMonitor());
}
}
} catch (CoreException e) {
e.printStackTrace();
}
}
private void forceCompile(IProject iProject){
IFolder eglSourceFolder = iProject.getFolder("EGLSource");
String irDest = (iProject.getLocation().append("edtIR")).toOSString();
File file = new File (irDest);
file.mkdir();
deleteDir(file);
String[] args = { "-irDestination", irDest, "-xmlOut", "-isVAGCompatible", eglSourceFolder.getLocation().toOSString() };
try {
EGL2IR.main(args);
} catch (Throwable t) {
t.printStackTrace();
}
}
private List<IRLoaderInfo> getIRLoaderInfoForProject(IProject iProject){
List<IRLoaderInfo> IRLoaderInfoList = new ArrayList<IRLoaderInfo>();
String irDest = (iProject.getLocation().append("edtIR")).toOSString();
IFolder eglIRFolder = iProject.getFolder("edtIR");
IRLoaderInfoList = getEGLFileList(eglIRFolder, irDest, "");
return IRLoaderInfoList;
}
private List<IRLoaderInfo> getEGLFileList(IFolder iFolder, String rootDir, String eglPackage) {
List<IRLoaderInfo> IRLoaderInfoList = new ArrayList<IRLoaderInfo> ();
String filePath;
IRLoaderInfo irLoaderInfo;
try {
IResource[] resources = ((IContainer) iFolder).members();
for (int i = 0; i < resources.length; i++) {
if (resources[i] instanceof IFolder){
String nextPackage = ((IFolder)resources[i]).getName();
if (eglPackage.length()>0) {
nextPackage = eglPackage+"."+((IFolder)resources[i]).getName();
}
IRLoaderInfoList.addAll(getEGLFileList((IFolder)resources[i], rootDir, nextPackage));
}
else if (resources[i] instanceof IFile && ((IFile)resources[i]).exists()){
filePath = ((IFile)resources[i]).getLocation().toOSString();
if ( filePath.endsWith(".eglxml")) {
irLoaderInfo = new IRLoaderInfo();
irLoaderInfo.partName=eglPackage+"."+((IFile)resources[i]).getName();
irLoaderInfo.partName = irLoaderInfo.partName.substring(0, irLoaderInfo.partName.length()-7);
irLoaderInfo.rootDir=rootDir;
IRLoaderInfoList.add(irLoaderInfo);
}
}
}
} catch (CoreException e) {
e.printStackTrace();
}
return IRLoaderInfoList;
}
private void deleteDir(File dir){
if(dir.isDirectory()){
for(File sub : dir.listFiles()){
deleteDir(sub);
}
dir.delete();
}else{
dir.delete();
}
}
private void processParts(List<IRLoaderInfo> irLoaderInfoList) {
for (Iterator<IRLoaderInfo> iterator = irLoaderInfoList.iterator(); iterator.hasNext();) {
IRLoaderInfo irLoaderInfo = (IRLoaderInfo) iterator.next();
Part part;
try {
part = IRLoader.loadEGLPart(irLoaderInfo.rootDir, irLoaderInfo.partName);
displayPart(part,System.out);
displaySerializedPart(part,System.out);
} catch (LoadPartException e) {
e.printStackTrace();
}
}
}
public void displayPart(Part part, PrintStream out) {
out.print(part.toString());
}
public void displaySerializedPart(Part part, PrintStream out) {
Serializer xml = new XMLSerializer();
xml.serialize(part);
out.print((String)xml.getContents());
}
}
|
|
|
|
|
|
|
|
Re: Building from source [message #668079 is a reply to message #668059] |
Tue, 03 May 2011 12:23  |
Eclipse User |
|
|
|
Hi Gilbert,
At this point EDT is mostly just about building the EGL Model for introspecting and then generating output. All of the editors and such are all part of future EDT milestone releases from IBM.
Since we don't really have an EGL development environment to work with that's the reason why I am using RBD 8011 as my base rather than a helios drop.
With regards to your questions about eglars.... i dont know... If i were you I would probably open a new thread on it so it doesnt get lost here
|
|
|
Powered by
FUDForum. Page generated in 0.05415 seconds