From c91f003551542c2aab62dd8ef89a7894c7e50689 Mon Sep 17 00:00:00 2001 From: Kenneth Russel Date: Mon, 15 Jun 2009 22:42:48 +0000 Subject: Copied JOGL_2_SANDBOX r145 on to trunk; JOGL_2_SANDBOX branch is now closed git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/../svn-server-sync/gluegen/trunk@147 a78bb65f-1512-4460-ba86-f6dc96a7bf27 --- src/java/com/sun/gluegen/ant/GlueGenTask.java | 520 ++++++++++++++++++++++ src/java/com/sun/gluegen/ant/StaticGLGenTask.java | 304 +++++++++++++ 2 files changed, 824 insertions(+) create mode 100644 src/java/com/sun/gluegen/ant/GlueGenTask.java create mode 100644 src/java/com/sun/gluegen/ant/StaticGLGenTask.java (limited to 'src/java/com/sun/gluegen/ant') diff --git a/src/java/com/sun/gluegen/ant/GlueGenTask.java b/src/java/com/sun/gluegen/ant/GlueGenTask.java new file mode 100644 index 0000000..af42392 --- /dev/null +++ b/src/java/com/sun/gluegen/ant/GlueGenTask.java @@ -0,0 +1,520 @@ +package com.sun.gluegen.ant; + +/* + * GlueGenTask.java + * Copyright (C) 2003 Rob Grzywinski (rgrzywinski@realityinteractive.com) + * + * Copying, distribution and use of this software in source and binary + * forms, with or without modification, is permitted provided that the + * following conditions are met: + * + * Distributions of source code must reproduce the copyright notice, + * this list of conditions and the following disclaimer in the source + * code header files; and Distributions of binary code must reproduce + * the copyright notice, this list of conditions and the following + * disclaimer in the documentation, Read me file, license file and/or + * other materials provided with the software distribution. + * + * The names of Sun Microsystems, Inc. ("Sun") and/or the copyright + * holder may not be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS," WITHOUT A WARRANTY OF ANY + * KIND. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND + * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, NON-INTERFERENCE, ACCURACY OF + * INFORMATIONAL CONTENT OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. THE + * COPYRIGHT HOLDER, SUN AND SUN'S LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL THE + * COPYRIGHT HOLDER, SUN OR SUN'S LICENSORS BE LIABLE FOR ANY LOST + * REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, + * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND + * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR + * INABILITY TO USE THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGES. YOU ACKNOWLEDGE THAT THIS SOFTWARE IS NOT + * DESIGNED, LICENSED OR INTENDED FOR USE IN THE DESIGN, CONSTRUCTION, + * OPERATION OR MAINTENANCE OF ANY NUCLEAR FACILITY. THE COPYRIGHT + * HOLDER, SUN AND SUN'S LICENSORS DISCLAIM ANY EXPRESS OR IMPLIED + * WARRANTY OF FITNESS FOR SUCH USES. + */ + +import java.io.IOException; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.DirectoryScanner; +import org.apache.tools.ant.Project; +import org.apache.tools.ant.Task; +import org.apache.tools.ant.taskdefs.Execute; +import org.apache.tools.ant.taskdefs.LogStreamHandler; +import org.apache.tools.ant.types.CommandlineJava; +import org.apache.tools.ant.types.DirSet; +import org.apache.tools.ant.types.FileSet; +import org.apache.tools.ant.types.Path; +import org.apache.tools.ant.types.PatternSet; +import org.apache.tools.ant.types.Reference; +import org.apache.tools.ant.util.JavaEnvUtils; + +/** + *

An ANT {@link org.apache.tools.ant.Task} + * for using {@link com.sun.gluegen.GlueGen}.

+ * + *

Usage:

+ *
+    <gluegen src="[source C file]" 
+                outputrootdir="[optional output root dir]"
+                includes="[optional directory pattern of include files to include]"
+                excludes="[optional directory pattern of include files to exclude]"
+                includeRefid="[optional FileSet or DirSet for include files]"
+                literalInclude="[optional hack to get around FileSet / DirSet issues with different drives]"
+                emitter="[emitter class name]"
+                config="[configuration file]" />
+ * 
+ * + * @author Rob Grzywinski rgrzywinski@yahoo.com + */ +// FIXME: blow out javadoc +// NOTE: this has not been exhaustively tested +public class GlueGenTask extends Task +{ + /** + *

