1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
// Copyright 2024 Google Inc. All rights reserved.
//
// 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.
package build
import (
"os"
"slices"
"strings"
)
var androidmk_denylist []string = []string{
"art/",
"bionic/",
"bootable/",
"build/",
"cts/",
"dalvik/",
"developers/",
"development/",
"device/common/",
"device/generic/",
"device/google/",
"device/google_car/",
"device/sample/",
"external/",
"frameworks/",
"hardware/google/",
"hardware/interfaces/",
"hardware/libhardware/",
"hardware/libhardware_legacy/",
"hardware/ril/",
// Do not block other directories in kernel/, see b/319658303.
"kernel/configs/",
"kernel/prebuilts/",
"kernel/tests/",
"libcore/",
"libnativehelper/",
"packages/",
"pdk/",
"platform_testing/",
"prebuilts/",
"sdk/",
"system/",
"test/",
"tools/",
"trusty/",
"toolchain/",
}
var androidmk_allowlist []string = []string{
"art/Android.mk",
"bootable/deprecated-ota/updater/Android.mk",
"external/mesa/android/Android.mk",
"tools/vendor/google_prebuilts/arc/Android.mk",
}
func getAllLines(ctx Context, filename string) []string {
bytes, err := os.ReadFile(filename)
if err != nil {
if os.IsNotExist(err) {
return []string{}
} else {
ctx.Fatalf("Could not read %s: %v", filename, err)
}
}
return strings.Split(strings.Trim(string(bytes), " \n"), "\n")
}
func blockAndroidMks(ctx Context, androidMks []string) {
allowlist_files := []string{
"vendor/google/build/androidmk/allowlist.txt",
"device/google/clockwork/build/androidmk/allowlist.txt",
"device/google/sdv/androidmk/allowlist.txt",
"device/google/harriet/androidmk/allowlist.txt",
"vendor/extra/build/androidmk/allowlist.txt",
}
for _, allowlist_file := range allowlist_files {
allowlist := getAllLines(ctx, allowlist_file)
androidmk_allowlist = append(androidmk_allowlist, allowlist...)
}
slices.Sort(androidmk_allowlist)
androidmk_allowlist = slices.Compact(androidmk_allowlist)
denylist := getAllLines(ctx, "vendor/google/build/androidmk/denylist.txt")
androidmk_denylist = append(androidmk_denylist, denylist...)
for _, mkFile := range androidMks {
for _, d := range androidmk_denylist {
if strings.HasPrefix(mkFile, d) && !slices.Contains(androidmk_allowlist, mkFile) {
ctx.Fatalf("Found blocked Android.mk file: %s. "+
"Please see androidmk_denylist.go for the blocked directories and contact build system team if the file should not be blocked.", mkFile)
}
}
}
}
var external_androidmks []string = []string{
// The Android.mk files in these directories are for NDK build system.
"external/fmtlib/",
"external/google-breakpad/",
"external/googletest/",
"external/libaom/",
"external/libusb/",
"external/libvpx/",
"external/libwebm/",
"external/libwebsockets/",
"external/vulkan-validation-layers/",
"external/walt/",
"external/webp/",
// These directories hold the published Android SDK, used in Unbundled Gradle builds.
"prebuilts/fullsdk-darwin",
"prebuilts/fullsdk-linux",
// wpa_supplicant_8 has been converted to Android.bp and Android.mk files are kept for troubleshooting.
"external/wpa_supplicant_8/",
// Empty Android.mk in package's top directory
"external/proguard/",
"external/swig/",
"toolchain/",
}
var art_androidmks = []string{
//"art/",
}
func ignoreSomeAndroidMks(androidMks []string) (filtered []string) {
ignore_androidmks := make([]string, 0, len(external_androidmks)+len(art_androidmks))
ignore_androidmks = append(ignore_androidmks, external_androidmks...)
ignore_androidmks = append(ignore_androidmks, art_androidmks...)
shouldKeep := func(androidmk string) bool {
for _, prefix := range ignore_androidmks {
if strings.HasPrefix(androidmk, prefix) {
return false
}
}
return true
}
for _, l := range androidMks {
if shouldKeep(l) {
filtered = append(filtered, l)
}
}
return
}
|