97b7dd7cb44de569fc3e8c01c39d5bbf159a0fe4
[iec.git] / src / type3_AndroidCloud / anbox-master / scripts / update-emugl-sources.sh
1 #!/bin/sh
2
3 # Copyright 2014 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
18 set -e
19
20 export LANG=C
21 export LC_ALL=C
22
23 PROGDIR=$(dirname "$0")
24 PROGNAME=$(basename "$0")
25
26 fatal () {
27     echo "ERROR: $@"
28     exit 1
29 }
30
31 ANBOX_DIR="$PWD"
32
33 OPT_ANBOX_DIR=
34 OPT_EMUGEN=
35 OPT_HELP=
36
37 for OPT; do
38     OPTARG=$(expr "x$OPT" : "x[^=]*=\\(.*\\)" || true)
39     case $OPT in
40     --help|-h|-\?)
41         OPT_HELP=true
42         ;;
43     --anbox-dir=*)
44         OPT_ANBOX_DIR=$OPTARG
45         ;;
46     --emugen=*)
47         OPT_EMUGEN=$OPTARG
48         ;;
49     -*)
50         fatal "Invalid option '$OPT', see --help."
51         ;;
52     *)
53         fatal "This script doesn't take arguments, see --help."
54         ;;
55     esac
56 done
57
58 if [ "$OPT_HELP" ]; then
59     cat <<EOF
60 Usage: $PROGNAME [options]
61
62 Update the sources of the GPU emulation encoder and decoder, after an update
63 to the 'emugen' tool.
64
65 Valid options (defaults are in brackets):
66     --help|-h|-?         Print this help.
67     --anbox-dir=<dir>    Specify top-level Anbox directory [$ANBOX_DIR].
68     --emugen=<program>   Emugen program path, if not in path.
69 EOF
70     exit 0
71 fi
72
73 EMUGEN=
74 if [ "$OPT_EMUGEN" ]; then
75     EMUGEN=$OPT_EMUGEN
76     if [ ! -f "$EMUGEN" ]; then
77         fatal "Missing emugen binary: $EMUGEN"
78     fi
79 else
80     EMUGEN=$PROGDIR/../../../objs/build/intermediates64/emugen/emugen
81     if [ ! -f "$EMUGEN" ]; then
82         fatal "Missing emugen binary: $EMUGEN, please build it or use --emugen=<program>"
83     fi
84     echo "Auto-config: --emugen=$EMUGEN"
85 fi
86
87 if [ "$OPT_ANBOX_DIR" ]; then
88     ANBOX_DIR=$OPT_ANBOX_DIR
89 else
90     echo "Auto-config: --anbox-dir=$ANBOX_DIR"
91 fi
92 if [ ! -d "$ANBOX_DIR/src/anbox" ]; then
93     fatal "Not an Anbox directory: $ANBOX_DIR"
94 fi
95
96 ANBOX_DIR=$(cd "$ANBOX_DIR" && pwd -P)
97
98 # Find the sources for the encoder:
99 ENCODER_TOP_DIR=$ANBOX_DIR/android/opengl/system
100 DECODER_TOP_DIR=$ANBOX_DIR/external/android-emugl/host/libs
101
102 if [ ! -d "$ENCODER_TOP_DIR" ]; then
103     fatal "Missing encoder source directory: $ENCODER_TOP_DIR"
104 fi
105 if [ ! -d "$DECODER_TOP_DIR" ]; then
106     fatal "Missing decoder source directory: $DECODER_TOP_DIR"
107 fi
108
109 # GLESv1 encoder
110 GLESv1_INPUT_DIR=$DECODER_TOP_DIR/GLESv1_dec
111 GLESv2_INPUT_DIR=$DECODER_TOP_DIR/GLESv2_dec
112 RENDERCONTROL_INPUT_DIR=$DECODER_TOP_DIR/renderControl_dec
113
114 # The encoder has prefix GL while decoder has GLES
115 cp -f $DECODER_TOP_DIR/GLESv1_dec/gles1.attrib $DECODER_TOP_DIR/GLESv1_dec/gl.attrib
116 cp -f $DECODER_TOP_DIR/GLESv1_dec/gles1.in $DECODER_TOP_DIR/GLESv1_dec/gl.in
117 cp -f $DECODER_TOP_DIR/GLESv1_dec/gles1.types $DECODER_TOP_DIR/GLESv1_dec/gl.types
118
119 cp -f $DECODER_TOP_DIR/GLESv2_dec/gles2.attrib $DECODER_TOP_DIR/GLESv2_dec/gl2.attrib
120 cp -f $DECODER_TOP_DIR/GLESv2_dec/gles2.in $DECODER_TOP_DIR/GLESv2_dec/gl2.in
121 cp -f $DECODER_TOP_DIR/GLESv2_dec/gles2.types $DECODER_TOP_DIR/GLESv2_dec/gl2.types
122
123 $EMUGEN -i $DECODER_TOP_DIR/GLESv1_dec -E $ENCODER_TOP_DIR/GLESv1_enc gl
124 $EMUGEN -i $DECODER_TOP_DIR/GLESv2_dec -E $ENCODER_TOP_DIR/GLESv2_enc gl2
125 $EMUGEN -i $DECODER_TOP_DIR/renderControl_dec -E $ENCODER_TOP_DIR/renderControl_enc renderControl
126
127 rm $DECODER_TOP_DIR/GLESv1_dec/gl.attrib
128 rm $DECODER_TOP_DIR/GLESv1_dec/gl.in
129 rm $DECODER_TOP_DIR/GLESv1_dec/gl.types
130
131 rm $DECODER_TOP_DIR/GLESv2_dec/gl2.attrib
132 rm $DECODER_TOP_DIR/GLESv2_dec/gl2.in
133 rm $DECODER_TOP_DIR/GLESv2_dec/gl2.types
134
135 echo "Done, see $ENCODER_TOP_DIR"
136 exit 0