8bea267caf
* We are interested mostly in the conversion the `default_applicable_licenses` attribute, as `default_visibility` cannot be handled until every module's `visibility` is handled. * Several referenced license modules had to be manually enabled for conversion, and likewise a few trivial Android.bp containing only package and license modules. * As Bazel allows only a single `package` rule, the package rules in a manually converted BUILD.bazel files were removed (in external/protobuf and prebuilts/clang/host/linux-x86 trees). * The converted package rule is emitted before the `load` statements per Bazel documentation. Bug: 190817312 Test: treehugger Change-Id: If8bf6fee1580177de3bb402923615bcd48923ed2
152 lines
3.6 KiB
Bash
152 lines
3.6 KiB
Bash
#!/bin/bash -eu
|
|
|
|
set -o pipefail
|
|
|
|
HARDWIRED_MOCK_TOP=
|
|
# Uncomment this to be able to view the source tree after a test is run
|
|
# HARDWIRED_MOCK_TOP=/tmp/td
|
|
|
|
REAL_TOP="$(readlink -f "$(dirname "$0")"/../../..)"
|
|
|
|
if [[ -n "$HARDWIRED_MOCK_TOP" ]]; then
|
|
MOCK_TOP="$HARDWIRED_MOCK_TOP"
|
|
else
|
|
MOCK_TOP=$(mktemp -t -d st.XXXXX)
|
|
trap cleanup_mock_top EXIT
|
|
fi
|
|
|
|
WARMED_UP_MOCK_TOP=$(mktemp -t soong_integration_tests_warmup.XXXXXX.tar.gz)
|
|
trap 'rm -f "$WARMED_UP_MOCK_TOP"' EXIT
|
|
|
|
function warmup_mock_top {
|
|
info "Warming up mock top ..."
|
|
info "Mock top warmup archive: $WARMED_UP_MOCK_TOP"
|
|
cleanup_mock_top
|
|
mkdir -p "$MOCK_TOP"
|
|
cd "$MOCK_TOP"
|
|
|
|
create_mock_soong
|
|
run_soong
|
|
tar czf "$WARMED_UP_MOCK_TOP" *
|
|
}
|
|
|
|
function cleanup_mock_top {
|
|
cd /
|
|
rm -fr "$MOCK_TOP"
|
|
}
|
|
|
|
function info {
|
|
echo -e "\e[92;1m[TEST HARNESS INFO]\e[0m" "$*"
|
|
}
|
|
|
|
function fail {
|
|
echo -e "\e[91;1mFAILED:\e[0m" "$*"
|
|
exit 1
|
|
}
|
|
|
|
function copy_directory {
|
|
local dir="$1"
|
|
local -r parent="$(dirname "$dir")"
|
|
|
|
mkdir -p "$MOCK_TOP/$parent"
|
|
cp -R "$REAL_TOP/$dir" "$MOCK_TOP/$parent"
|
|
}
|
|
|
|
function symlink_file {
|
|
local file="$1"
|
|
|
|
mkdir -p "$MOCK_TOP/$(dirname "$file")"
|
|
ln -s "$REAL_TOP/$file" "$MOCK_TOP/$file"
|
|
}
|
|
|
|
function symlink_directory {
|
|
local dir="$1"
|
|
|
|
mkdir -p "$MOCK_TOP/$dir"
|
|
# We need to symlink the contents of the directory individually instead of
|
|
# using one symlink for the whole directory because finder.go doesn't follow
|
|
# symlinks when looking for Android.bp files
|
|
for i in "$REAL_TOP/$dir"/*; do
|
|
i=$(basename "$i")
|
|
local target="$MOCK_TOP/$dir/$i"
|
|
local source="$REAL_TOP/$dir/$i"
|
|
|
|
if [[ -e "$target" ]]; then
|
|
if [[ ! -d "$source" || ! -d "$target" ]]; then
|
|
fail "Trying to symlink $dir twice"
|
|
fi
|
|
else
|
|
ln -s "$REAL_TOP/$dir/$i" "$MOCK_TOP/$dir/$i";
|
|
fi
|
|
done
|
|
}
|
|
|
|
function create_mock_soong {
|
|
copy_directory build/blueprint
|
|
copy_directory build/soong
|
|
copy_directory build/make/tools/rbcrun
|
|
|
|
symlink_directory prebuilts/sdk
|
|
symlink_directory prebuilts/go
|
|
symlink_directory prebuilts/build-tools
|
|
symlink_directory prebuilts/clang/host
|
|
symlink_directory external/go-cmp
|
|
symlink_directory external/golang-protobuf
|
|
symlink_directory external/starlark-go
|
|
|
|
touch "$MOCK_TOP/Android.bp"
|
|
}
|
|
|
|
function setup {
|
|
cleanup_mock_top
|
|
mkdir -p "$MOCK_TOP"
|
|
|
|
echo
|
|
echo ----------------------------------------------------------------------------
|
|
info "Running test case \e[96;1m${FUNCNAME[1]}\e[0m"
|
|
cd "$MOCK_TOP"
|
|
|
|
tar xzf "$WARMED_UP_MOCK_TOP"
|
|
}
|
|
|
|
# shellcheck disable=SC2120
|
|
function run_soong {
|
|
USE_RBE=false build/soong/soong_ui.bash --make-mode --skip-ninja --skip-config --soong-only --skip-soong-tests "$@"
|
|
}
|
|
|
|
function create_mock_bazel {
|
|
copy_directory build/bazel
|
|
copy_directory build/bazel_common_rules
|
|
|
|
symlink_directory prebuilts/bazel
|
|
symlink_directory prebuilts/clang
|
|
symlink_directory prebuilts/jdk
|
|
symlink_directory external/bazel-skylib
|
|
symlink_directory external/bazelbuild-rules_android
|
|
symlink_directory external/bazelbuild-rules_license
|
|
symlink_directory external/bazelbuild-kotlin-rules
|
|
|
|
symlink_file WORKSPACE
|
|
symlink_file BUILD
|
|
symlink_file tools/bazel
|
|
}
|
|
|
|
function run_bazel {
|
|
# Remove the ninja_build output marker file to communicate to buildbot that this is not a regular Ninja build, and its
|
|
# output should not be parsed as such.
|
|
rm -rf out/ninja_build
|
|
|
|
tools/bazel "$@"
|
|
}
|
|
|
|
function run_ninja {
|
|
build/soong/soong_ui.bash --make-mode --skip-config --soong-only --skip-soong-tests "$@"
|
|
}
|
|
|
|
info "Starting Soong integration test suite $(basename "$0")"
|
|
info "Mock top: $MOCK_TOP"
|
|
|
|
|
|
export ALLOW_MISSING_DEPENDENCIES=true
|
|
export ALLOW_BP_UNDER_SYMLINKS=true
|
|
warmup_mock_top
|