The {@link com.sun.gluegen.GlueGen} classname.

+ */ + private static final String GLUE_GEN = "com.sun.gluegen.GlueGen"; + + // ========================================================================= + /** + *

The {@link org.apache.tools.ant.types.CommandlineJava} that is used + * to execute {@link com.sun.gluegen.GlueGen}.

+ */ + private CommandlineJava gluegenCommandline; + + // ========================================================================= + /** + *

The optional output root dir.

+ */ + private String outputRootDir; + + /** + *

The name of the emitter class.

+ */ + private String emitter; + + /** + *

The configuration file name.

+ */ + private String configuration; + + /** + *

The name of the source C file that is to be parsed.

+ */ + private String sourceFile; + + /** + *

The {@link org.apache.tools.ant.types.FileSet} of includes.

+ */ + private FileSet includeSet = new FileSet(); + + /** + *

Because a {@link org.apache.tools.ant.types.FileSet} will include + * everything in its base directory if it is left untouched, the includeSet + * must only be added to the set of includes if it has been explicitly + * set.

+ */ + private boolean usedIncludeSet = false; // by default it is not used + + /** + *

The set of include sets. This allows includes to be added in multiple + * fashions.

+ */ + // FIXME: rename to listXXXX + private List setOfIncludeSets = new LinkedList(); + + /** + *

A single literal directory to include. This is to get around the + * fact that neither {@link org.apache.tools.ant.types.FileSet} nor + * {@link org.apache.tools.ant.types.DirSet} can handle multiple drives in + * a sane manner. If null then it has not been specified.

+ */ + private String literalInclude; + + // ========================================================================= + /** + *

Create and add the VM and classname to {@link org.apache.tools.ant.types.CommandlineJava}.

