From d23c726b3655187f0016968811335c72e04239cb Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Fri, 11 Dec 2020 18:13:08 +0000 Subject: [PATCH] Add RemoveOptionalPrebuiltPrefix() helper function Test: m nothing Bug: 171061220 Change-Id: Iaca95efcaf3f02e066751c6e988d609ac40e048a --- android/prebuilt.go | 7 +++++++ apex/apex.go | 2 +- cc/cc.go | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/android/prebuilt.go b/android/prebuilt.go index bb98ed438..8114a65a5 100644 --- a/android/prebuilt.go +++ b/android/prebuilt.go @@ -17,6 +17,7 @@ package android import ( "fmt" "reflect" + "strings" "github.com/google/blueprint" "github.com/google/blueprint/proptools" @@ -74,6 +75,12 @@ type Prebuilt struct { srcsPropertyName string } +// RemoveOptionalPrebuiltPrefix returns the result of removing the "prebuilt_" prefix from the +// supplied name if it has one, or returns the name unmodified if it does not. +func RemoveOptionalPrebuiltPrefix(name string) string { + return strings.TrimPrefix(name, "prebuilt_") +} + func (p *Prebuilt) Name(name string) string { return "prebuilt_" + name } diff --git a/apex/apex.go b/apex/apex.go index 40ef0c2e8..261284c72 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -2178,7 +2178,7 @@ func baselineApexAvailable(apex, moduleName string) bool { func normalizeModuleName(moduleName string) string { // Prebuilt modules (e.g. java_import, etc.) have "prebuilt_" prefix added by the build // system. Trim the prefix for the check since they are confusing - moduleName = strings.TrimPrefix(moduleName, "prebuilt_") + moduleName = android.RemoveOptionalPrebuiltPrefix(moduleName) if strings.HasPrefix(moduleName, "libclang_rt.") { // This module has many arch variants that depend on the product being built. // We don't want to list them all diff --git a/cc/cc.go b/cc/cc.go index 9383e390b..d1f5c47e3 100644 --- a/cc/cc.go +++ b/cc/cc.go @@ -2749,7 +2749,7 @@ func orderStaticModuleDeps(staticDeps []StaticLibraryInfo, sharedDeps []SharedLi func baseLibName(depName string) string { libName := strings.TrimSuffix(depName, llndkLibrarySuffix) libName = strings.TrimSuffix(libName, vendorPublicLibrarySuffix) - libName = strings.TrimPrefix(libName, "prebuilt_") + libName = android.RemoveOptionalPrebuiltPrefix(libName) return libName }