blob: feef20737dc46f2ccb4972f08d083c5d23f7ee33 [file] [log] [blame]
# Copyright 2015 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
shell_import utils/aosp_dir.shi
shell_import utils/option_parser.shi
# Default location of prebuilts directory.
DEFAULT_PREBUILTS_DIR=/tmp/$USER-emulator-prebuilts
prebuilts_dir_register_option () {
OPT_PREBUILTS_DIR=
option_register_var "--prebuilts-dir=<dir>" OPT_PREBUILTS_DIR \
"Specify prebuilts root directory [$DEFAULT_PREBUILTS_DIR]"
}
prebuilts_dir_parse_option () {
if [ "$OPT_PREBUILTS_DIR" ]; then
PREBUILTS_DIR=$OPT_PREBUILTS_DIR
log "Using prebuilts dir: $PREBUILTS_DIR"
elif [ "$ANDROID_EMULATOR_PREBUILTS_DIR" ]; then
PREBUILTS_DIR=$ANDROID_EMULATOR_PREBUILTS_DIR
log "Auto-config: --prebuilts-dir=$PREBUILTS_DIR [environment]"
else
local AOSP_TOP
AOSP_TOP=$(aosp_find_top_dir_from "$(program_directory)")
if [ -z "$AOSP_TOP" ]; then
panic "Could not find AOSP top-level directory. Please use --prebuilts-dir=<dir>."
fi
PREBUILTS_DIR=$AOSP_TOP/prebuilts/android-emulator-build
if [ ! -d "$PREBUILTS_DIR" ]; then
panic "Missing directory, please use --prebuilts-dir=<dir>: [$PREBUILTS_DIR]"
fi
log "Auto-config: --prebuilts-dir=$PREBUILTS_DIR [default]"
fi
}