2009-04-15 02:00:09 +00:00
#!/bin/bash
set -u
2009-04-16 02:13:17 +00:00
set -e
2009-03-04 03:31:44 +00:00
rm -rf out generated
mkdir out
2009-06-16 04:03:24 +00:00
# Create dummy Java files for Android APIs that are used by the code we generate.
# This allows us to test the generated code without building the rest of Android.
2009-03-04 03:31:44 +00:00
mkdir -p out/javax/microedition/khronos/opengles
mkdir -p out/com/google/android/gles_jni
2009-06-16 04:03:24 +00:00
mkdir -p out/android/app
2009-03-04 03:31:44 +00:00
mkdir -p out/android/graphics
2012-06-15 23:22:43 +00:00
mkdir -p out/android/view
2009-04-16 02:13:17 +00:00
mkdir -p out/android/opengl
2009-06-16 04:03:24 +00:00
mkdir -p out/android/content
mkdir -p out/android/content/pm
mkdir -p out/android/os
mkdir -p out/android/util
2009-03-04 03:31:44 +00:00
echo "package android.graphics;" > out/android/graphics/Canvas.java
echo "public interface Canvas {}" >> out/android/graphics/Canvas.java
2011-04-09 03:01:01 +00:00
echo "package android.app; import android.content.pm.IPackageManager; public class AppGlobals { public static IPackageManager getPackageManager() { return null;} }" > out/android/app/AppGlobals.java
2009-06-16 04:03:24 +00:00
# echo "package android.content; import android.content.pm.PackageManager; public interface Context { public PackageManager getPackageManager(); }" > out/android/content/Context.java
echo "package android.content.pm; public class ApplicationInfo {public int targetSdkVersion;}" > out/android/content/pm/ApplicationInfo.java
2012-06-15 23:22:43 +00:00
echo "package android.content.pm; public interface IPackageManager {ApplicationInfo getApplicationInfo(java.lang.String packageName, int flags, java.lang.String userId) throws android.os.RemoteException;}" > out/android/content/pm/IPackageManager.java
2009-06-16 04:03:24 +00:00
echo "package android.os; public class Build {public static class VERSION_CODES { public static final int CUPCAKE = 3;}; }" > out/android/os/Build.java
2013-02-23 04:04:22 +00:00
echo "package android.os; public class UserHandle {public static String myUserId() { return \"\"; } }" > out/android/os/UserHandle.java
2009-06-16 04:03:24 +00:00
echo "package android.os; public class RemoteException extends Exception {}" > out/android/os/RemoteException.java
echo "package android.util; public class Log {public static void w(String a, String b) {} public static void e(String a, String b) {}}" > out/android/util/Log.java
2012-06-15 23:22:43 +00:00
echo "package android.opengl; public abstract class EGLObjectHandle { public int getHandle() { return 0; } }" > out/android/opengl/EGLObjectHandle.java
echo "package android.opengl; public class EGLSurface extends EGLObjectHandle { }" > out/android/opengl/EGLSurface.java
echo "package android.opengl; public class EGLContext extends EGLObjectHandle { }" > out/android/opengl/EGLContext.java
echo "package android.opengl; public class EGLDisplay extends EGLObjectHandle { }" > out/android/opengl/EGLDisplay.java
echo "package android.opengl; public class EGLConfig extends EGLObjectHandle { }" > out/android/opengl/EGLConfig.java
echo "package android.graphics;" > out/android/graphics/SurfaceTexture.java
echo "public interface SurfaceTexture {}" >> out/android/graphics/SurfaceTexture.java
echo "package android.view;" > out/android/view/SurfaceView.java
echo "public interface SurfaceView { SurfaceHolder getHolder(); }" >> out/android/view/SurfaceView.java
echo "package android.view;" > out/android/view/Surface.java
echo "public interface Surface {}" >> out/android/view/Surface.java
echo "package android.view;" > out/android/view/SurfaceHolder.java
echo "public interface SurfaceHolder { Surface getSurface(); }" >> out/android/view/SurfaceHolder.java
2009-03-04 03:31:44 +00:00
GLFILE=out/javax/microedition/khronos/opengles/GL.java
2009-04-16 02:13:17 +00:00
cp stubs/jsr239/GLHeader.java-if $GLFILE
2009-03-04 03:31:44 +00:00
2012-06-15 23:22:43 +00:00
GLGEN_FILES="CFunc.java CType.java CodeEmitter.java EGLCodeEmitter.java GenerateEGL.java GenerateGL.java GenerateGLES.java GLESCodeEmitter.java JFunc.java JniCodeEmitter.java JType.java Jsr239CodeEmitter.java ParameterChecker.java"
2009-03-04 03:31:44 +00:00
pushd src > /dev/null
javac ${GLGEN_FILES}
2009-04-15 02:00:09 +00:00
JAVAC_RESULT=$?
if [ $JAVAC_RESULT -ne 0 ]; then
echo "Could not compile glgen."
exit $JAVAC_RESULT
fi
2009-03-04 03:31:44 +00:00
popd > /dev/null
2009-04-16 02:13:17 +00:00
echo "Generating JSR239-like APIs"
2013-03-29 17:49:58 +00:00
java -classpath src GenerateGL -c specs/jsr239/glspec-1.0 \
specs/jsr239/glspec-1.0ext \
specs/jsr239/glspec-1.1 \
specs/jsr239/glspec-1.1ext \
specs/jsr239/glspec-1.1extpack \
specs/jsr239/glspec-checks
2009-04-16 02:13:17 +00:00
JAVA_RESULT=$?
if [ $JAVA_RESULT -ne 0 ]; then
echo "Could not run GenerateGL."
exit $JAVA_RESULT
fi
2013-02-23 03:34:06 +00:00
echo "Generating static OpenGLES bindings"
2009-04-16 02:13:17 +00:00
java -classpath src GenerateGLES
JAVA_RESULT=$?
if [ $JAVA_RESULT -ne 0 ]; then
echo "Could not run GenerateGLES."
exit $JAVA_RESULT
fi
2013-02-23 03:34:06 +00:00
echo "Generating static EGL bindings"
2012-06-15 23:22:43 +00:00
java -classpath src GenerateEGL
JAVA_RESULT=$?
if [ $JAVA_RESULT -ne 0 ]; then
echo "Could not run GenerateEGL."
exit $JAVA_RESULT
fi
2009-04-15 02:00:09 +00:00
rm src/*.class
2009-03-04 03:31:44 +00:00
pushd out > /dev/null
mkdir classes
2013-03-29 17:49:58 +00:00
javac -d classes android/opengl/EGL14.java \
com/google/android/gles_jni/GLImpl.java \
javax/microedition/khronos/opengles/GL10.java \
javax/microedition/khronos/opengles/GL10Ext.java \
javax/microedition/khronos/opengles/GL11.java \
javax/microedition/khronos/opengles/GL11Ext.java \
javax/microedition/khronos/opengles/GL11ExtensionPack.java \
android/opengl/GLES10.java \
android/opengl/GLES10Ext.java \
android/opengl/GLES11.java \
android/opengl/GLES11Ext.java \
android/opengl/GLES20.java
2009-03-04 03:31:44 +00:00
popd > /dev/null
2009-04-16 02:13:17 +00:00
JAVA_RESULT=$?
if [ $JAVA_RESULT -ne 0 ]; then
echo "Could not compile generated classes."
exit $JAVA_RESULT
fi
2009-03-04 03:31:44 +00:00
rm -rf generated
mkdir -p generated/C
cp out/com_google_android_gles_jni_GLImpl.cpp generated/C
cp -r out/com generated
cp -r out/javax generated
2009-04-16 02:13:17 +00:00
cp out/android_opengl_*.cpp generated/C
mkdir -p generated/android/opengl
cp -r out/android/opengl generated/android
2009-03-04 03:31:44 +00:00
rm -rf out
2009-04-02 20:38:26 +00:00
KEEP_GENERATED=0
2009-04-16 02:13:17 +00:00
SAID_PLEASE=0
# compareGenerated destDir generatedDir file
compareGenerated() {
if cmp -s $1/$3 $2/$3 ; then
echo "# " $3 unchanged
else
2012-06-15 23:22:43 +00:00
echo "# " $3 changed
2009-04-16 02:13:17 +00:00
if [ $SAID_PLEASE == "0" ] ; then
echo Please evaluate the following commands:
echo
SAID_PLEASE=1
fi
echo " " cp $2/$3 $1
echo " " git add $1/$3
KEEP_GENERATED=1
fi
}
2012-06-15 23:22:43 +00:00
compareGenerated ../../../../base/core/jni generated/C com_google_android_gles_jni_GLImpl.cpp
compareGenerated ../../../../base/opengl/java/com/google/android/gles_jni generated/com/google/android/gles_jni GLImpl.java
2009-04-16 02:13:17 +00:00
for x in GL.java GL10.java GL10Ext.java GL11.java GL11Ext.java GL11ExtensionPack.java
do
2012-06-15 23:22:43 +00:00
compareGenerated ../../../../base/opengl/java/javax/microedition/khronos/opengles generated/javax/microedition/khronos/opengles $x
2009-04-16 02:13:17 +00:00
done
2012-06-15 23:22:43 +00:00
for x in EGL14 GLES10 GLES10Ext GLES11 GLES11Ext GLES20
2009-04-16 02:13:17 +00:00
do
2012-06-15 23:22:43 +00:00
compareGenerated ../../../../base/opengl/java/android/opengl generated/android/opengl ${x}.java
compareGenerated ../../../../base/core/jni generated/C android_opengl_${x}.cpp
2009-04-16 02:13:17 +00:00
done
2009-03-04 03:31:44 +00:00
2009-04-02 20:38:26 +00:00
if [ $KEEP_GENERATED == "0" ] ; then
2009-04-16 02:13:17 +00:00
rm -rf generated
2009-04-02 20:38:26 +00:00
fi