apex_available tracks static dependencies am: 0f80c1848a
Change-Id: I9a1909deec5d97a9be461b95f93e3078c065aacb
This commit is contained in:
@@ -180,20 +180,20 @@ func (m *ApexModuleBase) checkApexAvailableProperty(mctx BaseModuleContext) {
|
|||||||
func (m *ApexModuleBase) CreateApexVariations(mctx BottomUpMutatorContext) []Module {
|
func (m *ApexModuleBase) CreateApexVariations(mctx BottomUpMutatorContext) []Module {
|
||||||
if len(m.apexVariations) > 0 {
|
if len(m.apexVariations) > 0 {
|
||||||
m.checkApexAvailableProperty(mctx)
|
m.checkApexAvailableProperty(mctx)
|
||||||
|
|
||||||
sort.Strings(m.apexVariations)
|
sort.Strings(m.apexVariations)
|
||||||
variations := []string{}
|
variations := []string{}
|
||||||
availableForPlatform := mctx.Module().(ApexModule).AvailableFor(AvailableToPlatform) || mctx.Host()
|
|
||||||
if availableForPlatform {
|
|
||||||
variations = append(variations, "") // Original variation for platform
|
variations = append(variations, "") // Original variation for platform
|
||||||
}
|
|
||||||
variations = append(variations, m.apexVariations...)
|
variations = append(variations, m.apexVariations...)
|
||||||
|
|
||||||
defaultVariation := ""
|
defaultVariation := ""
|
||||||
mctx.SetDefaultDependencyVariation(&defaultVariation)
|
mctx.SetDefaultDependencyVariation(&defaultVariation)
|
||||||
|
|
||||||
modules := mctx.CreateVariations(variations...)
|
modules := mctx.CreateVariations(variations...)
|
||||||
for i, m := range modules {
|
for i, m := range modules {
|
||||||
if availableForPlatform && i == 0 {
|
platformVariation := i == 0
|
||||||
continue
|
if platformVariation && !mctx.Host() && !m.(ApexModule).AvailableFor(AvailableToPlatform) {
|
||||||
|
m.SkipInstall()
|
||||||
}
|
}
|
||||||
m.(ApexModule).setApexName(variations[i])
|
m.(ApexModule).setApexName(variations[i])
|
||||||
}
|
}
|
||||||
|
927
apex/apex.go
927
apex/apex.go
File diff suppressed because it is too large
Load Diff
@@ -469,6 +469,11 @@ func TestBasicApex(t *testing.T) {
|
|||||||
sdk_version: "none",
|
sdk_version: "none",
|
||||||
system_modules: "none",
|
system_modules: "none",
|
||||||
compile_dex: true,
|
compile_dex: true,
|
||||||
|
// TODO: remove //apex_available:platform
|
||||||
|
apex_available: [
|
||||||
|
"//apex_available:platform",
|
||||||
|
"myapex",
|
||||||
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
java_library {
|
java_library {
|
||||||
@@ -760,7 +765,7 @@ func TestApexWithStubs(t *testing.T) {
|
|||||||
ensureNotContains(t, mylibLdFlags, "mylib3/android_arm64_armv8-a_shared_12_myapex/mylib3.so")
|
ensureNotContains(t, mylibLdFlags, "mylib3/android_arm64_armv8-a_shared_12_myapex/mylib3.so")
|
||||||
|
|
||||||
// Ensure that stubs libs are built without -include flags
|
// Ensure that stubs libs are built without -include flags
|
||||||
mylib2Cflags := ctx.ModuleForTests("mylib2", "android_arm64_armv8-a_static_myapex").Rule("cc").Args["cFlags"]
|
mylib2Cflags := ctx.ModuleForTests("mylib2", "android_arm64_armv8-a_static").Rule("cc").Args["cFlags"]
|
||||||
ensureNotContains(t, mylib2Cflags, "-include ")
|
ensureNotContains(t, mylib2Cflags, "-include ")
|
||||||
|
|
||||||
// Ensure that genstub is invoked with --apex
|
// Ensure that genstub is invoked with --apex
|
||||||
@@ -886,6 +891,7 @@ func TestApexWithRuntimeLibsDependency(t *testing.T) {
|
|||||||
stubs: {
|
stubs: {
|
||||||
versions: ["10", "20", "30"],
|
versions: ["10", "20", "30"],
|
||||||
},
|
},
|
||||||
|
apex_available: [ "myapex" ],
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_library {
|
cc_library {
|
||||||
@@ -1573,6 +1579,7 @@ func TestHeaderLibsDependency(t *testing.T) {
|
|||||||
export_include_dirs: ["my_include"],
|
export_include_dirs: ["my_include"],
|
||||||
system_shared_libs: [],
|
system_shared_libs: [],
|
||||||
stl: "none",
|
stl: "none",
|
||||||
|
apex_available: [ "myapex" ],
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_library {
|
cc_library {
|
||||||
@@ -3026,6 +3033,7 @@ func TestApexWithApps(t *testing.T) {
|
|||||||
srcs: ["mylib.cpp"],
|
srcs: ["mylib.cpp"],
|
||||||
stl: "none",
|
stl: "none",
|
||||||
system_shared_libs: [],
|
system_shared_libs: [],
|
||||||
|
apex_available: [ "myapex" ],
|
||||||
}
|
}
|
||||||
`)
|
`)
|
||||||
|
|
||||||
@@ -3281,10 +3289,15 @@ func TestApexAvailable(t *testing.T) {
|
|||||||
}`)
|
}`)
|
||||||
|
|
||||||
// check that libfoo and libbar are created only for myapex, but not for the platform
|
// check that libfoo and libbar are created only for myapex, but not for the platform
|
||||||
ensureListContains(t, ctx.ModuleVariantsForTests("libfoo"), "android_arm64_armv8-a_shared_myapex")
|
// TODO(jiyong) the checks for the platform variant are removed because we now create
|
||||||
ensureListNotContains(t, ctx.ModuleVariantsForTests("libfoo"), "android_arm64_armv8-a_shared")
|
// the platform variant regardless of the apex_availability. Instead, we will make sure that
|
||||||
ensureListContains(t, ctx.ModuleVariantsForTests("libbar"), "android_arm64_armv8-a_shared_myapex")
|
// the platform variants are not used from other platform modules. When that is done,
|
||||||
ensureListNotContains(t, ctx.ModuleVariantsForTests("libbar"), "android_arm64_armv8-a_shared")
|
// these checks will be replaced by expecting a specific error message that will be
|
||||||
|
// emitted when the platform variant is used.
|
||||||
|
// ensureListContains(t, ctx.ModuleVariantsForTests("libfoo"), "android_arm64_armv8-a_shared_myapex")
|
||||||
|
// ensureListNotContains(t, ctx.ModuleVariantsForTests("libfoo"), "android_arm64_armv8-a_shared")
|
||||||
|
// ensureListContains(t, ctx.ModuleVariantsForTests("libbar"), "android_arm64_armv8-a_shared_myapex")
|
||||||
|
// ensureListNotContains(t, ctx.ModuleVariantsForTests("libbar"), "android_arm64_armv8-a_shared")
|
||||||
|
|
||||||
ctx, _ = testApex(t, `
|
ctx, _ = testApex(t, `
|
||||||
apex {
|
apex {
|
||||||
@@ -3333,11 +3346,16 @@ func TestApexAvailable(t *testing.T) {
|
|||||||
}`)
|
}`)
|
||||||
|
|
||||||
// shared variant of libfoo is only available to myapex
|
// shared variant of libfoo is only available to myapex
|
||||||
ensureListContains(t, ctx.ModuleVariantsForTests("libfoo"), "android_arm64_armv8-a_shared_myapex")
|
// TODO(jiyong) the checks for the platform variant are removed because we now create
|
||||||
ensureListNotContains(t, ctx.ModuleVariantsForTests("libfoo"), "android_arm64_armv8-a_shared")
|
// the platform variant regardless of the apex_availability. Instead, we will make sure that
|
||||||
// but the static variant is available to both myapex and the platform
|
// the platform variants are not used from other platform modules. When that is done,
|
||||||
ensureListContains(t, ctx.ModuleVariantsForTests("libfoo"), "android_arm64_armv8-a_static_myapex")
|
// these checks will be replaced by expecting a specific error message that will be
|
||||||
ensureListContains(t, ctx.ModuleVariantsForTests("libfoo"), "android_arm64_armv8-a_static")
|
// emitted when the platform variant is used.
|
||||||
|
// ensureListContains(t, ctx.ModuleVariantsForTests("libfoo"), "android_arm64_armv8-a_shared_myapex")
|
||||||
|
// ensureListNotContains(t, ctx.ModuleVariantsForTests("libfoo"), "android_arm64_armv8-a_shared")
|
||||||
|
// // but the static variant is available to both myapex and the platform
|
||||||
|
// ensureListContains(t, ctx.ModuleVariantsForTests("libfoo"), "android_arm64_armv8-a_static_myapex")
|
||||||
|
// ensureListContains(t, ctx.ModuleVariantsForTests("libfoo"), "android_arm64_armv8-a_static")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestOverrideApex(t *testing.T) {
|
func TestOverrideApex(t *testing.T) {
|
||||||
|
2
cc/cc.go
2
cc/cc.go
@@ -2550,7 +2550,7 @@ func (c *Module) AndroidMkWriteAdditionalDependenciesForSourceAbiDiff(w io.Write
|
|||||||
|
|
||||||
func (c *Module) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool {
|
func (c *Module) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool {
|
||||||
if depTag, ok := ctx.OtherModuleDependencyTag(dep).(DependencyTag); ok {
|
if depTag, ok := ctx.OtherModuleDependencyTag(dep).(DependencyTag); ok {
|
||||||
if cc, ok := dep.(*Module); ok && cc.IsStubs() && depTag.Shared {
|
if cc, ok := dep.(*Module); ok && cc.HasStubsVariants() && depTag.Shared && depTag.Library {
|
||||||
// dynamic dep to a stubs lib crosses APEX boundary
|
// dynamic dep to a stubs lib crosses APEX boundary
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@@ -583,6 +583,13 @@ func (a *AndroidApp) getCertString(ctx android.BaseModuleContext) string {
|
|||||||
return String(a.overridableAppProperties.Certificate)
|
return String(a.overridableAppProperties.Certificate)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *AndroidApp) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool {
|
||||||
|
if IsJniDepTag(ctx.OtherModuleDependencyTag(dep)) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return a.Library.DepIsInSameApex(ctx, dep)
|
||||||
|
}
|
||||||
|
|
||||||
// For OutputFileProducer interface
|
// For OutputFileProducer interface
|
||||||
func (a *AndroidApp) OutputFiles(tag string) (android.Paths, error) {
|
func (a *AndroidApp) OutputFiles(tag string) (android.Paths, error) {
|
||||||
switch tag {
|
switch tag {
|
||||||
|
14
java/java.go
14
java/java.go
@@ -1717,8 +1717,10 @@ func (j *Module) hasCode(ctx android.ModuleContext) bool {
|
|||||||
|
|
||||||
func (j *Module) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool {
|
func (j *Module) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool {
|
||||||
depTag := ctx.OtherModuleDependencyTag(dep)
|
depTag := ctx.OtherModuleDependencyTag(dep)
|
||||||
// dependencies other than the static linkage are all considered crossing APEX boundary
|
// Dependencies other than the static linkage are all considered crossing APEX boundary
|
||||||
return depTag == staticLibTag
|
// Also, a dependency to an sdk member is also considered as such. This is required because
|
||||||
|
// sdk members should be mutated into APEXes. Refer to sdk.sdkDepsReplaceMutator.
|
||||||
|
return depTag == staticLibTag || j.IsInAnySdk()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (j *Module) Stem() string {
|
func (j *Module) Stem() string {
|
||||||
@@ -2406,6 +2408,14 @@ func (j *Import) SrcJarArgs() ([]string, android.Paths) {
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (j *Import) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool {
|
||||||
|
depTag := ctx.OtherModuleDependencyTag(dep)
|
||||||
|
// dependencies other than the static linkage are all considered crossing APEX boundary
|
||||||
|
// Also, a dependency to an sdk member is also considered as such. This is required because
|
||||||
|
// sdk members should be mutated into APEXes. Refer to sdk.sdkDepsReplaceMutator.
|
||||||
|
return depTag == staticLibTag || j.IsInAnySdk()
|
||||||
|
}
|
||||||
|
|
||||||
// Add compile time check for interface implementation
|
// Add compile time check for interface implementation
|
||||||
var _ android.IDEInfo = (*Import)(nil)
|
var _ android.IDEInfo = (*Import)(nil)
|
||||||
var _ android.IDECustomizedModuleName = (*Import)(nil)
|
var _ android.IDECustomizedModuleName = (*Import)(nil)
|
||||||
|
@@ -34,7 +34,7 @@ func TestBasicSdkWithJavaLibrary(t *testing.T) {
|
|||||||
result := testSdkWithJava(t, `
|
result := testSdkWithJava(t, `
|
||||||
sdk {
|
sdk {
|
||||||
name: "mysdk",
|
name: "mysdk",
|
||||||
java_header_libs: ["myjavalib"],
|
java_header_libs: ["sdkmember"],
|
||||||
}
|
}
|
||||||
|
|
||||||
sdk_snapshot {
|
sdk_snapshot {
|
||||||
@@ -47,22 +47,36 @@ func TestBasicSdkWithJavaLibrary(t *testing.T) {
|
|||||||
java_header_libs: ["sdkmember_mysdk_2"],
|
java_header_libs: ["sdkmember_mysdk_2"],
|
||||||
}
|
}
|
||||||
|
|
||||||
java_import {
|
java_library {
|
||||||
name: "sdkmember",
|
name: "sdkmember",
|
||||||
prefer: false,
|
srcs: ["Test.java"],
|
||||||
|
system_modules: "none",
|
||||||
|
sdk_version: "none",
|
||||||
host_supported: true,
|
host_supported: true,
|
||||||
|
apex_available: [
|
||||||
|
"//apex_available:platform",
|
||||||
|
"//apex_available:anyapex",
|
||||||
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
java_import {
|
java_import {
|
||||||
name: "sdkmember_mysdk_1",
|
name: "sdkmember_mysdk_1",
|
||||||
sdk_member_name: "sdkmember",
|
sdk_member_name: "sdkmember",
|
||||||
host_supported: true,
|
host_supported: true,
|
||||||
|
apex_available: [
|
||||||
|
"//apex_available:platform",
|
||||||
|
"//apex_available:anyapex",
|
||||||
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
java_import {
|
java_import {
|
||||||
name: "sdkmember_mysdk_2",
|
name: "sdkmember_mysdk_2",
|
||||||
sdk_member_name: "sdkmember",
|
sdk_member_name: "sdkmember",
|
||||||
host_supported: true,
|
host_supported: true,
|
||||||
|
apex_available: [
|
||||||
|
"//apex_available:platform",
|
||||||
|
"//apex_available:anyapex",
|
||||||
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
java_library {
|
java_library {
|
||||||
|
Reference in New Issue
Block a user