summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-06-15 05:27:51 +0200
committerSven Gothel <[email protected]>2013-06-15 05:27:51 +0200
commitd01cb422c4621fbc1b5ea2bcd7d19f3ff8602715 (patch)
tree769518d62bc409191667355a924e559e9ab52770
parenta7802a2ab90a68ecbba962149a335f975fce24e7 (diff)
Fix CStruct APT File Location - Threw FileNotFoundException w/ Java7
-rwxr-xr-xmake/scripts/make.gluegen.all.linux-x86_64.java7.sh25
-rw-r--r--make/scripts/setenv-build-jogl-x86_64.java7.sh52
-rw-r--r--make/scripts/setenv-build-jogl-x86_64.sh4
-rw-r--r--src/java/com/jogamp/gluegen/structgen/CStructAnnotationProcessor.java70
4 files changed, 116 insertions, 35 deletions
diff --git a/make/scripts/make.gluegen.all.linux-x86_64.java7.sh b/make/scripts/make.gluegen.all.linux-x86_64.java7.sh
new file mode 100755
index 0000000..967a21e
--- /dev/null
+++ b/make/scripts/make.gluegen.all.linux-x86_64.java7.sh
@@ -0,0 +1,25 @@
+#! /bin/sh
+
+SDIR=`dirname $0`
+
+if [ -e $SDIR/setenv-build-jogl-x86_64.java7.sh ] ; then
+ . $SDIR/setenv-build-jogl-x86_64.java7.sh
+fi
+
+# -Dc.compiler.debug=true
+# -Dgluegen.cpptasks.detected.os=true \
+# -DisUnix=true \
+# -DisLinux=true \
+# -DisLinuxAMD64=true \
+# -DisX11=true \
+#
+# -Dtarget.sourcelevel=1.6 \
+# -Dtarget.targetlevel=1.6 \
+# -Dtarget.rt.jar=/opt-share/jre1.6.0_30/lib/rt.jar \
+
+# BUILD_ARCHIVE=true \
+ant \
+ -Dc.compiler.debug=true \
+ -Djavacdebuglevel="source,lines,vars" \
+ -Drootrel.build=build-x86_64.java7 \
+ $* 2>&1 | tee make.gluegen.all.linux-x86_64.java7.log
diff --git a/make/scripts/setenv-build-jogl-x86_64.java7.sh b/make/scripts/setenv-build-jogl-x86_64.java7.sh
new file mode 100644
index 0000000..6d293a0
--- /dev/null
+++ b/make/scripts/setenv-build-jogl-x86_64.java7.sh
@@ -0,0 +1,52 @@
+#! /bin/sh
+
+echo $0
+
+if [ -e /opt-share/apache-ant ] ; then
+ ANT_PATH=/opt-share/apache-ant
+ PATH=$ANT_PATH/bin:$PATH
+ export ANT_PATH
+fi
+if [ -z "$ANT_PATH" ] ; then
+ if [ -e /usr/share/ant/bin/ant -a -e /usr/share/ant/lib/ant.jar ] ; then
+ ANT_PATH=/usr/share/ant
+ export ANT_PATH
+ echo autosetting ANT_PATH to $ANT_PATH
+ fi
+fi
+if [ -z "$ANT_PATH" ] ; then
+ if [ -e /usr/share/ant/bin/ant -a -e /usr/share/ant/lib/ant.jar ] ; then
+ ANT_PATH=/usr/share/ant
+ export ANT_PATH
+ echo autosetting ANT_PATH to $ANT_PATH
+ fi
+fi
+if [ -z "$ANT_PATH" ] ; then
+ echo ANT_PATH does not exist, set it
+ exit
+fi
+
+if [ -e /opt-linux-x86_64/jre7 -a -e /opt-linux-x86_64/j2se7 ] ; then
+ J2RE_HOME=/opt-linux-x86_64/jre7
+ JAVA_HOME=/opt-linux-x86_64/j2se7
+ PATH=$J2RE_HOME/bin:$JAVA_HOME/bin:$PATH
+ export J2RE_HOME JAVA_HOME
+elif [ -e /usr/java/jre/bin/amd64 -a -e /usr/java/bin/amd64 ] ; then
+ # make a symbolic link: /usr/java/bin/amd64/bin$ ln -s . bin
+ # since ant looks for $JAVA_HOME/bin/java and we need to force the 64bit JVM
+ J2RE_HOME=/usr/java/jre/bin/amd64
+ JAVA_HOME=/usr/java/bin/amd64
+ PATH=$J2RE_HOME:$JAVA_HOME:$PATH
+ export J2RE_HOME JAVA_HOME
+elif [ -e /opt-solaris-x86_64/jre6 -a -e /opt-solaris-x86_64/j2se6 ] ; then
+ # make a symbolic link: /opt-solaris-x86_64/jre6/bin/amd64/bin$ ln -s . bin
+ # since ant looks for $JAVA_HOME/bin/java and we need to force the 64bit JVM
+ J2RE_HOME=/opt-solaris-x86_64/jre6/bin/amd64
+ JAVA_HOME=/opt-solaris-x86_64/j2se6/bin/amd64
+ PATH=$J2RE_HOME:$JAVA_HOME:$PATH
+ export J2RE_HOME JAVA_HOME
+fi
+
+export PATH
+
+
diff --git a/make/scripts/setenv-build-jogl-x86_64.sh b/make/scripts/setenv-build-jogl-x86_64.sh
index 9c7d674..6b2a66e 100644
--- a/make/scripts/setenv-build-jogl-x86_64.sh
+++ b/make/scripts/setenv-build-jogl-x86_64.sh
@@ -31,9 +31,7 @@ if [ -e /opt-linux-x86_64/jre6 -a -e /opt-linux-x86_64/j2se6 ] ; then
JAVA_HOME=/opt-linux-x86_64/j2se6
PATH=$J2RE_HOME/bin:$JAVA_HOME/bin:$PATH
export J2RE_HOME JAVA_HOME
-fi
-
-if [ -e /usr/java/jre/bin/amd64 -a -e /usr/java/bin/amd64 ] ; then
+elif [ -e /usr/java/jre/bin/amd64 -a -e /usr/java/bin/amd64 ] ; then
# make a symbolic link: /usr/java/bin/amd64/bin$ ln -s . bin
# since ant looks for $JAVA_HOME/bin/java and we need to force the 64bit JVM
J2RE_HOME=/usr/java/jre/bin/amd64
diff --git a/src/java/com/jogamp/gluegen/structgen/CStructAnnotationProcessor.java b/src/java/com/jogamp/gluegen/structgen/CStructAnnotationProcessor.java
index fef8545..fc60265 100644
--- a/src/java/com/jogamp/gluegen/structgen/CStructAnnotationProcessor.java
+++ b/src/java/com/jogamp/gluegen/structgen/CStructAnnotationProcessor.java
@@ -53,8 +53,6 @@ import javax.tools.StandardLocation;
import jogamp.common.Debug;
-import static java.io.File.*;
-
/**
* <p>
* If the <i>header file</i> is absolute, the <i>root path</i> is the parent folder of the folder containing the package source, i.e.:
@@ -108,57 +106,65 @@ public class CStructAnnotationProcessor extends AbstractProcessor {
outputPath = outputPath == null ? STRUCTGENOUTPUT : outputPath;
}
+ private File locateSource(String packageName, String relativeName) {
+ try {
+ if( DEBUG ) {
+ System.err.println("CStruct.locateSource.0: p "+packageName+", r "+relativeName);
+ }
+ final FileObject h = filer.getResource(StandardLocation.SOURCE_PATH, packageName, relativeName);
+ if( DEBUG ) {
+ System.err.println("CStruct.locateSource.1: h "+h.toUri());
+ }
+ final File f = new File( h.toUri().getPath() ); // URI is incomplete (no scheme), hence use path only!
+ if( f.exists() ) {
+ return f;
+ }
+ } catch (IOException e) { if(DEBUG) { System.err.println("Catched "+e.getClass().getSimpleName()+": "+e.getMessage()); /* e.printStackTrace(); */ } }
+ return null;
+ }
+
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment env) {
+ final String user_dir = System.getProperty("user.dir");
- Set<? extends Element> elements = env.getElementsAnnotatedWith(CStruct.class);
+ final Set<? extends Element> elements = env.getElementsAnnotatedWith(CStruct.class);
for (Element element : elements) {
final String packageName = eltUtils.getPackageOf(element).toString();
- final String user_dir = System.getProperty("user.dir");
try {
final CStruct struct = element.getAnnotation(CStruct.class);
final String headerRelPath = struct.header();
- final FileObject header;
- final File headerFileRel;
+ final Element enclElement = element.getEnclosingElement();
+
+ System.err.println("CStruct: "+struct+", package "+packageName+", header "+headerRelPath);
+ if(DEBUG) {
+ System.err.println("CStruct.0: user.dir: "+user_dir);
+ System.err.println("CStruct.0: element: "+element+", .simpleName "+element.getSimpleName());
+ System.err.println("CStruct.0: enclElement: "+enclElement+", .simpleName "+enclElement.getSimpleName()+", .package "+eltUtils.getPackageOf(enclElement).toString());
+ }
+
+ final File headerFile;
{
- FileObject h = filer.getResource(StandardLocation.SOURCE_PATH, packageName, headerRelPath);
- File f = new File( h.toUri().getPath() ); // URI is incomplete (no scheme), hence use path only!
- if( !f.exists() ) {
- h = filer.getResource(StandardLocation.SOURCE_PATH, "", headerRelPath);
- f = new File( h.toUri().getPath() ); // URI is incomplete (no scheme), hence use path only!
- if( !f.exists() ) {
+ File f = locateSource(packageName, headerRelPath);
+ if( null == f ) {
+ f = locateSource("", headerRelPath);
+ if( null == f ) {
// bail out
throw new RuntimeException("Could not locate header "+headerRelPath+", package "+packageName);
}
}
- header = h;
- headerFileRel = f;
+ headerFile = f;
}
- final boolean headerFileRelIsAbsolute = headerFileRel.isAbsolute();
-
final String root;
- final File headerFile;
- if( headerFileRelIsAbsolute ) {
- headerFile = headerFileRel;
-
+ {
String root0 = headerFile.getAbsolutePath();
root0 = root0.substring(0, root0.length()-headerFile.getName().length()-1);
root = root0.substring(0, root0.length()-packageName.length()) +"..";
- } else {
- root = user_dir;
- headerFile = new File(root + separator + header.toUri());
- }
- System.err.println("CStruct: "+struct);
- System.err.println("CStruct: package "+packageName+", header "+headerRelPath+": "+headerFile);
- if(DEBUG) {
- System.err.println("CStruct: header "+headerFileRel+", abs-path: "+headerFileRelIsAbsolute);
- System.err.println("CStruct: Root: "+root);
- System.err.println("CStruct: user.dir: "+user_dir);
}
+ System.err.println("CStruct: "+headerFile+", abs: "+headerFile.isAbsolute()+", root "+root);
generateStructBinding(element, struct, root, packageName, headerFile);
} catch (IOException ex) {
@@ -185,8 +191,8 @@ public class CStructAnnotationProcessor extends AbstractProcessor {
final File outputDirFile = new File(outputPath);
outputDirAbs = outputDirFile.isAbsolute();
}
- final String outputPath1 = outputDirAbs ? outputPath : root + separator + outputPath;
- final String config = outputPath1 + separator + header.getName() + ".cfg";
+ final String outputPath1 = outputDirAbs ? outputPath : root + File.separator + outputPath;
+ final String config = outputPath1 + File.separator + header.getName() + ".cfg";
final File configFile = new File(config);
if(DEBUG) {
System.err.println("CStruct: OutputDir: "+outputPath+", is-abs "+outputDirAbs);