blob: a8044dfbf8a8bc82b7171b93edb660abf2d1148a [file] [log] [blame]
Wei Li0d723112024-01-02 17:56:51 -08001// Copyright 2024 Google Inc. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package build
16
17import (
18 "strings"
Wei Lif6ac2752024-10-15 18:35:53 +000019
20 "android/soong/android"
Wei Li0d723112024-01-02 17:56:51 -080021)
22
23var androidmk_denylist []string = []string{
Wei Li8778d262024-06-12 00:34:33 +000024 "bionic/",
Wei Li0d723112024-01-02 17:56:51 -080025 "chained_build_config/",
26 "cts/",
27 "dalvik/",
28 "developers/",
Wei Li8778d262024-06-12 00:34:33 +000029 "development/",
Wei Li7df32b12024-09-11 19:36:41 +000030 "device/common/",
31 "device/google_car/",
Wei Li8778d262024-06-12 00:34:33 +000032 "device/sample/",
Nelson Liad3dae82024-04-03 02:04:45 +000033 "frameworks/",
Wei Lia2924462024-01-11 12:04:40 -080034 // Do not block other directories in kernel/, see b/319658303.
35 "kernel/configs/",
36 "kernel/prebuilts/",
37 "kernel/tests/",
Wei Li0d723112024-01-02 17:56:51 -080038 "libcore/",
39 "libnativehelper/",
Wei Liffb99492024-08-23 22:54:28 +000040 "packages/",
Wei Li0d723112024-01-02 17:56:51 -080041 "pdk/",
Wei Li8778d262024-06-12 00:34:33 +000042 "prebuilts/",
43 "sdk/",
44 "test/",
45 "trusty/",
Stephen Hines728bb712024-02-08 01:37:34 -080046 // Add back toolchain/ once defensive Android.mk files are removed
47 //"toolchain/",
Wei Li7df32b12024-09-11 19:36:41 +000048 "vendor/google_contexthub/",
49 "vendor/google_data/",
50 "vendor/google_elmyra/",
51 "vendor/google_mhl/",
52 "vendor/google_pdk/",
53 "vendor/google_testing/",
54 "vendor/partner_testing/",
55 "vendor/partner_tools/",
56 "vendor/pdk/",
Wei Li0d723112024-01-02 17:56:51 -080057}
58
Wei Lid0a2e322024-02-06 11:54:55 -080059func blockAndroidMks(ctx Context, androidMks []string) {
60 for _, mkFile := range androidMks {
Wei Li0d723112024-01-02 17:56:51 -080061 for _, d := range androidmk_denylist {
Wei Lid0a2e322024-02-06 11:54:55 -080062 if strings.HasPrefix(mkFile, d) {
63 ctx.Fatalf("Found blocked Android.mk file: %s. "+
64 "Please see androidmk_denylist.go for the blocked directories and contact build system team if the file should not be blocked.", mkFile)
Wei Li0d723112024-01-02 17:56:51 -080065 }
66 }
Wei Lid0a2e322024-02-06 11:54:55 -080067 }
Wei Li0d723112024-01-02 17:56:51 -080068}
Wei Lif6ac2752024-10-15 18:35:53 +000069
70// The Android.mk files in these directories are for NDK build system.
71var external_ndk_androidmks []string = []string{
72 "external/fmtlib/",
73 "external/google-breakpad/",
74 "external/googletest/",
75 "external/libaom/",
76 "external/libusb/",
77 "external/libvpx/",
78 "external/libwebm/",
79 "external/libwebsockets/",
80 "external/vulkan-validation-layers/",
81 "external/walt/",
82 "external/webp/",
83}
84
85func ignoreNdkAndroidMks(androidMks []string) []string {
86 return android.FilterListPred(androidMks, func(s string) bool {
87 for _, d := range external_ndk_androidmks {
88 if strings.HasPrefix(s, d) {
89 return false
90 }
91 }
92 return true
93 })
94}