diff options
-rw-r--r-- | README.txt | 29 | ||||
-rwxr-xr-x | make/build.xml | 167 | ||||
-rwxr-xr-x | make/joal.properties | 13 | ||||
-rwxr-xr-x | src/java/net/java/games/joal/impl/ALProcAddressLookup.java | 92 |
4 files changed, 168 insertions, 133 deletions
@@ -82,10 +82,9 @@ packages and tools have been used: -- OSX Developer Tools -- OpenAL1.0 SDK from Creative Labs (avaulable at http://developer.creative.com under "Gaming->Development Kits->Open AL") -The sources currently require a built JOGL source tree as a sibling -directory of your JOAL tree; this is to pick up the GlueGen tool, -which currently lives in the JOGL workspace. We plan to move this tool -into its own workspace and thereby break this dependence. +JOAL requires the GlueGen workspace to be checked out as a sibling +directory to the joal directory ("cvs co gluegen"). GlueGen will be +built automatially during the JOAL build process. Directory Organization: ======================= @@ -125,17 +124,21 @@ Preparations: JOAL Build Instructions: =================== -Copy the joal.properties file from the make/ subdirectory into your -home directory, or in particular where the Java system property -user.home points to (on Windows, this is C:\Documents and Settings\username\) +Download the current ANTLR jar file (http://www.antlr.org/). -Download the current ANTLR jar file (http://www.antlr.org/). Edit the -value of the antlr.jar property in this file to point to the full path -of this jar. ANTLR is used during the glue code generation process. +Copy the gluegen.properties file from the make/ subdirectory of the +GlueGen workspace into your home directory, or in particular where the +Java system property user.home points to (on Windows, this is +C:\Documents and Settings\username\). Edit the value of the antlr.jar +property this file to point to the full path of the ANTLR jar. ANTLR +is used during the glue code generation process. -Edit the joal.lib.dir property to point to the lib directory of your -current OpenAL installation. For Windows this might be "C:/Program -Files/OpenAL 1.1 SDK/libs/Win32". +Copy the joal.properties file from the make/ subdirectory into your +home directory, or in particular where the Java system property +user.home points to (on Windows, this is C:\Documents and +Settings\username\). Edit the joal.lib.dir property to point to the +lib directory of your current OpenAL installation. For Windows this +might be "C:/Program Files/OpenAL 1.1 SDK/libs/Win32". Under Linux set the property to the toplevel directory of your OpenAL CVS version. If OpenAl came with your distribution and the header files are in /usr/include/AL, diff --git a/make/build.xml b/make/build.xml index e04f629..9a63977 100755 --- a/make/build.xml +++ b/make/build.xml @@ -17,87 +17,34 @@ - the "make" directory. This also means that this build.xml MUST - be run from the "make" directory. - - - All targets do the following: - - Build the ancillary Ant tasks. - - Generate the Java and C files. - - Compile all sources. - - Create the joal.jar and platform library. - Public targets: - - linux - - macosx - - solaris - - win32.vc6 - - win32.vc7 - - win32.mingw: build everything (jar, DSOs) for the current platform + - all: (default; autodetects OS and chooses C compiler from joal.properties) - clean: clean all built - javadoc: create the standard developer Javadoc - - - Optional properties: - - -Djoal.cg=1 when combined with the build or javadoc targets will cause - - the experimental binding to NVidia's Cg language to be built. - - - Thanks to Rob Grzywinski and Artur Biesiadowski for the bulk of the - ANT build, including the GlueGen and StaticGLInfo tasks, the building of - the Java generated sources, the first and second phase Java compiles, and - - the building of the jar file. + - the building of the jar file. Thanks to Alex Radeski for the bulk of the + - port to the ant-contrib CPPTask framework. Thanks to Athomas Goldberg for + - the original OS detection code. --> <project name="JOAL" basedir="." default="all"> + <!-- Pull in GlueGen cpptasks build file --> + <property name="gluegen.root" value="../../gluegen" /> + <import file="${gluegen.root}/make/gluegen-cpptasks.xml" /> + <!-- ================================================================== --> <!-- - Base initialization and detection of operating system. --> - <target name="base.init"> + <target name="base.init" depends="gluegen.cpptasks.detect.os"> <!-- Set the project root directory to be up one directory. --> <property name="project.root" value=".." /> <!-- Set the configuration and build files to this directory. --> <property name="make" value="." /> - - <!-- Detection of operating system. --> - <condition property="isOSX"> - <and> - <os family="mac"/> - <os family="unix"/> - </and> - </condition> - <condition property="isUnix"> - <and> - <os family="unix" /> - <not> - <os family="mac" /> - </not> - </and> - </condition> - <condition property="isLinux"> - <os name="Linux" /> - </condition> - <condition property="isSolaris"> - <os name="SunOS" /> - </condition> - <condition property="isWindows"> - <os family="windows" /> - </condition> - <condition property="isFreeBSD"> - <os name="FreeBSD" /> - </condition> - <condition property="isLinuxAMD64"> - <and> - <istrue value="${isLinux}" /> - <os arch="AMD64" /> - </and> - </condition> - <condition property="isIA64"> - <os arch="IA64" /> - </condition> - <echo message="OS X=${isOSX}" /> - <echo message="Windows=${isWindows}" /> - <echo message="Unix=${isUnix}" /> - <echo message="Linux=${isLinux}" /> - <echo message="Solaris=${isSolaris}" /> - <echo message="FreeBSD=${isFreeBSD}" /> - <echo message="LinuxAMD64=${isLinuxAMD64}" /> - <echo message="IA64=${isIA64}" /> </target> <!-- ================================================================== --> @@ -111,8 +58,10 @@ <property name="user.properties.file" value="${user.home}/joal.properties" /> <property file="${user.properties.file}" /> <echo message="Loaded ${user.properties.file}." /> + <property file="${user.home}/gluegen.properties" /> + <echo message="Loaded ${user.home}/gluegen.properties." /> <echo message="antlr.jar=${antlr.jar}" /> - <fail message="antlr.jar was not specified in joal.properties. Please see README.txt for instructions" unless="antlr.jar"/> + <fail message="antlr.jar was not specified in joal.properties or gluegen.properties. Please see README.txt for instructions" unless="antlr.jar"/> <fail message="joal.lib.dir was not specified in joal.properties. Please see README.txt for instructions" unless="joal.lib.dir"/> <condition property="isVC6"> <and> @@ -154,34 +103,40 @@ <!-- - Declare all paths and user defined variables. --> - <target name="declare.common" description="Declare properties" depends="base.init"> - <!-- Shorthand for file.separator --> - <property name="sep" value="${file.separator}" /> - + <target name="declare.common" description="Declare properties" depends="setup.java.home.dir, gluegen.cpptasks.detect.compiler"> <!-- The location and name of the configuration ANT file that will - validate to ensure that all user-define variables are set. --> <property name="validate.user.properties" value="${make}/validate-properties.xml" /> - <!-- Properties pointing to root of the workspace containing GlueGen. - This build.xml expects that GlueGen has already been built and that its - classes are in the build/classes subdirectory of this other workspace. - Currently we expect that it is contained in the JOGL project. --> - <property name="jogl.root" value="../../jogl" /> - <property name="gluegen.classes" value="${jogl.root}/build/classes" /> + <!-- GlueGen properties. --> + <!-- NOTE that these require a checked-out GlueGen workspace as a --> + <!-- sibling of the JOAL workspace. --> + <property name="gluegen.make.dir" value="../../gluegen/make" /> + <property name="gluegen.build.xml" value="${gluegen.make.dir}/build.xml" /> + <property name="gluegen.jar" value="../../gluegen/build/gluegen.jar" /> + <property name="gluegen-rt.jar" value="../../gluegen/build/gluegen-rt.jar" /> + + <!-- Create the classpath that includes GlueGen and + - ANTLR. This requires the user-defined "antlr.jar" + - property. --> + <path id="gluegen.classpath"> + <pathelement location="${gluegen.jar}" /> + <pathelement location="${antlr.jar}" /> + </path> <!-- Names of directories relative to the project root. Some of these are used in FileMappers later for dependence information and need exact string matching, which is why they use file.separator instead of "/". --> <property name="rootrel.src" value="src" /> - <property name="rootrel.src.java" value="${rootrel.src}${sep}java" /> - <property name="rootrel.src.c" value="${rootrel.src}${sep}native" /> + <property name="rootrel.src.java" value="${rootrel.src}/java" /> + <property name="rootrel.src.c" value="${rootrel.src}/native" /> <property name="rootrel.build" value="build" /> - <property name="rootrel.src.generated" value="${rootrel.build}${sep}gensrc" /> - <property name="rootrel.generated.java" value="${rootrel.src.generated}${sep}classes" /> - <property name="rootrel.generated.c.joal" value="${rootrel.src.generated}${sep}native${sep}joal" /> - <property name="rootrel.obj" value="${rootrel.build}${sep}obj" /> - <property name="rootrel.obj.joal" value="${rootrel.obj}${sep}joal" /> + <property name="rootrel.src.generated" value="${rootrel.build}/gensrc" /> + <property name="rootrel.generated.java" value="${rootrel.src.generated}/classes" /> + <property name="rootrel.generated.c.joal" value="${rootrel.src.generated}/native/joal" /> + <property name="rootrel.obj" value="${rootrel.build}/obj" /> + <property name="rootrel.obj.joal" value="${rootrel.obj}/joal" /> <!-- The source directories. --> <property name="src" value="${project.root}/${rootrel.src}" /> @@ -220,16 +175,6 @@ <property name="java.includes.dir.solaris" value="${java.includes.dir}/solaris" /> <property name="java.includes.dir.macosx" value="/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Headers" /> - <!-- Create the classpath that includes ANTLR and any already - - compiled classes. This requires the user-defined "antlr.jar" - - property. --> - <path id="antlr.classpath"> - <pathelement path="${classpath}" /> - <pathelement location="${gluegen.classes}" /> - <pathelement location="${classes}" /> - <pathelement location="${antlr.jar}" /> - </path> - <!-- The resulting joal.jar. --> <property name="joal.jar" value="${build}/joal.jar" /> @@ -347,6 +292,23 @@ <target name="declare" depends="init,declare.win32,declare.linux,declare.solaris,declare.macosx,declare.freebsd" /> <!-- ================================================================== --> + <!-- GlueGen and BuildStaticGLInfo creation, task setup and Java file generation --> + <!-- + - Build GlueGen + --> + <target name="build.gluegen" depends="init"> + <!-- Run the GlueGen build to ensure that the GlueGen ANT task + - has been built. --> + <ant antfile="${gluegen.build.xml}" dir="${gluegen.make.dir}" target="all" inheritAll="false" /> + + <!-- Extract the GlueGen runtime classes into our build directory. + - We currently bundle them into jogl.jar; they could be kept in + - a separate jar, but this makes deployment simpler. + --> + <unjar src="${gluegen-rt.jar}" dest="${classes}" /> + </target> + + <!-- ================================================================== --> <!-- Java file generation --> <!-- - Check to see whether we need to rebuild the generated sources. @@ -378,10 +340,10 @@ - from the C GL headers. This involves setting the taskdef and creating - the classpath reference id then running the task on each header. --> - <target name="java.generate" depends="java.generate.check" unless="java.generate.skip"> + <target name="java.generate" depends="build.gluegen, java.generate.check" unless="java.generate.skip"> <!-- Add the GlueGen task to ANT --> <taskdef name="gluegen" classname="com.sun.gluegen.ant.GlueGenTask" - classpathref="antlr.classpath" /> + classpathref="gluegen.classpath" /> <!-- Use the GlueGen task to generate the Java files --> @@ -390,7 +352,7 @@ config="${joal.cfg}" includeRefid="stub.includes.fileset.all" emitter="com.sun.gluegen.procaddress.ProcAddressEmitter"> - <classpath refid="antlr.classpath" /> + <classpath refid="gluegen.classpath" /> </gluegen> <!-- Generate the ALConstants interface class --> @@ -398,7 +360,7 @@ config="${joal.constants.cfg}" includeRefid="stub.includes.fileset.all" emitter="com.sun.gluegen.JavaEmitter"> - <classpath refid="antlr.classpath" /> + <classpath refid="gluegen.classpath" /> </gluegen> <!-- Generate the ALC interface class and implementation --> @@ -406,7 +368,7 @@ config="${joal.alc.cfg}" includeRefid="stub.includes.fileset.all" emitter="com.sun.gluegen.procaddress.ProcAddressEmitter"> - <classpath refid="antlr.classpath" /> + <classpath refid="gluegen.classpath" /> </gluegen> <!-- Generate the ALCConstants interface class --> @@ -414,7 +376,7 @@ config="${joal.alc.constants.cfg}" includeRefid="stub.includes.fileset.all" emitter="com.sun.gluegen.JavaEmitter"> - <classpath refid="antlr.classpath" /> + <classpath refid="gluegen.classpath" /> </gluegen> <!-- Inform the user that the generators have successfully created @@ -432,7 +394,6 @@ <javac destdir="${classes}" source="1.4" debug="true" debuglevel="source,lines"> <src path="${src.java}" /> <src path="${src.generated.java}" /> - <classpath refid="antlr.classpath" /> </javac> </target> @@ -443,10 +404,6 @@ <target name="c.configure"> - <!-- import cpptasks --> - <typedef resource="net/sf/antcontrib/cpptasks/antlib.xml" classpath="${jogl.root}/make/lib/cpptasks.jar"/> - <!--typedef resource="net/sf/antcontrib/cpptasks/antlib.xml"/--> - <!-- compiler configuration --> <compiler id="compiler.cfg.linux" name="gcc" /> @@ -533,8 +490,7 @@ <linkerarg value="/MACHINE:IX86" /> <!-- explicity set target platform --> <syslibset dir="${joal.lib.dir}" libs="openal32" /> - <syslibset dir="${c.linker.lib.root}/lib" libs="kernel32" unless="isVC7"/> - <syslibset dir="${c.linker.lib.root}/PlatformSDK/lib" libs="kernel32" if="isVC7"/> + <syslibset libs="kernel32"/> </linker> <linker id="linker.cfg.macosx" name="gcc"> @@ -631,8 +587,6 @@ <jar destfile="${joal.jar}"> <fileset dir="${classes}"> <include name="net/java/games/**" /> - </fileset> - <fileset dir="${gluegen.classes}"> <include name="com/sun/gluegen/runtime/**" /> </fileset> </jar> @@ -649,7 +603,6 @@ <target name="javadoc" depends="setup.java.home.dir,init"> <javadoc packagenames="${javadoc.packagenames}" sourcepath="${src.java};${src.generated.java}" - classpath="${gluegen.classes}" destdir="${javadoc}" windowtitle="JOAL API" source="1.4" link="${javadoc.link}" /> @@ -734,7 +687,7 @@ <!-- - Build everything. --> - <target name="all" depends="setup.java.home.dir,init,declare"> + <target name="all" depends="init,declare"> <!-- Generate, compile, and build the jar for the Java sources. --> <antcall target="jar" inheritRefs="true" /> diff --git a/make/joal.properties b/make/joal.properties index 436dc9f..635d975 100755 --- a/make/joal.properties +++ b/make/joal.properties @@ -12,19 +12,6 @@ # java.home.dir=C:/jdk1.4.2 # -# The required antlr.jar property that is the full path to the antlr.jar -# including the name of the jar -# -# Windows -antlr.jar=C:/Users/kbr/ANTLR/antlr-2.7.2/antlr.jar -# Linux -# antlr.jar=/home/kbr/antlr-2.7.2/antlr.jar -# Mac OS X -# antlr.jar=/Users/kbr/antlr-2.7.2/antlr.jar -# Solaris -# antlr.jar=/export/kbr/ANTLR/antlr-2.7.2/antlr.jar - -# # The required joal.lib.dir points to the directory containing the # OpenAL library against which JOAL is linked. On Windows, this is the # directory containing OpenAL32.lib (the import library); on other diff --git a/src/java/net/java/games/joal/impl/ALProcAddressLookup.java b/src/java/net/java/games/joal/impl/ALProcAddressLookup.java new file mode 100755 index 0000000..5291587 --- /dev/null +++ b/src/java/net/java/games/joal/impl/ALProcAddressLookup.java @@ -0,0 +1,92 @@ +/** + * Copyright (c) 2003-2005 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * -Redistribution of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * -Redistribution in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of contributors may + * 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 OR + * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS + * 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 SUN OR ITS 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 SUN HAS + * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that this software is not designed or intended for use in the + * design, construction, operation or maintenance of any nuclear facility. + */ + +package net.java.games.joal.impl; + +import net.java.games.joal.*; +import com.sun.gluegen.runtime.*; + +/** Helper class for managing OpenAL-related proc address tables. */ + +public class ALProcAddressLookup { + private static final ALProcAddressTable alTable = new ALProcAddressTable(); + private static volatile boolean alTableInitialized = false; + private static final ALCProcAddressTable alcTable = new ALCProcAddressTable(); + private static volatile boolean alcTableInitialized = false; + + public static void resetALProcAddressTable() { + if (!alTableInitialized) { + synchronized (ALProcAddressLookup.class) { + if (!alTableInitialized) { + // At some point this may require an OpenAL context to be + // current as we will actually use alGetProcAddress. Since + // this routine is currently broken and there are no + // per-context function pointers anyway we could actually do + // this work anywhere. We should also in theory have + // per-ALcontext ALProcAddressTables and per-ALCdevice + // ALCProcAddressTables. + ALImpl impl = (ALImpl) ALFactory.getAL(); + ProcAddressHelper.resetProcAddressTable(alTable, impl); + alTableInitialized = true; + } + } + } + } + + public static void resetALCProcAddressTable() { + if (!alcTableInitialized) { + synchronized (ALProcAddressLookup.class) { + if (!alcTableInitialized) { + // At some point this may require an OpenAL device to be + // created as we will actually use alcGetProcAddress. Since + // this routine is currently broken and there are no + // per-device function pointers anyway we could actually do + // this work anywhere. We should also in theory have + // per-ALcontext ALProcAddressTables and per-ALCdevice + // ALCProcAddressTables. + ALImpl impl = (ALImpl) ALFactory.getAL(); + ProcAddressHelper.resetProcAddressTable(alcTable, impl); + alcTableInitialized = true; + } + } + } + } + + public static ALProcAddressTable getALProcAddressTable() { + return alTable; + } + + public static ALCProcAddressTable getALCProcAddressTable() { + return alcTable; + } +} |