blob: c54d55faac7dcf4be42c9147615814236a4cff55 [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 Li0d723112024-01-02 17:56:51 -080019)
20
21var androidmk_denylist []string = []string{
Wei Li8778d262024-06-12 00:34:33 +000022 "bionic/",
Wei Li0d723112024-01-02 17:56:51 -080023 "chained_build_config/",
24 "cts/",
25 "dalvik/",
26 "developers/",
Wei Li8778d262024-06-12 00:34:33 +000027 "development/",
Wei Li7df32b12024-09-11 19:36:41 +000028 "device/common/",
29 "device/google_car/",
Wei Li8778d262024-06-12 00:34:33 +000030 "device/sample/",
Nelson Liad3dae82024-04-03 02:04:45 +000031 "frameworks/",
Wei Lia2924462024-01-11 12:04:40 -080032 // Do not block other directories in kernel/, see b/319658303.
33 "kernel/configs/",
34 "kernel/prebuilts/",
35 "kernel/tests/",
Wei Li0d723112024-01-02 17:56:51 -080036 "libcore/",
37 "libnativehelper/",
Wei Liffb99492024-08-23 22:54:28 +000038 "packages/",
Wei Li0d723112024-01-02 17:56:51 -080039 "pdk/",
Wei Li8778d262024-06-12 00:34:33 +000040 "prebuilts/",
41 "sdk/",
42 "test/",
43 "trusty/",
Stephen Hines728bb712024-02-08 01:37:34 -080044 // Add back toolchain/ once defensive Android.mk files are removed
45 //"toolchain/",
Wei Li7df32b12024-09-11 19:36:41 +000046 "vendor/google_contexthub/",
47 "vendor/google_data/",
48 "vendor/google_elmyra/",
49 "vendor/google_mhl/",
50 "vendor/google_pdk/",
51 "vendor/google_testing/",
52 "vendor/partner_testing/",
53 "vendor/partner_tools/",
54 "vendor/pdk/",
Wei Li0d723112024-01-02 17:56:51 -080055}
56
Wei Lid0a2e322024-02-06 11:54:55 -080057func blockAndroidMks(ctx Context, androidMks []string) {
58 for _, mkFile := range androidMks {
Wei Li0d723112024-01-02 17:56:51 -080059 for _, d := range androidmk_denylist {
Wei Lid0a2e322024-02-06 11:54:55 -080060 if strings.HasPrefix(mkFile, d) {
61 ctx.Fatalf("Found blocked Android.mk file: %s. "+
62 "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 -080063 }
64 }
Wei Lid0a2e322024-02-06 11:54:55 -080065 }
Wei Li0d723112024-01-02 17:56:51 -080066}
Wei Lif6ac2752024-10-15 18:35:53 +000067
68// The Android.mk files in these directories are for NDK build system.
69var external_ndk_androidmks []string = []string{
70 "external/fmtlib/",
71 "external/google-breakpad/",
72 "external/googletest/",
73 "external/libaom/",
74 "external/libusb/",
75 "external/libvpx/",
76 "external/libwebm/",
77 "external/libwebsockets/",
78 "external/vulkan-validation-layers/",
79 "external/walt/",
80 "external/webp/",
81}
82
Joe Onoratoc5288af2024-10-21 16:02:22 -070083func ignoreNdkAndroidMks(androidMks []string) (filtered []string) {
84 filter := func(s string) bool {
Wei Lif6ac2752024-10-15 18:35:53 +000085 for _, d := range external_ndk_androidmks {
86 if strings.HasPrefix(s, d) {
87 return false
88 }
89 }
90 return true
Joe Onoratoc5288af2024-10-21 16:02:22 -070091 }
92
93 for _, l := range androidMks {
94 if filter(l) {
95 filtered = append(filtered, l)
96 }
97 }
98
99 return
Wei Lif6ac2752024-10-15 18:35:53 +0000100}