Home | History | Annotate | Download | only in Renderscript
      1 #!/bin/bash
      2 
      3 # This shell script automatically extracts RenderScript stub functions .
      4 # To regenerate files RSStubsWhiteList.{cpp,h} run the following command
      5 # sh generate-whitelist.sh RSStubsWhiteList $ANDROID_BUILD_TOP/frameworks/rs/driver/rsdRuntimeStubs.cpp $ANDROID_BUILD_TOP/frameworks/rs/cpu_ref/rsCpuRuntimeStubs.cpp $ANDROID_BUILD_TOP/frameworks/rs/cpu_ref/rsCpuRuntimeMath.cpp
      6 
      7 OUT_PATH_PREFIX=$1
      8 OUT_PREFIX=`basename $OUT_PATH_PREFIX`
      9 STUB_FILES=${@:2}
     10 
     11 whitelist=`grep "{ \"_Z" $STUB_FILES | awk '{print $3}' | sort | uniq`
     12 
     13 OUT_HEADER=$OUT_PATH_PREFIX\.h
     14 OUT_CPP=$OUT_PATH_PREFIX\.cpp
     15 
     16 read -d '' COPYRIGHT << EOF
     17 /*
     18  * Copyright 2014, The Android Open Source Project
     19  *
     20  * Licensed under the Apache License, Version 2.0 (the "License");
     21  * you may not use this file except in compliance with the License.
     22  * You may obtain a copy of the License at
     23  *
     24  *     http://www.apache.org/licenses/LICENSE-2.0
     25  *
     26  * Unless required by applicable law or agreed to in writing, software
     27  * distributed under the License is distributed on an "AS IS" BASIS,
     28  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     29  * See the License for the specific language governing permissions and
     30  * limitations under the License.
     31  */
     32 EOF
     33 
     34 
     35 cat > $OUT_HEADER << EOF
     36 $COPYRIGHT
     37 
     38 #ifndef ${OUT_PREFIX}_H
     39 #define ${OUT_PREFIX}_H
     40 
     41 #include <cstdlib>
     42 #include <vector>
     43 #include <string>
     44 
     45 extern std::vector<std::string> stubList;
     46 
     47 #endif // ${OUT_PREFIX}_H
     48 EOF
     49 
     50 cat > $OUT_CPP  << EOF
     51 $COPYRIGHT
     52 
     53 #include "$OUT_PREFIX.h"
     54 
     55 std::vector<std::string> stubList = {
     56 $whitelist
     57 };
     58 EOF
     59 
     60 echo Wrote to $OUT_HEADER $OUT_CPP
     61