summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSilenio Quarti <silenio>2008-09-06 08:35:19 +0000
committerSilenio Quarti <silenio>2008-09-06 08:35:19 +0000
commit480755e4d244ebfdf52445cea4be8de0045beb97 (patch)
tree6de6ae185f5f569f91bfbb56048205290fbbd4d1
parentf2cd9269f3f78ae5bba95d647c8b976440352cd3 (diff)
downloadeclipse.platform.swt-480755e4d244ebfdf52445cea4be8de0045beb97.tar.gz
eclipse.platform.swt-480755e4d244ebfdf52445cea4be8de0045beb97.tar.xz
eclipse.platform.swt-480755e4d244ebfdf52445cea4be8de0045beb97.zip
*** empty log message ***
-rw-r--r--bundles/org.eclipse.swt.tools/plugin.properties1
-rw-r--r--bundles/org.eclipse.swt.tools/plugin.xml10
-rw-r--r--bundles/org.eclipse.swt.tools/src/org/eclipse/swt/tools/jni/builder/JNIBuilder.java76
3 files changed, 87 insertions, 0 deletions
diff --git a/bundles/org.eclipse.swt.tools/plugin.properties b/bundles/org.eclipse.swt.tools/plugin.properties
index a01e595408..8ec5b8faf5 100644
--- a/bundles/org.eclipse.swt.tools/plugin.properties
+++ b/bundles/org.eclipse.swt.tools/plugin.properties
@@ -11,3 +11,4 @@
pluginName = SWT Tools
providerName = Eclipse.org
macViewName = Mac Generator
+jniBuilderName = JNI Builder
diff --git a/bundles/org.eclipse.swt.tools/plugin.xml b/bundles/org.eclipse.swt.tools/plugin.xml
index ce152ee74d..3578893d5c 100644
--- a/bundles/org.eclipse.swt.tools/plugin.xml
+++ b/bundles/org.eclipse.swt.tools/plugin.xml
@@ -23,4 +23,14 @@
translations="$nl$/templates/jnitemplates.properties">
</include>
</extension>
+
+ <extension
+ id="jnibuilder"
+ name="%jniBuilderName"
+ point="org.eclipse.core.resources.builders">
+ <builder hasNature="false">
+ <run class="org.eclipse.swt.tools.jni.builder.JNIBuilder"/>
+ </builder>
+ </extension>
+
</plugin>
diff --git a/bundles/org.eclipse.swt.tools/src/org/eclipse/swt/tools/jni/builder/JNIBuilder.java b/bundles/org.eclipse.swt.tools/src/org/eclipse/swt/tools/jni/builder/JNIBuilder.java
new file mode 100644
index 0000000000..366519b65d
--- /dev/null
+++ b/bundles/org.eclipse.swt.tools/src/org/eclipse/swt/tools/jni/builder/JNIBuilder.java
@@ -0,0 +1,76 @@
+package org.eclipse.swt.tools.jni.builder;
+
+import java.util.Map;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.resources.IResourceDeltaVisitor;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.swt.tools.internal.JNIGeneratorApp;
+import org.eclipse.swt.tools.internal.MetaData;
+
+public class JNIBuilder extends IncrementalProjectBuilder {
+
+ MetaData metaData;
+ MainClass[] classes;
+
+ static class MainClass {
+ public String mainClassName;
+ public String outputDir;
+ public boolean build;
+
+ public String toString() {
+ return mainClassName + "->" + outputDir;
+ }
+ }
+
+ public JNIBuilder() {
+ metaData = new MetaData("org.eclipse.swt.internal");
+ String mainClasses = metaData.getMetaData("swt_main_classes", null);
+ if (mainClasses != null) {
+ String[] list = mainClasses.split(",");
+ classes = new MainClass[list.length / 2];
+ for (int i = 0; i < list.length; i += 2) {
+ MainClass clazz = classes[i/2] = new MainClass();
+ clazz.mainClassName = list[i];
+ clazz.outputDir = list[i+1].substring(2, list[i+1].length());
+ }
+ }
+ }
+
+ protected IProject[] build(int kind, Map args, final IProgressMonitor monitor) throws CoreException {
+ IResourceDelta delta = getDelta(getProject());
+ delta.accept(new IResourceDeltaVisitor() {
+ public boolean visit(IResourceDelta delta) throws CoreException {
+ String path = delta.getFullPath().toPortableString();
+ for (int i = 0; i < classes.length; i++) {
+ if (classes[i].build) continue;
+ String outputDir = classes[i].outputDir;
+ if (path.startsWith(outputDir.substring(0, outputDir.length() - "library/".length()))) {
+ classes[i].build = true;
+ }
+ }
+ return true;
+ }
+ });
+ final IWorkspaceRoot root = getProject().getWorkspace().getRoot();
+ for (int i = 0; i < classes.length; i++) {
+ MainClass mainClass = classes[i];
+ if (mainClass.build) {
+ mainClass.build = false;
+ System.out.println(mainClass.mainClassName);
+ IResource library = root.findMember(mainClass.outputDir);
+ JNIGeneratorApp gen = new JNIGeneratorApp();
+ gen.setMainClassName(mainClass.mainClassName, library.getLocation().toPortableString());
+ gen.generate();
+ library.refreshLocal(IResource.DEPTH_INFINITE, null);
+ }
+ }
+ return null;
+ }
+
+}