apex_available tracks static dependencies am: 0f80c1848a
am: 820d29f9df
Change-Id: I6ccfa012f0fe4df43ea52d0ce4698c76a3cce324
This commit is contained in:
commit
9476209070
|
@ -180,20 +180,20 @@ func (m *ApexModuleBase) checkApexAvailableProperty(mctx BaseModuleContext) {
|
|||
func (m *ApexModuleBase) CreateApexVariations(mctx BottomUpMutatorContext) []Module {
|
||||
if len(m.apexVariations) > 0 {
|
||||
m.checkApexAvailableProperty(mctx)
|
||||
|
||||
sort.Strings(m.apexVariations)
|
||||
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...)
|
||||
|
||||
defaultVariation := ""
|
||||
mctx.SetDefaultDependencyVariation(&defaultVariation)
|
||||
|
||||
modules := mctx.CreateVariations(variations...)
|
||||
for i, m := range modules {
|
||||
if availableForPlatform && i == 0 {
|
||||
continue
|
||||
platformVariation := i == 0
|
||||
if platformVariation && !mctx.Host() && !m.(ApexModule).AvailableFor(AvailableToPlatform) {
|
||||
m.SkipInstall()
|
||||
}
|
||||
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",
|
||||
system_modules: "none",
|
||||
compile_dex: true,
|
||||
// TODO: remove //apex_available:platform
|
||||
apex_available: [
|
||||
"//apex_available:platform",
|
||||
"myapex",
|
||||
],
|
||||
}
|
||||
|
||||
java_library {
|
||||
|
@ -760,7 +765,7 @@ func TestApexWithStubs(t *testing.T) {
|
|||
ensureNotContains(t, mylibLdFlags, "mylib3/android_arm64_armv8-a_shared_12_myapex/mylib3.so")
|
||||
|
||||
// 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 ")
|
||||
|
||||
// Ensure that genstub is invoked with --apex
|
||||
|
@ -886,6 +891,7 @@ func TestApexWithRuntimeLibsDependency(t *testing.T) {
|
|||
stubs: {
|
||||
versions: ["10", "20", "30"],
|
||||
},
|
||||
apex_available: [ "myapex" ],
|
||||
}
|
||||
|
||||
cc_library {
|
||||
|
@ -1573,6 +1579,7 @@ func TestHeaderLibsDependency(t *testing.T) {
|
|||
export_include_dirs: ["my_include"],
|
||||
system_shared_libs: [],
|
||||
stl: "none",
|
||||
apex_available: [ "myapex" ],
|
||||
}
|
||||
|
||||
cc_library {
|
||||
|
@ -3026,6 +3033,7 @@ func TestApexWithApps(t *testing.T) {
|
|||
srcs: ["mylib.cpp"],
|
||||
stl: "none",
|
||||
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
|
||||
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")
|
||||
// TODO(jiyong) the checks for the platform variant are removed because we now create
|
||||
// the platform variant regardless of the apex_availability. Instead, we will make sure that
|
||||
// the platform variants are not used from other platform modules. When that is done,
|
||||
// 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, `
|
||||
apex {
|
||||
|
@ -3333,11 +3346,16 @@ func TestApexAvailable(t *testing.T) {
|
|||
}`)
|
||||
|
||||
// shared variant of libfoo is only available to myapex
|
||||
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")
|
||||
// TODO(jiyong) the checks for the platform variant are removed because we now create
|
||||
// the platform variant regardless of the apex_availability. Instead, we will make sure that
|
||||
// the platform variants are not used from other platform modules. When that is done,
|
||||
// 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")
|
||||
// // 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) {
|
||||
|
|
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 {
|
||||
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
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -583,6 +583,13 @@ func (a *AndroidApp) getCertString(ctx android.BaseModuleContext) string {
|
|||
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
|
||||
func (a *AndroidApp) OutputFiles(tag string) (android.Paths, error) {
|
||||
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 {
|
||||
depTag := ctx.OtherModuleDependencyTag(dep)
|
||||
// dependencies other than the static linkage are all considered crossing APEX boundary
|
||||
return depTag == staticLibTag
|
||||
// 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()
|
||||
}
|
||||
|
||||
func (j *Module) Stem() string {
|
||||
|
@ -2406,6 +2408,14 @@ func (j *Import) SrcJarArgs() ([]string, android.Paths) {
|
|||
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
|
||||
var _ android.IDEInfo = (*Import)(nil)
|
||||
var _ android.IDECustomizedModuleName = (*Import)(nil)
|
||||
|
|
|
@ -34,7 +34,7 @@ func TestBasicSdkWithJavaLibrary(t *testing.T) {
|
|||
result := testSdkWithJava(t, `
|
||||
sdk {
|
||||
name: "mysdk",
|
||||
java_header_libs: ["myjavalib"],
|
||||
java_header_libs: ["sdkmember"],
|
||||
}
|
||||
|
||||
sdk_snapshot {
|
||||
|
@ -47,22 +47,36 @@ func TestBasicSdkWithJavaLibrary(t *testing.T) {
|
|||
java_header_libs: ["sdkmember_mysdk_2"],
|
||||
}
|
||||
|
||||
java_import {
|
||||
java_library {
|
||||
name: "sdkmember",
|
||||
prefer: false,
|
||||
srcs: ["Test.java"],
|
||||
system_modules: "none",
|
||||
sdk_version: "none",
|
||||
host_supported: true,
|
||||
apex_available: [
|
||||
"//apex_available:platform",
|
||||
"//apex_available:anyapex",
|
||||
],
|
||||
}
|
||||
|
||||
java_import {
|
||||
name: "sdkmember_mysdk_1",
|
||||
sdk_member_name: "sdkmember",
|
||||
host_supported: true,
|
||||
apex_available: [
|
||||
"//apex_available:platform",
|
||||
"//apex_available:anyapex",
|
||||
],
|
||||
}
|
||||
|
||||
java_import {
|
||||
name: "sdkmember_mysdk_2",
|
||||
sdk_member_name: "sdkmember",
|
||||
host_supported: true,
|
||||
apex_available: [
|
||||
"//apex_available:platform",
|
||||
"//apex_available:anyapex",
|
||||
],
|
||||
}
|
||||
|
||||
java_library {
|
||||
|
|
Loading…
Reference in New Issue