blob: e3e9dc774f44b553fcd5958a9b1f805918244363 [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
#
# 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 manage --aosp-prebuilts-dir=<dir> and
# --no-aosp-prebuilts options.
shell_import utils/option_parser.shi
aosp_prebuilts_dir_register_options () {
AOSP_PREBUILTS_DIR=
OPT_AOSP_PREBUILTS_DIR=
option_register_var "--aosp-prebuilts-dir=<dir>" OPT_AOSP_PREBUILTS_DIR \
"Set location of AOSP prebuilt toolchain root [autodetect]"
OPT_NO_AOSP_PREBUILTS=
option_register_var "--no-aosp-prebuilts" OPT_NO_AOSP_PREBUILTS \
"Do not use prebuilt AOSP toolchain"
}
_shu_is_aosp_prebuilts_dir () {
[ -d "$1"/gcc -a -d "$1"/clang ]
}
# Probe a given directory path $2 to see if it matches an $AOSP/prebuilts/
# directory. And if it does, set variable name $1 to its path.
# $1: Variable name
# $2: Directory to probe
_shu_probe_aosp_prebuilts_dir () {
log2 "Probing AOSP prebuilts dir: $2"
if [ -d "$2"/gcc -a -d "$2"/clang ]; then
var_assign $1 "$2"
fi
}
aosp_prebuilts_dir_parse_options () {
if [ "$OPT_AOSP_PREBUILTS_DIR" ]; then
if [ "$OPT_NO_AOSP_PREBUILTS" ]; then
panic "One cannot use --aosp-prebuilts-dir and --no-aosp-prebuilts at the same time!"
fi
AOSP_PREBUILTS_DIR=$OPT_AOSP_PREBUILTS_DIR
if [ ! -d "$AOSP_PREBUILTS_DIR" ]; then
panic "Directory does not exist: $AOSP_PREBUILTS_DIR"
fi
elif [ -z "$OPT_NO_AOSP_PREBUILTS" ]; then
if [ "$AOSP_DIR" ]; then
_shu_probe_aosp_prebuilts_dir AOSP_PREBUILTS_DIR \
"$AOSP_DIR"/prebuilts
else
_shu_probe_aosp_prebuilts_dir AOSP_PREBUILTS_DIR \
"$(program_directory)"/../../../../prebuilts
fi
if [ -z "$AOSP_PREBUILTS_DIR" ]; then
panic "Can't find <AOSP>/prebuilts/ dir, please use --aosp-prebuilts-dir=<dir> or --no-aosp-prebuilts."
fi
log "Auto-config: --aosp-prebuilts-dir=$AOSP_PREBUILTS_DIR [default]"
fi
}