diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | build.xml | 28 | ||||
-rw-r--r-- | etc/src/com/mbien/ant/FunctionParamUncommenter.java (renamed from etc/FunctionParamUncommenter.java) | 51 | ||||
-rw-r--r-- | resources/includes/CL_orig/cl.h (renamed from resources/includes/CL/cl.h) | 0 | ||||
-rw-r--r-- | resources/includes/CL_orig/cl_gl.h (renamed from resources/includes/CL/cl_gl.h) | 0 | ||||
-rw-r--r-- | resources/includes/CL_orig/cl_platform.h (renamed from resources/includes/CL/cl_platform.h) | 0 |
6 files changed, 61 insertions, 19 deletions
@@ -1,5 +1,6 @@ build dist gensrc +resources/includes/CL **~ nbproject/private @@ -15,11 +15,13 @@ <property name="gluegen.root" value="${basedir}/../gluegen" /> <property name="jogl.root" value="${basedir}/../jogl" /> + + <property name="etc.build.dir" value="${basedir}/etc/build" /> <!-- Pull in GlueGen cpptasks build file --> <import file="${gluegen.root}/make/gluegen-cpptasks.xml" /> - <target name="-pre-compile"> + <target name="-pre-compile" depends="prepare-build"> <path id="gluegen.classpath"> <pathelement location="${gluegen.root}/build/gluegen.jar" /> @@ -65,6 +67,29 @@ </target> + <target name="prepare-build"> + + <!--compile build utilities--> + <mkdir dir="${etc.build.dir}"/> + + <javac destdir="${etc.build.dir}" classpath="${ant.core.lib}" source="1.5" debug="true" debuglevel="lines,vars,source"> + <src path="${basedir}/etc/src"/> + </javac> + + <taskdef name="uncomment-function-params" classname="com.mbien.ant.FunctionParamUncommenter" classpath="${etc.build.dir}"/> + + <property name="headers.orig" value="${basedir}/resources/includes/CL_orig" /> + <property name="headers.dest" value="${basedir}/resources/includes/CL" /> + + <!--uncomment function names in c headers and copy modified files into include path--> + <uncomment-function-params src="${headers.orig}/cl.h" dest="${headers.dest}/cl.h"/> + <uncomment-function-params src="${headers.orig}/cl_gl.h" dest="${headers.dest}/cl_gl.h"/> + + <!--nothing to uncomment in cl_platform.h--> + <copyfile src="${headers.orig}/cl_platform.h" dest="${headers.dest}/cl_platform.h" forceoverwrite="true"/> + + </target> + <target name="-post-compile" depends="c.configure.all"> <property name="obj.dir" value="${build.dir}/obj"/> @@ -174,6 +199,7 @@ <target name="-post-clean"> <delete dir="gensrc"/> + <delete dir="${etc.build.dir}"/> </target> <!-- diff --git a/etc/FunctionParamUncommenter.java b/etc/src/com/mbien/ant/FunctionParamUncommenter.java index 9296895e..df69471e 100644 --- a/etc/FunctionParamUncommenter.java +++ b/etc/src/com/mbien/ant/FunctionParamUncommenter.java @@ -1,3 +1,4 @@ +package com.mbien.ant; import java.io.BufferedWriter; import java.io.File; @@ -7,6 +8,8 @@ import java.io.FileWriter; import java.io.IOException; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.Task; import static java.util.regex.Pattern.*; /** @@ -20,7 +23,7 @@ import static java.util.regex.Pattern.*; * * @author Michael Bien */ -public class FunctionParamUncommenter { +public class FunctionParamUncommenter extends Task { final static Pattern PARAMS_PATTERN = compile("cl\\w+ \\( ( \\s* [^;]+ ) \\)", MULTILINE|COMMENTS); @@ -28,20 +31,26 @@ public class FunctionParamUncommenter { final static Pattern COMMENT_PATTERN = compile("\\s*(const)?\\w+\\s* \\**\\s+ (/\\*) \\s+[^\\*\\[]+ (\\*/)", MULTILINE|COMMENTS); //^ array size in param name causes some problems - - //TODO integrate in build... - public static void main(String[] args) throws FileNotFoundException, IOException { - String path = "/home/mbien/NetBeansProjects/JOGL/jocl/resources/includes/CL/"; - uncomment(path + "cl.h", false); - uncomment(path + "cl_gl.h", false); + private String src; + private String dest; + + @Override + public void execute() throws BuildException { + try { + uncomment(src, dest, true); + } catch (FileNotFoundException ex) { + throw new BuildException(ex); + } catch (IOException ex) { + throw new BuildException(ex); + } } - private static void uncomment(String file, boolean replace) throws FileNotFoundException, IOException { + private final void uncomment(String srcFile, String destFile, boolean replace) throws FileNotFoundException, IOException { - System.out.println("- - - begin uncomment - - -"); + System.out.println("uncommenting params in "+srcFile); - StringBuilder src = readSourceFile(new File(file)); - Matcher matcher = PARAMS_PATTERN.matcher(src); + StringBuilder headerSrc = readSourceFile(new File(srcFile)); + Matcher matcher = PARAMS_PATTERN.matcher(headerSrc); // iterate through funcions while (matcher.find()) { @@ -60,23 +69,21 @@ public class FunctionParamUncommenter { } //replace old params with uncommented params - src.replace(matcher.start(1), matcher.end(1), params.toString()); + headerSrc.replace(matcher.start(1), matcher.end(1), params.toString()); } if(replace) { //replace old file - BufferedWriter out = new BufferedWriter(new FileWriter(file)); - out.write(src.toString()); + BufferedWriter out = new BufferedWriter(new FileWriter(destFile)); + out.write(headerSrc.toString()); out.close(); }else{ - System.out.println(src); + System.out.println(headerSrc); } - - System.out.println("- - - done - - -"); } - private static StringBuilder readSourceFile(File file) throws FileNotFoundException, IOException { + private final StringBuilder readSourceFile(File file) throws FileNotFoundException, IOException { char[] buffer = new char[(int)file.length()]; FileReader reader = new FileReader(file); @@ -91,4 +98,12 @@ public class FunctionParamUncommenter { return sb; } + public void setSrc(String src) { + this.src = src; + } + + public void setDest(String dest) { + this.dest = dest; + } + } diff --git a/resources/includes/CL/cl.h b/resources/includes/CL_orig/cl.h index 58848eed..58848eed 100644 --- a/resources/includes/CL/cl.h +++ b/resources/includes/CL_orig/cl.h diff --git a/resources/includes/CL/cl_gl.h b/resources/includes/CL_orig/cl_gl.h index d4a6e4f8..d4a6e4f8 100644 --- a/resources/includes/CL/cl_gl.h +++ b/resources/includes/CL_orig/cl_gl.h diff --git a/resources/includes/CL/cl_platform.h b/resources/includes/CL_orig/cl_platform.h index 91f007c0..91f007c0 100644 --- a/resources/includes/CL/cl_platform.h +++ b/resources/includes/CL_orig/cl_platform.h |