1#!/bin/bash
2
3#
4# Copyright (C) 2017 The Android Open Source Project
5#
6# Licensed under the Apache License, Version 2.0 (the "License");
7# you may not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
10#      http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS,
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17
18function all-targets() {
19    local target_device=$(echo $TARGET_PRODUCT | sed "s/^aosp_//")
20    $ANDROID_BUILD_TOP/build/soong/soong_ui.bash --make-mode -j "out/target/product/$target_device/module-info.json"
21
22    python3 -c "import json; print('\n'.join(sorted(json.load(open('$ANDROID_PRODUCT_OUT/module-info.json')).keys())))" \
23        | grep -vP "_32$"
24}
25
26function update_file() {
27    local file_inception="$1"
28    local variable_name="$2"
29    local pattern="$3"
30
31    local filename="$ANDROID_BUILD_TOP/test/vts/tools/build/tasks/list/$variable_name"
32
33    echo "#
34# Copyright (C) $file_inception The Android Open Source Project
35#
36# Licensed under the Apache License, Version 2.0 (the "License");
37# you may not use this file except in compliance with the License.
38# You may obtain a copy of the License at
39#
40#      http://www.apache.org/licenses/LICENSE-2.0
41#
42# Unless required by applicable law or agreed to in writing, software
43# distributed under the License is distributed on an \"AS IS\" BASIS,
44# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
45# See the License for the specific language governing permissions and
46# limitations under the License.
47
48$variable_name := \\
49$(all-targets | grep -P "$pattern" | awk '{print "  " $0 " \\"}')" > "$filename".mk
50}
51
52# note, must come up with pattern to weed out vendor-specific files
53update_file 2017 vts_adapter_package_list '@.*-adapter'