blob: 31f41906ff25895bccdfecf0b1f33b75373d8d72 [file] [log] [blame]
Jack Palevich4e70a9e2009-04-14 19:00:09 -07001#!/bin/bash
2set -u
Jack Palevich27f80022009-04-15 19:13:17 -07003set -e
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004rm -rf out generated
5
6mkdir out
Jack Palevich91a27ae2009-06-15 21:03:24 -07007
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 Project9066cfe2009-03-03 19:31:44 -080011mkdir -p out/javax/microedition/khronos/opengles
12mkdir -p out/com/google/android/gles_jni
Jack Palevich91a27ae2009-06-15 21:03:24 -070013mkdir -p out/android/app
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080014mkdir -p out/android/graphics
Jack Palevich27f80022009-04-15 19:13:17 -070015mkdir -p out/android/opengl
Jack Palevich91a27ae2009-06-15 21:03:24 -070016mkdir -p out/android/content
17mkdir -p out/android/content/pm
18mkdir -p out/android/os
19mkdir -p out/android/util
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080020
21echo "package android.graphics;" > out/android/graphics/Canvas.java
22echo "public interface Canvas {}" >> out/android/graphics/Canvas.java
23
Elliott Hughes24ce5fb2011-04-08 20:01:01 -070024echo "package android.app; import android.content.pm.IPackageManager; public class AppGlobals { public static IPackageManager getPackageManager() { return null;} }" > out/android/app/AppGlobals.java
Jack Palevich91a27ae2009-06-15 21:03:24 -070025# echo "package android.content; import android.content.pm.PackageManager; public interface Context { public PackageManager getPackageManager(); }" > out/android/content/Context.java
26echo "package android.content.pm; public class ApplicationInfo {public int targetSdkVersion;}" > out/android/content/pm/ApplicationInfo.java
27echo "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
28echo "package android.os; public class Build {public static class VERSION_CODES { public static final int CUPCAKE = 3;}; }" > out/android/os/Build.java
29echo "package android.os; public class RemoteException extends Exception {}" > out/android/os/RemoteException.java
30echo "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 Project9066cfe2009-03-03 19:31:44 -080032GLFILE=out/javax/microedition/khronos/opengles/GL.java
Jack Palevich27f80022009-04-15 19:13:17 -070033cp stubs/jsr239/GLHeader.java-if $GLFILE
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080034
Jack Palevich27f80022009-04-15 19:13:17 -070035GLGEN_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 Project9066cfe2009-03-03 19:31:44 -080036
37pushd src > /dev/null
38javac ${GLGEN_FILES}
Jack Palevich4e70a9e2009-04-14 19:00:09 -070039JAVAC_RESULT=$?
40if [ $JAVAC_RESULT -ne 0 ]; then
41 echo "Could not compile glgen."
42 exit $JAVAC_RESULT
43fi
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080044popd > /dev/null
Jack Palevich27f80022009-04-15 19:13:17 -070045
46echo "Generating JSR239-like APIs"
47java -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
48JAVA_RESULT=$?
49if [ $JAVA_RESULT -ne 0 ]; then
50 echo "Could not run GenerateGL."
51 exit $JAVA_RESULT
52fi
53
54echo "Generating static OpenGLES 1.1 bindings"
55java -classpath src GenerateGLES
56JAVA_RESULT=$?
57if [ $JAVA_RESULT -ne 0 ]; then
58 echo "Could not run GenerateGLES."
59 exit $JAVA_RESULT
60fi
61
Jack Palevich4e70a9e2009-04-14 19:00:09 -070062rm src/*.class
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080063
64pushd out > /dev/null
65mkdir classes
Jack Palevich560814f2009-11-19 16:34:55 +080066javac -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 Project9066cfe2009-03-03 19:31:44 -080067popd > /dev/null
Jack Palevich27f80022009-04-15 19:13:17 -070068JAVA_RESULT=$?
69if [ $JAVA_RESULT -ne 0 ]; then
70 echo "Could not compile generated classes."
71 exit $JAVA_RESULT
72fi
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080073
74rm -rf generated
75mkdir -p generated/C
76cp out/com_google_android_gles_jni_GLImpl.cpp generated/C
77cp -r out/com generated
78cp -r out/javax generated
79
Jack Palevich27f80022009-04-15 19:13:17 -070080cp out/android_opengl_*.cpp generated/C
81mkdir -p generated/android/opengl
82cp -r out/android/opengl generated/android
83
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080084rm -rf out
Jack Palevichc005f8b2009-04-02 13:38:26 -070085KEEP_GENERATED=0
Jack Palevich27f80022009-04-15 19:13:17 -070086SAID_PLEASE=0
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080087
Jack Palevich27f80022009-04-15 19:13:17 -070088# compareGenerated destDir generatedDir file
89compareGenerated() {
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 Project9066cfe2009-03-03 19:31:44 -0800103
Jack Palevich27f80022009-04-15 19:13:17 -0700104compareGenerated ../../../core/jni generated/C com_google_android_gles_jni_GLImpl.cpp
105compareGenerated ../../java/com/google/android/gles_jni generated/com/google/android/gles_jni GLImpl.java
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800106
Jack Palevich27f80022009-04-15 19:13:17 -0700107for x in GL.java GL10.java GL10Ext.java GL11.java GL11Ext.java GL11ExtensionPack.java
108do
109 compareGenerated ../../java/javax/microedition/khronos/opengles generated/javax/microedition/khronos/opengles $x
110done
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800111
Jack Palevich560814f2009-11-19 16:34:55 +0800112for x in GLES10 GLES10Ext GLES11 GLES11Ext GLES20
Jack Palevich27f80022009-04-15 19:13:17 -0700113do
114 compareGenerated ../../java/android/opengl generated/android/opengl ${x}.java
115 compareGenerated ../../../core/jni generated/C android_opengl_${x}.cpp
116done
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800117
Jack Palevichc005f8b2009-04-02 13:38:26 -0700118if [ $KEEP_GENERATED == "0" ] ; then
Jack Palevich27f80022009-04-15 19:13:17 -0700119 rm -rf generated
Jack Palevichc005f8b2009-04-02 13:38:26 -0700120fi