Merge changes Iedcff7df,I4cb294c2 am: 001ca325fb
Change-Id: Ib66c8c59ab9b90934e1251a6ea3d6403e9ef693c
This commit is contained in:
@@ -168,7 +168,7 @@ func (m *ApexModuleBase) IsInstallableToApex() bool {
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
AvailableToPlatform = "//apex_available:platform"
|
AvailableToPlatform = "//apex_available:platform"
|
||||||
availableToAnyApex = "//apex_available:anyapex"
|
AvailableToAnyApex = "//apex_available:anyapex"
|
||||||
)
|
)
|
||||||
|
|
||||||
func CheckAvailableForApex(what string, apex_available []string) bool {
|
func CheckAvailableForApex(what string, apex_available []string) bool {
|
||||||
@@ -178,7 +178,7 @@ func CheckAvailableForApex(what string, apex_available []string) bool {
|
|||||||
return what == AvailableToPlatform
|
return what == AvailableToPlatform
|
||||||
}
|
}
|
||||||
return InList(what, apex_available) ||
|
return InList(what, apex_available) ||
|
||||||
(what != AvailableToPlatform && InList(availableToAnyApex, apex_available))
|
(what != AvailableToPlatform && InList(AvailableToAnyApex, apex_available))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *ApexModuleBase) AvailableFor(what string) bool {
|
func (m *ApexModuleBase) AvailableFor(what string) bool {
|
||||||
@@ -212,7 +212,7 @@ func (m *ApexModuleBase) ShouldSupportAndroid10() bool {
|
|||||||
|
|
||||||
func (m *ApexModuleBase) checkApexAvailableProperty(mctx BaseModuleContext) {
|
func (m *ApexModuleBase) checkApexAvailableProperty(mctx BaseModuleContext) {
|
||||||
for _, n := range m.ApexProperties.Apex_available {
|
for _, n := range m.ApexProperties.Apex_available {
|
||||||
if n == AvailableToPlatform || n == availableToAnyApex {
|
if n == AvailableToPlatform || n == AvailableToAnyApex {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if !mctx.OtherModuleExists(n) && !mctx.Config().AllowMissingDependencies() {
|
if !mctx.OtherModuleExists(n) && !mctx.Config().AllowMissingDependencies() {
|
||||||
|
47
apex/apex.go
47
apex/apex.go
@@ -63,8 +63,26 @@ var (
|
|||||||
usesTag = dependencyTag{name: "uses"}
|
usesTag = dependencyTag{name: "uses"}
|
||||||
androidAppTag = dependencyTag{name: "androidApp", payload: true}
|
androidAppTag = dependencyTag{name: "androidApp", payload: true}
|
||||||
apexAvailWl = makeApexAvailableWhitelist()
|
apexAvailWl = makeApexAvailableWhitelist()
|
||||||
|
|
||||||
|
inverseApexAvailWl = invertApexWhiteList(apexAvailWl)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Transform the map of apex -> modules to module -> apexes.
|
||||||
|
func invertApexWhiteList(m map[string][]string) map[string][]string {
|
||||||
|
r := make(map[string][]string)
|
||||||
|
for apex, modules := range m {
|
||||||
|
for _, module := range modules {
|
||||||
|
r[module] = append(r[module], apex)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve the while list of apexes to which the supplied module belongs.
|
||||||
|
func WhitelistedApexAvailable(moduleName string) []string {
|
||||||
|
return inverseApexAvailWl[normalizeModuleName(moduleName)]
|
||||||
|
}
|
||||||
|
|
||||||
// This is a map from apex to modules, which overrides the
|
// This is a map from apex to modules, which overrides the
|
||||||
// apex_available setting for that particular module to make
|
// apex_available setting for that particular module to make
|
||||||
// it available for the apex regardless of its setting.
|
// it available for the apex regardless of its setting.
|
||||||
@@ -964,7 +982,7 @@ func makeApexAvailableWhitelist() map[string][]string {
|
|||||||
//
|
//
|
||||||
// Module separator
|
// Module separator
|
||||||
//
|
//
|
||||||
m["//any"] = []string{
|
m[android.AvailableToAnyApex] = []string{
|
||||||
"crtbegin_dynamic",
|
"crtbegin_dynamic",
|
||||||
"crtbegin_dynamic1",
|
"crtbegin_dynamic1",
|
||||||
"crtbegin_so",
|
"crtbegin_so",
|
||||||
@@ -2395,6 +2413,21 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
|
|
||||||
func whitelistedApexAvailable(apex, moduleName string) bool {
|
func whitelistedApexAvailable(apex, moduleName string) bool {
|
||||||
key := apex
|
key := apex
|
||||||
|
moduleName = normalizeModuleName(moduleName)
|
||||||
|
|
||||||
|
if val, ok := apexAvailWl[key]; ok && android.InList(moduleName, val) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
key = android.AvailableToAnyApex
|
||||||
|
if val, ok := apexAvailWl[key]; ok && android.InList(moduleName, val) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func normalizeModuleName(moduleName string) string {
|
||||||
// Prebuilt modules (e.g. java_import, etc.) have "prebuilt_" prefix added by the build
|
// 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
|
// system. Trim the prefix for the check since they are confusing
|
||||||
moduleName = strings.TrimPrefix(moduleName, "prebuilt_")
|
moduleName = strings.TrimPrefix(moduleName, "prebuilt_")
|
||||||
@@ -2403,17 +2436,7 @@ func whitelistedApexAvailable(apex, moduleName string) bool {
|
|||||||
// We don't want to list them all
|
// We don't want to list them all
|
||||||
moduleName = "libclang_rt"
|
moduleName = "libclang_rt"
|
||||||
}
|
}
|
||||||
|
return moduleName
|
||||||
if val, ok := apexAvailWl[key]; ok && android.InList(moduleName, val) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
key = "//any"
|
|
||||||
if val, ok := apexAvailWl[key]; ok && android.InList(moduleName, val) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func newApexBundle() *apexBundle {
|
func newApexBundle() *apexBundle {
|
||||||
|
22
cc/cc.go
22
cc/cc.go
@@ -250,6 +250,8 @@ type BaseProperties struct {
|
|||||||
// Used by vendor snapshot to record dependencies from snapshot modules.
|
// Used by vendor snapshot to record dependencies from snapshot modules.
|
||||||
SnapshotSharedLibs []string `blueprint:"mutated"`
|
SnapshotSharedLibs []string `blueprint:"mutated"`
|
||||||
SnapshotRuntimeLibs []string `blueprint:"mutated"`
|
SnapshotRuntimeLibs []string `blueprint:"mutated"`
|
||||||
|
|
||||||
|
Installable *bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type VendorProperties struct {
|
type VendorProperties struct {
|
||||||
@@ -371,6 +373,7 @@ type linker interface {
|
|||||||
type installer interface {
|
type installer interface {
|
||||||
installerProps() []interface{}
|
installerProps() []interface{}
|
||||||
install(ctx ModuleContext, path android.Path)
|
install(ctx ModuleContext, path android.Path)
|
||||||
|
everInstallable() bool
|
||||||
inData() bool
|
inData() bool
|
||||||
inSanitizerDir() bool
|
inSanitizerDir() bool
|
||||||
hostToolPath() android.OptionalPath
|
hostToolPath() android.OptionalPath
|
||||||
@@ -1488,6 +1491,13 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
|
|||||||
if ctx.Failed() {
|
if ctx.Failed() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
} else if !proptools.BoolDefault(c.Properties.Installable, true) {
|
||||||
|
// If the module has been specifically configure to not be installed then
|
||||||
|
// skip the installation as otherwise it will break when running inside make
|
||||||
|
// as the output path to install will not be specified. Not all uninstallable
|
||||||
|
// modules can skip installation as some are needed for resolving make side
|
||||||
|
// dependencies.
|
||||||
|
c.SkipInstall()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2629,8 +2639,18 @@ func (c *Module) AvailableFor(what string) bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return true if the module is ever installable.
|
||||||
|
func (c *Module) EverInstallable() bool {
|
||||||
|
return c.installer != nil &&
|
||||||
|
// Check to see whether the module is actually ever installable.
|
||||||
|
c.installer.everInstallable()
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Module) installable() bool {
|
func (c *Module) installable() bool {
|
||||||
ret := c.installer != nil && !c.Properties.PreventInstall && c.outputFile.Valid()
|
ret := c.EverInstallable() &&
|
||||||
|
// Check to see whether the module has been configured to not be installed.
|
||||||
|
proptools.BoolDefault(c.Properties.Installable, true) &&
|
||||||
|
!c.Properties.PreventInstall && c.outputFile.Valid()
|
||||||
|
|
||||||
// The platform variant doesn't need further condition. Apex variants however might not
|
// The platform variant doesn't need further condition. Apex variants however might not
|
||||||
// be installable because it will likely to be included in the APEX and won't appear
|
// be installable because it will likely to be included in the APEX and won't appear
|
||||||
|
@@ -86,6 +86,11 @@ func (installer *baseInstaller) install(ctx ModuleContext, file android.Path) {
|
|||||||
installer.path = ctx.InstallFile(installer.installDir(ctx), file.Base(), file)
|
installer.path = ctx.InstallFile(installer.installDir(ctx), file.Base(), file)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (installer *baseInstaller) everInstallable() bool {
|
||||||
|
// Most cc modules are installable.
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
func (installer *baseInstaller) inData() bool {
|
func (installer *baseInstaller) inData() bool {
|
||||||
return installer.location == InstallInData
|
return installer.location == InstallInData
|
||||||
}
|
}
|
||||||
|
@@ -1220,6 +1220,12 @@ func (library *libraryDecorator) install(ctx ModuleContext, file android.Path) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (library *libraryDecorator) everInstallable() bool {
|
||||||
|
// Only shared and static libraries are installed. Header libraries (which are
|
||||||
|
// neither static or shared) are not installed.
|
||||||
|
return library.shared() || library.static()
|
||||||
|
}
|
||||||
|
|
||||||
func (library *libraryDecorator) static() bool {
|
func (library *libraryDecorator) static() bool {
|
||||||
return library.MutatedProperties.VariantIsStatic
|
return library.MutatedProperties.VariantIsStatic
|
||||||
}
|
}
|
||||||
|
@@ -297,6 +297,7 @@ func TestSnapshotWithCcSharedLibraryCommonProperties(t *testing.T) {
|
|||||||
cc_prebuilt_library_shared {
|
cc_prebuilt_library_shared {
|
||||||
name: "mysdk_mynativelib@current",
|
name: "mysdk_mynativelib@current",
|
||||||
sdk_member_name: "mynativelib",
|
sdk_member_name: "mynativelib",
|
||||||
|
installable: false,
|
||||||
export_include_dirs: ["include/include"],
|
export_include_dirs: ["include/include"],
|
||||||
arch: {
|
arch: {
|
||||||
arm64: {
|
arm64: {
|
||||||
@@ -366,6 +367,7 @@ func TestSnapshotWithCcBinary(t *testing.T) {
|
|||||||
cc_prebuilt_binary {
|
cc_prebuilt_binary {
|
||||||
name: "mymodule_exports_mynativebinary@current",
|
name: "mymodule_exports_mynativebinary@current",
|
||||||
sdk_member_name: "mynativebinary",
|
sdk_member_name: "mynativebinary",
|
||||||
|
installable: false,
|
||||||
compile_multilib: "both",
|
compile_multilib: "both",
|
||||||
arch: {
|
arch: {
|
||||||
arm64: {
|
arm64: {
|
||||||
@@ -447,6 +449,7 @@ cc_prebuilt_binary {
|
|||||||
sdk_member_name: "mynativebinary",
|
sdk_member_name: "mynativebinary",
|
||||||
device_supported: false,
|
device_supported: false,
|
||||||
host_supported: true,
|
host_supported: true,
|
||||||
|
installable: false,
|
||||||
target: {
|
target: {
|
||||||
linux_glibc: {
|
linux_glibc: {
|
||||||
compile_multilib: "both",
|
compile_multilib: "both",
|
||||||
@@ -539,6 +542,7 @@ cc_prebuilt_library_shared {
|
|||||||
"apex1",
|
"apex1",
|
||||||
"apex2",
|
"apex2",
|
||||||
],
|
],
|
||||||
|
installable: false,
|
||||||
export_include_dirs: ["include/include"],
|
export_include_dirs: ["include/include"],
|
||||||
arch: {
|
arch: {
|
||||||
arm64: {
|
arm64: {
|
||||||
@@ -634,6 +638,7 @@ cc_prebuilt_library_shared {
|
|||||||
sdk_member_name: "mynativelib",
|
sdk_member_name: "mynativelib",
|
||||||
device_supported: false,
|
device_supported: false,
|
||||||
host_supported: true,
|
host_supported: true,
|
||||||
|
installable: false,
|
||||||
sdk_version: "minimum",
|
sdk_version: "minimum",
|
||||||
export_include_dirs: ["include/include"],
|
export_include_dirs: ["include/include"],
|
||||||
arch: {
|
arch: {
|
||||||
@@ -735,6 +740,7 @@ cc_prebuilt_library_shared {
|
|||||||
sdk_member_name: "mynativelib",
|
sdk_member_name: "mynativelib",
|
||||||
device_supported: false,
|
device_supported: false,
|
||||||
host_supported: true,
|
host_supported: true,
|
||||||
|
installable: false,
|
||||||
target: {
|
target: {
|
||||||
linux_glibc_x86_64: {
|
linux_glibc_x86_64: {
|
||||||
srcs: ["linux_glibc/x86_64/lib/mynativelib.so"],
|
srcs: ["linux_glibc/x86_64/lib/mynativelib.so"],
|
||||||
@@ -814,6 +820,7 @@ func TestSnapshotWithCcStaticLibrary(t *testing.T) {
|
|||||||
cc_prebuilt_library_static {
|
cc_prebuilt_library_static {
|
||||||
name: "myexports_mynativelib@current",
|
name: "myexports_mynativelib@current",
|
||||||
sdk_member_name: "mynativelib",
|
sdk_member_name: "mynativelib",
|
||||||
|
installable: false,
|
||||||
export_include_dirs: ["include/include"],
|
export_include_dirs: ["include/include"],
|
||||||
arch: {
|
arch: {
|
||||||
arm64: {
|
arm64: {
|
||||||
@@ -904,6 +911,7 @@ cc_prebuilt_library_static {
|
|||||||
sdk_member_name: "mynativelib",
|
sdk_member_name: "mynativelib",
|
||||||
device_supported: false,
|
device_supported: false,
|
||||||
host_supported: true,
|
host_supported: true,
|
||||||
|
installable: false,
|
||||||
export_include_dirs: ["include/include"],
|
export_include_dirs: ["include/include"],
|
||||||
arch: {
|
arch: {
|
||||||
x86_64: {
|
x86_64: {
|
||||||
@@ -1003,6 +1011,7 @@ cc_prebuilt_library_static {
|
|||||||
sdk_member_name: "mynativelib",
|
sdk_member_name: "mynativelib",
|
||||||
device_supported: false,
|
device_supported: false,
|
||||||
host_supported: true,
|
host_supported: true,
|
||||||
|
installable: false,
|
||||||
export_include_dirs: ["include/include"],
|
export_include_dirs: ["include/include"],
|
||||||
arch: {
|
arch: {
|
||||||
x86_64: {
|
x86_64: {
|
||||||
|
@@ -20,6 +20,7 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"android/soong/apex"
|
||||||
"github.com/google/blueprint"
|
"github.com/google/blueprint"
|
||||||
"github.com/google/blueprint/proptools"
|
"github.com/google/blueprint/proptools"
|
||||||
|
|
||||||
@@ -409,8 +410,19 @@ type propertyTag struct {
|
|||||||
name string
|
name string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// A BpPropertyTag to add to a property that contains references to other sdk members.
|
||||||
|
//
|
||||||
|
// This will cause the references to be rewritten to a versioned reference in the version
|
||||||
|
// specific instance of a snapshot module.
|
||||||
var sdkMemberReferencePropertyTag = propertyTag{"sdkMemberReferencePropertyTag"}
|
var sdkMemberReferencePropertyTag = propertyTag{"sdkMemberReferencePropertyTag"}
|
||||||
|
|
||||||
|
// A BpPropertyTag that indicates the property should only be present in the versioned
|
||||||
|
// module.
|
||||||
|
//
|
||||||
|
// This will cause the property to be removed from the unversioned instance of a
|
||||||
|
// snapshot module.
|
||||||
|
var sdkVersionedOnlyPropertyTag = propertyTag{"sdkVersionedOnlyPropertyTag"}
|
||||||
|
|
||||||
type unversionedToVersionedTransformation struct {
|
type unversionedToVersionedTransformation struct {
|
||||||
identityTransformation
|
identityTransformation
|
||||||
builder *snapshotBuilder
|
builder *snapshotBuilder
|
||||||
@@ -452,6 +464,9 @@ func (t unversionedTransformation) transformModule(module *bpModule) *bpModule {
|
|||||||
func (t unversionedTransformation) transformProperty(name string, value interface{}, tag android.BpPropertyTag) (interface{}, android.BpPropertyTag) {
|
func (t unversionedTransformation) transformProperty(name string, value interface{}, tag android.BpPropertyTag) (interface{}, android.BpPropertyTag) {
|
||||||
if tag == sdkMemberReferencePropertyTag {
|
if tag == sdkMemberReferencePropertyTag {
|
||||||
return t.builder.unversionedSdkMemberNames(value.([]string)), tag
|
return t.builder.unversionedSdkMemberNames(value.([]string)), tag
|
||||||
|
} else if tag == sdkVersionedOnlyPropertyTag {
|
||||||
|
// The property is not allowed in the unversioned module so remove it.
|
||||||
|
return nil, nil
|
||||||
} else {
|
} else {
|
||||||
return value, tag
|
return value, tag
|
||||||
}
|
}
|
||||||
@@ -626,11 +641,26 @@ func (s *snapshotBuilder) AddPrebuiltModule(member android.SdkMember, moduleType
|
|||||||
// Where available copy apex_available properties from the member.
|
// Where available copy apex_available properties from the member.
|
||||||
if apexAware, ok := variant.(interface{ ApexAvailable() []string }); ok {
|
if apexAware, ok := variant.(interface{ ApexAvailable() []string }); ok {
|
||||||
apexAvailable := apexAware.ApexAvailable()
|
apexAvailable := apexAware.ApexAvailable()
|
||||||
|
|
||||||
|
// Add in any white listed apex available settings.
|
||||||
|
apexAvailable = append(apexAvailable, apex.WhitelistedApexAvailable(member.Name())...)
|
||||||
|
|
||||||
if len(apexAvailable) > 0 {
|
if len(apexAvailable) > 0 {
|
||||||
|
// Remove duplicates and sort.
|
||||||
|
apexAvailable = android.FirstUniqueStrings(apexAvailable)
|
||||||
|
sort.Strings(apexAvailable)
|
||||||
|
|
||||||
m.AddProperty("apex_available", apexAvailable)
|
m.AddProperty("apex_available", apexAvailable)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Disable installation in the versioned module of those modules that are ever installable.
|
||||||
|
if installable, ok := variant.(interface{ EverInstallable() bool }); ok {
|
||||||
|
if installable.EverInstallable() {
|
||||||
|
m.AddPropertyWithTag("installable", false, sdkVersionedOnlyPropertyTag)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
s.prebuiltModules[name] = m
|
s.prebuiltModules[name] = m
|
||||||
s.prebuiltOrder = append(s.prebuiltOrder, m)
|
s.prebuiltOrder = append(s.prebuiltOrder, m)
|
||||||
return m
|
return m
|
||||||
|
Reference in New Issue
Block a user