1// 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"
19)
20
21var androidmk_denylist []string = []string{
22	"bionic/",
23	"chained_build_config/",
24	"cts/",
25	"dalvik/",
26	"developers/",
27	"development/",
28	"device/sample/",
29	"frameworks/",
30	// Do not block other directories in kernel/, see b/319658303.
31	"kernel/configs/",
32	"kernel/prebuilts/",
33	"kernel/tests/",
34	"libcore/",
35	"libnativehelper/",
36	"pdk/",
37	"prebuilts/",
38	"sdk/",
39	"test/",
40	"trusty/",
41	// Add back toolchain/ once defensive Android.mk files are removed
42	//"toolchain/",
43}
44
45func blockAndroidMks(ctx Context, androidMks []string) {
46	for _, mkFile := range androidMks {
47		for _, d := range androidmk_denylist {
48			if strings.HasPrefix(mkFile, d) {
49				ctx.Fatalf("Found blocked Android.mk file: %s. "+
50					"Please see androidmk_denylist.go for the blocked directories and contact build system team if the file should not be blocked.", mkFile)
51			}
52		}
53	}
54}
55