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