c079fe787627965a6b482d965a7651002081802b
[iec.git] / src / type3_AndroidCloud / anbox-master / external / android-emugl / scripts / gen-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
25 panic () {
26     echo "ERROR: $@"
27     exit 1
28 }
29
30 QEMU_TOP_DIR=$(cd $PROGDIR/../../.. && pwd -P)
31 SCRIPT_DIR=android/scripts
32 if [ ! -d "$QEMU_TOP_DIR/$SCRIPT_DIR" ]; then
33     panic "Missing scripts directory: $QEMU_TOP_DIR/$SCRIPT_DIR"
34 fi
35
36 cd $QEMU_TOP_DIR
37 GEN_ENTRIES=$SCRIPT_DIR/gen-entries.py
38 if [ ! -f "$GEN_ENTRIES" ]; then
39     panic "Missing script: $GEN_ENTRIES"
40 fi
41
42 FAILURES=
43
44 # $1: Source file
45 # $2: Target file
46 # $3: gen-entries script.
47 gen_functions_header () {
48     local SRC_FILE="$1"
49     local DST_FILE="$2"
50     local GEN_ENTRIES="$3"
51     if [ ! -f "$SRC_FILE" ]; then
52         echo "ERROR: Missing source file: $SRC_FILE"
53         FAILURES=true
54     else
55         echo "Generating $DST_FILE"
56         $GEN_ENTRIES --mode=functions $SRC_FILE --output=$DST_FILE
57     fi
58 }
59
60 # $1: Source file
61 # $2: Target file
62 # $3: gen-entries script.
63 gen_funcargs_header () {
64     local SRC_FILE="$1"
65     local DST_FILE="$2"
66     local GEN_ENTRIES="$3"
67     if [ ! -f "$SRC_FILE" ]; then
68         echo "ERROR: Missing source file: $SRC_FILE"
69         FAILURES=true
70     else
71         echo "Generating $DST_FILE"
72         $GEN_ENTRIES --mode=funcargs $SRC_FILE --output=$DST_FILE
73     fi
74 }
75
76
77 ##
78 ##  libOpenglRender headers.
79 ##
80 LIBRENDER_DIR=distrib/android-emugl/host/libs/libOpenglRender
81 LIBRENDER_INCLUDE=distrib/android-emugl/host/include/OpenglRender
82 gen_funcargs_header \
83         "$LIBRENDER_DIR"/render_api.entries \
84         "$LIBRENDER_INCLUDE"/render_api_functions.h \
85         "$GEN_ENTRIES"
86
87 ##
88 ## libOpenGLESDispatch headers.
89 ##
90 OPENGLES_DISPATCH_SRCDIR=distrib/android-emugl/host/libs/libOpenGLESDispatch
91 OPENGLES_DISPATCH_INCLUDE=distrib/android-emugl/host/include/OpenGLESDispatch
92
93 gen_functions_header \
94         "$OPENGLES_DISPATCH_SRCDIR"/render_egl.entries \
95         "$OPENGLES_DISPATCH_INCLUDE"/RenderEGL_functions.h \
96         "$GEN_ENTRIES"
97
98 gen_functions_header \
99         "$OPENGLES_DISPATCH_SRCDIR"/render_egl_extensions.entries \
100         "$OPENGLES_DISPATCH_INCLUDE"/RenderEGL_extensions_functions.h \
101         "$GEN_ENTRIES"
102
103 GLES_ENTRIES="gles_common gles_extensions gles1_only gles1_extensions gles2_only \
104 gles2_extensions gles3_only"
105
106 for ENTRY in $GLES_ENTRIES; do
107     SRC_FILE=$OPENGLES_DISPATCH_SRCDIR/${ENTRY}.entries
108     DST_FILE=$OPENGLES_DISPATCH_INCLUDE/${ENTRY}_functions.h
109     gen_funcargs_header "$SRC_FILE" "$DST_FILE" "$GEN_ENTRIES"
110 done
111
112 if [ "$FAILURES" ]; then
113     exit 1
114 fi