1#!/usr/bin/env bash 2# 3# Copyright 2016 - 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 18set -e 19 20TOOLS_DIR=$(realpath $(dirname $0)) 21LTP_ANDROID_DIR=$(realpath $TOOLS_DIR/..) 22LTP_ROOT=$(realpath $LTP_ANDROID_DIR/..) 23CUSTOM_CFLAGS_PATH=$TOOLS_DIR/custom_cflags.json 24OUTPUT_MK=$LTP_ANDROID_DIR/Android.ltp.mk 25OUTPUT_PLIST=$LTP_ANDROID_DIR/ltp_package_list.mk 26OUTPUT_BP=$LTP_ROOT/gen.bp 27 28export PYTHONDONTWRITEBYTECODE=1 29 30cd $TOOLS_DIR 31 32case $1 in 33 -u|--update) 34 echo "Update option enabled. Regenerating..." 35 rm -rf *.dump 36 ;; 37 -h|--help) 38 echo "Generate Android.ltp.mk / gen.bp." 39 echo "Please use \"--update\" option to update and regenerate Android.ltp.mk / gen.bp." 40 exit 0 41 ;; 42esac 43 44if ! [ -f $TOOLS_DIR/make_dry_run.dump ]; then 45 DOCKER_USERNAME=$(id -un) 46 DOCKER_UID=$(id -u) 47 DOCKER_GID=$(id -g) 48 49 echo "LTP make dry_run not dumped. Dumping..." 50 echo "" 51 echo "This may need your sudo password in order to access docker:" 52 set -x 53 sudo docker build --build-arg userid=$DOCKER_UID --build-arg groupid=$DOCKER_GID --build-arg username=$DOCKER_USERNAME --build-arg ltproot=$LTP_ROOT -t android-gen-ltp . 54 sudo docker run -it --rm -v $LTP_ROOT:/src -w /src/android/tools android-gen-ltp 55 set +x 56fi 57 58cat $LTP_ANDROID_DIR/AOSP_license_text.txt > $OUTPUT_MK 59echo "" >> $OUTPUT_MK 60echo "# This file is autogenerated by $(basename $0)" >> $OUTPUT_MK 61echo "" >> $OUTPUT_MK 62 63cat $LTP_ANDROID_DIR/AOSP_license_text.txt > $OUTPUT_PLIST 64echo "" >> $OUTPUT_PLIST 65echo "# This file is autogenerated by $(basename $0)" >> $OUTPUT_PLIST 66echo "" >> $OUTPUT_PLIST 67 68sed "s%#%//%" $LTP_ANDROID_DIR/AOSP_license_text.txt > $OUTPUT_BP 69echo "" >> $OUTPUT_BP 70echo "// This file is autogenerated by $(basename $0)" >> $OUTPUT_BP 71echo "" >> $OUTPUT_BP 72 73python android_build_generator.py --ltp_root $LTP_ROOT --output_mk_path $OUTPUT_MK \ 74 --output_bp_path $OUTPUT_BP --output_plist_path $OUTPUT_PLIST \ 75 --custom_cflags_file $CUSTOM_CFLAGS_PATH 76