Jack Palevich | 4e70a9e | 2009-04-14 19:00:09 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | set -u |
Jack Palevich | 27f8002 | 2009-04-15 19:13:17 -0700 | [diff] [blame] | 3 | set -e |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 4 | rm -rf out generated |
| 5 | |
| 6 | mkdir out |
Jack Palevich | 91a27ae | 2009-06-15 21:03:24 -0700 | [diff] [blame] | 7 | |
| 8 | # Create dummy Java files for Android APIs that are used by the code we generate. |
| 9 | # This allows us to test the generated code without building the rest of Android. |
| 10 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 11 | mkdir -p out/javax/microedition/khronos/opengles |
| 12 | mkdir -p out/com/google/android/gles_jni |
Jack Palevich | 91a27ae | 2009-06-15 21:03:24 -0700 | [diff] [blame] | 13 | mkdir -p out/android/app |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 14 | mkdir -p out/android/graphics |
Jack Palevich | 27f8002 | 2009-04-15 19:13:17 -0700 | [diff] [blame] | 15 | mkdir -p out/android/opengl |
Jack Palevich | 91a27ae | 2009-06-15 21:03:24 -0700 | [diff] [blame] | 16 | mkdir -p out/android/content |
| 17 | mkdir -p out/android/content/pm |
| 18 | mkdir -p out/android/os |
| 19 | mkdir -p out/android/util |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 20 | |
| 21 | echo "package android.graphics;" > out/android/graphics/Canvas.java |
| 22 | echo "public interface Canvas {}" >> out/android/graphics/Canvas.java |
| 23 | |
Elliott Hughes | 24ce5fb | 2011-04-08 20:01:01 -0700 | [diff] [blame] | 24 | echo "package android.app; import android.content.pm.IPackageManager; public class AppGlobals { public static IPackageManager getPackageManager() { return null;} }" > out/android/app/AppGlobals.java |
Jack Palevich | 91a27ae | 2009-06-15 21:03:24 -0700 | [diff] [blame] | 25 | # echo "package android.content; import android.content.pm.PackageManager; public interface Context { public PackageManager getPackageManager(); }" > out/android/content/Context.java |
| 26 | echo "package android.content.pm; public class ApplicationInfo {public int targetSdkVersion;}" > out/android/content/pm/ApplicationInfo.java |
| 27 | echo "package android.content.pm; public interface IPackageManager {ApplicationInfo getApplicationInfo(java.lang.String packageName, int flags) throws android.os.RemoteException;}" > out/android/content/pm/IPackageManager.java |
| 28 | echo "package android.os; public class Build {public static class VERSION_CODES { public static final int CUPCAKE = 3;}; }" > out/android/os/Build.java |
| 29 | echo "package android.os; public class RemoteException extends Exception {}" > out/android/os/RemoteException.java |
| 30 | 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 |
| 31 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 32 | GLFILE=out/javax/microedition/khronos/opengles/GL.java |
Jack Palevich | 27f8002 | 2009-04-15 19:13:17 -0700 | [diff] [blame] | 33 | cp stubs/jsr239/GLHeader.java-if $GLFILE |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 34 | |
Jack Palevich | 27f8002 | 2009-04-15 19:13:17 -0700 | [diff] [blame] | 35 | GLGEN_FILES="CFunc.java CType.java CodeEmitter.java GenerateGL.java GenerateGLES.java GLESCodeEmitter.java JFunc.java JniCodeEmitter.java JType.java Jsr239CodeEmitter.java ParameterChecker.java" |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 36 | |
| 37 | pushd src > /dev/null |
| 38 | javac ${GLGEN_FILES} |
Jack Palevich | 4e70a9e | 2009-04-14 19:00:09 -0700 | [diff] [blame] | 39 | JAVAC_RESULT=$? |
| 40 | if [ $JAVAC_RESULT -ne 0 ]; then |
| 41 | echo "Could not compile glgen." |
| 42 | exit $JAVAC_RESULT |
| 43 | fi |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 44 | popd > /dev/null |
Jack Palevich | 27f8002 | 2009-04-15 19:13:17 -0700 | [diff] [blame] | 45 | |
| 46 | echo "Generating JSR239-like APIs" |
| 47 | 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 |
| 48 | JAVA_RESULT=$? |
| 49 | if [ $JAVA_RESULT -ne 0 ]; then |
| 50 | echo "Could not run GenerateGL." |
| 51 | exit $JAVA_RESULT |
| 52 | fi |
| 53 | |
| 54 | echo "Generating static OpenGLES 1.1 bindings" |
| 55 | java -classpath src GenerateGLES |
| 56 | JAVA_RESULT=$? |
| 57 | if [ $JAVA_RESULT -ne 0 ]; then |
| 58 | echo "Could not run GenerateGLES." |
| 59 | exit $JAVA_RESULT |
| 60 | fi |
| 61 | |
Jack Palevich | 4e70a9e | 2009-04-14 19:00:09 -0700 | [diff] [blame] | 62 | rm src/*.class |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 63 | |
| 64 | pushd out > /dev/null |
| 65 | mkdir classes |
Jack Palevich | 560814f | 2009-11-19 16:34:55 +0800 | [diff] [blame] | 66 | javac -d classes 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 |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 67 | popd > /dev/null |
Jack Palevich | 27f8002 | 2009-04-15 19:13:17 -0700 | [diff] [blame] | 68 | JAVA_RESULT=$? |
| 69 | if [ $JAVA_RESULT -ne 0 ]; then |
| 70 | echo "Could not compile generated classes." |
| 71 | exit $JAVA_RESULT |
| 72 | fi |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 73 | |
| 74 | rm -rf generated |
| 75 | mkdir -p generated/C |
| 76 | cp out/com_google_android_gles_jni_GLImpl.cpp generated/C |
| 77 | cp -r out/com generated |
| 78 | cp -r out/javax generated |
| 79 | |
Jack Palevich | 27f8002 | 2009-04-15 19:13:17 -0700 | [diff] [blame] | 80 | cp out/android_opengl_*.cpp generated/C |
| 81 | mkdir -p generated/android/opengl |
| 82 | cp -r out/android/opengl generated/android |
| 83 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 84 | rm -rf out |
Jack Palevich | c005f8b | 2009-04-02 13:38:26 -0700 | [diff] [blame] | 85 | KEEP_GENERATED=0 |
Jack Palevich | 27f8002 | 2009-04-15 19:13:17 -0700 | [diff] [blame] | 86 | SAID_PLEASE=0 |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 87 | |
Jack Palevich | 27f8002 | 2009-04-15 19:13:17 -0700 | [diff] [blame] | 88 | # compareGenerated destDir generatedDir file |
| 89 | compareGenerated() { |
| 90 | if cmp -s $1/$3 $2/$3 ; then |
| 91 | echo "# " $3 unchanged |
| 92 | else |
| 93 | if [ $SAID_PLEASE == "0" ] ; then |
| 94 | echo Please evaluate the following commands: |
| 95 | echo |
| 96 | SAID_PLEASE=1 |
| 97 | fi |
| 98 | echo " " cp $2/$3 $1 |
| 99 | echo " " git add $1/$3 |
| 100 | KEEP_GENERATED=1 |
| 101 | fi |
| 102 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 103 | |
Jack Palevich | 27f8002 | 2009-04-15 19:13:17 -0700 | [diff] [blame] | 104 | compareGenerated ../../../core/jni generated/C com_google_android_gles_jni_GLImpl.cpp |
| 105 | compareGenerated ../../java/com/google/android/gles_jni generated/com/google/android/gles_jni GLImpl.java |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 106 | |
Jack Palevich | 27f8002 | 2009-04-15 19:13:17 -0700 | [diff] [blame] | 107 | for x in GL.java GL10.java GL10Ext.java GL11.java GL11Ext.java GL11ExtensionPack.java |
| 108 | do |
| 109 | compareGenerated ../../java/javax/microedition/khronos/opengles generated/javax/microedition/khronos/opengles $x |
| 110 | done |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 111 | |
Jack Palevich | 560814f | 2009-11-19 16:34:55 +0800 | [diff] [blame] | 112 | for x in GLES10 GLES10Ext GLES11 GLES11Ext GLES20 |
Jack Palevich | 27f8002 | 2009-04-15 19:13:17 -0700 | [diff] [blame] | 113 | do |
| 114 | compareGenerated ../../java/android/opengl generated/android/opengl ${x}.java |
| 115 | compareGenerated ../../../core/jni generated/C android_opengl_${x}.cpp |
| 116 | done |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 117 | |
Jack Palevich | c005f8b | 2009-04-02 13:38:26 -0700 | [diff] [blame] | 118 | if [ $KEEP_GENERATED == "0" ] ; then |
Jack Palevich | 27f8002 | 2009-04-15 19:13:17 -0700 | [diff] [blame] | 119 | rm -rf generated |
Jack Palevich | c005f8b | 2009-04-02 13:38:26 -0700 | [diff] [blame] | 120 | fi |