TYPE3
[iec.git] / src / type3_AndroidCloud / anbox-master / scripts / gen-emugl-headers.sh
1 #!/bin/sh
2
3 # Copyright (C) 2015 The Android Open Source Project
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 # Run this script to re-generate headers with the gen-entries.py script.
18
19 set -e
20 export LANG=C
21 export LC_ALL=C
22
23 PROGDIR=$(dirname "$0")
24 OUTDIR=$1
25
26 panic () {
27     echo "ERROR: $@"
28     exit 1
29 }
30
31 if [ -z "$OUTDIR" ]; then
32     panic "No output dir defined!"
33 fi
34
35 QEMU_TOP_DIR=$(cd $PROGDIR/../ && pwd -P)
36 SCRIPT_DIR=scripts
37 if [ ! -d "$QEMU_TOP_DIR/$SCRIPT_DIR" ]; then
38     panic "Missing scripts directory: $QEMU_TOP_DIR/$SCRIPT_DIR"
39 fi
40
41 cd $QEMU_TOP_DIR
42 GEN_ENTRIES=$SCRIPT_DIR/gen-emugl-entries.py
43 if [ ! -f "$GEN_ENTRIES" ]; then
44     panic "Missing script: $GEN_ENTRIES"
45 fi
46
47 FAILURES=
48
49 # $1: Source file
50 # $2: Target file
51 # $3: gen-entries script.
52 gen_functions_header () {
53     local SRC_FILE="$1"
54     local DST_FILE="$2"
55     local GEN_ENTRIES="$3"
56     if [ ! -f "$SRC_FILE" ]; then
57         echo "ERROR: Missing source file: $SRC_FILE"
58         FAILURES=true
59     else
60         echo "Generating $DST_FILE"
61         $GEN_ENTRIES --mode=functions $SRC_FILE --output=$DST_FILE
62     fi
63 }
64
65 # $1: Source file
66 # $2: Target file
67 # $3: gen-entries script.
68 gen_funcargs_header () {
69     local SRC_FILE="$1"
70     local DST_FILE="$2"
71     local GEN_ENTRIES="$3"
72     if [ ! -f "$SRC_FILE" ]; then
73         echo "ERROR: Missing source file: $SRC_FILE"
74         FAILURES=true
75     else
76         echo "Generating $DST_FILE"
77         $GEN_ENTRIES --mode=funcargs $SRC_FILE --output=$DST_FILE
78     fi
79 }
80
81
82 ##
83 ## libOpenGLESDispatch headers.
84 ##
85 OPENGLES_DISPATCH_SRCDIR=external/android-emugl/host/libs/libOpenGLESDispatch
86 OPENGLES_DISPATCH_INCLUDE=$OUTDIR/external/android-emugl/host/include/OpenGLESDispatch
87 mkdir -p $OPENGLES_DISPATCH_INCLUDE
88
89 gen_functions_header \
90         "$OPENGLES_DISPATCH_SRCDIR"/render_egl.entries \
91         "$OPENGLES_DISPATCH_INCLUDE"/RenderEGL_functions.h \
92         "$GEN_ENTRIES"
93
94 gen_functions_header \
95         "$OPENGLES_DISPATCH_SRCDIR"/render_egl_extensions.entries \
96         "$OPENGLES_DISPATCH_INCLUDE"/RenderEGL_extensions_functions.h \
97         "$GEN_ENTRIES"
98
99 GLES_ENTRIES="gles_common gles_extensions gles1_only gles1_extensions gles2_only \
100 gles2_extensions gles3_only"
101
102 for ENTRY in $GLES_ENTRIES; do
103     SRC_FILE=$OPENGLES_DISPATCH_SRCDIR/${ENTRY}.entries
104     DST_FILE=$OPENGLES_DISPATCH_INCLUDE/${ENTRY}_functions.h
105     gen_funcargs_header "$SRC_FILE" "$DST_FILE" "$GEN_ENTRIES"
106 done
107
108 if [ "$FAILURES" ]; then
109     exit 1
110 fi