+ */ + public GlueGenTask() + { + // create the CommandlineJava that will be used to call GlueGen + gluegenCommandline = new CommandlineJava(); + + // set the VM and classname in the commandline + gluegenCommandline.setVm(JavaEnvUtils.getJreExecutable("java")); + gluegenCommandline.setClassname(GLUE_GEN); + // gluegenCommandline.createVmArgument().setValue("-verbose:class"); + } + + // ========================================================================= + // ANT getters and setters + + /** + *

Set the output root dir (optional). This is called by ANT.

+ * + * @param outputRootDir the optional output root dir + */ + public void setOutputRootDir(String outputRootDir) + { + log( ("Setting output root dir: " + outputRootDir), Project.MSG_VERBOSE); + this.outputRootDir=outputRootDir; + } + + /** + *

Set the emitter class name. This is called by ANT.

+ * + * @param emitter the name of the emitter class + */ + public void setEmitter(String emitter) + { + log( ("Setting emitter class name to: " + emitter), Project.MSG_VERBOSE); + this.emitter = emitter; + } + + /** + *

Set the configuration file name. This is called by ANT.

+ * + * @param configuration the name of the configuration file + */ + public void setConfig(String configuration) + { + log( ("Setting configuration file name to: " + configuration), + Project.MSG_VERBOSE); + this.configuration = configuration; + } + + /** + *

Set the source C file that is to be parsed. This is called by ANT.

+ * + * @param sourceFile the name of the source file + */ + public void setSrc(String sourceFile) + { + log( ("Setting source file name to: " + sourceFile), Project.MSG_VERBOSE); + this.sourceFile = sourceFile; + } + + /** + *

Set a single literal include directory. See the literalInclude + * javadoc for more information.

+ * + * @param directory the directory to include + */ + public void setLiteralInclude(String directory) + { + this.literalInclude = directory; + } + + /** + *

Add an include file to the list. This is called by ANT for a nested + * element.

+ * + * @return {@link org.apache.tools.ant.types.PatternSet.NameEntry} + */ + public PatternSet.NameEntry createInclude() + { + usedIncludeSet = true; + return includeSet.createInclude(); + } + + /** + *

Add an include file to the list. This is called by ANT for a nested + * element.

+ * + * @return {@link org.apache.tools.ant.types.PatternSet.NameEntry} + */ + public PatternSet.NameEntry createIncludesFile() + { + usedIncludeSet = true; + return includeSet.createIncludesFile(); + } + + /** + *

Set the set of include patterns. Patterns may be separated by a comma + * or a space. This is called by ANT.

+ * + * @param includes the string containing the include patterns + */ + public void setIncludes(String includes) + { + usedIncludeSet = true; + includeSet.setIncludes(includes); + } + + /** + *

Add an include file to the list that is to be exluded. This is called + * by ANT for a nested element.

+ * + * @return {@link org.apache.tools.ant.types.PatternSet.NameEntry} + */ + public PatternSet.NameEntry createExclude() + { + usedIncludeSet = true; + return includeSet.createExclude(); + } + + /** + *

Add an exclude file to the list. This is called by ANT for a nested + * element.

+ * + * @return {@link org.apache.tools.ant.types.PatternSet.NameEntry} + */ + public PatternSet.NameEntry createExcludesFile() + { + usedIncludeSet = true; + return includeSet.createExcludesFile(); + } + + /** + *

Set the set of exclude patterns. Patterns may be separated by a comma + * or a space. This is called by ANT.

+ * + * @param includes the string containing the exclude patterns + */ + public void setExcludes(String excludes) + { + usedIncludeSet = true; + includeSet.setExcludes(excludes); + } + + /** + *

Set a {@link org.apache.tools.ant.types.Reference} to simplify adding + * of complex sets of files to include. This is called by ANT.

? + * + * @param reference a Reference to a {@link org.apache.tools.ant.types.FileSet} + * or {@link org.apache.tools.ant.types.DirSet} + * @throws BuildException if the specified Reference is not + * either a FileSet or DirSet + */ + public void setIncludeRefid(Reference reference) + { + // ensure that the referenced object is either a FileSet or DirSet + final Object referencedObject = reference.getReferencedObject(getProject()); + if( !( (referencedObject instanceof FileSet) || + (referencedObject instanceof DirSet)) ) + { + throw new BuildException("Only FileSets or DirSets are allowed as an include refid."); + } + + // add the referenced object to the set of include sets + setOfIncludeSets.add(referencedObject); + } + + /** + *

Add a nested {@link org.apache.tools.ant.types.DirSet} to specify + * the files to include. This is called by ANT.

+ * + * @param dirset the DirSet to be added + */ + public void addDirset(DirSet dirset) + { + setOfIncludeSets.add(dirset); + } + + /** + *

Add an optional classpath that defines the location of {@link com.sun.gluegen.GlueGen} + * and GlueGen's dependencies.

+ * + * @returns {@link org.apache.tools.ant.types.Path} + */ + public Path createClasspath() + { + return gluegenCommandline.createClasspath(project).createPath(); + } + + // ========================================================================= + /** + *

Run the task. This involves validating the set attributes, creating + * the command line to be executed and finally executing the command.

+ * + * @see org.apache.tools.ant.Task#execute() + */ + public void execute() + throws BuildException + { + // validate that all of the required attributes have been set + validateAttributes(); + + // TODO: add logic to determine if the generated file needs to be + // regenerated + + // add the attributes to the CommandlineJava + addAttributes(); + + log(gluegenCommandline.describeCommand(), Project.MSG_VERBOSE); + + // execute the command and throw on error + final int error = execute(gluegenCommandline.getCommandline()); + if(error == 1) + throw new BuildException( ("GlueGen returned: " + error), location); + } + + /** + *

Ensure that the user specified all required arguments.

+ * + * @throws BuildException if there are required arguments that are not + * present or not valid + */ + private void validateAttributes() + throws BuildException + { + // outputRootDir is optional .. + + // validate that the emitter class is set + if(!isValid(emitter)) + throw new BuildException("Invalid emitter class name: " + emitter); + + // validate that the configuration file is set + if(!isValid(configuration)) + throw new BuildException("Invalid configuration file name: " + configuration); + + // validate that the source file is set + if(!isValid(sourceFile)) + throw new BuildException("Invalid source file name: " + sourceFile); + + // CHECK: do there need to be includes to be valid? + } + + /** + *

Is the specified string valid? A valid string is non-null + * and has a non-zero length.

+ * + * @param string the string to be tested for validity + * @return true if the string is valid. false + * otherwise. + */ + private boolean isValid(String string) + { + // check for null + if(string == null) + return false; + + // ensure that the string has a non-zero length + // NOTE: must trim() to remove leading and trailing whitespace + if(string.trim().length() < 1) + return false; + + // the string is valid + return true; + } + + /** + *

Add all of the attributes to the command line. They have already + * been validated.

+ */ + private void addAttributes() + throws BuildException + { + // NOTE: GlueGen uses concatenated flag / value rather than two + // separate arguments + + // add the output root dir + if(null!=outputRootDir && outputRootDir.trim().length()>0) { + gluegenCommandline.createArgument().setValue("-O" + outputRootDir); + } + + // add the emitter class name + gluegenCommandline.createArgument().setValue("-E" + emitter); + + // add the configuration file name + gluegenCommandline.createArgument().setValue("-C" + configuration); + + // add the includedSet to the setOfIncludeSets to simplify processing + // all types of include sets ONLY if it has been set. + // NOTE: see the usedIncludeSet member javadoc for more info + // NOTE: references and nested DirSets have already been added to the + // set of include sets + if(usedIncludeSet) + { + includeSet.setDir(getProject().getBaseDir()); // NOTE: the base dir must be set + setOfIncludeSets.add(includeSet); + } + + // iterate over all include sets and add their directories to the + // list of included directories. + final List includedDirectories = new LinkedList(); + for(Iterator includes=setOfIncludeSets.iterator(); includes.hasNext(); ) + { + // get the included set and based on its type add the directories + // to includedDirectories + Object include = (Object)includes.next(); + final String[] directoryDirs; + if(include instanceof FileSet) + { + final FileSet fileSet = (FileSet)include; + DirectoryScanner directoryScanner = fileSet.getDirectoryScanner(getProject()); + directoryDirs = directoryScanner.getIncludedDirectories(); + } else if(include instanceof DirSet) + { + final DirSet dirSet = (DirSet)include; + DirectoryScanner directoryScanner = dirSet.getDirectoryScanner(getProject()); + directoryDirs = directoryScanner.getIncludedDirectories(); + } else + { + // NOTE: this cannot occur as it is checked on setXXX() but + // just to be pedantic this is here + throw new BuildException("Invalid included construct."); + } + + // add the directoryDirs to the includedDirectories + // TODO: exclude any directory that is already in the list + for(int i=0; iExecute {@link com.sun.gluegen.GlueGen} in a forked JVM.

+ * + * @throws BuildException + */ + private int execute(String[] command) + throws BuildException + { + // create the object that will perform the command execution + Execute execute = new Execute(new LogStreamHandler(this, Project.MSG_INFO, + Project.MSG_WARN), + null); + + // set the project and command line + execute.setAntRun(project); + execute.setCommandline(command); + execute.setWorkingDirectory( project.getBaseDir() ); + + // execute the command + try + { + return execute.execute(); + } catch(IOException ioe) + { + throw new BuildException(ioe, location); + } + } +} diff --git a/src/java/com/sun/gluegen/ant/StaticGLGenTask.java b/src/java/com/sun/gluegen/ant/StaticGLGenTask.java new file mode 100644 index 0000000..8761942 --- /dev/null +++ b/src/java/com/sun/gluegen/ant/StaticGLGenTask.java @@ -0,0 +1,304 @@ +package com.sun.gluegen.ant; + +/* + * StaticGLGenTask.java + * Copyright (C) 2003 Rob Grzywinski (rgrzywinski@realityinteractive.com) + * + * Copying, distribution and use of this software in source and binary + * forms, with or without modification, is permitted provided that the + * following conditions are met: + * + * Distributions of source code must reproduce the copyright notice, + * this list of conditions and the following disclaimer in the source + * code header files; and Distributions of binary code must reproduce + * the copyright notice, this list of conditions and the following + * disclaimer in the documentation, Read me file, license file and/or + * other materials provided with the software distribution. + * + * The names of Sun Microsystems, Inc. ("Sun") and/or the copyright + * holder may not be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS," WITHOUT A WARRANTY OF ANY + * KIND. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND + * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, NON-INTERFERENCE, ACCURACY OF + * INFORMATIONAL CONTENT OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. THE + * COPYRIGHT HOLDER, SUN AND SUN'S LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL THE + * COPYRIGHT HOLDER, SUN OR SUN'S LICENSORS BE LIABLE FOR ANY LOST + * REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, + * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND + * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR + * INABILITY TO USE THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGES. YOU ACKNOWLEDGE THAT THIS SOFTWARE IS NOT + * DESIGNED, LICENSED OR INTENDED FOR USE IN THE DESIGN, CONSTRUCTION, + * OPERATION OR MAINTENANCE OF ANY NUCLEAR FACILITY. THE COPYRIGHT + * HOLDER, SUN AND SUN'S LICENSORS DISCLAIM ANY EXPRESS OR IMPLIED + * WARRANTY OF FITNESS FOR SUCH USES. + */ + +import java.io.IOException; + +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.DirectoryScanner; +import org.apache.tools.ant.Project; +import org.apache.tools.ant.Task; +import org.apache.tools.ant.taskdefs.Execute; +import org.apache.tools.ant.taskdefs.LogStreamHandler; +import org.apache.tools.ant.types.CommandlineJava; +import org.apache.tools.ant.types.FileSet; +import org.apache.tools.ant.types.Path; +import org.apache.tools.ant.types.PatternSet; +import org.apache.tools.ant.util.JavaEnvUtils; + +/** + *

An ANT {@link org.apache.tools.ant.Task} + * for using {@link com.sun.gluegen.opengl.BuildStaticGLInfo}.

+ * + *

Usage:

+ *
+    <staticglgen package="[generated files package]" 
+                    headers="[file pattern of GL headers]"
+                    outputdir="[directory to output the generated files]" />
+ * 
+ * + * @author Rob Grzywinski rgrzywinski@yahoo.com + */ +// FIXME: blow out javadoc +public class StaticGLGenTask extends Task +{ + /** + *

The {@link com.sun.gluegen.opengl.BuildStaticGLInfo} classname.

+ */ + private static final String GL_GEN = "com.sun.gluegen.opengl.BuildStaticGLInfo"; + + // ========================================================================= + /** + *

The {@link org.apache.tools.ant.types.CommandlineJava} that is used + * to execute {@link com.sun.gluegen.opengl.BuildStaticGLInfo}.

+ */ + private CommandlineJava glgenCommandline; + + // ========================================================================= + /** + *

The package name for the generated files.

+ */ + private String packageName; + + /** + *

The output directory.

+ */ + private String outputDirectory; + + /** + *

The {@link org.apache.tools.ant.types.FileSet} of GL headers.

+ */ + private FileSet headerSet = new FileSet(); + + // ========================================================================= + /** + *

Create and add the VM and classname to {@link org.apache.tools.ant.types.CommandlineJava}.

+ */ + public StaticGLGenTask() + { + // create the CommandlineJava that will be used to call BuildStaticGLInfo + glgenCommandline = new CommandlineJava(); + + // set the VM and classname in the commandline + glgenCommandline.setVm(JavaEnvUtils.getJreExecutable("java")); + glgenCommandline.setClassname(GL_GEN); + } + + // ========================================================================= + // ANT getters and setters + /** + *

Set the package name for the generated files. This is called by ANT.

+ * + * @param packageName the name of the package for the generated files + */ + public void setPackage(String packageName) + { + log( ("Setting package name to: " + packageName), Project.MSG_VERBOSE); + this.packageName = packageName; + } + + /** + *

Set the output directory. This is called by ANT.

+ * + * @param directory the output directory + */ + public void setOutputDir(String directory) + { + log( ("Setting output directory to: " + directory), + Project.MSG_VERBOSE); + this.outputDirectory = directory; + } + + /** + *

Add a header file to the list. This is called by ANT for a nested + * element.

+ * + * @return {@link org.apache.tools.ant.types.PatternSet.NameEntry} + */ + public PatternSet.NameEntry createHeader() + { + return headerSet.createInclude(); + } + + /** + *

Add a header file to the list. This is called by ANT for a nested + * element.

+ * + * @return {@link org.apache.tools.ant.types.PatternSet.NameEntry} + */ + public PatternSet.NameEntry createHeadersFile() + { + return headerSet.createIncludesFile(); + } + + /** + *

Set the set of header patterns. Patterns may be separated by a comma + * or a space. This is called by ANT.

+ * + * @param headers the string containing the header patterns + */ + public void setHeaders(String headers) + { + headerSet.setIncludes(headers); + } + + /** + *

Add an optional classpath that defines the location of {@link com.sun.gluegen.opengl.BuildStaticGLInfo} + * and BuildStaticGLInfo's dependencies.

+ * + * @returns {@link org.apache.tools.ant.types.Path} + */ + public Path createClasspath() + { + return glgenCommandline.createClasspath(project).createPath(); + } + + // ========================================================================= + /** + *

Run the task. This involves validating the set attributes, creating + * the command line to be executed and finally executing the command.

+ * + * @see org.apache.tools.ant.Task#execute() + */ + public void execute() + throws BuildException + { + // validate that all of the required attributes have been set + validateAttributes(); + + // TODO: add logic to determine if the generated file needs to be + // regenerated + + // add the attributes to the CommandlineJava + addAttributes(); + + log(glgenCommandline.describeCommand(), Project.MSG_VERBOSE); + + // execute the command and throw on error + final int error = execute(glgenCommandline.getCommandline()); + if(error == 1) + throw new BuildException( ("BuildStaticGLInfo returned: " + error), location); + } + + /** + *

Ensure that the user specified all required arguments.

+ * + * @throws BuildException if there are required arguments that are not + * present or not valid + */ + private void validateAttributes() + throws BuildException + { + // validate that the package name is set + if(!isValid(packageName)) + throw new BuildException("Invalid package name: " + packageName); + + // validate that the output directory is set + // TODO: switch to file and ensure that it exists + if(!isValid(outputDirectory)) + throw new BuildException("Invalid output directory name: " + outputDirectory); + + // TODO: validate that there are headers set + } + + /** + *

Is the specified string valid? A valid string is non-null + * and has a non-zero length.

+ * + * @param string the string to be tested for validity + * @return true if the string is valid. false + * otherwise. + */ + private boolean isValid(String string) + { + // check for null + if(string == null) + return false; + + // ensure that the string has a non-zero length + // NOTE: must trim() to remove leading and trailing whitespace + if(string.trim().length() < 1) + return false; + + // the string is valid + return true; + } + + /** + *

Add all of the attributes to the command line. They have already + * been validated.

+ */ + private void addAttributes() + { + // add the package name + glgenCommandline.createArgument().setValue(packageName); + + // add the output directory name + glgenCommandline.createArgument().setValue(outputDirectory); + + // add the header -files- from the FileSet + headerSet.setDir(getProject().getBaseDir()); + DirectoryScanner directoryScanner = headerSet.getDirectoryScanner(getProject()); + String[] directoryFiles = directoryScanner.getIncludedFiles(); + for(int i=0; iExecute {@link com.sun.gluegen.opengl.BuildStaticGLInfo} in a + * forked JVM.

+ * + * @throws BuildException + */ + private int execute(String[] command) + throws BuildException + { + // create the object that will perform the command execution + Execute execute = new Execute(new LogStreamHandler(this, Project.MSG_INFO, + Project.MSG_WARN), + null); + + // set the project and command line + execute.setAntRun(project); + execute.setCommandline(command); + execute.setWorkingDirectory( project.getBaseDir() ); + + // execute the command + try + { + return execute.execute(); + } catch(IOException ioe) + { + throw new BuildException(ioe, location); + } + } +} -- cgit v1.2.3