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/common/", 29 "device/google_car/", 30 "device/sample/", 31 "frameworks/", 32 "hardware/libhardware/", 33 "hardware/libhardware_legacy/", 34 "hardware/ril/", 35 // Do not block other directories in kernel/, see b/319658303. 36 "kernel/configs/", 37 "kernel/prebuilts/", 38 "kernel/tests/", 39 "libcore/", 40 "libnativehelper/", 41 "packages/", 42 "pdk/", 43 "platform_testing/", 44 "prebuilts/", 45 "sdk/", 46 "system/", 47 "test/", 48 "trusty/", 49 // Add back toolchain/ once defensive Android.mk files are removed 50 //"toolchain/", 51 "vendor/google_contexthub/", 52 "vendor/google_data/", 53 "vendor/google_elmyra/", 54 "vendor/google_mhl/", 55 "vendor/google_pdk/", 56 "vendor/google_testing/", 57 "vendor/partner_testing/", 58 "vendor/partner_tools/", 59 "vendor/pdk/", 60} 61 62func blockAndroidMks(ctx Context, androidMks []string) { 63 for _, mkFile := range androidMks { 64 for _, d := range androidmk_denylist { 65 if strings.HasPrefix(mkFile, d) { 66 ctx.Fatalf("Found blocked Android.mk file: %s. "+ 67 "Please see androidmk_denylist.go for the blocked directories and contact build system team if the file should not be blocked.", mkFile) 68 } 69 } 70 } 71} 72 73// The Android.mk files in these directories are for NDK build system. 74var external_ndk_androidmks []string = []string{ 75 "external/fmtlib/", 76 "external/google-breakpad/", 77 "external/googletest/", 78 "external/libaom/", 79 "external/libusb/", 80 "external/libvpx/", 81 "external/libwebm/", 82 "external/libwebsockets/", 83 "external/vulkan-validation-layers/", 84 "external/walt/", 85 "external/webp/", 86} 87 88func ignoreNdkAndroidMks(androidMks []string) (filtered []string) { 89 filter := func(s string) bool { 90 for _, d := range external_ndk_androidmks { 91 if strings.HasPrefix(s, d) { 92 return false 93 } 94 } 95 return true 96 } 97 98 for _, l := range androidMks { 99 if filter(l) { 100 filtered = append(filtered, l) 101 } 102 } 103 104 return 105} 106