blob: c7361964cf52131132da0d62e00e70df6dc80b59 [file] [log] [blame]
#!/bin/sh
# 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
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Functions used to handle an --install-dir=<dir> option, this can be used
# to specify an installation path under <prebuilts>/
#
# Usage:
#
# 1) Call 'install_dir_register_option <name>' to register the option
# and use '<prebuilts>/<name>' as the default location. If <name> is
# empty, then '<prebuilts>/install' will be used as the default.
#
# 2) After parsing the options, and _after_ 'prebuilts_dir_parse_option',
# call 'install_dir_parse_option'. This will define the INSTALL_DIR
# global variable correspoinding to your installation directory.
#
# $1: installation sub-directory. Optional, default is 'install'
install_dir_register_option () {
DEFAULT_INSTALL_SUBDIR=${1:-install}
option_register_var "--install-dir=<dir>" OPT_INSTALL_DIR \
"Set installation directory [<prebuilts>/$DEFAULT_INSTALL_SUBDIR]"
}
install_dir_parse_option () {
if [ "$OPT_INSTALL_DIR" ]; then
INSTALL_DIR=$OPT_INSTALL_DIR
log "Using install dir: $INSTALL_DIR"
else
INSTALL_DIR=$PREBUILTS_DIR/$DEFAULT_INSTALL_SUBDIR
log "Auto-config: --install-dir=$INSTALL_DIR [default]"
fi
}