Merge "raw_binary output should not be executable."
diff --git a/android/allowlists/allowlists.go b/android/allowlists/allowlists.go
index 622c3c4..0cb6946 100644
--- a/android/allowlists/allowlists.go
+++ b/android/allowlists/allowlists.go
@@ -39,14 +39,15 @@
Bp2buildDefaultConfig = Bp2BuildConfig{
"art/libartpalette": Bp2BuildDefaultTrueRecursively,
"art/libdexfile": Bp2BuildDefaultTrueRecursively,
+ "art/libnativebridge": Bp2BuildDefaultTrueRecursively,
"art/runtime": Bp2BuildDefaultTrueRecursively,
"art/tools": Bp2BuildDefaultTrue,
"bionic": Bp2BuildDefaultTrueRecursively,
"bootable/recovery/tools/recovery_l10n": Bp2BuildDefaultTrue,
+ "build/bazel/examples/apex/minimal": Bp2BuildDefaultTrueRecursively,
"build/bazel/examples/soong_config_variables": Bp2BuildDefaultTrueRecursively,
- "build/bazel/examples/apex/minimal": Bp2BuildDefaultTrueRecursively,
- "build/make/tools/signapk": Bp2BuildDefaultTrue,
"build/make/target/product/security": Bp2BuildDefaultTrue,
+ "build/make/tools/signapk": Bp2BuildDefaultTrue,
"build/soong": Bp2BuildDefaultTrue,
"build/soong/cc/libbuildversion": Bp2BuildDefaultTrue, // Skip tests subdir
"build/soong/cc/ndkstubgen": Bp2BuildDefaultTrue,
@@ -90,6 +91,7 @@
"development/samples/VoicemailProviderDemo": Bp2BuildDefaultTrue,
"development/samples/WiFiDirectDemo": Bp2BuildDefaultTrue,
"development/sdk": Bp2BuildDefaultTrueRecursively,
+ "external/aac": Bp2BuildDefaultTrueRecursively,
"external/arm-optimized-routines": Bp2BuildDefaultTrueRecursively,
"external/auto/android-annotation-stubs": Bp2BuildDefaultTrueRecursively,
"external/auto/common": Bp2BuildDefaultTrueRecursively,
@@ -99,7 +101,9 @@
"external/brotli": Bp2BuildDefaultTrue,
"external/conscrypt": Bp2BuildDefaultTrue,
"external/e2fsprogs": Bp2BuildDefaultTrueRecursively,
+ "external/eigen": Bp2BuildDefaultTrueRecursively,
"external/error_prone": Bp2BuildDefaultTrueRecursively,
+ "external/flac": Bp2BuildDefaultTrueRecursively,
"external/fmtlib": Bp2BuildDefaultTrueRecursively,
"external/google-benchmark": Bp2BuildDefaultTrueRecursively,
"external/googletest": Bp2BuildDefaultTrueRecursively,
@@ -113,10 +117,14 @@
"external/jemalloc_new": Bp2BuildDefaultTrueRecursively,
"external/jsoncpp": Bp2BuildDefaultTrueRecursively,
"external/junit": Bp2BuildDefaultTrueRecursively,
+ "external/libavc": Bp2BuildDefaultTrueRecursively,
"external/libcap": Bp2BuildDefaultTrueRecursively,
"external/libcxx": Bp2BuildDefaultTrueRecursively,
"external/libcxxabi": Bp2BuildDefaultTrueRecursively,
"external/libevent": Bp2BuildDefaultTrueRecursively,
+ "external/libgav1": Bp2BuildDefaultTrueRecursively,
+ "external/libhevc": Bp2BuildDefaultTrueRecursively,
+ "external/libmpeg2": Bp2BuildDefaultTrueRecursively,
"external/libpng": Bp2BuildDefaultTrueRecursively,
"external/lz4/lib": Bp2BuildDefaultTrue,
"external/lzma/C": Bp2BuildDefaultTrueRecursively,
@@ -131,10 +139,15 @@
"external/selinux/libsepol": Bp2BuildDefaultTrueRecursively,
"external/zlib": Bp2BuildDefaultTrueRecursively,
"external/zstd": Bp2BuildDefaultTrueRecursively,
+ "frameworks/av/media/codecs/g711/decoder": Bp2BuildDefaultTrueRecursively,
+ "frameworks/av/services/minijail": Bp2BuildDefaultTrueRecursively,
"frameworks/base/media/tests/MediaDump": Bp2BuildDefaultTrue,
"frameworks/base/startop/apps/test": Bp2BuildDefaultTrue,
"frameworks/base/tests/appwidgets/AppWidgetHostTest": Bp2BuildDefaultTrueRecursively,
"frameworks/native/libs/adbd_auth": Bp2BuildDefaultTrueRecursively,
+ "frameworks/native/libs/arect": Bp2BuildDefaultTrueRecursively,
+ "frameworks/native/libs/math": Bp2BuildDefaultTrueRecursively,
+ "frameworks/native/libs/nativebase": Bp2BuildDefaultTrueRecursively,
"frameworks/native/opengl/tests/gl2_cameraeye": Bp2BuildDefaultTrue,
"frameworks/native/opengl/tests/gl2_java": Bp2BuildDefaultTrue,
"frameworks/native/opengl/tests/testLatency": Bp2BuildDefaultTrue,
@@ -160,8 +173,8 @@
"prebuilts/clang/host/linux-x86": Bp2BuildDefaultTrueRecursively,
"prebuilts/tools/common/m2": Bp2BuildDefaultTrue,
"system/apex": Bp2BuildDefaultFalse, // TODO(b/207466993): flaky failures
- "system/apex/proto": Bp2BuildDefaultTrueRecursively,
"system/apex/libs": Bp2BuildDefaultTrueRecursively,
+ "system/apex/proto": Bp2BuildDefaultTrueRecursively,
"system/core/debuggerd": Bp2BuildDefaultTrueRecursively,
"system/core/diagnose_usb": Bp2BuildDefaultTrueRecursively,
"system/core/libasyncio": Bp2BuildDefaultTrue,
@@ -175,10 +188,14 @@
"system/core/libutils": Bp2BuildDefaultTrueRecursively,
"system/core/libvndksupport": Bp2BuildDefaultTrueRecursively,
"system/core/property_service/libpropertyinfoparser": Bp2BuildDefaultTrueRecursively,
+ "system/libartpalette": Bp2BuildDefaultTrueRecursively,
"system/libbase": Bp2BuildDefaultTrueRecursively,
+ "system/libfmq": Bp2BuildDefaultTrue,
+ "system/libhwbinder": Bp2BuildDefaultTrueRecursively,
"system/libprocinfo": Bp2BuildDefaultTrue,
"system/libziparchive": Bp2BuildDefaultTrueRecursively,
"system/logging/liblog": Bp2BuildDefaultTrueRecursively,
+ "system/media/audio": Bp2BuildDefaultTrueRecursively,
"system/memory/libmemunreachable": Bp2BuildDefaultTrueRecursively,
"system/sepolicy/apex": Bp2BuildDefaultTrueRecursively,
"system/timezone/apex": Bp2BuildDefaultTrueRecursively,
@@ -237,6 +254,23 @@
}
Bp2buildModuleAlwaysConvertList = []string{
+ // cc mainline modules
+ "libnativeloader-headers",
+ "libgui_bufferqueue_sources",
+ "code_coverage.policy",
+ "code_coverage.policy.other",
+ "codec2_soft_exports",
+ "com.android.media.swcodec-ld.config.txt",
+ "libcodec2_headers",
+ "libcodec2_internal",
+ "com.android.media.swcodec-mediaswcodec.rc",
+ "flatbuffer_headers",
+ "gemmlowp_headers",
+ "gl_headers",
+ "libbluetooth-types-header",
+ "libaudioclient_aidl_conversion_util",
+ "libaudioutils_fixedfft",
+
//external/avb
"avbtool",
"libavb",
diff --git a/android/bazel.go b/android/bazel.go
index 378eb6f..40f2917 100644
--- a/android/bazel.go
+++ b/android/bazel.go
@@ -321,25 +321,31 @@
return a
}
-var bp2buildAllowlist = NewBp2BuildAllowlist().
- SetDefaultConfig(allowlists.Bp2buildDefaultConfig).
- SetKeepExistingBuildFile(allowlists.Bp2buildKeepExistingBuildFile).
- SetModuleAlwaysConvertList(allowlists.Bp2buildModuleAlwaysConvertList).
- SetModuleTypeAlwaysConvertList(allowlists.Bp2buildModuleTypeAlwaysConvertList).
- SetModuleDoNotConvertList(allowlists.Bp2buildModuleDoNotConvertList).
- SetCcLibraryStaticOnlyList(allowlists.Bp2buildCcLibraryStaticOnlyList).
- SetMixedBuildsDisabledList(allowlists.MixedBuildsDisabledList)
+var bp2BuildAllowListKey = NewOnceKey("Bp2BuildAllowlist")
+var bp2buildAllowlist OncePer
+
+func getBp2BuildAllowList() bp2BuildConversionAllowlist {
+ return bp2buildAllowlist.Once(bp2BuildAllowListKey, func() interface{} {
+ return NewBp2BuildAllowlist().SetDefaultConfig(allowlists.Bp2buildDefaultConfig).
+ SetKeepExistingBuildFile(allowlists.Bp2buildKeepExistingBuildFile).
+ SetModuleAlwaysConvertList(allowlists.Bp2buildModuleAlwaysConvertList).
+ SetModuleTypeAlwaysConvertList(allowlists.Bp2buildModuleTypeAlwaysConvertList).
+ SetModuleDoNotConvertList(allowlists.Bp2buildModuleDoNotConvertList).
+ SetCcLibraryStaticOnlyList(allowlists.Bp2buildCcLibraryStaticOnlyList).
+ SetMixedBuildsDisabledList(allowlists.MixedBuildsDisabledList)
+ }).(bp2BuildConversionAllowlist)
+}
// GenerateCcLibraryStaticOnly returns whether a cc_library module should only
// generate a static version of itself based on the current global configuration.
func GenerateCcLibraryStaticOnly(moduleName string) bool {
- return bp2buildAllowlist.ccLibraryStaticOnly[moduleName]
+ return getBp2BuildAllowList().ccLibraryStaticOnly[moduleName]
}
// ShouldKeepExistingBuildFileForDir returns whether an existing BUILD file should be
// added to the build symlink forest based on the current global configuration.
func ShouldKeepExistingBuildFileForDir(dir string) bool {
- return shouldKeepExistingBuildFileForDir(bp2buildAllowlist, dir)
+ return shouldKeepExistingBuildFileForDir(getBp2BuildAllowList(), dir)
}
func shouldKeepExistingBuildFileForDir(allowlist bp2BuildConversionAllowlist, dir string) bool {
@@ -392,7 +398,7 @@
// variants of a cc_library.
return false
}
- return !bp2buildAllowlist.mixedBuildsDisabled[ctx.Module().Name()]
+ return !getBp2BuildAllowList().mixedBuildsDisabled[ctx.Module().Name()]
}
// ConvertedToBazel returns whether this module has been converted (with bp2build or manually) to Bazel.
diff --git a/android/bazel_test.go b/android/bazel_test.go
index 482df2a..e14649e 100644
--- a/android/bazel_test.go
+++ b/android/bazel_test.go
@@ -14,11 +14,12 @@
package android
import (
- "android/soong/android/allowlists"
- "android/soong/bazel"
"fmt"
"testing"
+ "android/soong/android/allowlists"
+ "android/soong/bazel"
+
"github.com/google/blueprint"
"github.com/google/blueprint/proptools"
)
@@ -386,3 +387,37 @@
})
}
}
+
+func TestBp2buildAllowList(t *testing.T) {
+ allowlist := getBp2BuildAllowList()
+ for k, v := range allowlists.Bp2buildDefaultConfig {
+ if allowlist.defaultConfig[k] != v {
+ t.Errorf("bp2build default config of %s: expected: %v, got: %v", k, v, allowlist.defaultConfig[k])
+ }
+ }
+ for k, v := range allowlists.Bp2buildKeepExistingBuildFile {
+ if allowlist.keepExistingBuildFile[k] != v {
+ t.Errorf("bp2build keep existing build file of %s: expected: %v, got: %v", k, v, allowlist.keepExistingBuildFile[k])
+ }
+ }
+ for _, k := range allowlists.Bp2buildModuleTypeAlwaysConvertList {
+ if !allowlist.moduleTypeAlwaysConvert[k] {
+ t.Errorf("bp2build module type always convert of %s: expected: true, got: %v", k, allowlist.moduleTypeAlwaysConvert[k])
+ }
+ }
+ for _, k := range allowlists.Bp2buildModuleDoNotConvertList {
+ if !allowlist.moduleDoNotConvert[k] {
+ t.Errorf("bp2build module do not convert of %s: expected: true, got: %v", k, allowlist.moduleDoNotConvert[k])
+ }
+ }
+ for _, k := range allowlists.Bp2buildCcLibraryStaticOnlyList {
+ if !allowlist.ccLibraryStaticOnly[k] {
+ t.Errorf("bp2build cc library static only of %s: expected: true, got: %v", k, allowlist.ccLibraryStaticOnly[k])
+ }
+ }
+ for _, k := range allowlists.MixedBuildsDisabledList {
+ if !allowlist.mixedBuildsDisabled[k] {
+ t.Errorf("bp2build mix build disabled of %s: expected: true, got: %v", k, allowlist.mixedBuildsDisabled[k])
+ }
+ }
+}
diff --git a/android/config.go b/android/config.go
index 9e96c6a..eb01baa 100644
--- a/android/config.go
+++ b/android/config.go
@@ -558,7 +558,7 @@
}
config.BazelContext, err = NewBazelContext(config)
- config.bp2buildPackageConfig = bp2buildAllowlist
+ config.bp2buildPackageConfig = getBp2BuildAllowList()
return Config{config}, err
}
@@ -698,6 +698,10 @@
return value == "0" || value == "n" || value == "no" || value == "off" || value == "false"
}
+func (c *config) TargetsJava17() bool {
+ return c.IsEnvTrue("EXPERIMENTAL_TARGET_JAVA_VERSION_17")
+}
+
// EnvDeps returns the environment variables this build depends on. The first
// call to this function blocks future reads from the environment.
func (c *config) EnvDeps() map[string]string {
diff --git a/android/gen_notice.go b/android/gen_notice.go
index f514975..fda91ac 100644
--- a/android/gen_notice.go
+++ b/android/gen_notice.go
@@ -67,7 +67,7 @@
if ctx.Failed() {
return
}
- out(ctx, gm.output, proptools.StringDefault(gm.properties.ArtifactName, defaultName), "", modules...)
+ out(ctx, gm.output, ctx.ModuleName(gm), proptools.StringDefault(gm.properties.ArtifactName, defaultName), "", modules...)
})
}
diff --git a/android/module.go b/android/module.go
index 97a46dd..21d5a3d 100644
--- a/android/module.go
+++ b/android/module.go
@@ -2462,7 +2462,7 @@
bazelConversionMode bool
}
-func (b *baseModuleContext) BazelConversionMode() bool {
+func (b *baseModuleContext) isBazelConversionMode() bool {
return b.bazelConversionMode
}
func (b *baseModuleContext) OtherModuleName(m blueprint.Module) string {
@@ -2851,7 +2851,7 @@
}
func (b *baseModuleContext) ModuleFromName(name string) (blueprint.Module, bool) {
- if !b.BazelConversionMode() {
+ if !b.isBazelConversionMode() {
panic("cannot call ModuleFromName if not in bazel conversion mode")
}
if moduleName, _ := SrcIsModuleWithTag(name); moduleName != "" {
diff --git a/android/mutator.go b/android/mutator.go
index 02a6143..f06ecda 100644
--- a/android/mutator.go
+++ b/android/mutator.go
@@ -232,9 +232,6 @@
// Rename all variants of a module. The new name is not visible to calls to ModuleName,
// AddDependency or OtherModuleName until after this mutator pass is complete.
Rename(name string)
-
- // BazelConversionMode returns whether this mutator is being run as part of Bazel Conversion.
- BazelConversionMode() bool
}
type TopDownMutator func(TopDownMutatorContext)
@@ -626,28 +623,11 @@
func (b *bottomUpMutatorContext) AddVariationDependencies(variations []blueprint.Variation, tag blueprint.DependencyTag,
names ...string) []blueprint.Module {
- if b.bazelConversionMode {
- _, noSelfDeps := RemoveFromList(b.ModuleName(), names)
- if len(noSelfDeps) == 0 {
- return []blueprint.Module(nil)
- }
- // In Bazel conversion mode, mutators should not have created any variants. So, when adding a
- // dependency, the variations would not exist and the dependency could not be added, by
- // specifying no variations, we will allow adding the dependency to succeed.
- return b.bp.AddFarVariationDependencies(nil, tag, noSelfDeps...)
- }
-
return b.bp.AddVariationDependencies(variations, tag, names...)
}
func (b *bottomUpMutatorContext) AddFarVariationDependencies(variations []blueprint.Variation,
tag blueprint.DependencyTag, names ...string) []blueprint.Module {
- if b.bazelConversionMode {
- // In Bazel conversion mode, mutators should not have created any variants. So, when adding a
- // dependency, the variations would not exist and the dependency could not be added, by
- // specifying no variations, we will allow adding the dependency to succeed.
- return b.bp.AddFarVariationDependencies(nil, tag, names...)
- }
return b.bp.AddFarVariationDependencies(variations, tag, names...)
}
diff --git a/android/notices.go b/android/notices.go
index b16dc58..562a156 100644
--- a/android/notices.go
+++ b/android/notices.go
@@ -47,14 +47,14 @@
}
// buildNoticeOutputFromLicenseMetadata writes out a notice file.
-func buildNoticeOutputFromLicenseMetadata(ctx BuilderContext, tool, name string, outputFile WritablePath, libraryName, stripPrefix string, modules ...Module) {
+func buildNoticeOutputFromLicenseMetadata(ctx BuilderContext, tool, ruleName string, outputFile WritablePath, libraryName, stripPrefix string, modules ...Module) {
depsFile := outputFile.ReplaceExtension(ctx, strings.TrimPrefix(outputFile.Ext()+".d", "."))
rule := NewRuleBuilder(pctx, ctx)
if len(modules) == 0 {
if mctx, ok := ctx.(ModuleContext); ok {
modules = []Module{mctx.Module()}
} else {
- panic(fmt.Errorf("%s %q needs a module to generate the notice for", name, libraryName))
+ panic(fmt.Errorf("%s %q needs a module to generate the notice for", ruleName, libraryName))
}
}
if libraryName == "" {
@@ -75,26 +75,26 @@
cmd = cmd.FlagWithArg("--product ", libraryName)
}
cmd = cmd.Inputs(modulesLicenseMetadata(ctx, modules...))
- rule.Build(name, "container notice file")
+ rule.Build(ruleName, "container notice file")
}
// BuildNoticeTextOutputFromLicenseMetadata writes out a notice text file based
// on the license metadata files for the input `modules` defaulting to the
// current context module if none given.
-func BuildNoticeTextOutputFromLicenseMetadata(ctx BuilderContext, outputFile WritablePath, libraryName, stripPrefix string, modules ...Module) {
- buildNoticeOutputFromLicenseMetadata(ctx, "textnotice", "text_notice", outputFile, libraryName, stripPrefix, modules...)
+func BuildNoticeTextOutputFromLicenseMetadata(ctx BuilderContext, outputFile WritablePath, ruleName, libraryName, stripPrefix string, modules ...Module) {
+ buildNoticeOutputFromLicenseMetadata(ctx, "textnotice", "text_notice_"+ruleName, outputFile, libraryName, stripPrefix, modules...)
}
// BuildNoticeHtmlOutputFromLicenseMetadata writes out a notice text file based
// on the license metadata files for the input `modules` defaulting to the
// current context module if none given.
-func BuildNoticeHtmlOutputFromLicenseMetadata(ctx BuilderContext, outputFile WritablePath, libraryName, stripPrefix string, modules ...Module) {
- buildNoticeOutputFromLicenseMetadata(ctx, "htmlnotice", "html_notice", outputFile, libraryName, stripPrefix, modules...)
+func BuildNoticeHtmlOutputFromLicenseMetadata(ctx BuilderContext, outputFile WritablePath, ruleName, libraryName, stripPrefix string, modules ...Module) {
+ buildNoticeOutputFromLicenseMetadata(ctx, "htmlnotice", "html_notice_"+ruleName, outputFile, libraryName, stripPrefix, modules...)
}
// BuildNoticeXmlOutputFromLicenseMetadata writes out a notice text file based
// on the license metadata files for the input `modules` defaulting to the
// current context module if none given.
-func BuildNoticeXmlOutputFromLicenseMetadata(ctx BuilderContext, outputFile WritablePath, libraryName, stripPrefix string, modules ...Module) {
- buildNoticeOutputFromLicenseMetadata(ctx, "xmlnotice", "xml_notice", outputFile, libraryName, stripPrefix, modules...)
+func BuildNoticeXmlOutputFromLicenseMetadata(ctx BuilderContext, outputFile WritablePath, ruleName, libraryName, stripPrefix string, modules ...Module) {
+ buildNoticeOutputFromLicenseMetadata(ctx, "xmlnotice", "xml_notice_"+ruleName, outputFile, libraryName, stripPrefix, modules...)
}
diff --git a/android/sdk.go b/android/sdk.go
index 9317910..2dc0bd7 100644
--- a/android/sdk.go
+++ b/android/sdk.go
@@ -670,6 +670,9 @@
// host OS variant explicitly and disable all other host OS'es.
IsHostOsDependent() bool
+ // SupportedLinkages returns the names of the linkage variants supported by this module.
+ SupportedLinkages() []string
+
// AddDependencies adds dependencies from the SDK module to all the module variants the member
// type contributes to the SDK. `names` is the list of module names given in the member type
// property (as returned by SdkPropertyName()) in the SDK module. The exact set of variants
@@ -733,6 +736,9 @@
// SupportedTraits returns the set of traits supported by this member type.
SupportedTraits() SdkMemberTraitSet
+
+ // Overrides returns whether type overrides other SdkMemberType
+ Overrides(SdkMemberType) bool
}
var _ sdkRegisterable = (SdkMemberType)(nil)
@@ -756,6 +762,13 @@
type SdkMemberTypeBase struct {
PropertyName string
+ // Property names that this SdkMemberTypeBase can override, this is useful when a module type is a
+ // superset of another module type.
+ OverridesPropertyNames map[string]bool
+
+ // The names of linkage variants supported by this module.
+ SupportedLinkageNames []string
+
// When set to true BpPropertyNotRequired indicates that the member type does not require the
// property to be specifiable in an Android.bp file.
BpPropertyNotRequired bool
@@ -796,6 +809,14 @@
return NewSdkMemberTraitSet(b.Traits)
}
+func (b *SdkMemberTypeBase) Overrides(other SdkMemberType) bool {
+ return b.OverridesPropertyNames[other.SdkPropertyName()]
+}
+
+func (b *SdkMemberTypeBase) SupportedLinkages() []string {
+ return b.SupportedLinkageNames
+}
+
// registeredModuleExportsMemberTypes is the set of registered SdkMemberTypes for module_exports
// modules.
var registeredModuleExportsMemberTypes = &sdkRegistry{}
diff --git a/android/singleton.go b/android/singleton.go
index ec7f63e..7c6cf4f 100644
--- a/android/singleton.go
+++ b/android/singleton.go
@@ -272,7 +272,8 @@
if depQualified.pkg != qualified.pkg {
rule := effectiveVisibilityRules(s.Config(), depQualified)
if !rule.matches(qualified) {
- s.ModuleErrorf(referer, "references %s which is not visible to this module\nYou may need to add %q to its visibility", depQualified, "//"+s.ModuleDir(m))
+ s.ModuleErrorf(referer, "module %q references %q which is not visible to this module\nYou may need to add %q to its visibility",
+ referer.Name(), depQualified, "//"+s.ModuleDir(referer))
continue
}
}
diff --git a/android/testing.go b/android/testing.go
index ac02db9..85bdca4 100644
--- a/android/testing.go
+++ b/android/testing.go
@@ -83,6 +83,8 @@
FixtureRegisterWithContext(registerLicenseMutators),
)
+var PrepareForTestWithGenNotice = FixtureRegisterWithContext(RegisterGenNoticeBuildComponents)
+
func registerLicenseMutators(ctx RegistrationContext) {
ctx.PreArchMutators(RegisterLicensesPackageMapper)
ctx.PreArchMutators(RegisterLicensesPropertyGatherer)
diff --git a/android/visibility_test.go b/android/visibility_test.go
index 714c92a..a66f0b6 100644
--- a/android/visibility_test.go
+++ b/android/visibility_test.go
@@ -135,7 +135,49 @@
name: "libexample",
visibility: ["//visibility:public"],
}
-
+
+ mock_library {
+ name: "libsamepackage",
+ deps: ["libexample"],
+ }
+
+ gen_notice {
+ name: "libexample-notice",
+ for: ["libexample"],
+ }`),
+ "top/nested/Android.bp": []byte(`
+ mock_library {
+ name: "libnested",
+ deps: ["libexample"],
+ }
+
+ gen_notice {
+ name: "nested-notice",
+ for: ["libexample"],
+ }`),
+ "other/Android.bp": []byte(`
+ mock_library {
+ name: "libother",
+ deps: ["libexample"],
+ }
+
+ gen_notice {
+ name: "other-notice",
+ for: ["libexample"],
+ }`),
+ },
+ },
+ {
+ // Verify that //visibility:private allows the module to be referenced from the current
+ // directory only.
+ name: "//visibility:private",
+ fs: MockFS{
+ "top/Android.bp": []byte(`
+ mock_library {
+ name: "libexample",
+ visibility: ["//visibility:private"],
+ }
+
mock_library {
name: "libsamepackage",
deps: ["libexample"],
@@ -151,18 +193,61 @@
deps: ["libexample"],
}`),
},
+ expectedErrors: []string{
+ `module "libnested" variant "android_common": depends on //top:libexample which is not` +
+ ` visible to this module`,
+ `module "libother" variant "android_common": depends on //top:libexample which is not` +
+ ` visible to this module`,
+ },
},
{
// Verify that //visibility:private allows the module to be referenced from the current
// directory only.
- name: "//visibility:private",
+ name: "//visibility:private (notices)",
fs: MockFS{
"top/Android.bp": []byte(`
mock_library {
name: "libexample",
visibility: ["//visibility:private"],
}
-
+
+ mock_library {
+ name: "libsamepackage",
+ deps: ["libexample"],
+ }
+
+ gen_notice {
+ name: "libexample-notice",
+ for: ["libexample"],
+ }`),
+ "top/nested/Android.bp": []byte(`
+ gen_notice {
+ name: "nested-notice",
+ for: ["libexample"],
+ }`),
+ "other/Android.bp": []byte(`
+ gen_notice {
+ name: "other-notice",
+ for: ["libexample"],
+ }`),
+ },
+ expectedErrors: []string{
+ `module "nested-notice" references "//top:libexample" which is not visible to this` +
+ ` module\nYou may need to add "//top/nested" to its visibility`,
+ `module "other-notice" references "//top:libexample" which is not visible to this module\n` +
+ `You may need to add "//other" to its visibility`,
+ },
+ },
+ {
+ // Verify that :__pkg__ allows the module to be referenced from the current directory only.
+ name: ":__pkg__",
+ fs: MockFS{
+ "top/Android.bp": []byte(`
+ mock_library {
+ name: "libexample",
+ visibility: [":__pkg__"],
+ }
+
mock_library {
name: "libsamepackage",
deps: ["libexample"],
@@ -187,34 +272,32 @@
},
{
// Verify that :__pkg__ allows the module to be referenced from the current directory only.
- name: ":__pkg__",
+ name: ":__pkg__ (notices)",
fs: MockFS{
"top/Android.bp": []byte(`
mock_library {
name: "libexample",
visibility: [":__pkg__"],
}
-
- mock_library {
- name: "libsamepackage",
- deps: ["libexample"],
+
+ gen_notice {
+ name: "libexample-notice",
+ for: ["libexample"],
}`),
"top/nested/Android.bp": []byte(`
- mock_library {
- name: "libnested",
- deps: ["libexample"],
+ gen_notice {
+ name: "nested-notice",
+ for: ["libexample"],
}`),
"other/Android.bp": []byte(`
- mock_library {
- name: "libother",
- deps: ["libexample"],
+ gen_notice {
+ name: "other-notice",
+ for: ["libexample"],
}`),
},
expectedErrors: []string{
- `module "libnested" variant "android_common": depends on //top:libexample which is not` +
- ` visible to this module`,
- `module "libother" variant "android_common": depends on //top:libexample which is not` +
- ` visible to this module`,
+ `module "nested-notice" references "//top:libexample" which is not visible to this module`,
+ `module "other-notice" references "//top:libexample" which is not visible to this module`,
},
},
{
@@ -227,7 +310,7 @@
name: "libexample",
visibility: ["//top/nested"],
}
-
+
mock_library {
name: "libsamepackage",
deps: ["libexample"],
@@ -256,6 +339,42 @@
},
},
{
+ // Verify that //top/nested allows the module to be referenced from the current directory and
+ // the top/nested directory only, not a subdirectory of top/nested and not peak directory.
+ name: "//top/nested (notices)",
+ fs: MockFS{
+ "top/Android.bp": []byte(`
+ mock_library {
+ name: "libexample",
+ visibility: ["//top/nested"],
+ }
+
+ gen_notice {
+ name: "libexample-notice",
+ for: ["libexample"],
+ }`),
+ "top/nested/Android.bp": []byte(`
+ gen_notice {
+ name: "nested-notice",
+ for: ["libexample"],
+ }`),
+ "top/nested/again/Android.bp": []byte(`
+ gen_notice {
+ name: "nestedagain-notice",
+ for: ["libexample"],
+ }`),
+ "peak/Android.bp": []byte(`
+ gen_notice {
+ name: "other-notice",
+ for: ["libexample"],
+ }`),
+ },
+ expectedErrors: []string{
+ `module "other-notice" references "//top:libexample" which is not visible to this module`,
+ `module "nestedagain-notice" references "//top:libexample" which is not visible to this module`,
+ },
+ },
+ {
// Verify that :__subpackages__ allows the module to be referenced from the current directory
// and sub directories but nowhere else.
name: ":__subpackages__",
@@ -265,7 +384,7 @@
name: "libexample",
visibility: [":__subpackages__"],
}
-
+
mock_library {
name: "libsamepackage",
deps: ["libexample"],
@@ -287,6 +406,36 @@
},
},
{
+ // Verify that :__subpackages__ allows the module to be referenced from the current directory
+ // and sub directories but nowhere else.
+ name: ":__subpackages__ (notices)",
+ fs: MockFS{
+ "top/Android.bp": []byte(`
+ mock_library {
+ name: "libexample",
+ visibility: [":__subpackages__"],
+ }
+
+ gen_notice {
+ name: "libexample-notice",
+ for: ["libexample"],
+ }`),
+ "top/nested/Android.bp": []byte(`
+ gen_notice {
+ name: "nested-notice",
+ for: ["libexample"],
+ }`),
+ "peak/other/Android.bp": []byte(`
+ gen_notice {
+ name: "other-notice",
+ for: ["libexample"],
+ }`),
+ },
+ expectedErrors: []string{
+ `module "other-notice" references "//top:libexample" which is not visible to this module`,
+ },
+ },
+ {
// Verify that //top/nested:__subpackages__ allows the module to be referenced from the current
// directory and sub directories but nowhere else.
name: "//top/nested:__subpackages__",
@@ -296,7 +445,7 @@
name: "libexample",
visibility: ["//top/nested:__subpackages__", "//other"],
}
-
+
mock_library {
name: "libsamepackage",
deps: ["libexample"],
@@ -318,6 +467,36 @@
},
},
{
+ // Verify that //top/nested:__subpackages__ allows the module to be referenced from the current
+ // directory and sub directories but nowhere else.
+ name: "//top/nested:__subpackages__ (notices)",
+ fs: MockFS{
+ "top/Android.bp": []byte(`
+ mock_library {
+ name: "libexample",
+ visibility: ["//top/nested:__subpackages__", "//other"],
+ }
+
+ gen_notice {
+ name: "libexample-notice",
+ for: ["libexample"],
+ }`),
+ "top/nested/Android.bp": []byte(`
+ gen_notice {
+ name: "nested-notice",
+ for: ["libexample"],
+ }`),
+ "top/other/Android.bp": []byte(`
+ gen_notice {
+ name: "other-notice",
+ for: ["libexample"],
+ }`),
+ },
+ expectedErrors: []string{
+ `module "other-notice" references "//top:libexample" which is not visible to this module`,
+ },
+ },
+ {
// Verify that ["//top/nested", "//peak:__subpackages"] allows the module to be referenced from
// the current directory, top/nested and peak and all its subpackages.
name: `["//top/nested", "//peak:__subpackages__"]`,
@@ -327,7 +506,7 @@
name: "libexample",
visibility: ["//top/nested", "//peak:__subpackages__"],
}
-
+
mock_library {
name: "libsamepackage",
deps: ["libexample"],
@@ -345,6 +524,33 @@
},
},
{
+ // Verify that ["//top/nested", "//peak:__subpackages"] allows the module to be referenced from
+ // the current directory, top/nested and peak and all its subpackages.
+ name: `["//top/nested", "//peak:__subpackages__ (notices)"]`,
+ fs: MockFS{
+ "top/Android.bp": []byte(`
+ mock_library {
+ name: "libexample",
+ visibility: ["//top/nested", "//peak:__subpackages__"],
+ }
+
+ gen_notice {
+ name: "libexample-notice",
+ for: ["libexample"],
+ }`),
+ "top/nested/Android.bp": []byte(`
+ gen_notice {
+ name: "nested-notice",
+ for: ["libexample"],
+ }`),
+ "peak/other/Android.bp": []byte(`
+ gen_notice {
+ name: "other-notice",
+ for: ["libexample"],
+ }`),
+ },
+ },
+ {
// Verify that //vendor... cannot be used outside vendor apart from //vendor:__subpackages__
name: `//vendor`,
fs: MockFS{
@@ -353,7 +559,7 @@
name: "libexample",
visibility: ["//vendor:__subpackages__"],
}
-
+
mock_library {
name: "libsamepackage",
visibility: ["//vendor/apps/AcmeSettings"],
@@ -418,6 +624,45 @@
},
},
{
+ // Check that visibility is the union of the defaults modules.
+ name: "defaults union, basic (notices)",
+ fs: MockFS{
+ "top/Android.bp": []byte(`
+ mock_defaults {
+ name: "libexample_defaults",
+ visibility: ["//other"],
+ }
+ mock_library {
+ name: "libexample",
+ visibility: ["//top/nested"],
+ defaults: ["libexample_defaults"],
+ }
+
+ gen_notice {
+ name: "libexample-notice",
+ for: ["libexample"],
+ }`),
+ "top/nested/Android.bp": []byte(`
+ gen_notice {
+ name: "nested-notice",
+ for: ["libexample"],
+ }`),
+ "other/Android.bp": []byte(`
+ gen_notice {
+ name: "other-notice",
+ for: ["libexample"],
+ }`),
+ "outsider/Android.bp": []byte(`
+ gen_notice {
+ name: "outsider-notice",
+ for: ["libexample"],
+ }`),
+ },
+ expectedErrors: []string{
+ `module "outsider-notice" references "//top:libexample" which is not visible to this module`,
+ },
+ },
+ {
name: "defaults union, multiple defaults",
fs: MockFS{
"top/Android.bp": []byte(`
@@ -459,6 +704,47 @@
},
},
{
+ name: "defaults union, multiple defaults (notices)",
+ fs: MockFS{
+ "top/Android.bp": []byte(`
+ mock_defaults {
+ name: "libexample_defaults_1",
+ visibility: ["//other"],
+ }
+ mock_defaults {
+ name: "libexample_defaults_2",
+ visibility: ["//top/nested"],
+ }
+ mock_library {
+ name: "libexample",
+ defaults: ["libexample_defaults_1", "libexample_defaults_2"],
+ }
+
+ gen_notice {
+ name: "libexample-notice",
+ for: ["libexample"],
+ }`),
+ "top/nested/Android.bp": []byte(`
+ gen_notice {
+ name: "nested-notice",
+ for: ["libexample"],
+ }`),
+ "other/Android.bp": []byte(`
+ gen_notice {
+ name: "other-notice",
+ for: ["libexample"],
+ }`),
+ "outsider/Android.bp": []byte(`
+ gen_notice {
+ name: "outsider-notice",
+ for: ["libexample"],
+ }`),
+ },
+ expectedErrors: []string{
+ `module "outsider-notice" references "//top:libexample" which is not visible to this module`,
+ },
+ },
+ {
name: "//visibility:public mixed with other in defaults",
fs: MockFS{
"top/Android.bp": []byte(`
@@ -500,6 +786,29 @@
},
},
{
+ name: "//visibility:public overriding defaults (notices)",
+ fs: MockFS{
+ "top/Android.bp": []byte(`
+ mock_defaults {
+ name: "libexample_defaults",
+ visibility: ["//namespace"],
+ }
+ mock_library {
+ name: "libexample",
+ visibility: ["//visibility:public"],
+ defaults: ["libexample_defaults"],
+ }`),
+ "outsider/Android.bp": []byte(`
+ gen_notice {
+ name: "outsider-notice",
+ for: ["libexample"],
+ }`),
+ },
+ effectiveVisibility: map[qualifiedModuleName][]string{
+ qualifiedModuleName{pkg: "top", name: "libexample"}: {"//visibility:public"},
+ },
+ },
+ {
name: "//visibility:public mixed with other from different defaults 1",
fs: MockFS{
"top/Android.bp": []byte(`
@@ -523,6 +832,34 @@
},
},
{
+ name: "//visibility:public mixed with other from different defaults 1",
+ fs: MockFS{
+ "top/Android.bp": []byte(`
+ mock_defaults {
+ name: "libexample_defaults_1",
+ visibility: ["//namespace"],
+ }
+ mock_defaults {
+ name: "libexample_defaults_2",
+ visibility: ["//visibility:public"],
+ }
+ mock_library {
+ name: "libexample",
+ defaults: ["libexample_defaults_1", "libexample_defaults_2"],
+ }
+
+ gen_notice {
+ name: "libexample-notice",
+ for: ["libexample"],
+ }`),
+ "outsider/Android.bp": []byte(`
+ gen_notice {
+ name: "outsider-notice",
+ for: ["libexample"],
+ }`),
+ },
+ },
+ {
name: "//visibility:public mixed with other from different defaults 2",
fs: MockFS{
"top/Android.bp": []byte(`
@@ -546,6 +883,29 @@
},
},
{
+ name: "//visibility:public mixed with other from different defaults 2 (notices)",
+ fs: MockFS{
+ "top/Android.bp": []byte(`
+ mock_defaults {
+ name: "libexample_defaults_1",
+ visibility: ["//visibility:public"],
+ }
+ mock_defaults {
+ name: "libexample_defaults_2",
+ visibility: ["//namespace"],
+ }
+ mock_library {
+ name: "libexample",
+ defaults: ["libexample_defaults_1", "libexample_defaults_2"],
+ }`),
+ "outsider/Android.bp": []byte(`
+ gen_notice {
+ name: "outsider-notice",
+ for: ["libexample"],
+ }`),
+ },
+ },
+ {
name: "//visibility:private in defaults",
fs: MockFS{
"top/Android.bp": []byte(`
@@ -580,6 +940,39 @@
},
},
{
+ name: "//visibility:private in defaults (notices)",
+ fs: MockFS{
+ "top/Android.bp": []byte(`
+ mock_defaults {
+ name: "libexample_defaults",
+ visibility: ["//visibility:private"],
+ }
+ mock_library {
+ name: "libexample",
+ defaults: ["libexample_defaults"],
+ }
+
+ gen_notice {
+ name: "libexample-notice",
+ for: ["libexample"],
+ }`),
+ "top/nested/Android.bp": []byte(`
+ gen_notice {
+ name: "nested-notice",
+ for: ["libexample"],
+ }`),
+ "other/Android.bp": []byte(`
+ gen_notice {
+ name: "other-notice",
+ for: ["libexample"],
+ }`),
+ },
+ expectedErrors: []string{
+ `module "nested-notice" references "//top:libexample" which is not visible to this module`,
+ `module "other-notice" references "//top:libexample" which is not visible to this module`,
+ },
+ },
+ {
name: "//visibility:private mixed with other in defaults",
fs: MockFS{
"top/Android.bp": []byte(`
@@ -706,6 +1099,27 @@
},
},
{
+ name: "//visibility:override discards //visibility:private (notices)",
+ fs: MockFS{
+ "top/Android.bp": []byte(`
+ mock_defaults {
+ name: "libexample_defaults",
+ visibility: ["//visibility:private"],
+ }
+ mock_library {
+ name: "libexample",
+ // Make this visibility to //other but not //visibility:private
+ visibility: ["//visibility:override", "//other"],
+ defaults: ["libexample_defaults"],
+ }`),
+ "other/Android.bp": []byte(`
+ gen_notice {
+ name: "other-notice",
+ for: ["libexample"],
+ }`),
+ },
+ },
+ {
name: "//visibility:override discards //visibility:public",
fs: MockFS{
"top/Android.bp": []byte(`
@@ -735,6 +1149,35 @@
},
},
{
+ name: "//visibility:override discards //visibility:public (notices)",
+ fs: MockFS{
+ "top/Android.bp": []byte(`
+ mock_defaults {
+ name: "libexample_defaults",
+ visibility: ["//visibility:public"],
+ }
+ mock_library {
+ name: "libexample",
+ // Make this visibility to //other but not //visibility:public
+ visibility: ["//visibility:override", "//other"],
+ defaults: ["libexample_defaults"],
+ }`),
+ "other/Android.bp": []byte(`
+ gen_notice {
+ name: "other-notice",
+ for: ["libexample"],
+ }`),
+ "namespace/Android.bp": []byte(`
+ gen_notice {
+ name: "namespace-notice",
+ for: ["libexample"],
+ }`),
+ },
+ expectedErrors: []string{
+ `module "namespace-notice" references "//top:libexample" which is not visible to this module\nYou may need to add "//namespace" to its visibility`,
+ },
+ },
+ {
name: "//visibility:override discards defaults supplied rules",
fs: MockFS{
"top/Android.bp": []byte(`
@@ -764,6 +1207,35 @@
},
},
{
+ name: "//visibility:override discards defaults supplied rules (notices)",
+ fs: MockFS{
+ "top/Android.bp": []byte(`
+ mock_defaults {
+ name: "libexample_defaults",
+ visibility: ["//namespace"],
+ }
+ mock_library {
+ name: "libexample",
+ // Make this visibility to //other but not //namespace
+ visibility: ["//visibility:override", "//other"],
+ defaults: ["libexample_defaults"],
+ }`),
+ "other/Android.bp": []byte(`
+ gen_notice {
+ name: "other-notice",
+ for: ["libexample"],
+ }`),
+ "namespace/Android.bp": []byte(`
+ gen_notice {
+ name: "namespace-notice",
+ for: ["libexample"],
+ }`),
+ },
+ expectedErrors: []string{
+ `module "namespace-notice" references "//top:libexample" which is not visible to this module\nYou may need to add "//namespace" to its visibility`,
+ },
+ },
+ {
name: "//visibility:override can override //visibility:public with //visibility:private",
fs: MockFS{
"top/Android.bp": []byte(`
@@ -787,6 +1259,29 @@
},
},
{
+ name: "//visibility:override can override //visibility:public with //visibility:private (notices)",
+ fs: MockFS{
+ "top/Android.bp": []byte(`
+ mock_defaults {
+ name: "libexample_defaults",
+ visibility: ["//visibility:public"],
+ }
+ mock_library {
+ name: "libexample",
+ visibility: ["//visibility:override", "//visibility:private"],
+ defaults: ["libexample_defaults"],
+ }`),
+ "namespace/Android.bp": []byte(`
+ gen_notice {
+ name: "namespace-notice",
+ for: ["libexample"],
+ }`),
+ },
+ expectedErrors: []string{
+ `module "namespace-notice" references "//top:libexample" which is not visible to this module`,
+ },
+ },
+ {
name: "//visibility:override can override //visibility:private with //visibility:public",
fs: MockFS{
"top/Android.bp": []byte(`
@@ -807,6 +1302,26 @@
},
},
{
+ name: "//visibility:override can override //visibility:private with //visibility:public (notices)",
+ fs: MockFS{
+ "top/Android.bp": []byte(`
+ mock_defaults {
+ name: "libexample_defaults",
+ visibility: ["//visibility:private"],
+ }
+ mock_library {
+ name: "libexample",
+ visibility: ["//visibility:override", "//visibility:public"],
+ defaults: ["libexample_defaults"],
+ }`),
+ "namespace/Android.bp": []byte(`
+ gen_notice {
+ name: "namespace-notice",
+ for: ["libexample"],
+ }`),
+ },
+ },
+ {
name: "//visibility:private mixed with itself",
fs: MockFS{
"top/Android.bp": []byte(`
@@ -834,6 +1349,33 @@
` visible to this module`,
},
},
+ {
+ name: "//visibility:private mixed with itself (notices)",
+ fs: MockFS{
+ "top/Android.bp": []byte(`
+ mock_defaults {
+ name: "libexample_defaults_1",
+ visibility: ["//visibility:private"],
+ }
+ mock_defaults {
+ name: "libexample_defaults_2",
+ visibility: ["//visibility:private"],
+ }
+ mock_library {
+ name: "libexample",
+ visibility: ["//visibility:private"],
+ defaults: ["libexample_defaults_1", "libexample_defaults_2"],
+ }`),
+ "outsider/Android.bp": []byte(`
+ gen_notice {
+ name: "outsider-notice",
+ for: ["libexample"],
+ }`),
+ },
+ expectedErrors: []string{
+ `module "outsider-notice" references "//top:libexample" which is not visible to this module`,
+ },
+ },
// Defaults module's defaults_visibility tests
{
@@ -903,6 +1445,28 @@
},
},
{
+ // This test relies on the default visibility being legacy_public.
+ name: "package default_visibility property used when no visibility specified (notices)",
+ fs: MockFS{
+ "top/Android.bp": []byte(`
+ package {
+ default_visibility: ["//visibility:private"],
+ }
+
+ mock_library {
+ name: "libexample",
+ }`),
+ "outsider/Android.bp": []byte(`
+ gen_notice {
+ name: "outsider-notice",
+ for: ["libexample"],
+ }`),
+ },
+ expectedErrors: []string{
+ `module "outsider-notice" references "//top:libexample" which is not visible to this module`,
+ },
+ },
+ {
name: "package default_visibility public does not override visibility private",
fs: MockFS{
"top/Android.bp": []byte(`
@@ -926,6 +1490,28 @@
},
},
{
+ name: "package default_visibility public does not override visibility private (notices)",
+ fs: MockFS{
+ "top/Android.bp": []byte(`
+ package {
+ default_visibility: ["//visibility:public"],
+ }
+
+ mock_library {
+ name: "libexample",
+ visibility: ["//visibility:private"],
+ }`),
+ "outsider/Android.bp": []byte(`
+ gen_notice {
+ name: "outsider-notice",
+ for: ["libexample"],
+ }`),
+ },
+ expectedErrors: []string{
+ `module "outsider-notice" references "//top:libexample" which is not visible to this module`,
+ },
+ },
+ {
name: "package default_visibility private does not override visibility public",
fs: MockFS{
"top/Android.bp": []byte(`
@@ -945,6 +1531,25 @@
},
},
{
+ name: "package default_visibility private does not override visibility public (notices)",
+ fs: MockFS{
+ "top/Android.bp": []byte(`
+ package {
+ default_visibility: ["//visibility:private"],
+ }
+
+ mock_library {
+ name: "libexample",
+ visibility: ["//visibility:public"],
+ }`),
+ "outsider/Android.bp": []byte(`
+ gen_notice {
+ name: "outsider-notice",
+ for: ["libexample"],
+ }`),
+ },
+ },
+ {
name: "package default_visibility :__subpackages__",
fs: MockFS{
"top/Android.bp": []byte(`
@@ -972,6 +1577,32 @@
},
},
{
+ name: "package default_visibility :__subpackages__ (notices)",
+ fs: MockFS{
+ "top/Android.bp": []byte(`
+ package {
+ default_visibility: [":__subpackages__"],
+ }
+
+ mock_library {
+ name: "libexample",
+ }`),
+ "top/nested/Android.bp": []byte(`
+ gen_notice {
+ name: "nested-notice",
+ for: ["libexample"],
+ }`),
+ "outsider/Android.bp": []byte(`
+ gen_notice {
+ name: "outsider-notice",
+ for: ["libexample"],
+ }`),
+ },
+ expectedErrors: []string{
+ `module "outsider-notice" references "//top:libexample" which is not visible to this module`,
+ },
+ },
+ {
name: "package default_visibility inherited to subpackages",
fs: MockFS{
"top/Android.bp": []byte(`
@@ -981,7 +1612,7 @@
mock_library {
name: "libexample",
- visibility: [":__subpackages__"],
+ visibility: [":__subpackages__"],
}`),
"top/nested/Android.bp": []byte(`
mock_library {
@@ -1000,6 +1631,38 @@
},
},
{
+ name: "package default_visibility inherited to subpackages (notices)",
+ fs: MockFS{
+ "top/Android.bp": []byte(`
+ package {
+ default_visibility: ["//outsider"],
+ }
+
+ mock_library {
+ name: "libexample",
+ visibility: [":__subpackages__"],
+ }`),
+ "top/nested/Android.bp": []byte(`
+ mock_library {
+ name: "libnested",
+ deps: ["libexample"],
+ }
+
+ gen_notice {
+ name: "nested-notice",
+ for: ["libexample"],
+ }`),
+ "outsider/Android.bp": []byte(`
+ gen_notice {
+ name: "outsider-notice",
+ for: ["libexample", "libnested"],
+ }`),
+ },
+ expectedErrors: []string{
+ `module "outsider-notice" references "//top:libexample" which is not visible to this module`,
+ },
+ },
+ {
name: "package default_visibility inherited to subpackages",
fs: MockFS{
"top/Android.bp": []byte(`
@@ -1030,6 +1693,41 @@
},
},
{
+ name: "package default_visibility inherited to subpackages (notices)",
+ fs: MockFS{
+ "top/Android.bp": []byte(`
+ package {
+ default_visibility: ["//visibility:private"],
+ }`),
+ "top/nested/Android.bp": []byte(`
+ package {
+ default_visibility: ["//outsider"],
+ }
+
+ mock_library {
+ name: "libnested",
+ }`),
+ "top/other/Android.bp": []byte(`
+ mock_library {
+ name: "libother",
+ }
+
+ gen_notice {
+ name: "other-notice",
+ for: ["libother"],
+ }`),
+ "outsider/Android.bp": []byte(`
+ gen_notice {
+ name: "outsider-notice",
+ for: ["libother", "libnested"],
+ }`),
+ },
+ expectedErrors: []string{
+ `module "outsider-notice" references "//top/other:libother" which is not visible to this` +
+ ` module\nYou may need to add "//outsider" to its visibility`,
+ },
+ },
+ {
name: "verify that prebuilt dependencies are ignored for visibility reasons (not preferred)",
fs: MockFS{
"prebuilts/Android.bp": []byte(`
@@ -1052,6 +1750,28 @@
},
},
{
+ name: "verify that prebuilt dependencies are ignored for visibility reasons (not preferred) (notices)",
+ fs: MockFS{
+ "prebuilts/Android.bp": []byte(`
+ prebuilt {
+ name: "module",
+ visibility: ["//top/other"],
+ }`),
+ "top/sources/source_file": nil,
+ "top/sources/Android.bp": []byte(`
+ source {
+ name: "module",
+ visibility: ["//top/other"],
+ }`),
+ "top/other/source_file": nil,
+ "top/other/Android.bp": []byte(`
+ gen_notice {
+ name: "other-notice",
+ for: ["module"],
+ }`),
+ },
+ },
+ {
name: "verify that prebuilt dependencies are ignored for visibility reasons (preferred)",
fs: MockFS{
"prebuilts/Android.bp": []byte(`
@@ -1075,6 +1795,29 @@
},
},
{
+ name: "verify that prebuilt dependencies are ignored for visibility reasons (preferred) (notices)",
+ fs: MockFS{
+ "prebuilts/Android.bp": []byte(`
+ prebuilt {
+ name: "module",
+ visibility: ["//top/other"],
+ prefer: true,
+ }`),
+ "top/sources/source_file": nil,
+ "top/sources/Android.bp": []byte(`
+ source {
+ name: "module",
+ visibility: ["//top/other"],
+ }`),
+ "top/other/source_file": nil,
+ "top/other/Android.bp": []byte(`
+ gen_notice {
+ name: "other-notice",
+ for: ["module"],
+ }`),
+ },
+ },
+ {
name: "ensure visibility properties are checked for correctness",
fs: MockFS{
"top/Android.bp": []byte(`
@@ -1137,6 +1880,30 @@
}`),
},
},
+ {
+ name: "automatic visibility inheritance enabled (notices)",
+ fs: MockFS{
+ "top/Android.bp": []byte(`
+ mock_parent {
+ name: "parent",
+ visibility: ["//top/nested"],
+ child: {
+ name: "libchild",
+ visibility: ["//top/other"],
+ },
+ }`),
+ "top/nested/Android.bp": []byte(`
+ gen_notice {
+ name: "nested-notice",
+ for: ["libchild"],
+ }`),
+ "top/other/Android.bp": []byte(`
+ gen_notice {
+ name: "other-notice",
+ for: ["libchild"],
+ }`),
+ },
+ },
}
func TestVisibility(t *testing.T) {
@@ -1147,6 +1914,7 @@
// registration order.
PrepareForTestWithArchMutator,
PrepareForTestWithDefaults,
+ PrepareForTestWithGenNotice,
PrepareForTestWithOverrides,
PrepareForTestWithPackageModule,
PrepareForTestWithPrebuilts,
diff --git a/android_sdk/sdk_repo_host.go b/android_sdk/sdk_repo_host.go
index c61afcb..9519be0 100644
--- a/android_sdk/sdk_repo_host.go
+++ b/android_sdk/sdk_repo_host.go
@@ -124,7 +124,7 @@
s.CopySpecsToDir(ctx, builder, packageSpecs, dir)
noticeFile := android.PathForModuleOut(ctx, "NOTICES.txt")
- android.BuildNoticeTextOutputFromLicenseMetadata(ctx, noticeFile, "", outputZipFile.String())
+ android.BuildNoticeTextOutputFromLicenseMetadata(ctx, noticeFile, "", "", outputZipFile.String())
builder.Command().Text("cp").
Input(noticeFile).
Text(filepath.Join(dir.String(), "NOTICE.txt"))
diff --git a/apex/apex.go b/apex/apex.go
index 83dd8b0..21725ff 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -2497,6 +2497,19 @@
if !ok {
continue
}
+
+ // Manifest is either empty or a file in the directory of base APEX and is not overridable.
+ // After it is converted in convertWithBp2build(baseApex, ctx),
+ // the attrs.Manifest.Value.Label is the file path relative to the directory
+ // of base apex. So the following code converts it to a label that looks like
+ // <package of base apex>:<path of manifest file> if base apex and override
+ // apex are not in the same package.
+ baseApexPackage := ctx.OtherModuleDir(a)
+ overrideApexPackage := ctx.ModuleDir()
+ if baseApexPackage != overrideApexPackage {
+ attrs.Manifest.Value.Label = "//" + baseApexPackage + ":" + attrs.Manifest.Value.Label
+ }
+
// Key
if overridableProperties.Key != nil {
attrs.Key = bazel.LabelAttribute{}
@@ -2760,7 +2773,7 @@
// A small list of exceptions where static executables are allowed in APEXes.
func isStaticExecutableAllowed(apex string, exec string) bool {
m := map[string][]string{
- "com.android.runtime": []string{
+ "com.android.runtime": {
"linker",
"linkerconfig",
},
@@ -3397,11 +3410,11 @@
// Adding code to the bootclasspath in new packages will cause issues on module update.
func qBcpPackages() map[string][]string {
return map[string][]string{
- "conscrypt": []string{
+ "conscrypt": {
"android.net.ssl",
"com.android.org.conscrypt",
},
- "updatable-media": []string{
+ "updatable-media": {
"android.media",
},
}
@@ -3411,32 +3424,32 @@
// Adding code to the bootclasspath in new packages will cause issues on module update.
func rBcpPackages() map[string][]string {
return map[string][]string{
- "framework-mediaprovider": []string{
+ "framework-mediaprovider": {
"android.provider",
},
- "framework-permission": []string{
+ "framework-permission": {
"android.permission",
"android.app.role",
"com.android.permission",
"com.android.role",
},
- "framework-sdkextensions": []string{
+ "framework-sdkextensions": {
"android.os.ext",
},
- "framework-statsd": []string{
+ "framework-statsd": {
"android.app",
"android.os",
"android.util",
"com.android.internal.statsd",
"com.android.server.stats",
},
- "framework-wifi": []string{
+ "framework-wifi": {
"com.android.server.wifi",
"com.android.wifi.x",
"android.hardware.wifi",
"android.net.wifi",
},
- "framework-tethering": []string{
+ "framework-tethering": {
"android.net",
},
}
@@ -3478,9 +3491,7 @@
func convertWithBp2build(a *apexBundle, ctx android.TopDownMutatorContext) (bazelApexBundleAttributes, bazel.BazelTargetModuleProperties) {
var manifestLabelAttribute bazel.LabelAttribute
- if a.properties.Manifest != nil {
- manifestLabelAttribute.SetValue(android.BazelLabelForModuleSrcSingle(ctx, *a.properties.Manifest))
- }
+ manifestLabelAttribute.SetValue(android.BazelLabelForModuleSrcSingle(ctx, proptools.StringDefault(a.properties.Manifest, "apex_manifest.json")))
var androidManifestLabelAttribute bazel.LabelAttribute
if a.properties.AndroidManifest != nil {
diff --git a/apex/builder.go b/apex/builder.go
index f959b7a..9119363 100644
--- a/apex/builder.go
+++ b/apex/builder.go
@@ -618,7 +618,7 @@
// Create a NOTICE file, and embed it as an asset file in the APEX.
a.htmlGzNotice = android.PathForModuleOut(ctx, "NOTICE.html.gz")
- android.BuildNoticeHtmlOutputFromLicenseMetadata(ctx, a.htmlGzNotice, "", unsignedOutputFile.String())
+ android.BuildNoticeHtmlOutputFromLicenseMetadata(ctx, a.htmlGzNotice, "", "", unsignedOutputFile.String())
noticeAssetPath := android.PathForModuleOut(ctx, "NOTICE", "NOTICE.html.gz")
builder := android.NewRuleBuilder(pctx, ctx)
builder.Command().Text("cp").
diff --git a/bp2build/apex_conversion_test.go b/bp2build/apex_conversion_test.go
index 3ed21db..d15dc0c 100644
--- a/bp2build/apex_conversion_test.go
+++ b/bp2build/apex_conversion_test.go
@@ -198,6 +198,7 @@
expectedBazelTargets: []string{
makeBazelTarget("apex", "com.android.apogee", attrNameToString{
"file_contexts": `"//a/b:com.android.apogee-file_contexts"`,
+ "manifest": `"apex_manifest.json"`,
}),
}})
}
@@ -217,6 +218,7 @@
expectedBazelTargets: []string{
makeBazelTarget("apex", "com.android.apogee", attrNameToString{
"file_contexts": `"file_contexts_file"`,
+ "manifest": `"apex_manifest.json"`,
}),
}})
}
@@ -245,6 +247,7 @@
expectedBazelTargets: []string{
makeBazelTarget("apex", "com.android.apogee", attrNameToString{
"file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
+ "manifest": `"apex_manifest.json"`,
}),
}})
}
@@ -288,6 +291,7 @@
"//conditions:default": [],
})`,
"file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
+ "manifest": `"apex_manifest.json"`,
}),
}})
}
@@ -336,6 +340,7 @@
"//conditions:default": [],
})`,
"file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
+ "manifest": `"apex_manifest.json"`,
}),
}})
}
@@ -366,6 +371,7 @@
"//conditions:default": [],
})`,
"file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
+ "manifest": `"apex_manifest.json"`,
}),
}})
}
@@ -401,6 +407,7 @@
"//conditions:default": [],
})`,
"file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
+ "manifest": `"apex_manifest.json"`,
}),
}})
}
@@ -643,3 +650,135 @@
}),
}})
}
+
+func TestApexBundleSimple_manifestIsEmpty_baseApexOverrideApexInDifferentAndroidBp(t *testing.T) {
+ runOverrideApexTestCase(t, bp2buildTestCase{
+ description: "override_apex - manifest of base apex is empty, base apex and override_apex is in different Android.bp",
+ moduleTypeUnderTest: "override_apex",
+ moduleTypeUnderTestFactory: apex.OverrideApexFactory,
+ filesystem: map[string]string{
+ "system/sepolicy/apex/Android.bp": `
+filegroup {
+ name: "com.android.apogee-file_contexts",
+ srcs: [ "apogee-file_contexts", ],
+ bazel_module: { bp2build_available: false },
+}`,
+ "a/b/Android.bp": `
+apex {
+ name: "com.android.apogee",
+ bazel_module: { bp2build_available: false },
+}
+`,
+ },
+ blueprint: `
+override_apex {
+ name: "com.google.android.apogee",
+ base: ":com.android.apogee",
+}
+`,
+ expectedBazelTargets: []string{
+ makeBazelTarget("apex", "com.google.android.apogee", attrNameToString{
+ "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
+ "manifest": `"//a/b:apex_manifest.json"`,
+ }),
+ }})
+}
+
+func TestApexBundleSimple_manifestIsSet_baseApexOverrideApexInDifferentAndroidBp(t *testing.T) {
+ runOverrideApexTestCase(t, bp2buildTestCase{
+ description: "override_apex - manifest of base apex is set, base apex and override_apex is in different Android.bp",
+ moduleTypeUnderTest: "override_apex",
+ moduleTypeUnderTestFactory: apex.OverrideApexFactory,
+ filesystem: map[string]string{
+ "system/sepolicy/apex/Android.bp": `
+filegroup {
+ name: "com.android.apogee-file_contexts",
+ srcs: [ "apogee-file_contexts", ],
+ bazel_module: { bp2build_available: false },
+}`,
+ "a/b/Android.bp": `
+apex {
+ name: "com.android.apogee",
+ manifest: "apogee_manifest.json",
+ bazel_module: { bp2build_available: false },
+}
+`,
+ },
+ blueprint: `
+override_apex {
+ name: "com.google.android.apogee",
+ base: ":com.android.apogee",
+}
+`,
+ expectedBazelTargets: []string{
+ makeBazelTarget("apex", "com.google.android.apogee", attrNameToString{
+ "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
+ "manifest": `"//a/b:apogee_manifest.json"`,
+ }),
+ }})
+}
+
+func TestApexBundleSimple_manifestIsEmpty_baseApexOverrideApexInSameAndroidBp(t *testing.T) {
+ runOverrideApexTestCase(t, bp2buildTestCase{
+ description: "override_apex - manifest of base apex is empty, base apex and override_apex is in same Android.bp",
+ moduleTypeUnderTest: "override_apex",
+ moduleTypeUnderTestFactory: apex.OverrideApexFactory,
+ filesystem: map[string]string{
+ "system/sepolicy/apex/Android.bp": `
+filegroup {
+ name: "com.android.apogee-file_contexts",
+ srcs: [ "apogee-file_contexts", ],
+ bazel_module: { bp2build_available: false },
+}`,
+ },
+ blueprint: `
+apex {
+ name: "com.android.apogee",
+ bazel_module: { bp2build_available: false },
+}
+
+override_apex {
+ name: "com.google.android.apogee",
+ base: ":com.android.apogee",
+}
+`,
+ expectedBazelTargets: []string{
+ makeBazelTarget("apex", "com.google.android.apogee", attrNameToString{
+ "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
+ "manifest": `"apex_manifest.json"`,
+ }),
+ }})
+}
+
+func TestApexBundleSimple_manifestIsSet_baseApexOverrideApexInSameAndroidBp(t *testing.T) {
+ runOverrideApexTestCase(t, bp2buildTestCase{
+ description: "override_apex - manifest of base apex is set, base apex and override_apex is in same Android.bp",
+ moduleTypeUnderTest: "override_apex",
+ moduleTypeUnderTestFactory: apex.OverrideApexFactory,
+ filesystem: map[string]string{
+ "system/sepolicy/apex/Android.bp": `
+filegroup {
+ name: "com.android.apogee-file_contexts",
+ srcs: [ "apogee-file_contexts", ],
+ bazel_module: { bp2build_available: false },
+}`,
+ },
+ blueprint: `
+apex {
+ name: "com.android.apogee",
+ manifest: "apogee_manifest.json",
+ bazel_module: { bp2build_available: false },
+}
+
+override_apex {
+ name: "com.google.android.apogee",
+ base: ":com.android.apogee",
+}
+`,
+ expectedBazelTargets: []string{
+ makeBazelTarget("apex", "com.google.android.apogee", attrNameToString{
+ "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
+ "manifest": `"apogee_manifest.json"`,
+ }),
+ }})
+}
diff --git a/bp2build/build_conversion_test.go b/bp2build/build_conversion_test.go
index 0f3ca79..0f6e139 100644
--- a/bp2build/build_conversion_test.go
+++ b/bp2build/build_conversion_test.go
@@ -1296,6 +1296,7 @@
"//conditions:default": [],
})`,
"srcs_version": `"PY3"`,
+ "imports": `["."]`,
}),
},
},
@@ -1321,6 +1322,7 @@
":reqd",
]`,
"srcs_version": `"PY3"`,
+ "imports": `["."]`,
}),
},
},
diff --git a/bp2build/conversion.go b/bp2build/conversion.go
index 1790dd7..4b013d9 100644
--- a/bp2build/conversion.go
+++ b/bp2build/conversion.go
@@ -152,6 +152,7 @@
"target": true, // interface prop type is not supported yet.
"visibility": true, // Bazel has native visibility semantics. Handle later.
"features": true, // There is already a built-in attribute 'features' which cannot be overridden.
+ "for": true, // reserved keyword, b/233579439
}
)
diff --git a/bp2build/python_library_conversion_test.go b/bp2build/python_library_conversion_test.go
index 356d52e..66c2290 100644
--- a/bp2build/python_library_conversion_test.go
+++ b/bp2build/python_library_conversion_test.go
@@ -2,6 +2,7 @@
import (
"fmt"
+ "strings"
"testing"
"android/soong/android"
@@ -16,6 +17,8 @@
filesystem map[string]string
blueprint string
expectedBazelTargets []testBazelTarget
+ dir string
+ expectedError error
}
func convertPythonLibTestCaseToBp2build_Host(tc pythonLibBp2BuildTestCase) bp2buildTestCase {
@@ -34,11 +37,19 @@
for _, t := range tc.expectedBazelTargets {
bp2BuildTargets = append(bp2BuildTargets, makeBazelTarget(t.typ, t.name, t.attrs))
}
+ // Copy the filesystem so that we can change stuff in it later without it
+ // affecting the original pythonLibBp2BuildTestCase
+ filesystemCopy := make(map[string]string)
+ for k, v := range tc.filesystem {
+ filesystemCopy[k] = v
+ }
return bp2buildTestCase{
description: tc.description,
- filesystem: tc.filesystem,
+ filesystem: filesystemCopy,
blueprint: tc.blueprint,
expectedBazelTargets: bp2BuildTargets,
+ dir: tc.dir,
+ expectedErr: tc.expectedError,
}
}
@@ -47,6 +58,11 @@
testCase := convertPythonLibTestCaseToBp2build(tc)
testCase.description = fmt.Sprintf(testCase.description, "python_library")
testCase.blueprint = fmt.Sprintf(testCase.blueprint, "python_library")
+ for name, contents := range testCase.filesystem {
+ if strings.HasSuffix(name, "Android.bp") {
+ testCase.filesystem[name] = fmt.Sprintf(contents, "python_library")
+ }
+ }
testCase.moduleTypeUnderTest = "python_library"
testCase.moduleTypeUnderTestFactory = python.PythonLibraryFactory
@@ -58,6 +74,11 @@
testCase := convertPythonLibTestCaseToBp2build_Host(tc)
testCase.description = fmt.Sprintf(testCase.description, "python_library_host")
testCase.blueprint = fmt.Sprintf(testCase.blueprint, "python_library_host")
+ for name, contents := range testCase.filesystem {
+ if strings.HasSuffix(name, "Android.bp") {
+ testCase.filesystem[name] = fmt.Sprintf(contents, "python_library_host")
+ }
+ }
testCase.moduleTypeUnderTest = "python_library_host"
testCase.moduleTypeUnderTestFactory = python.PythonLibraryHostFactory
runBp2BuildTestCase(t, func(ctx android.RegistrationContext) {
@@ -109,6 +130,7 @@
"b/d.py",
]`,
"srcs_version": `"PY3"`,
+ "imports": `["."]`,
},
},
},
@@ -136,6 +158,7 @@
attrs: attrNameToString{
"srcs": `["a.py"]`,
"srcs_version": `"PY2"`,
+ "imports": `["."]`,
},
},
},
@@ -163,6 +186,7 @@
attrs: attrNameToString{
"srcs": `["a.py"]`,
"srcs_version": `"PY3"`,
+ "imports": `["."]`,
},
},
},
@@ -189,11 +213,54 @@
typ: "py_library",
name: "foo",
attrs: attrNameToString{
- "srcs": `["a.py"]`,
+ "srcs": `["a.py"]`,
+ "imports": `["."]`,
},
},
},
},
+ {
+ description: "%s: pkg_path in a subdirectory of the same name converts correctly",
+ dir: "mylib/subpackage",
+ filesystem: map[string]string{
+ "mylib/subpackage/a.py": "",
+ "mylib/subpackage/Android.bp": `%s {
+ name: "foo",
+ srcs: ["a.py"],
+ pkg_path: "mylib/subpackage",
+
+ bazel_module: { bp2build_available: true },
+ }`,
+ },
+ blueprint: `%s {name: "bar"}`,
+ expectedBazelTargets: []testBazelTarget{
+ {
+ // srcs_version is PY2ANDPY3 by default.
+ typ: "py_library",
+ name: "foo",
+ attrs: attrNameToString{
+ "srcs": `["a.py"]`,
+ "imports": `["../.."]`,
+ "srcs_version": `"PY3"`,
+ },
+ },
+ },
+ },
+ {
+ description: "%s: pkg_path in a subdirectory of a different name fails",
+ dir: "mylib/subpackage",
+ filesystem: map[string]string{
+ "mylib/subpackage/a.py": "",
+ "mylib/subpackage/Android.bp": `%s {
+ name: "foo",
+ srcs: ["a.py"],
+ pkg_path: "mylib/subpackage2",
+ bazel_module: { bp2build_available: true },
+ }`,
+ },
+ blueprint: `%s {name: "bar"}`,
+ expectedError: fmt.Errorf("Currently, bp2build only supports pkg_paths that are the same as the folders the Android.bp file is in."),
+ },
}
for _, tc := range testCases {
@@ -232,6 +299,7 @@
"//conditions:default": [],
})`,
"srcs_version": `"PY3"`,
+ "imports": `["."]`,
},
},
},
diff --git a/bp2build/testing.go b/bp2build/testing.go
index 029ba49..9341495 100644
--- a/bp2build/testing.go
+++ b/bp2build/testing.go
@@ -119,8 +119,8 @@
return
}
- errs := append(parseErrs, resolveDepsErrs...)
- if tc.expectedErr != nil && checkError(t, errs, tc.expectedErr) {
+ parseAndResolveErrs := append(parseErrs, resolveDepsErrs...)
+ if tc.expectedErr != nil && checkError(t, parseAndResolveErrs, tc.expectedErr) {
return
}
@@ -135,7 +135,7 @@
if checkError(t, errs, tc.expectedErr) {
return
} else {
- t.Errorf("Expected error: %q, got: %q", tc.expectedErr, errs)
+ t.Errorf("Expected error: %q, got: %q and %q", tc.expectedErr, errs, parseAndResolveErrs)
}
} else {
android.FailIfErrored(t, errs)
diff --git a/cc/binary.go b/cc/binary.go
index 7b5591a..b2f2482 100644
--- a/cc/binary.go
+++ b/cc/binary.go
@@ -183,7 +183,7 @@
}
}
- if !binary.static() && inList("libc", deps.StaticLibs) && !ctx.BazelConversionMode() {
+ if !binary.static() && inList("libc", deps.StaticLibs) {
ctx.ModuleErrorf("statically linking libc to dynamic executable, please remove libc\n" +
"from static libs or set static_executable: true")
}
@@ -563,11 +563,11 @@
}
type ccBinaryBazelHandler struct {
- BazelHandler
-
module *Module
}
+var _ BazelHandler = (*ccBinaryBazelHandler)(nil)
+
func (handler *ccBinaryBazelHandler) QueueBazelCall(ctx android.BaseModuleContext, label string) {
bazelCtx := ctx.Config().BazelContext
bazelCtx.QueueBazelRequest(label, cquery.GetOutputFiles, android.GetConfigKey(ctx))
diff --git a/cc/bp2build.go b/cc/bp2build.go
index a2041f4..4155aa3 100644
--- a/cc/bp2build.go
+++ b/cc/bp2build.go
@@ -835,22 +835,7 @@
SystemIncludes bazel.StringListAttribute
}
-func bp2BuildParseExportedIncludes(ctx android.BazelConversionPathContext, module *Module, existingIncludes BazelIncludes) BazelIncludes {
- libraryDecorator := module.linker.(*libraryDecorator)
- return bp2BuildParseExportedIncludesHelper(ctx, module, libraryDecorator, &existingIncludes)
-}
-
-// Bp2buildParseExportedIncludesForPrebuiltLibrary returns a BazelIncludes with Bazel-ified values
-// to export includes from the underlying module's properties.
-func Bp2BuildParseExportedIncludesForPrebuiltLibrary(ctx android.BazelConversionPathContext, module *Module) BazelIncludes {
- prebuiltLibraryLinker := module.linker.(*prebuiltLibraryLinker)
- libraryDecorator := prebuiltLibraryLinker.libraryDecorator
- return bp2BuildParseExportedIncludesHelper(ctx, module, libraryDecorator, nil)
-}
-
-// bp2BuildParseExportedIncludes creates a string list attribute contains the
-// exported included directories of a module.
-func bp2BuildParseExportedIncludesHelper(ctx android.BazelConversionPathContext, module *Module, libraryDecorator *libraryDecorator, includes *BazelIncludes) BazelIncludes {
+func bp2BuildParseExportedIncludes(ctx android.BazelConversionPathContext, module *Module, includes *BazelIncludes) BazelIncludes {
var exported BazelIncludes
if includes != nil {
exported = *includes
diff --git a/cc/cc.go b/cc/cc.go
index 3d21f63..da8a807 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -2059,12 +2059,6 @@
deps.HeaderLibs = android.LastUniqueStrings(deps.HeaderLibs)
deps.RuntimeLibs = android.LastUniqueStrings(deps.RuntimeLibs)
- // In Bazel conversion mode, we dependency and build validations will occur in Bazel, so there is
- // no need to do so in Soong.
- if ctx.BazelConversionMode() {
- return deps
- }
-
for _, lib := range deps.ReexportSharedLibHeaders {
if !inList(lib, deps.SharedLibs) {
ctx.PropertyErrorf("export_shared_lib_headers", "Shared library not in shared_libs: '%s'", lib)
diff --git a/cc/config/global.go b/cc/config/global.go
index 1c4ad7f..178e80b 100644
--- a/cc/config/global.go
+++ b/cc/config/global.go
@@ -191,7 +191,6 @@
"-Werror=int-in-bool-context",
"-Werror=int-to-pointer-cast",
"-Werror=pointer-to-int-cast",
- "-Werror=string-compare",
"-Werror=xor-used-as-pow",
// http://b/161386391 for -Wno-void-pointer-to-enum-cast
"-Wno-void-pointer-to-enum-cast",
@@ -225,7 +224,6 @@
"-Wno-misleading-indentation", // http://b/153746954
"-Wno-zero-as-null-pointer-constant", // http://b/68236239
"-Wno-deprecated-anon-enum-enum-conversion", // http://b/153746485
- "-Wno-string-compare", // http://b/153764102
"-Wno-pessimizing-move", // http://b/154270751
// New warnings to be fixed after clang-r399163
"-Wno-non-c-typedef-for-linkage", // http://b/161304145
diff --git a/cc/config/toolchain.go b/cc/config/toolchain.go
index 7175fdc..253bb06 100644
--- a/cc/config/toolchain.go
+++ b/cc/config/toolchain.go
@@ -36,19 +36,10 @@
Arch() android.Arch
}
-type conversionContext interface {
- BazelConversionMode() bool
-}
-
func FindToolchainWithContext(ctx toolchainContext) Toolchain {
t, err := findToolchain(ctx.Os(), ctx.Arch())
if err != nil {
- if c, ok := ctx.(conversionContext); ok && c.BazelConversionMode() {
- // TODO(b/179123288): determine conversion for toolchain
- return &toolchainX86_64{}
- } else {
- panic(err)
- }
+ panic(err)
}
return t
}
diff --git a/cc/library.go b/cc/library.go
index 5746529..d819c62 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -289,7 +289,7 @@
baseAttributes := bp2BuildParseBaseProps(ctx, m)
compilerAttrs := baseAttributes.compilerAttributes
linkerAttrs := baseAttributes.linkerAttributes
- exportedIncludes := bp2BuildParseExportedIncludes(ctx, m, compilerAttrs.includes)
+ exportedIncludes := bp2BuildParseExportedIncludes(ctx, m, &compilerAttrs.includes)
srcs := compilerAttrs.srcs
@@ -642,11 +642,11 @@
}
type ccLibraryBazelHandler struct {
- BazelHandler
-
module *Module
}
+var _ BazelHandler = (*ccLibraryBazelHandler)(nil)
+
// generateStaticBazelBuildActions constructs the StaticLibraryInfo Soong
// provider from a Bazel shared library's CcInfo provider.
func (handler *ccLibraryBazelHandler) generateStaticBazelBuildActions(ctx android.ModuleContext, label string, ccInfo cquery.CcInfo) {
@@ -2446,7 +2446,7 @@
compilerAttrs := baseAttributes.compilerAttributes
linkerAttrs := baseAttributes.linkerAttributes
- exportedIncludes := bp2BuildParseExportedIncludes(ctx, module, compilerAttrs.includes)
+ exportedIncludes := bp2BuildParseExportedIncludes(ctx, module, &compilerAttrs.includes)
// Append shared/static{} stanza properties. These won't be specified on
// cc_library_* itself, but may be specified in cc_defaults that this module
diff --git a/cc/library_headers.go b/cc/library_headers.go
index 6fd9568..7232290 100644
--- a/cc/library_headers.go
+++ b/cc/library_headers.go
@@ -49,12 +49,12 @@
}
type libraryHeaderBazelHandler struct {
- BazelHandler
-
module *Module
library *libraryDecorator
}
+var _ BazelHandler = (*libraryHeaderBazelHandler)(nil)
+
func (handler *libraryHeaderBazelHandler) QueueBazelCall(ctx android.BaseModuleContext, label string) {
bazelCtx := ctx.Config().BazelContext
bazelCtx.QueueBazelRequest(label, cquery.GetCcInfo, android.GetConfigKey(ctx))
@@ -123,7 +123,7 @@
func libraryHeadersBp2Build(ctx android.TopDownMutatorContext, module *Module) {
baseAttributes := bp2BuildParseBaseProps(ctx, module)
- exportedIncludes := bp2BuildParseExportedIncludes(ctx, module, baseAttributes.includes)
+ exportedIncludes := bp2BuildParseExportedIncludes(ctx, module, &baseAttributes.includes)
linkerAttrs := baseAttributes.linkerAttributes
attrs := &bazelCcLibraryHeadersAttributes{
diff --git a/cc/library_sdk_member.go b/cc/library_sdk_member.go
index 8988de2..1bcbdc5 100644
--- a/cc/library_sdk_member.go
+++ b/cc/library_sdk_member.go
@@ -27,32 +27,33 @@
var sharedLibrarySdkMemberType = &librarySdkMemberType{
SdkMemberTypeBase: android.SdkMemberTypeBase{
- PropertyName: "native_shared_libs",
- SupportsSdk: true,
- HostOsDependent: true,
+ PropertyName: "native_shared_libs",
+ SupportsSdk: true,
+ HostOsDependent: true,
+ SupportedLinkageNames: []string{"shared"},
},
prebuiltModuleType: "cc_prebuilt_library_shared",
- linkTypes: []string{"shared"},
}
var staticLibrarySdkMemberType = &librarySdkMemberType{
SdkMemberTypeBase: android.SdkMemberTypeBase{
- PropertyName: "native_static_libs",
- SupportsSdk: true,
- HostOsDependent: true,
+ PropertyName: "native_static_libs",
+ SupportsSdk: true,
+ HostOsDependent: true,
+ SupportedLinkageNames: []string{"static"},
},
prebuiltModuleType: "cc_prebuilt_library_static",
- linkTypes: []string{"static"},
}
var staticAndSharedLibrarySdkMemberType = &librarySdkMemberType{
SdkMemberTypeBase: android.SdkMemberTypeBase{
- PropertyName: "native_libs",
- SupportsSdk: true,
- HostOsDependent: true,
+ PropertyName: "native_libs",
+ OverridesPropertyNames: map[string]bool{"native_shared_libs": true, "native_static_libs": true},
+ SupportsSdk: true,
+ HostOsDependent: true,
+ SupportedLinkageNames: []string{"static", "shared"},
},
prebuiltModuleType: "cc_prebuilt_library",
- linkTypes: []string{"static", "shared"},
}
func init() {
@@ -69,9 +70,6 @@
noOutputFiles bool // True if there are no srcs files.
- // The set of link types supported. A set of "static", "shared", or nil to
- // skip link type variations.
- linkTypes []string
}
func (mt *librarySdkMemberType) AddDependencies(ctx android.SdkDependencyContext, dependencyTag blueprint.DependencyTag, names []string) {
@@ -165,12 +163,12 @@
// Add any additional dependencies needed.
variations = append(variations, dependency.imageVariations...)
- if mt.linkTypes == nil {
+ if mt.SupportedLinkageNames == nil {
// No link types are supported so add a dependency directly.
ctx.AddFarVariationDependencies(variations, dependencyTag, name)
} else {
// Otherwise, add a dependency on each supported link type in turn.
- for _, linkType := range mt.linkTypes {
+ for _, linkType := range mt.SupportedLinkageNames {
libVariations := append(variations,
blueprint.Variation{Mutator: "link", Variation: linkType})
// If this is for the device and a shared link type then add a dependency onto the
diff --git a/cc/linker.go b/cc/linker.go
index f346584..4e9404c 100644
--- a/cc/linker.go
+++ b/cc/linker.go
@@ -389,9 +389,7 @@
}
deps.SystemSharedLibs = linker.Properties.System_shared_libs
- // In Bazel conversion mode, variations have not been specified, so SystemSharedLibs may
- // inaccuarately appear unset, which can cause issues with circular dependencies.
- if deps.SystemSharedLibs == nil && !ctx.BazelConversionMode() {
+ if deps.SystemSharedLibs == nil {
// Provide a default system_shared_libs if it is unspecified. Note: If an
// empty list [] is specified, it implies that the module declines the
// default system_shared_libs.
diff --git a/cc/object.go b/cc/object.go
index a3be6b1..65a11e0 100644
--- a/cc/object.go
+++ b/cc/object.go
@@ -38,7 +38,6 @@
SupportsSdk: true,
},
prebuiltModuleType: "cc_prebuilt_object",
- linkTypes: nil,
}
type objectLinker struct {
@@ -47,11 +46,11 @@
}
type objectBazelHandler struct {
- BazelHandler
-
module *Module
}
+var _ BazelHandler = (*objectBazelHandler)(nil)
+
func (handler *objectBazelHandler) QueueBazelCall(ctx android.BaseModuleContext, label string) {
bazelCtx := ctx.Config().BazelContext
bazelCtx.QueueBazelRequest(label, cquery.GetOutputFiles, android.GetConfigKey(ctx))
diff --git a/cc/prebuilt.go b/cc/prebuilt.go
index e8c60ba..a29e618 100644
--- a/cc/prebuilt.go
+++ b/cc/prebuilt.go
@@ -355,7 +355,7 @@
func prebuiltLibraryStaticBp2Build(ctx android.TopDownMutatorContext, module *Module, fullBuild bool) {
prebuiltAttrs := Bp2BuildParsePrebuiltLibraryProps(ctx, module, true)
- exportedIncludes := Bp2BuildParseExportedIncludesForPrebuiltLibrary(ctx, module)
+ exportedIncludes := bp2BuildParseExportedIncludes(ctx, module, nil)
attrs := &bazelPrebuiltLibraryStaticAttributes{
Static_library: prebuiltAttrs.Src,
@@ -407,12 +407,12 @@
}
type prebuiltStaticLibraryBazelHandler struct {
- BazelHandler
-
module *Module
library *libraryDecorator
}
+var _ BazelHandler = (*prebuiltStaticLibraryBazelHandler)(nil)
+
func (h *prebuiltStaticLibraryBazelHandler) QueueBazelCall(ctx android.BaseModuleContext, label string) {
bazelCtx := ctx.Config().BazelContext
bazelCtx.QueueBazelRequest(label, cquery.GetCcInfo, android.GetConfigKey(ctx))
@@ -458,12 +458,12 @@
}
type prebuiltSharedLibraryBazelHandler struct {
- BazelHandler
-
module *Module
library *libraryDecorator
}
+var _ BazelHandler = (*prebuiltSharedLibraryBazelHandler)(nil)
+
func (h *prebuiltSharedLibraryBazelHandler) QueueBazelCall(ctx android.BaseModuleContext, label string) {
bazelCtx := ctx.Config().BazelContext
bazelCtx.QueueBazelRequest(label, cquery.GetCcInfo, android.GetConfigKey(ctx))
diff --git a/cc/sanitize.go b/cc/sanitize.go
index 87cee9f..42a112e 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -1428,9 +1428,12 @@
}
}
} else if sanitizeable, ok := mctx.Module().(Sanitizeable); ok && sanitizeable.IsSanitizerEnabled(mctx, t.name()) {
- // APEX and Java fuzz modules fall here
+ // APEX fuzz modules fall here
sanitizeable.AddSanitizerDependencies(mctx, t.name())
mctx.CreateVariations(t.variationName())
+ } else if _, ok := mctx.Module().(JniSanitizeable); ok {
+ // Java fuzz modules fall here
+ mctx.CreateVariations(t.variationName())
} else if c, ok := mctx.Module().(*Module); ok {
//TODO: When Rust modules have vendor support, enable this path for PlatformSanitizeable
diff --git a/cmd/soong_build/main.go b/cmd/soong_build/main.go
index ad379d5..a51db36 100644
--- a/cmd/soong_build/main.go
+++ b/cmd/soong_build/main.go
@@ -144,6 +144,7 @@
ctx.SetBeforePrepareBuildActionsHook(bazelHook)
ninjaDeps := bootstrap.RunBlueprint(cmdlineArgs, bootstrap.DoEverything, ctx.Context, configuration)
+ ninjaDeps = append(ninjaDeps, extraNinjaDeps...)
globListFiles := writeBuildGlobsNinjaFile(ctx, configuration.SoongOutDir(), configuration)
ninjaDeps = append(ninjaDeps, globListFiles...)
diff --git a/java/app.go b/java/app.go
index da496f1..86238d5 100755
--- a/java/app.go
+++ b/java/app.go
@@ -656,7 +656,7 @@
if Bool(a.appProperties.Embed_notices) || ctx.Config().IsEnvTrue("ALWAYS_EMBED_NOTICES") {
noticeFile := android.PathForModuleOut(ctx, "NOTICE.html.gz")
- android.BuildNoticeHtmlOutputFromLicenseMetadata(ctx, noticeFile, "", a.outputFile.String())
+ android.BuildNoticeHtmlOutputFromLicenseMetadata(ctx, noticeFile, "", "", a.outputFile.String())
noticeAssetPath := android.PathForModuleOut(ctx, "NOTICE", "NOTICE.html.gz")
builder := android.NewRuleBuilder(pctx, ctx)
builder.Command().Text("cp").
diff --git a/java/fuzz.go b/java/fuzz.go
index cf2c981..b306991 100644
--- a/java/fuzz.go
+++ b/java/fuzz.go
@@ -54,11 +54,12 @@
// cc.JniSanitizeable. It returns a bool for whether a cc dependency should be
// sanitized for the given sanitizer or not.
func (j *JavaFuzzLibrary) IsSanitizerEnabledForJni(ctx android.BaseModuleContext, sanitizerName string) bool {
- for _, s := range j.jniProperties.Sanitizers {
- if sanitizerName == s {
- return true
- }
- }
+ // TODO: once b/231370928 is resolved, please uncomment the loop
+ // for _, s := range j.jniProperties.Sanitizers {
+ // if sanitizerName == s {
+ // return true
+ // }
+ // }
return false
}
diff --git a/java/java.go b/java/java.go
index 4476cec..0dfb968 100644
--- a/java/java.go
+++ b/java/java.go
@@ -468,6 +468,12 @@
return normalizeJavaVersion(ctx, javaVersion)
} else if ctx.Device() {
return defaultJavaLanguageVersion(ctx, sdkContext.SdkVersion(ctx))
+ } else if ctx.Config().TargetsJava17() {
+ // Temporary experimental flag to be able to try and build with
+ // java version 17 options. The flag, if used, just sets Java
+ // 17 as the default version, leaving any components that
+ // target an older version intact.
+ return JAVA_VERSION_17
} else {
return JAVA_VERSION_11
}
@@ -482,6 +488,7 @@
JAVA_VERSION_8 = 8
JAVA_VERSION_9 = 9
JAVA_VERSION_11 = 11
+ JAVA_VERSION_17 = 17
)
func (v javaVersion) String() string {
@@ -496,6 +503,8 @@
return "1.9"
case JAVA_VERSION_11:
return "11"
+ case JAVA_VERSION_17:
+ return "17"
default:
return "unsupported"
}
@@ -518,8 +527,10 @@
return JAVA_VERSION_9
case "11":
return JAVA_VERSION_11
- case "10":
- ctx.PropertyErrorf("java_version", "Java language levels 10 is not supported")
+ case "17":
+ return JAVA_VERSION_11
+ case "10", "12", "13", "14", "15", "16":
+ ctx.PropertyErrorf("java_version", "Java language level %s is not supported", javaVersion)
return JAVA_VERSION_UNSUPPORTED
default:
ctx.PropertyErrorf("java_version", "Unrecognized Java language level")
@@ -1247,10 +1258,10 @@
}
func (j *Binary) DepsMutator(ctx android.BottomUpMutatorContext) {
- if ctx.Arch().ArchType == android.Common || ctx.BazelConversionMode() {
+ if ctx.Arch().ArchType == android.Common {
j.deps(ctx)
}
- if ctx.Arch().ArchType != android.Common || ctx.BazelConversionMode() {
+ if ctx.Arch().ArchType != android.Common {
// These dependencies ensure the host installation rules will install the jar file and
// the jni libraries when the wrapper is installed.
ctx.AddVariationDependencies(nil, jniInstallTag, j.binaryProperties.Jni_libs...)
diff --git a/java/proto.go b/java/proto.go
index 5ba486f..5280077 100644
--- a/java/proto.go
+++ b/java/proto.go
@@ -91,7 +91,7 @@
case "lite", unspecifiedProtobufPluginType:
ctx.AddVariationDependencies(nil, staticLibTag, "libprotobuf-java-lite")
case "full":
- if ctx.Host() || ctx.BazelConversionMode() {
+ if ctx.Host() {
ctx.AddVariationDependencies(nil, staticLibTag, "libprotobuf-java-full")
} else {
ctx.PropertyErrorf("proto.type", "full java protos only supported on the host")
diff --git a/java/sdk.go b/java/sdk.go
index 0dddd40..b0da5af 100644
--- a/java/sdk.go
+++ b/java/sdk.go
@@ -57,6 +57,12 @@
return JAVA_VERSION_8
} else if sdk.FinalOrFutureInt() <= 31 {
return JAVA_VERSION_9
+ } else if ctx.Config().TargetsJava17() {
+ // Temporary experimental flag to be able to try and build with
+ // java version 17 options. The flag, if used, just sets Java
+ // 17 as the default version, leaving any components that
+ // target an older version intact.
+ return JAVA_VERSION_17
} else {
return JAVA_VERSION_11
}
diff --git a/python/library.go b/python/library.go
index d026c13..3a27591 100644
--- a/python/library.go
+++ b/python/library.go
@@ -17,6 +17,9 @@
// This file contains the module types for building Python library.
import (
+ "path/filepath"
+ "strings"
+
"android/soong/android"
"android/soong/bazel"
@@ -43,6 +46,7 @@
type bazelPythonLibraryAttributes struct {
Srcs bazel.LabelListAttribute
Deps bazel.LabelListAttribute
+ Imports bazel.StringListAttribute
Srcs_version *string
}
@@ -64,16 +68,44 @@
// do nothing, since python_version defaults to PY2ANDPY3
}
+ // Bazel normally requires `import path.from.top.of.tree` statements in
+ // python code, but with soong you can directly import modules from libraries.
+ // Add "imports" attributes to the bazel library so it matches soong's behavior.
+ imports := "."
+ if m.properties.Pkg_path != nil {
+ // TODO(b/215119317) This is a hack to handle the fact that we don't convert
+ // pkg_path properly right now. If the folder structure that contains this
+ // Android.bp file matches pkg_path, we can set imports to an appropriate
+ // number of ../..s to emulate moving the files under a pkg_path folder.
+ pkg_path := filepath.Clean(*m.properties.Pkg_path)
+ if strings.HasPrefix(pkg_path, "/") {
+ ctx.ModuleErrorf("pkg_path cannot start with a /: %s", pkg_path)
+ return
+ }
+
+ if !strings.HasSuffix(ctx.ModuleDir(), "/"+pkg_path) && ctx.ModuleDir() != pkg_path {
+ ctx.ModuleErrorf("Currently, bp2build only supports pkg_paths that are the same as the folders the Android.bp file is in. pkg_path: %s, module directory: %s", pkg_path, ctx.ModuleDir())
+ return
+ }
+ numFolders := strings.Count(pkg_path, "/") + 1
+ dots := make([]string, numFolders)
+ for i := 0; i < numFolders; i++ {
+ dots[i] = ".."
+ }
+ imports = strings.Join(dots, "/")
+ }
+
baseAttrs := m.makeArchVariantBaseAttributes(ctx)
attrs := &bazelPythonLibraryAttributes{
Srcs: baseAttrs.Srcs,
Deps: baseAttrs.Deps,
Srcs_version: python_version,
+ Imports: bazel.MakeStringListAttribute([]string{imports}),
}
props := bazel.BazelTargetModuleProperties{
- Rule_class: "py_library",
- Bzl_load_location: "//build/bazel/rules/python:library.bzl",
+ // Use the native py_library rule.
+ Rule_class: "py_library",
}
ctx.CreateBazelTargetModule(props, android.CommonAttributes{
diff --git a/rust/library.go b/rust/library.go
index 1286549..c2ce9de 100644
--- a/rust/library.go
+++ b/rust/library.go
@@ -246,10 +246,6 @@
return rlibAutoDep
} else if library.dylib() || library.shared() {
return dylibAutoDep
- } else if ctx.BazelConversionMode() {
- // In Bazel conversion mode, we are currently ignoring the deptag, so we just need to supply a
- // compatible tag in order to add the dependency.
- return rlibAutoDep
} else {
panic(fmt.Errorf("autoDep called on library %q that has no enabled variants.", ctx.ModuleName()))
}
diff --git a/sdk/bootclasspath_fragment_sdk_test.go b/sdk/bootclasspath_fragment_sdk_test.go
index 2dacdb5..a60039a 100644
--- a/sdk/bootclasspath_fragment_sdk_test.go
+++ b/sdk/bootclasspath_fragment_sdk_test.go
@@ -124,7 +124,7 @@
preparerForSnapshot := fixtureAddPrebuiltApexForBootclasspathFragment("com.android.art", "mybootclasspathfragment")
CheckSnapshot(t, result, "mysdk", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
prebuilt_bootclasspath_fragment {
@@ -152,41 +152,6 @@
jars: ["java_boot_libs/snapshot/jars/are/invalid/mybootlib.jar"],
}
`),
- checkVersionedAndroidBpContents(`
-// This is auto-generated. DO NOT EDIT.
-
-prebuilt_bootclasspath_fragment {
- name: "mysdk_mybootclasspathfragment@current",
- sdk_member_name: "mybootclasspathfragment",
- visibility: ["//visibility:public"],
- apex_available: ["com.android.art"],
- image_name: "art",
- contents: ["mysdk_mybootlib@current"],
- hidden_api: {
- annotation_flags: "hiddenapi/annotation-flags.csv",
- metadata: "hiddenapi/metadata.csv",
- index: "hiddenapi/index.csv",
- signature_patterns: "hiddenapi/signature-patterns.csv",
- filtered_stub_flags: "hiddenapi/filtered-stub-flags.csv",
- filtered_flags: "hiddenapi/filtered-flags.csv",
- },
-}
-
-java_import {
- name: "mysdk_mybootlib@current",
- sdk_member_name: "mybootlib",
- visibility: ["//visibility:public"],
- apex_available: ["com.android.art"],
- jars: ["java_boot_libs/snapshot/jars/are/invalid/mybootlib.jar"],
-}
-
-sdk_snapshot {
- name: "mysdk@current",
- visibility: ["//visibility:public"],
- bootclasspath_fragments: ["mysdk_mybootclasspathfragment@current"],
- java_boot_libs: ["mysdk_mybootlib@current"],
-}
-`),
checkAllCopyRules(`
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/annotation-flags.csv -> hiddenapi/annotation-flags.csv
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/metadata.csv -> hiddenapi/metadata.csv
@@ -317,7 +282,7 @@
preparerForSnapshot := fixtureAddPrebuiltApexForBootclasspathFragment("myapex", "mybootclasspathfragment")
CheckSnapshot(t, result, "mysdk", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
prebuilt_bootclasspath_fragment {
@@ -402,103 +367,6 @@
},
}
`),
- checkVersionedAndroidBpContents(`
-// This is auto-generated. DO NOT EDIT.
-
-prebuilt_bootclasspath_fragment {
- name: "mysdk_mybootclasspathfragment@current",
- sdk_member_name: "mybootclasspathfragment",
- visibility: ["//visibility:public"],
- apex_available: ["myapex"],
- contents: [
- "mysdk_mybootlib@current",
- "mysdk_myothersdklibrary@current",
- ],
- api: {
- stub_libs: ["mysdk_mysdklibrary@current"],
- },
- core_platform_api: {
- stub_libs: ["mysdk_mycoreplatform@current"],
- },
- hidden_api: {
- annotation_flags: "hiddenapi/annotation-flags.csv",
- metadata: "hiddenapi/metadata.csv",
- index: "hiddenapi/index.csv",
- signature_patterns: "hiddenapi/signature-patterns.csv",
- filtered_stub_flags: "hiddenapi/filtered-stub-flags.csv",
- filtered_flags: "hiddenapi/filtered-flags.csv",
- },
-}
-
-java_import {
- name: "mysdk_mybootlib@current",
- sdk_member_name: "mybootlib",
- visibility: ["//visibility:public"],
- apex_available: ["myapex"],
- jars: ["java_boot_libs/snapshot/jars/are/invalid/mybootlib.jar"],
- permitted_packages: ["mybootlib"],
-}
-
-java_sdk_library_import {
- name: "mysdk_myothersdklibrary@current",
- sdk_member_name: "myothersdklibrary",
- visibility: ["//visibility:public"],
- apex_available: ["myapex"],
- shared_library: true,
- compile_dex: true,
- permitted_packages: ["myothersdklibrary"],
- public: {
- jars: ["sdk_library/public/myothersdklibrary-stubs.jar"],
- stub_srcs: ["sdk_library/public/myothersdklibrary_stub_sources"],
- current_api: "sdk_library/public/myothersdklibrary.txt",
- removed_api: "sdk_library/public/myothersdklibrary-removed.txt",
- sdk_version: "current",
- },
-}
-
-java_sdk_library_import {
- name: "mysdk_mysdklibrary@current",
- sdk_member_name: "mysdklibrary",
- visibility: ["//visibility:public"],
- apex_available: ["myapex"],
- shared_library: false,
- public: {
- jars: ["sdk_library/public/mysdklibrary-stubs.jar"],
- stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"],
- current_api: "sdk_library/public/mysdklibrary.txt",
- removed_api: "sdk_library/public/mysdklibrary-removed.txt",
- sdk_version: "current",
- },
-}
-
-java_sdk_library_import {
- name: "mysdk_mycoreplatform@current",
- sdk_member_name: "mycoreplatform",
- visibility: ["//visibility:public"],
- apex_available: ["myapex"],
- shared_library: true,
- compile_dex: true,
- public: {
- jars: ["sdk_library/public/mycoreplatform-stubs.jar"],
- stub_srcs: ["sdk_library/public/mycoreplatform_stub_sources"],
- current_api: "sdk_library/public/mycoreplatform.txt",
- removed_api: "sdk_library/public/mycoreplatform-removed.txt",
- sdk_version: "current",
- },
-}
-
-sdk_snapshot {
- name: "mysdk@current",
- visibility: ["//visibility:public"],
- bootclasspath_fragments: ["mysdk_mybootclasspathfragment@current"],
- java_boot_libs: ["mysdk_mybootlib@current"],
- java_sdk_libs: [
- "mysdk_myothersdklibrary@current",
- "mysdk_mysdklibrary@current",
- "mysdk_mycoreplatform@current",
- ],
-}
- `),
checkAllCopyRules(`
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/annotation-flags.csv -> hiddenapi/annotation-flags.csv
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/metadata.csv -> hiddenapi/metadata.csv
@@ -630,7 +498,7 @@
preparerForSnapshot := fixtureAddPrebuiltApexForBootclasspathFragment("myapex", "mybootclasspathfragment")
CheckSnapshot(t, result, "mysdk", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
prebuilt_bootclasspath_fragment {
@@ -828,7 +696,7 @@
preparerForSnapshot := fixtureAddPrebuiltApexForBootclasspathFragment("myapex", "mybootclasspathfragment")
CheckSnapshot(t, result, "mysdk", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
prebuilt_bootclasspath_fragment {
diff --git a/sdk/bp.go b/sdk/bp.go
index e2dace8..7ff85a1 100644
--- a/sdk/bp.go
+++ b/sdk/bp.go
@@ -298,15 +298,15 @@
return module
}
-func (t identityTransformation) transformPropertySetBeforeContents(name string, propertySet *bpPropertySet, tag android.BpPropertyTag) (*bpPropertySet, android.BpPropertyTag) {
+func (t identityTransformation) transformPropertySetBeforeContents(_ string, propertySet *bpPropertySet, tag android.BpPropertyTag) (*bpPropertySet, android.BpPropertyTag) {
return propertySet, tag
}
-func (t identityTransformation) transformPropertySetAfterContents(name string, propertySet *bpPropertySet, tag android.BpPropertyTag) (*bpPropertySet, android.BpPropertyTag) {
+func (t identityTransformation) transformPropertySetAfterContents(_ string, propertySet *bpPropertySet, tag android.BpPropertyTag) (*bpPropertySet, android.BpPropertyTag) {
return propertySet, tag
}
-func (t identityTransformation) transformProperty(name string, value interface{}, tag android.BpPropertyTag) (interface{}, android.BpPropertyTag) {
+func (t identityTransformation) transformProperty(_ string, value interface{}, tag android.BpPropertyTag) (interface{}, android.BpPropertyTag) {
return value, tag
}
@@ -332,7 +332,7 @@
return &moduleCopy
}
-func (t deepCopyTransformation) transformPropertySetBeforeContents(name string, propertySet *bpPropertySet, tag android.BpPropertyTag) (*bpPropertySet, android.BpPropertyTag) {
+func (t deepCopyTransformation) transformPropertySetBeforeContents(_ string, propertySet *bpPropertySet, tag android.BpPropertyTag) (*bpPropertySet, android.BpPropertyTag) {
// Create a shallow copy of the properties map. Any mutable property values will be copied by the
// transformer.
propertiesCopy := make(map[string]interface{})
@@ -354,7 +354,7 @@
}, tag
}
-func (t deepCopyTransformation) transformProperty(name string, value interface{}, tag android.BpPropertyTag) (interface{}, android.BpPropertyTag) {
+func (t deepCopyTransformation) transformProperty(_ string, value interface{}, tag android.BpPropertyTag) (interface{}, android.BpPropertyTag) {
// Copy string slice, otherwise return value.
if values, ok := value.([]string); ok {
valuesCopy := make([]string, len(values))
@@ -372,7 +372,7 @@
order []*bpModule
}
-// Add a module.
+// AddModule adds a module to this.
//
// The module must have had its "name" property set to a string value that
// is unique within this file.
diff --git a/sdk/cc_sdk_test.go b/sdk/cc_sdk_test.go
index 571d214..265579a 100644
--- a/sdk/cc_sdk_test.go
+++ b/sdk/cc_sdk_test.go
@@ -120,7 +120,7 @@
`)
CheckSnapshot(t, result, "mysdk", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
cc_prebuilt_library_shared {
@@ -145,48 +145,6 @@
},
}
`),
- checkVersionedAndroidBpContents(`
-// This is auto-generated. DO NOT EDIT.
-
-cc_prebuilt_library_shared {
- name: "mysdk_sdkmember@current",
- sdk_member_name: "sdkmember",
- visibility: ["//visibility:public"],
- apex_available: ["//apex_available:platform"],
- host_supported: true,
- installable: false,
- stl: "none",
- compile_multilib: "64",
- target: {
- host: {
- enabled: false,
- },
- android_arm64: {
- srcs: ["android/arm64/lib/sdkmember.so"],
- },
- linux_glibc_x86_64: {
- enabled: true,
- srcs: ["linux_glibc/x86_64/lib/sdkmember.so"],
- },
- },
-}
-
-sdk_snapshot {
- name: "mysdk@current",
- visibility: ["//visibility:public"],
- host_supported: true,
- compile_multilib: "64",
- native_shared_libs: ["mysdk_sdkmember@current"],
- target: {
- host: {
- enabled: false,
- },
- linux_glibc_x86_64: {
- enabled: true,
- },
- },
-}
-`),
checkAllCopyRules(`
.intermediates/sdkmember/android_arm64_armv8-a_shared/sdkmember.so -> android/arm64/lib/sdkmember.so
.intermediates/sdkmember/linux_glibc_x86_64_shared/sdkmember.so -> linux_glibc/x86_64/lib/sdkmember.so
@@ -265,7 +223,7 @@
`)
CheckSnapshot(t, result, "mysdk", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
cc_prebuilt_object {
@@ -289,37 +247,6 @@
},
}
`),
- // Make sure that the generated sdk_snapshot uses the native_objects property.
- checkVersionedAndroidBpContents(`
-// This is auto-generated. DO NOT EDIT.
-
-cc_prebuilt_object {
- name: "mysdk_crtobj@current",
- sdk_member_name: "crtobj",
- visibility: ["//visibility:public"],
- apex_available: ["//apex_available:platform"],
- stl: "none",
- compile_multilib: "both",
- system_shared_libs: [],
- sanitize: {
- never: true,
- },
- arch: {
- arm64: {
- srcs: ["arm64/lib/crtobj.o"],
- },
- arm: {
- srcs: ["arm/lib/crtobj.o"],
- },
- },
-}
-
-sdk_snapshot {
- name: "mysdk@current",
- visibility: ["//visibility:public"],
- native_objects: ["mysdk_crtobj@current"],
-}
-`),
checkAllCopyRules(`
.intermediates/crtobj/android_arm64_armv8-a/crtobj.o -> arm64/lib/crtobj.o
.intermediates/crtobj/android_arm_armv7-a-neon/crtobj.o -> arm/lib/crtobj.o
@@ -403,7 +330,7 @@
errorHandler := android.FixtureExpectsAtLeastOneErrorMatchingPattern(`module source path "snapshot/include_gen/generated_foo/gen/protos" does not exist`)
CheckSnapshot(t, result, "mysdk", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
cc_prebuilt_library_shared {
@@ -476,7 +403,7 @@
`)
CheckSnapshot(t, result, "mysdk", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
cc_prebuilt_library_shared {
@@ -535,7 +462,7 @@
`)
CheckSnapshot(t, result, "mymodule_exports", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
cc_prebuilt_binary {
@@ -554,33 +481,6 @@
},
}
`),
- // Make sure that the generated sdk_snapshot uses the native_binaries property.
- checkVersionedAndroidBpContents(`
-// This is auto-generated. DO NOT EDIT.
-
-cc_prebuilt_binary {
- name: "mymodule_exports_mynativebinary@current",
- sdk_member_name: "mynativebinary",
- visibility: ["//visibility:public"],
- apex_available: ["//apex_available:platform"],
- installable: false,
- compile_multilib: "both",
- arch: {
- arm64: {
- srcs: ["arm64/bin/mynativebinary"],
- },
- arm: {
- srcs: ["arm/bin/mynativebinary"],
- },
- },
-}
-
-module_exports_snapshot {
- name: "mymodule_exports@current",
- visibility: ["//visibility:public"],
- native_binaries: ["mymodule_exports_mynativebinary@current"],
-}
-`),
checkAllCopyRules(`
.intermediates/mynativebinary/android_arm64_armv8-a/mynativebinary -> arm64/bin/mynativebinary
.intermediates/mynativebinary/android_arm_armv7-a-neon/mynativebinary -> arm/bin/mynativebinary
@@ -620,7 +520,7 @@
`)
CheckSnapshot(t, result, "myexports", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
cc_prebuilt_binary {
@@ -656,68 +556,6 @@
},
}
`),
- checkVersionedAndroidBpContents(`
-// This is auto-generated. DO NOT EDIT.
-
-cc_prebuilt_binary {
- name: "myexports_mynativebinary@current",
- sdk_member_name: "mynativebinary",
- visibility: ["//visibility:public"],
- apex_available: ["//apex_available:platform"],
- device_supported: false,
- host_supported: true,
- installable: false,
- stl: "none",
- target: {
- host: {
- enabled: false,
- },
- linux_glibc: {
- compile_multilib: "both",
- },
- linux_glibc_x86_64: {
- enabled: true,
- srcs: ["linux_glibc/x86_64/bin/mynativebinary"],
- },
- linux_glibc_x86: {
- enabled: true,
- srcs: ["linux_glibc/x86/bin/mynativebinary"],
- },
- windows: {
- compile_multilib: "64",
- },
- windows_x86_64: {
- enabled: true,
- srcs: ["windows/x86_64/bin/mynativebinary.exe"],
- },
- },
-}
-
-module_exports_snapshot {
- name: "myexports@current",
- visibility: ["//visibility:public"],
- device_supported: false,
- host_supported: true,
- native_binaries: ["myexports_mynativebinary@current"],
- target: {
- windows: {
- compile_multilib: "64",
- },
- host: {
- enabled: false,
- },
- linux_glibc_x86_64: {
- enabled: true,
- },
- linux_glibc_x86: {
- enabled: true,
- },
- windows_x86_64: {
- enabled: true,
- },
- },
-}
-`),
checkAllCopyRules(`
.intermediates/mynativebinary/linux_glibc_x86_64/mynativebinary -> linux_glibc/x86_64/bin/mynativebinary
.intermediates/mynativebinary/linux_glibc_x86/mynativebinary -> linux_glibc/x86/bin/mynativebinary
@@ -780,7 +618,7 @@
`)
CheckSnapshot(t, result, "myexports", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
cc_prebuilt_binary {
@@ -823,69 +661,6 @@
},
}
`),
- checkVersionedAndroidBpContents(`
-// This is auto-generated. DO NOT EDIT.
-
-cc_prebuilt_binary {
- name: "myexports_mynativebinary@current",
- sdk_member_name: "mynativebinary",
- visibility: ["//visibility:public"],
- apex_available: ["//apex_available:platform"],
- device_supported: false,
- host_supported: true,
- installable: false,
- stl: "none",
- compile_multilib: "64",
- target: {
- host: {
- enabled: false,
- },
- linux_bionic_x86_64: {
- enabled: true,
- srcs: ["x86_64/bin/mynativebinary"],
- },
- },
-}
-
-cc_prebuilt_library_shared {
- name: "myexports_mynativelib@current",
- sdk_member_name: "mynativelib",
- visibility: ["//visibility:public"],
- apex_available: ["//apex_available:platform"],
- device_supported: false,
- host_supported: true,
- installable: false,
- stl: "none",
- compile_multilib: "64",
- target: {
- host: {
- enabled: false,
- },
- linux_bionic_x86_64: {
- enabled: true,
- srcs: ["x86_64/lib/mynativelib.so"],
- },
- },
-}
-
-module_exports_snapshot {
- name: "myexports@current",
- visibility: ["//visibility:public"],
- device_supported: false,
- host_supported: true,
- compile_multilib: "64",
- native_binaries: ["myexports_mynativebinary@current"],
- native_shared_libs: ["myexports_mynativelib@current"],
- target: {
- host: {
- enabled: false,
- },
- linux_bionic_x86_64: {
- enabled: true,
- },
- },
-}
-`),
checkAllCopyRules(`
.intermediates/mynativebinary/linux_bionic_x86_64/mynativebinary -> x86_64/bin/mynativebinary
.intermediates/mynativelib/linux_bionic_x86_64_shared/mynativelib.so -> x86_64/lib/mynativelib.so
@@ -918,7 +693,7 @@
`)
CheckSnapshot(t, result, "mymodule_exports", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
cc_prebuilt_binary {
@@ -947,55 +722,6 @@
},
}
`),
- checkVersionedAndroidBpContents(`
-// This is auto-generated. DO NOT EDIT.
-
-cc_prebuilt_binary {
- name: "mymodule_exports_linker@current",
- sdk_member_name: "linker",
- visibility: ["//visibility:public"],
- apex_available: ["//apex_available:platform"],
- device_supported: false,
- host_supported: true,
- installable: false,
- stl: "none",
- compile_multilib: "both",
- static_executable: true,
- nocrt: true,
- target: {
- host: {
- enabled: false,
- },
- linux_glibc_x86_64: {
- enabled: true,
- srcs: ["x86_64/bin/linker"],
- },
- linux_glibc_x86: {
- enabled: true,
- srcs: ["x86/bin/linker"],
- },
- },
-}
-
-module_exports_snapshot {
- name: "mymodule_exports@current",
- visibility: ["//visibility:public"],
- device_supported: false,
- host_supported: true,
- native_binaries: ["mymodule_exports_linker@current"],
- target: {
- host: {
- enabled: false,
- },
- linux_glibc_x86_64: {
- enabled: true,
- },
- linux_glibc_x86: {
- enabled: true,
- },
- },
-}
-`),
checkAllCopyRules(`
.intermediates/linker/linux_glibc_x86_64/linker -> x86_64/bin/linker
.intermediates/linker/linux_glibc_x86/linker -> x86/bin/linker
@@ -1026,7 +752,7 @@
`)
CheckSnapshot(t, result, "mysdk", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
cc_prebuilt_library_shared {
@@ -1127,7 +853,7 @@
`)
CheckSnapshot(t, result, "mysdk", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
cc_prebuilt_library_shared {
@@ -1224,7 +950,7 @@
`)
CheckSnapshot(t, result, "mysdk", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
cc_prebuilt_library_shared {
@@ -1255,57 +981,6 @@
},
}
`),
- checkVersionedAndroidBpContents(`
-// This is auto-generated. DO NOT EDIT.
-
-cc_prebuilt_library_shared {
- name: "mysdk_mynativelib@current",
- sdk_member_name: "mynativelib",
- visibility: ["//visibility:public"],
- apex_available: ["//apex_available:platform"],
- device_supported: false,
- host_supported: true,
- installable: false,
- sdk_version: "minimum",
- stl: "none",
- compile_multilib: "both",
- export_include_dirs: ["include/myinclude"],
- target: {
- host: {
- enabled: false,
- },
- linux_glibc_x86_64: {
- enabled: true,
- srcs: ["x86_64/lib/mynativelib.so"],
- export_include_dirs: ["x86_64/include_gen/mynativelib/linux_glibc_x86_64_shared/gen/aidl"],
- },
- linux_glibc_x86: {
- enabled: true,
- srcs: ["x86/lib/mynativelib.so"],
- export_include_dirs: ["x86/include_gen/mynativelib/linux_glibc_x86_shared/gen/aidl"],
- },
- },
-}
-
-sdk_snapshot {
- name: "mysdk@current",
- visibility: ["//visibility:public"],
- device_supported: false,
- host_supported: true,
- native_shared_libs: ["mysdk_mynativelib@current"],
- target: {
- host: {
- enabled: false,
- },
- linux_glibc_x86_64: {
- enabled: true,
- },
- linux_glibc_x86: {
- enabled: true,
- },
- },
-}
-`),
checkAllCopyRules(`
myinclude/Test.h -> include/myinclude/Test.h
.intermediates/mynativelib/linux_glibc_x86_64_shared/mynativelib.so -> x86_64/lib/mynativelib.so
@@ -1351,7 +1026,7 @@
`)
CheckSnapshot(t, result, "mysdk", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
cc_prebuilt_library_shared {
@@ -1387,68 +1062,6 @@
},
}
`),
- checkVersionedAndroidBpContents(`
-// This is auto-generated. DO NOT EDIT.
-
-cc_prebuilt_library_shared {
- name: "mysdk_mynativelib@current",
- sdk_member_name: "mynativelib",
- visibility: ["//visibility:public"],
- apex_available: ["//apex_available:platform"],
- device_supported: false,
- host_supported: true,
- installable: false,
- stl: "none",
- target: {
- host: {
- enabled: false,
- },
- linux_glibc: {
- compile_multilib: "both",
- },
- linux_glibc_x86_64: {
- enabled: true,
- srcs: ["linux_glibc/x86_64/lib/mynativelib.so"],
- },
- linux_glibc_x86: {
- enabled: true,
- srcs: ["linux_glibc/x86/lib/mynativelib.so"],
- },
- windows: {
- compile_multilib: "64",
- },
- windows_x86_64: {
- enabled: true,
- srcs: ["windows/x86_64/lib/mynativelib.dll"],
- },
- },
-}
-
-sdk_snapshot {
- name: "mysdk@current",
- visibility: ["//visibility:public"],
- device_supported: false,
- host_supported: true,
- native_shared_libs: ["mysdk_mynativelib@current"],
- target: {
- windows: {
- compile_multilib: "64",
- },
- host: {
- enabled: false,
- },
- linux_glibc_x86_64: {
- enabled: true,
- },
- linux_glibc_x86: {
- enabled: true,
- },
- windows_x86_64: {
- enabled: true,
- },
- },
-}
-`),
checkAllCopyRules(`
.intermediates/mynativelib/linux_glibc_x86_64_shared/mynativelib.so -> linux_glibc/x86_64/lib/mynativelib.so
.intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> linux_glibc/x86/lib/mynativelib.so
@@ -1479,7 +1092,7 @@
`)
CheckSnapshot(t, result, "myexports", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
cc_prebuilt_library_static {
@@ -1542,7 +1155,7 @@
`)
CheckSnapshot(t, result, "myexports", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
cc_prebuilt_library_static {
@@ -1572,56 +1185,6 @@
},
}
`),
- checkVersionedAndroidBpContents(`
-// This is auto-generated. DO NOT EDIT.
-
-cc_prebuilt_library_static {
- name: "myexports_mynativelib@current",
- sdk_member_name: "mynativelib",
- visibility: ["//visibility:public"],
- apex_available: ["//apex_available:platform"],
- device_supported: false,
- host_supported: true,
- installable: false,
- stl: "none",
- compile_multilib: "both",
- export_include_dirs: ["include/myinclude"],
- target: {
- host: {
- enabled: false,
- },
- linux_glibc_x86_64: {
- enabled: true,
- srcs: ["x86_64/lib/mynativelib.a"],
- export_include_dirs: ["x86_64/include_gen/mynativelib/linux_glibc_x86_64_static/gen/aidl"],
- },
- linux_glibc_x86: {
- enabled: true,
- srcs: ["x86/lib/mynativelib.a"],
- export_include_dirs: ["x86/include_gen/mynativelib/linux_glibc_x86_static/gen/aidl"],
- },
- },
-}
-
-module_exports_snapshot {
- name: "myexports@current",
- visibility: ["//visibility:public"],
- device_supported: false,
- host_supported: true,
- native_static_libs: ["myexports_mynativelib@current"],
- target: {
- host: {
- enabled: false,
- },
- linux_glibc_x86_64: {
- enabled: true,
- },
- linux_glibc_x86: {
- enabled: true,
- },
- },
-}
-`),
checkAllCopyRules(`
myinclude/Test.h -> include/myinclude/Test.h
.intermediates/mynativelib/linux_glibc_x86_64_static/mynativelib.a -> x86_64/lib/mynativelib.a
@@ -1656,7 +1219,7 @@
`)
CheckSnapshot(t, result, "myexports", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
cc_prebuilt_library {
@@ -1688,46 +1251,6 @@
},
}
`),
- // Make sure that the generated sdk_snapshot uses the native_libs property.
- checkVersionedAndroidBpContents(`
-// This is auto-generated. DO NOT EDIT.
-
-cc_prebuilt_library {
- name: "myexports_mynativelib@current",
- sdk_member_name: "mynativelib",
- visibility: ["//visibility:public"],
- apex_available: ["//apex_available:platform"],
- installable: false,
- vendor_available: true,
- stl: "none",
- compile_multilib: "both",
- export_include_dirs: ["include/myinclude"],
- arch: {
- arm64: {
- static: {
- srcs: ["arm64/lib/mynativelib.a"],
- },
- shared: {
- srcs: ["arm64/lib/mynativelib.so"],
- },
- },
- arm: {
- static: {
- srcs: ["arm/lib/mynativelib.a"],
- },
- shared: {
- srcs: ["arm/lib/mynativelib.so"],
- },
- },
- },
-}
-
-module_exports_snapshot {
- name: "myexports@current",
- visibility: ["//visibility:public"],
- native_libs: ["myexports_mynativelib@current"],
-}
-`),
checkAllCopyRules(`
myinclude/Test.h -> include/myinclude/Test.h
.intermediates/mynativelib/android_arm64_armv8-a_static/mynativelib.a -> arm64/lib/mynativelib.a
@@ -1740,6 +1263,229 @@
)
}
+func TestSnapshotSameLibraryWithNativeLibsAndNativeSharedLib(t *testing.T) {
+ result := testSdkWithCc(t, `
+ module_exports {
+ host_supported: true,
+ name: "myexports",
+ target: {
+ android: {
+ native_shared_libs: [
+ "mynativelib",
+ ],
+ },
+ not_windows: {
+ native_libs: [
+ "mynativelib",
+ ],
+ },
+ },
+ }
+
+ cc_library {
+ name: "mynativelib",
+ host_supported: true,
+ srcs: [
+ "Test.cpp",
+ ],
+ stl: "none",
+ recovery_available: true,
+ vendor_available: true,
+ }
+ `)
+
+ CheckSnapshot(t, result, "myexports", "",
+ checkAndroidBpContents(`
+// This is auto-generated. DO NOT EDIT.
+
+cc_prebuilt_library {
+ name: "mynativelib",
+ prefer: false,
+ visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
+ host_supported: true,
+ vendor_available: true,
+ stl: "none",
+ compile_multilib: "both",
+ target: {
+ host: {
+ enabled: false,
+ },
+ android_arm64: {
+ shared: {
+ srcs: ["android/arm64/lib/mynativelib.so"],
+ },
+ static: {
+ enabled: false,
+ },
+ },
+ android_arm: {
+ shared: {
+ srcs: ["android/arm/lib/mynativelib.so"],
+ },
+ static: {
+ enabled: false,
+ },
+ },
+ linux_glibc_x86_64: {
+ enabled: true,
+ static: {
+ srcs: ["linux_glibc/x86_64/lib/mynativelib.a"],
+ },
+ shared: {
+ srcs: ["linux_glibc/x86_64/lib/mynativelib.so"],
+ },
+ },
+ linux_glibc_x86: {
+ enabled: true,
+ static: {
+ srcs: ["linux_glibc/x86/lib/mynativelib.a"],
+ },
+ shared: {
+ srcs: ["linux_glibc/x86/lib/mynativelib.so"],
+ },
+ },
+ },
+}
+`),
+ checkAllCopyRules(`
+.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> android/arm64/lib/mynativelib.so
+.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> android/arm/lib/mynativelib.so
+.intermediates/mynativelib/linux_glibc_x86_64_static/mynativelib.a -> linux_glibc/x86_64/lib/mynativelib.a
+.intermediates/mynativelib/linux_glibc_x86_64_shared/mynativelib.so -> linux_glibc/x86_64/lib/mynativelib.so
+.intermediates/mynativelib/linux_glibc_x86_static/mynativelib.a -> linux_glibc/x86/lib/mynativelib.a
+.intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> linux_glibc/x86/lib/mynativelib.so
+`),
+ )
+}
+
+func TestSnapshotSameLibraryWithAndroidNativeLibsAndHostNativeSharedLib(t *testing.T) {
+ result := testSdkWithCc(t, `
+ module_exports {
+ host_supported: true,
+ name: "myexports",
+ target: {
+ android: {
+ native_libs: [
+ "mynativelib",
+ ],
+ },
+ not_windows: {
+ native_shared_libs: [
+ "mynativelib",
+ ],
+ },
+ },
+ }
+
+ cc_library {
+ name: "mynativelib",
+ host_supported: true,
+ srcs: [
+ "Test.cpp",
+ ],
+ stl: "none",
+ recovery_available: true,
+ vendor_available: true,
+ }
+ `)
+
+ CheckSnapshot(t, result, "myexports", "",
+ checkAndroidBpContents(`
+// This is auto-generated. DO NOT EDIT.
+
+cc_prebuilt_library {
+ name: "mynativelib",
+ prefer: false,
+ visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
+ host_supported: true,
+ vendor_available: true,
+ stl: "none",
+ compile_multilib: "both",
+ target: {
+ host: {
+ enabled: false,
+ },
+ android_arm64: {
+ static: {
+ srcs: ["android/arm64/lib/mynativelib.a"],
+ },
+ shared: {
+ srcs: ["android/arm64/lib/mynativelib.so"],
+ },
+ },
+ android_arm: {
+ static: {
+ srcs: ["android/arm/lib/mynativelib.a"],
+ },
+ shared: {
+ srcs: ["android/arm/lib/mynativelib.so"],
+ },
+ },
+ linux_glibc_x86_64: {
+ enabled: true,
+ shared: {
+ srcs: ["linux_glibc/x86_64/lib/mynativelib.so"],
+ },
+ static: {
+ enabled: false,
+ },
+ },
+ linux_glibc_x86: {
+ enabled: true,
+ shared: {
+ srcs: ["linux_glibc/x86/lib/mynativelib.so"],
+ },
+ static: {
+ enabled: false,
+ },
+ },
+ },
+}
+`),
+ checkAllCopyRules(`
+.intermediates/mynativelib/android_arm64_armv8-a_static/mynativelib.a -> android/arm64/lib/mynativelib.a
+.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> android/arm64/lib/mynativelib.so
+.intermediates/mynativelib/android_arm_armv7-a-neon_static/mynativelib.a -> android/arm/lib/mynativelib.a
+.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> android/arm/lib/mynativelib.so
+.intermediates/mynativelib/linux_glibc_x86_64_shared/mynativelib.so -> linux_glibc/x86_64/lib/mynativelib.so
+.intermediates/mynativelib/linux_glibc_x86_shared/mynativelib.so -> linux_glibc/x86/lib/mynativelib.so
+`),
+ )
+}
+
+func TestSnapshotSameLibraryWithNativeStaticLibsAndNativeSharedLib(t *testing.T) {
+ testSdkError(t, "Incompatible member types", `
+ module_exports {
+ host_supported: true,
+ name: "myexports",
+ target: {
+ android: {
+ native_shared_libs: [
+ "mynativelib",
+ ],
+ },
+ not_windows: {
+ native_static_libs: [
+ "mynativelib",
+ ],
+ },
+ },
+ }
+
+ cc_library {
+ name: "mynativelib",
+ host_supported: true,
+ srcs: [
+ ],
+ stl: "none",
+ recovery_available: true,
+ vendor_available: true,
+ }
+ `)
+}
+
func TestHostSnapshotWithMultiLib64(t *testing.T) {
result := testSdkWithCc(t, `
module_exports {
@@ -1771,7 +1517,7 @@
`)
CheckSnapshot(t, result, "myexports", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
cc_prebuilt_library_static {
@@ -1798,51 +1544,6 @@
},
}
`),
- checkVersionedAndroidBpContents(`
-// This is auto-generated. DO NOT EDIT.
-
-cc_prebuilt_library_static {
- name: "myexports_mynativelib@current",
- sdk_member_name: "mynativelib",
- visibility: ["//visibility:public"],
- apex_available: ["//apex_available:platform"],
- device_supported: false,
- host_supported: true,
- installable: false,
- stl: "none",
- compile_multilib: "64",
- export_include_dirs: [
- "include/myinclude",
- "include_gen/mynativelib/linux_glibc_x86_64_static/gen/aidl",
- ],
- target: {
- host: {
- enabled: false,
- },
- linux_glibc_x86_64: {
- enabled: true,
- srcs: ["x86_64/lib/mynativelib.a"],
- },
- },
-}
-
-module_exports_snapshot {
- name: "myexports@current",
- visibility: ["//visibility:public"],
- device_supported: false,
- host_supported: true,
- compile_multilib: "64",
- native_static_libs: ["myexports_mynativelib@current"],
- target: {
- host: {
- enabled: false,
- },
- linux_glibc_x86_64: {
- enabled: true,
- },
- },
-}
-`),
checkAllCopyRules(`
myinclude/Test.h -> include/myinclude/Test.h
.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/Test.h -> include_gen/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/Test.h
@@ -1868,7 +1569,7 @@
`)
CheckSnapshot(t, result, "mysdk", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
cc_prebuilt_library_headers {
@@ -1912,7 +1613,7 @@
`)
CheckSnapshot(t, result, "mysdk", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
cc_prebuilt_library_headers {
@@ -1997,7 +1698,7 @@
`, trait, property))
CheckSnapshot(t, result, "mysdk", "",
- checkUnversionedAndroidBpContents(fmt.Sprintf(`
+ checkAndroidBpContents(fmt.Sprintf(`
// This is auto-generated. DO NOT EDIT.
cc_prebuilt_library_headers {
@@ -2046,7 +1747,7 @@
`)
CheckSnapshot(t, result, "mysdk", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
cc_prebuilt_library_headers {
@@ -2072,51 +1773,6 @@
},
}
`),
- checkVersionedAndroidBpContents(`
-// This is auto-generated. DO NOT EDIT.
-
-cc_prebuilt_library_headers {
- name: "mysdk_mynativeheaders@current",
- sdk_member_name: "mynativeheaders",
- visibility: ["//visibility:public"],
- apex_available: ["//apex_available:platform"],
- device_supported: false,
- host_supported: true,
- stl: "none",
- compile_multilib: "both",
- export_include_dirs: ["include/myinclude"],
- target: {
- host: {
- enabled: false,
- },
- linux_glibc_x86_64: {
- enabled: true,
- },
- linux_glibc_x86: {
- enabled: true,
- },
- },
-}
-
-sdk_snapshot {
- name: "mysdk@current",
- visibility: ["//visibility:public"],
- device_supported: false,
- host_supported: true,
- native_header_libs: ["mysdk_mynativeheaders@current"],
- target: {
- host: {
- enabled: false,
- },
- linux_glibc_x86_64: {
- enabled: true,
- },
- linux_glibc_x86: {
- enabled: true,
- },
- },
-}
-`),
checkAllCopyRules(`
myinclude/Test.h -> include/myinclude/Test.h
`),
@@ -2148,7 +1804,7 @@
`)
CheckSnapshot(t, result, "mysdk", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
cc_prebuilt_library_headers {
@@ -2179,55 +1835,6 @@
},
}
`),
- checkVersionedAndroidBpContents(`
-// This is auto-generated. DO NOT EDIT.
-
-cc_prebuilt_library_headers {
- name: "mysdk_mynativeheaders@current",
- sdk_member_name: "mynativeheaders",
- visibility: ["//visibility:public"],
- apex_available: ["//apex_available:platform"],
- host_supported: true,
- stl: "none",
- compile_multilib: "both",
- export_system_include_dirs: ["common_os/include/myinclude"],
- target: {
- host: {
- enabled: false,
- },
- android: {
- export_include_dirs: ["android/include/myinclude-android"],
- },
- linux_glibc: {
- export_include_dirs: ["linux_glibc/include/myinclude-host"],
- },
- linux_glibc_x86_64: {
- enabled: true,
- },
- linux_glibc_x86: {
- enabled: true,
- },
- },
-}
-
-sdk_snapshot {
- name: "mysdk@current",
- visibility: ["//visibility:public"],
- host_supported: true,
- native_header_libs: ["mysdk_mynativeheaders@current"],
- target: {
- host: {
- enabled: false,
- },
- linux_glibc_x86_64: {
- enabled: true,
- },
- linux_glibc_x86: {
- enabled: true,
- },
- },
-}
-`),
checkAllCopyRules(`
myinclude/Test.h -> common_os/include/myinclude/Test.h
myinclude-android/AndroidTest.h -> android/include/myinclude-android/AndroidTest.h
@@ -2260,7 +1867,7 @@
`)
CheckSnapshot(t, result, "mysdk", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
cc_prebuilt_library_shared {
@@ -2333,7 +1940,7 @@
`)
CheckSnapshot(t, result, "mysdk", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
cc_prebuilt_library_shared {
@@ -2367,59 +1974,7 @@
},
}
`),
- checkVersionedAndroidBpContents(`
-// This is auto-generated. DO NOT EDIT.
-
-cc_prebuilt_library_shared {
- name: "mysdk_sslvariants@current",
- sdk_member_name: "sslvariants",
- visibility: ["//visibility:public"],
- apex_available: ["//apex_available:platform"],
- host_supported: true,
- installable: false,
- compile_multilib: "both",
- target: {
- host: {
- enabled: false,
- },
- android: {
- system_shared_libs: [],
- },
- android_arm64: {
- srcs: ["android/arm64/lib/sslvariants.so"],
- },
- android_arm: {
- srcs: ["android/arm/lib/sslvariants.so"],
- },
- linux_glibc_x86_64: {
- enabled: true,
- srcs: ["linux_glibc/x86_64/lib/sslvariants.so"],
- },
- linux_glibc_x86: {
- enabled: true,
- srcs: ["linux_glibc/x86/lib/sslvariants.so"],
- },
- },
-}
-
-sdk_snapshot {
- name: "mysdk@current",
- visibility: ["//visibility:public"],
- host_supported: true,
- native_shared_libs: ["mysdk_sslvariants@current"],
- target: {
- host: {
- enabled: false,
- },
- linux_glibc_x86_64: {
- enabled: true,
- },
- linux_glibc_x86: {
- enabled: true,
- },
- },
-}
-`))
+ )
}
func TestStubsLibrary(t *testing.T) {
@@ -2444,7 +1999,7 @@
`)
CheckSnapshot(t, result, "mysdk", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
cc_prebuilt_library_shared {
@@ -2498,7 +2053,7 @@
`)
CheckSnapshot(t, result, "mysdk", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
cc_prebuilt_library_shared {
@@ -2537,64 +2092,7 @@
},
}
`),
- checkVersionedAndroidBpContents(`
-// This is auto-generated. DO NOT EDIT.
-
-cc_prebuilt_library_shared {
- name: "mysdk_stubslib@current",
- sdk_member_name: "stubslib",
- visibility: ["//visibility:public"],
- apex_available: ["//apex_available:platform"],
- host_supported: true,
- installable: false,
- compile_multilib: "both",
- stubs: {
- versions: [
- "1",
- "2",
- "3",
- "current",
- ],
- },
- target: {
- host: {
- enabled: false,
- },
- android_arm64: {
- srcs: ["android/arm64/lib/stubslib.so"],
- },
- android_arm: {
- srcs: ["android/arm/lib/stubslib.so"],
- },
- linux_glibc_x86_64: {
- enabled: true,
- srcs: ["linux_glibc/x86_64/lib/stubslib.so"],
- },
- linux_glibc_x86: {
- enabled: true,
- srcs: ["linux_glibc/x86/lib/stubslib.so"],
- },
- },
-}
-
-sdk_snapshot {
- name: "mysdk@current",
- visibility: ["//visibility:public"],
- host_supported: true,
- native_shared_libs: ["mysdk_stubslib@current"],
- target: {
- host: {
- enabled: false,
- },
- linux_glibc_x86_64: {
- enabled: true,
- },
- linux_glibc_x86: {
- enabled: true,
- },
- },
-}
-`))
+ )
}
func TestUniqueHostSoname(t *testing.T) {
@@ -2613,7 +2111,7 @@
`)
CheckSnapshot(t, result, "mysdk", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
cc_prebuilt_library_shared {
@@ -2645,57 +2143,6 @@
},
}
`),
- checkVersionedAndroidBpContents(`
-// This is auto-generated. DO NOT EDIT.
-
-cc_prebuilt_library_shared {
- name: "mysdk_mylib@current",
- sdk_member_name: "mylib",
- visibility: ["//visibility:public"],
- apex_available: ["//apex_available:platform"],
- host_supported: true,
- installable: false,
- unique_host_soname: true,
- compile_multilib: "both",
- target: {
- host: {
- enabled: false,
- },
- android_arm64: {
- srcs: ["android/arm64/lib/mylib.so"],
- },
- android_arm: {
- srcs: ["android/arm/lib/mylib.so"],
- },
- linux_glibc_x86_64: {
- enabled: true,
- srcs: ["linux_glibc/x86_64/lib/mylib-host.so"],
- },
- linux_glibc_x86: {
- enabled: true,
- srcs: ["linux_glibc/x86/lib/mylib-host.so"],
- },
- },
-}
-
-sdk_snapshot {
- name: "mysdk@current",
- visibility: ["//visibility:public"],
- host_supported: true,
- native_shared_libs: ["mysdk_mylib@current"],
- target: {
- host: {
- enabled: false,
- },
- linux_glibc_x86_64: {
- enabled: true,
- },
- linux_glibc_x86: {
- enabled: true,
- },
- },
-}
-`),
checkAllCopyRules(`
.intermediates/mylib/android_arm64_armv8-a_shared/mylib.so -> android/arm64/lib/mylib.so
.intermediates/mylib/android_arm_armv7-a-neon_shared/mylib.so -> android/arm/lib/mylib.so
@@ -2728,7 +2175,7 @@
`)
CheckSnapshot(t, result, "mysdk", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
cc_prebuilt_library_shared {
diff --git a/sdk/compat_config_sdk_test.go b/sdk/compat_config_sdk_test.go
index 00073c2..d166add 100644
--- a/sdk/compat_config_sdk_test.go
+++ b/sdk/compat_config_sdk_test.go
@@ -37,23 +37,7 @@
`)
CheckSnapshot(t, result, "mysdk", "",
- checkVersionedAndroidBpContents(`
-// This is auto-generated. DO NOT EDIT.
-
-prebuilt_platform_compat_config {
- name: "mysdk_myconfig@current",
- sdk_member_name: "myconfig",
- visibility: ["//visibility:public"],
- metadata: "compat_configs/myconfig/myconfig_meta.xml",
-}
-
-sdk_snapshot {
- name: "mysdk@current",
- visibility: ["//visibility:public"],
- compat_configs: ["mysdk_myconfig@current"],
-}
-`),
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
prebuilt_platform_compat_config {
diff --git a/sdk/exports.go b/sdk/exports.go
index 9a0ba4e..7645d3f 100644
--- a/sdk/exports.go
+++ b/sdk/exports.go
@@ -31,7 +31,7 @@
return newSdkModule(true)
}
-// module_exports_snapshot is a versioned snapshot of prebuilt versions of all the exports
+// module_exports_snapshot is a snapshot of prebuilt versions of all the exports
// of a mainline module.
func ModuleExportsSnapshotsFactory() android.Module {
s := newSdkModule(true)
diff --git a/sdk/exports_test.go b/sdk/exports_test.go
index 17ddf17..2605fd1 100644
--- a/sdk/exports_test.go
+++ b/sdk/exports_test.go
@@ -43,7 +43,7 @@
})
CheckSnapshot(t, result, "myexports", "package",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_import {
@@ -54,22 +54,5 @@
jars: ["java/myjavalib.jar"],
}
`),
- checkVersionedAndroidBpContents(`
-// This is auto-generated. DO NOT EDIT.
-
-java_import {
- name: "myexports_myjavalib@current",
- sdk_member_name: "myjavalib",
- visibility: ["//visibility:public"],
- apex_available: ["//apex_available:platform"],
- jars: ["java/myjavalib.jar"],
-}
-
-module_exports_snapshot {
- name: "myexports@current",
- visibility: ["//visibility:public"],
- java_libs: ["myexports_myjavalib@current"],
-}
-`),
)
}
diff --git a/sdk/java_sdk_test.go b/sdk/java_sdk_test.go
index f33aa26..d25138f 100644
--- a/sdk/java_sdk_test.go
+++ b/sdk/java_sdk_test.go
@@ -96,7 +96,7 @@
`)
CheckSnapshot(t, result, "mysdk", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_import {
@@ -108,24 +108,6 @@
permitted_packages: ["pkg.myjavalib"],
}
`),
- checkVersionedAndroidBpContents(`
-// This is auto-generated. DO NOT EDIT.
-
-java_import {
- name: "mysdk_myjavalib@current",
- sdk_member_name: "myjavalib",
- visibility: ["//visibility:public"],
- apex_available: ["//apex_available:platform"],
- jars: ["java/myjavalib.jar"],
- permitted_packages: ["pkg.myjavalib"],
-}
-
-sdk_snapshot {
- name: "mysdk@current",
- visibility: ["//visibility:public"],
- java_header_libs: ["mysdk_myjavalib@current"],
-}
-`),
checkAllCopyRules(`
.intermediates/myjavalib/android_common/turbine-combined/myjavalib.jar -> java/myjavalib.jar
aidl/foo/bar/Test.aidl -> aidl/aidl/foo/bar/Test.aidl
@@ -160,7 +142,7 @@
`)
CheckSnapshot(t, result, "mysdk", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_import {
@@ -173,27 +155,6 @@
jars: ["java/myjavalib.jar"],
}
`),
- checkVersionedAndroidBpContents(`
-// This is auto-generated. DO NOT EDIT.
-
-java_import {
- name: "mysdk_myjavalib@current",
- sdk_member_name: "myjavalib",
- visibility: ["//visibility:public"],
- apex_available: ["//apex_available:platform"],
- device_supported: false,
- host_supported: true,
- jars: ["java/myjavalib.jar"],
-}
-
-sdk_snapshot {
- name: "mysdk@current",
- visibility: ["//visibility:public"],
- device_supported: false,
- host_supported: true,
- java_header_libs: ["mysdk_myjavalib@current"],
-}
-`),
checkAllCopyRules(`
.intermediates/myjavalib/linux_glibc_common/javac/myjavalib.jar -> java/myjavalib.jar
aidl/foo/bar/Test.aidl -> aidl/aidl/foo/bar/Test.aidl
@@ -220,7 +181,7 @@
`)
CheckSnapshot(t, result, "mysdk", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_import {
@@ -239,32 +200,6 @@
},
}
`),
- checkVersionedAndroidBpContents(`
-// This is auto-generated. DO NOT EDIT.
-
-java_import {
- name: "mysdk_myjavalib@current",
- sdk_member_name: "myjavalib",
- visibility: ["//visibility:public"],
- apex_available: ["//apex_available:platform"],
- host_supported: true,
- target: {
- android: {
- jars: ["java/android/myjavalib.jar"],
- },
- linux_glibc: {
- jars: ["java/linux_glibc/myjavalib.jar"],
- },
- },
-}
-
-sdk_snapshot {
- name: "mysdk@current",
- visibility: ["//visibility:public"],
- host_supported: true,
- java_header_libs: ["mysdk_myjavalib@current"],
-}
-`),
checkAllCopyRules(`
.intermediates/myjavalib/android_common/turbine-combined/myjavalib.jar -> java/android/myjavalib.jar
.intermediates/myjavalib/linux_glibc_common/javac/myjavalib.jar -> java/linux_glibc/myjavalib.jar
@@ -298,7 +233,7 @@
`)
CheckSnapshot(t, result, "myexports", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_import {
@@ -309,23 +244,6 @@
jars: ["java/myjavalib.jar"],
}
`),
- checkVersionedAndroidBpContents(`
-// This is auto-generated. DO NOT EDIT.
-
-java_import {
- name: "myexports_myjavalib@current",
- sdk_member_name: "myjavalib",
- visibility: ["//visibility:public"],
- apex_available: ["//apex_available:platform"],
- jars: ["java/myjavalib.jar"],
-}
-
-module_exports_snapshot {
- name: "myexports@current",
- visibility: ["//visibility:public"],
- java_libs: ["myexports_myjavalib@current"],
-}
-`),
checkAllCopyRules(`
.intermediates/myjavalib/android_common/withres/myjavalib.jar -> java/myjavalib.jar
aidl/foo/bar/Test.aidl -> aidl/aidl/foo/bar/Test.aidl
@@ -361,7 +279,7 @@
`)
CheckSnapshot(t, result, "myexports", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_import {
@@ -373,25 +291,6 @@
permitted_packages: ["pkg.myjavalib"],
}
`),
- checkVersionedAndroidBpContents(`
-// This is auto-generated. DO NOT EDIT.
-
-java_import {
- name: "myexports_myjavalib@current",
- sdk_member_name: "myjavalib",
- visibility: ["//visibility:public"],
- apex_available: ["//apex_available:platform"],
- jars: ["java_boot_libs/snapshot/jars/are/invalid/myjavalib.jar"],
- permitted_packages: ["pkg.myjavalib"],
-}
-
-module_exports_snapshot {
- name: "myexports@current",
- visibility: ["//visibility:public"],
- java_boot_libs: ["myexports_myjavalib@current"],
-}
-
-`),
checkAllCopyRules(`
.intermediates/myexports/common_os/empty -> java_boot_libs/snapshot/jars/are/invalid/myjavalib.jar
`),
@@ -427,7 +326,7 @@
`)
CheckSnapshot(t, result, "myexports", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_import {
@@ -439,24 +338,6 @@
permitted_packages: ["pkg.myjavalib"],
}
`),
- checkVersionedAndroidBpContents(`
-// This is auto-generated. DO NOT EDIT.
-
-java_import {
- name: "myexports_myjavalib@current",
- sdk_member_name: "myjavalib",
- visibility: ["//visibility:public"],
- apex_available: ["//apex_available:platform"],
- jars: ["java_systemserver_libs/snapshot/jars/are/invalid/myjavalib.jar"],
- permitted_packages: ["pkg.myjavalib"],
-}
-
-module_exports_snapshot {
- name: "myexports@current",
- visibility: ["//visibility:public"],
- java_systemserver_libs: ["myexports_myjavalib@current"],
-}
-`),
checkAllCopyRules(`
.intermediates/myexports/common_os/empty -> java_systemserver_libs/snapshot/jars/are/invalid/myjavalib.jar
`),
@@ -490,7 +371,7 @@
`)
CheckSnapshot(t, result, "myexports", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_import {
@@ -503,27 +384,6 @@
jars: ["java/myjavalib.jar"],
}
`),
- checkVersionedAndroidBpContents(`
-// This is auto-generated. DO NOT EDIT.
-
-java_import {
- name: "myexports_myjavalib@current",
- sdk_member_name: "myjavalib",
- visibility: ["//visibility:public"],
- apex_available: ["//apex_available:platform"],
- device_supported: false,
- host_supported: true,
- jars: ["java/myjavalib.jar"],
-}
-
-module_exports_snapshot {
- name: "myexports@current",
- visibility: ["//visibility:public"],
- device_supported: false,
- host_supported: true,
- java_libs: ["myexports_myjavalib@current"],
-}
-`),
checkAllCopyRules(`
.intermediates/myjavalib/linux_glibc_common/javac/myjavalib.jar -> java/myjavalib.jar
aidl/foo/bar/Test.aidl -> aidl/aidl/foo/bar/Test.aidl
@@ -549,7 +409,7 @@
`)
CheckSnapshot(t, result, "myexports", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_test_import {
@@ -561,24 +421,6 @@
test_config: "java/myjavatests-AndroidTest.xml",
}
`),
- checkVersionedAndroidBpContents(`
-// This is auto-generated. DO NOT EDIT.
-
-java_test_import {
- name: "myexports_myjavatests@current",
- sdk_member_name: "myjavatests",
- visibility: ["//visibility:public"],
- apex_available: ["//apex_available:platform"],
- jars: ["java/myjavatests.jar"],
- test_config: "java/myjavatests-AndroidTest.xml",
-}
-
-module_exports_snapshot {
- name: "myexports@current",
- visibility: ["//visibility:public"],
- java_tests: ["myexports_myjavatests@current"],
-}
-`),
checkAllCopyRules(`
.intermediates/myjavatests/android_common/javac/myjavatests.jar -> java/myjavatests.jar
.intermediates/myjavatests/android_common/myjavatests.config -> java/myjavatests-AndroidTest.xml
@@ -607,7 +449,7 @@
`)
CheckSnapshot(t, result, "myexports", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_test_import {
@@ -621,28 +463,6 @@
test_config: "java/myjavatests-AndroidTest.xml",
}
`),
- checkVersionedAndroidBpContents(`
-// This is auto-generated. DO NOT EDIT.
-
-java_test_import {
- name: "myexports_myjavatests@current",
- sdk_member_name: "myjavatests",
- visibility: ["//visibility:public"],
- apex_available: ["//apex_available:platform"],
- device_supported: false,
- host_supported: true,
- jars: ["java/myjavatests.jar"],
- test_config: "java/myjavatests-AndroidTest.xml",
-}
-
-module_exports_snapshot {
- name: "myexports@current",
- visibility: ["//visibility:public"],
- device_supported: false,
- host_supported: true,
- java_tests: ["myexports_myjavatests@current"],
-}
-`),
checkAllCopyRules(`
.intermediates/myjavatests/linux_glibc_common/javac/myjavatests.jar -> java/myjavatests.jar
.intermediates/myjavatests/linux_glibc_common/myjavatests.config -> java/myjavatests-AndroidTest.xml
@@ -703,7 +523,7 @@
`)
CheckSnapshot(t, result, "mysdk", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_import {
@@ -748,59 +568,6 @@
],
}
`),
- checkVersionedAndroidBpContents(`
-// This is auto-generated. DO NOT EDIT.
-
-java_import {
- name: "mysdk_exported-system-module@current",
- sdk_member_name: "exported-system-module",
- visibility: ["//visibility:public"],
- apex_available: ["//apex_available:platform"],
- jars: ["java/exported-system-module.jar"],
-}
-
-java_import {
- name: "mysdk_system-module@current",
- sdk_member_name: "system-module",
- visibility: ["//visibility:private"],
- apex_available: ["//apex_available:platform"],
- jars: ["java/system-module.jar"],
-}
-
-java_sdk_library_import {
- name: "mysdk_myjavalib@current",
- sdk_member_name: "myjavalib",
- visibility: ["//visibility:public"],
- apex_available: ["//apex_available:anyapex"],
- shared_library: false,
- public: {
- jars: ["sdk_library/public/myjavalib-stubs.jar"],
- stub_srcs: ["sdk_library/public/myjavalib_stub_sources"],
- current_api: "sdk_library/public/myjavalib.txt",
- removed_api: "sdk_library/public/myjavalib-removed.txt",
- sdk_version: "current",
- },
-}
-
-java_system_modules_import {
- name: "mysdk_my-system-modules@current",
- sdk_member_name: "my-system-modules",
- visibility: ["//visibility:public"],
- libs: [
- "mysdk_system-module@current",
- "mysdk_exported-system-module@current",
- "mysdk_myjavalib.stubs@current",
- ],
-}
-
-sdk_snapshot {
- name: "mysdk@current",
- visibility: ["//visibility:public"],
- java_header_libs: ["mysdk_exported-system-module@current"],
- java_sdk_libs: ["mysdk_myjavalib@current"],
- java_system_modules: ["mysdk_my-system-modules@current"],
-}
-`),
checkAllCopyRules(`
.intermediates/exported-system-module/android_common/turbine-combined/exported-system-module.jar -> java/exported-system-module.jar
.intermediates/system-module/android_common/turbine-combined/system-module.jar -> java/system-module.jar
@@ -885,7 +652,7 @@
`)
CheckSnapshot(t, result, "mysdk", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_import {
@@ -907,36 +674,6 @@
libs: ["mysdk_system-module"],
}
`),
- checkVersionedAndroidBpContents(`
-// This is auto-generated. DO NOT EDIT.
-
-java_import {
- name: "mysdk_system-module@current",
- sdk_member_name: "system-module",
- visibility: ["//visibility:private"],
- apex_available: ["//apex_available:platform"],
- device_supported: false,
- host_supported: true,
- jars: ["java/system-module.jar"],
-}
-
-java_system_modules_import {
- name: "mysdk_my-system-modules@current",
- sdk_member_name: "my-system-modules",
- visibility: ["//visibility:public"],
- device_supported: false,
- host_supported: true,
- libs: ["mysdk_system-module@current"],
-}
-
-sdk_snapshot {
- name: "mysdk@current",
- visibility: ["//visibility:public"],
- device_supported: false,
- host_supported: true,
- java_system_modules: ["mysdk_my-system-modules@current"],
-}
-`),
checkAllCopyRules(".intermediates/system-module/linux_glibc_common/javac/system-module.jar -> java/system-module.jar"),
)
}
@@ -979,7 +716,7 @@
`)
CheckSnapshot(t, result, "myexports", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_import {
@@ -1016,58 +753,6 @@
},
}
`),
- checkVersionedAndroidBpContents(`
-// This is auto-generated. DO NOT EDIT.
-
-java_import {
- name: "myexports_hostjavalib@current",
- sdk_member_name: "hostjavalib",
- visibility: ["//visibility:public"],
- apex_available: ["//apex_available:platform"],
- device_supported: false,
- host_supported: true,
- jars: ["java/hostjavalib.jar"],
-}
-
-java_import {
- name: "myexports_androidjavalib@current",
- sdk_member_name: "androidjavalib",
- visibility: ["//visibility:public"],
- apex_available: ["//apex_available:platform"],
- jars: ["java/androidjavalib.jar"],
-}
-
-java_import {
- name: "myexports_myjavalib@current",
- sdk_member_name: "myjavalib",
- visibility: ["//visibility:public"],
- apex_available: ["//apex_available:platform"],
- host_supported: true,
- target: {
- android: {
- jars: ["java/android/myjavalib.jar"],
- },
- linux_glibc: {
- jars: ["java/linux_glibc/myjavalib.jar"],
- },
- },
-}
-
-module_exports_snapshot {
- name: "myexports@current",
- visibility: ["//visibility:public"],
- host_supported: true,
- java_libs: ["myexports_myjavalib@current"],
- target: {
- android: {
- java_header_libs: ["myexports_androidjavalib@current"],
- },
- linux_glibc: {
- java_header_libs: ["myexports_hostjavalib@current"],
- },
- },
-}
-`),
checkAllCopyRules(`
.intermediates/hostjavalib/linux_glibc_common/javac/hostjavalib.jar -> java/hostjavalib.jar
.intermediates/androidjavalib/android_common/turbine-combined/androidjavalib.jar -> java/androidjavalib.jar
@@ -1097,7 +782,7 @@
`)
CheckSnapshot(t, result, "mysdk", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_sdk_library_import {
@@ -1130,45 +815,6 @@
},
}
`),
- checkVersionedAndroidBpContents(`
-// This is auto-generated. DO NOT EDIT.
-
-java_sdk_library_import {
- name: "mysdk_myjavalib@current",
- sdk_member_name: "myjavalib",
- visibility: ["//visibility:public"],
- apex_available: ["//apex_available:anyapex"],
- shared_library: false,
- permitted_packages: ["pkg.myjavalib"],
- public: {
- jars: ["sdk_library/public/myjavalib-stubs.jar"],
- stub_srcs: ["sdk_library/public/myjavalib_stub_sources"],
- current_api: "sdk_library/public/myjavalib.txt",
- removed_api: "sdk_library/public/myjavalib-removed.txt",
- sdk_version: "current",
- },
- system: {
- jars: ["sdk_library/system/myjavalib-stubs.jar"],
- stub_srcs: ["sdk_library/system/myjavalib_stub_sources"],
- current_api: "sdk_library/system/myjavalib.txt",
- removed_api: "sdk_library/system/myjavalib-removed.txt",
- sdk_version: "system_current",
- },
- test: {
- jars: ["sdk_library/test/myjavalib-stubs.jar"],
- stub_srcs: ["sdk_library/test/myjavalib_stub_sources"],
- current_api: "sdk_library/test/myjavalib.txt",
- removed_api: "sdk_library/test/myjavalib-removed.txt",
- sdk_version: "test_current",
- },
-}
-
-sdk_snapshot {
- name: "mysdk@current",
- visibility: ["//visibility:public"],
- java_sdk_libs: ["mysdk_myjavalib@current"],
-}
-`),
checkAllCopyRules(`
.intermediates/myjavalib.stubs/android_common/javac/myjavalib.stubs.jar -> sdk_library/public/myjavalib-stubs.jar
.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
@@ -1185,12 +831,6 @@
".intermediates/mysdk/common_os/tmp/sdk_library/system/myjavalib_stub_sources.zip",
".intermediates/mysdk/common_os/tmp/sdk_library/test/myjavalib_stub_sources.zip",
),
- snapshotTestChecker(checkSnapshotWithoutSource, func(t *testing.T, result *android.TestResult) {
- // Make sure that the name of the child modules created by a versioned java_sdk_library_import
- // module is correct, i.e. the suffix is added before the version and not after.
- result.Module("mysdk_myjavalib.stubs@current", "android_common")
- result.Module("mysdk_myjavalib.stubs.source@current", "android_common")
- }),
)
}
@@ -1218,7 +858,7 @@
`)
CheckSnapshot(t, result, "mysdk", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_sdk_library_import {
@@ -1265,7 +905,7 @@
`)
CheckSnapshot(t, result, "mysdk", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_sdk_library_import {
@@ -1319,7 +959,7 @@
`)
CheckSnapshot(t, result, "mysdk", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_sdk_library_import {
@@ -1369,7 +1009,7 @@
`)
CheckSnapshot(t, result, "mysdk", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_sdk_library_import {
@@ -1436,7 +1076,7 @@
`)
CheckSnapshot(t, result, "mysdk", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_sdk_library_import {
@@ -1454,30 +1094,6 @@
},
}
`),
- checkVersionedAndroidBpContents(`
-// This is auto-generated. DO NOT EDIT.
-
-java_sdk_library_import {
- name: "mysdk_myjavalib@current",
- sdk_member_name: "myjavalib",
- visibility: ["//visibility:public"],
- apex_available: ["//apex_available:platform"],
- shared_library: true,
- public: {
- jars: ["sdk_library/public/myjavalib-stubs.jar"],
- stub_srcs: ["sdk_library/public/myjavalib_stub_sources"],
- current_api: "sdk_library/public/myjavalib.txt",
- removed_api: "sdk_library/public/myjavalib-removed.txt",
- sdk_version: "none",
- },
-}
-
-sdk_snapshot {
- name: "mysdk@current",
- visibility: ["//visibility:public"],
- java_sdk_libs: ["mysdk_myjavalib@current"],
-}
-`),
checkAllCopyRules(`
.intermediates/myjavalib.stubs/android_common/javac/myjavalib.stubs.jar -> sdk_library/public/myjavalib-stubs.jar
.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
@@ -1508,7 +1124,7 @@
`)
CheckSnapshot(t, result, "mysdk", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_sdk_library_import {
@@ -1526,30 +1142,6 @@
},
}
`),
- checkVersionedAndroidBpContents(`
-// This is auto-generated. DO NOT EDIT.
-
-java_sdk_library_import {
- name: "mysdk_myjavalib@current",
- sdk_member_name: "myjavalib",
- visibility: ["//visibility:public"],
- apex_available: ["//apex_available:platform"],
- shared_library: true,
- public: {
- jars: ["sdk_library/public/myjavalib-stubs.jar"],
- stub_srcs: ["sdk_library/public/myjavalib_stub_sources"],
- current_api: "sdk_library/public/myjavalib.txt",
- removed_api: "sdk_library/public/myjavalib-removed.txt",
- sdk_version: "module_current",
- },
-}
-
-sdk_snapshot {
- name: "mysdk@current",
- visibility: ["//visibility:public"],
- java_sdk_libs: ["mysdk_myjavalib@current"],
-}
-`),
checkAllCopyRules(`
.intermediates/myjavalib.stubs/android_common/javac/myjavalib.stubs.jar -> sdk_library/public/myjavalib-stubs.jar
.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
@@ -1583,7 +1175,7 @@
`)
CheckSnapshot(t, result, "mysdk", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_sdk_library_import {
@@ -1608,37 +1200,6 @@
},
}
`),
- checkVersionedAndroidBpContents(`
-// This is auto-generated. DO NOT EDIT.
-
-java_sdk_library_import {
- name: "mysdk_myjavalib@current",
- sdk_member_name: "myjavalib",
- visibility: ["//visibility:public"],
- apex_available: ["//apex_available:anyapex"],
- shared_library: true,
- public: {
- jars: ["sdk_library/public/myjavalib-stubs.jar"],
- stub_srcs: ["sdk_library/public/myjavalib_stub_sources"],
- current_api: "sdk_library/public/myjavalib.txt",
- removed_api: "sdk_library/public/myjavalib-removed.txt",
- sdk_version: "current",
- },
- system: {
- jars: ["sdk_library/system/myjavalib-stubs.jar"],
- stub_srcs: ["sdk_library/system/myjavalib_stub_sources"],
- current_api: "sdk_library/system/myjavalib.txt",
- removed_api: "sdk_library/system/myjavalib-removed.txt",
- sdk_version: "system_current",
- },
-}
-
-sdk_snapshot {
- name: "mysdk@current",
- visibility: ["//visibility:public"],
- java_sdk_libs: ["mysdk_myjavalib@current"],
-}
-`),
checkAllCopyRules(`
.intermediates/myjavalib.stubs/android_common/javac/myjavalib.stubs.jar -> sdk_library/public/myjavalib-stubs.jar
.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
@@ -1679,7 +1240,7 @@
`)
CheckSnapshot(t, result, "mysdk", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_sdk_library_import {
@@ -1711,44 +1272,6 @@
},
}
`),
- checkVersionedAndroidBpContents(`
-// This is auto-generated. DO NOT EDIT.
-
-java_sdk_library_import {
- name: "mysdk_myjavalib@current",
- sdk_member_name: "myjavalib",
- visibility: ["//visibility:public"],
- apex_available: ["//apex_available:anyapex"],
- shared_library: true,
- public: {
- jars: ["sdk_library/public/myjavalib-stubs.jar"],
- stub_srcs: ["sdk_library/public/myjavalib_stub_sources"],
- current_api: "sdk_library/public/myjavalib.txt",
- removed_api: "sdk_library/public/myjavalib-removed.txt",
- sdk_version: "current",
- },
- system: {
- jars: ["sdk_library/system/myjavalib-stubs.jar"],
- stub_srcs: ["sdk_library/system/myjavalib_stub_sources"],
- current_api: "sdk_library/system/myjavalib.txt",
- removed_api: "sdk_library/system/myjavalib-removed.txt",
- sdk_version: "system_current",
- },
- module_lib: {
- jars: ["sdk_library/module-lib/myjavalib-stubs.jar"],
- stub_srcs: ["sdk_library/module-lib/myjavalib_stub_sources"],
- current_api: "sdk_library/module-lib/myjavalib.txt",
- removed_api: "sdk_library/module-lib/myjavalib-removed.txt",
- sdk_version: "module_current",
- },
-}
-
-sdk_snapshot {
- name: "mysdk@current",
- visibility: ["//visibility:public"],
- java_sdk_libs: ["mysdk_myjavalib@current"],
-}
-`),
checkAllCopyRules(`
.intermediates/myjavalib.stubs/android_common/javac/myjavalib.stubs.jar -> sdk_library/public/myjavalib-stubs.jar
.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
@@ -1790,7 +1313,7 @@
`)
CheckSnapshot(t, result, "mysdk", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_sdk_library_import {
@@ -1815,37 +1338,6 @@
},
}
`),
- checkVersionedAndroidBpContents(`
-// This is auto-generated. DO NOT EDIT.
-
-java_sdk_library_import {
- name: "mysdk_myjavalib@current",
- sdk_member_name: "myjavalib",
- visibility: ["//visibility:public"],
- apex_available: ["//apex_available:anyapex"],
- shared_library: true,
- public: {
- jars: ["sdk_library/public/myjavalib-stubs.jar"],
- stub_srcs: ["sdk_library/public/myjavalib_stub_sources"],
- current_api: "sdk_library/public/myjavalib.txt",
- removed_api: "sdk_library/public/myjavalib-removed.txt",
- sdk_version: "current",
- },
- system_server: {
- jars: ["sdk_library/system-server/myjavalib-stubs.jar"],
- stub_srcs: ["sdk_library/system-server/myjavalib_stub_sources"],
- current_api: "sdk_library/system-server/myjavalib.txt",
- removed_api: "sdk_library/system-server/myjavalib-removed.txt",
- sdk_version: "system_server_current",
- },
-}
-
-sdk_snapshot {
- name: "mysdk@current",
- visibility: ["//visibility:public"],
- java_sdk_libs: ["mysdk_myjavalib@current"],
-}
-`),
checkAllCopyRules(`
.intermediates/myjavalib.stubs/android_common/javac/myjavalib.stubs.jar -> sdk_library/public/myjavalib-stubs.jar
.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
@@ -1881,7 +1373,7 @@
`)
CheckSnapshot(t, result, "mysdk", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_sdk_library_import {
@@ -1900,31 +1392,6 @@
},
}
`),
- checkVersionedAndroidBpContents(`
-// This is auto-generated. DO NOT EDIT.
-
-java_sdk_library_import {
- name: "mysdk_myjavalib@current",
- sdk_member_name: "myjavalib",
- visibility: ["//visibility:public"],
- apex_available: ["//apex_available:anyapex"],
- naming_scheme: "default",
- shared_library: true,
- public: {
- jars: ["sdk_library/public/myjavalib-stubs.jar"],
- stub_srcs: ["sdk_library/public/myjavalib_stub_sources"],
- current_api: "sdk_library/public/myjavalib.txt",
- removed_api: "sdk_library/public/myjavalib-removed.txt",
- sdk_version: "current",
- },
-}
-
-sdk_snapshot {
- name: "mysdk@current",
- visibility: ["//visibility:public"],
- java_sdk_libs: ["mysdk_myjavalib@current"],
-}
-`),
checkAllCopyRules(`
.intermediates/myjavalib.stubs/android_common/javac/myjavalib.stubs.jar -> sdk_library/public/myjavalib-stubs.jar
.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
@@ -1963,7 +1430,7 @@
`)
CheckSnapshot(t, result, "mysdk", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_sdk_library_import {
@@ -1982,31 +1449,6 @@
},
}
`),
- checkVersionedAndroidBpContents(`
-// This is auto-generated. DO NOT EDIT.
-
-java_sdk_library_import {
- name: "mysdk_myjavalib@current",
- sdk_member_name: "myjavalib",
- visibility: ["//visibility:public"],
- apex_available: ["//apex_available:platform"],
- shared_library: true,
- doctag_files: ["doctags/docs/known_doctags"],
- public: {
- jars: ["sdk_library/public/myjavalib-stubs.jar"],
- stub_srcs: ["sdk_library/public/myjavalib_stub_sources"],
- current_api: "sdk_library/public/myjavalib.txt",
- removed_api: "sdk_library/public/myjavalib-removed.txt",
- sdk_version: "current",
- },
-}
-
-sdk_snapshot {
- name: "mysdk@current",
- visibility: ["//visibility:public"],
- java_sdk_libs: ["mysdk_myjavalib@current"],
-}
-`),
checkAllCopyRules(`
.intermediates/myjavalib.stubs/android_common/javac/myjavalib.stubs.jar -> sdk_library/public/myjavalib-stubs.jar
.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
diff --git a/sdk/license_sdk_test.go b/sdk/license_sdk_test.go
index 1ef6fe6..829edf1 100644
--- a/sdk/license_sdk_test.go
+++ b/sdk/license_sdk_test.go
@@ -60,7 +60,7 @@
`)
CheckSnapshot(t, result, "mysdk", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
package {
@@ -91,44 +91,6 @@
],
}
`),
- checkVersionedAndroidBpContents(`
-// This is auto-generated. DO NOT EDIT.
-
-package {
- // A default list here prevents the license LSC from adding its own list which would
- // be unnecessary as every module in the sdk already has its own licenses property.
- default_applicable_licenses: ["Android-Apache-2.0"],
-}
-
-java_import {
- name: "mysdk_myjavalib@current",
- sdk_member_name: "myjavalib",
- visibility: ["//visibility:public"],
- apex_available: ["//apex_available:platform"],
- licenses: ["mysdk_mylicense@current"],
- jars: ["java/myjavalib.jar"],
-}
-
-license {
- name: "mysdk_mylicense@current",
- sdk_member_name: "mylicense",
- visibility: ["//visibility:private"],
- license_kinds: [
- "SPDX-license-identifier-Apache-2.0",
- "legacy_unencumbered",
- ],
- license_text: [
- "licenses/NOTICE1",
- "licenses/NOTICE2",
- ],
-}
-
-sdk_snapshot {
- name: "mysdk@current",
- visibility: ["//visibility:public"],
- java_header_libs: ["mysdk_myjavalib@current"],
-}
- `),
checkAllCopyRules(`
.intermediates/myjavalib/android_common/turbine-combined/myjavalib.jar -> java/myjavalib.jar
NOTICE1 -> licenses/NOTICE1
diff --git a/sdk/member_trait_test.go b/sdk/member_trait_test.go
index a3db189..99caf13 100644
--- a/sdk/member_trait_test.go
+++ b/sdk/member_trait_test.go
@@ -134,7 +134,7 @@
).RunTest(t)
CheckSnapshot(t, result, "mysdk", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_import {
@@ -145,23 +145,6 @@
jars: ["javalibs/myjavalib.jar"],
}
`),
- checkVersionedAndroidBpContents(`
-// This is auto-generated. DO NOT EDIT.
-
-java_import {
- name: "mysdk_myjavalib@current",
- sdk_member_name: "myjavalib",
- visibility: ["//visibility:public"],
- apex_available: ["//apex_available:platform"],
- jars: ["javalibs/myjavalib.jar"],
-}
-
-sdk_snapshot {
- name: "mysdk@current",
- visibility: ["//visibility:public"],
- fake_members: ["mysdk_myjavalib@current"],
-}
-`),
)
}
@@ -216,7 +199,7 @@
).RunTest(t)
CheckSnapshot(t, result, "mysdk", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_test_import {
diff --git a/sdk/sdk.go b/sdk/sdk.go
index b37eaad..aeeedb4 100644
--- a/sdk/sdk.go
+++ b/sdk/sdk.go
@@ -146,7 +146,7 @@
return s
}
-// sdk_snapshot is a versioned snapshot of an SDK. This is an auto-generated module.
+// sdk_snapshot is a snapshot of an SDK. This is an auto-generated module.
func SnapshotModuleFactory() android.Module {
s := newSdkModule(false)
s.properties.Snapshot = true
@@ -281,7 +281,6 @@
func RegisterPreDepsMutators(ctx android.RegisterMutatorsContext) {
ctx.BottomUp("SdkMember", memberMutator).Parallel()
ctx.TopDown("SdkMember_deps", memberDepsMutator).Parallel()
- ctx.BottomUp("SdkMemberInterVersion", memberInterVersionMutator).Parallel()
}
type dependencyTag struct {
@@ -293,38 +292,6 @@
var _ android.ExcludeFromApexContentsTag = dependencyTag{}
-// For dependencies from an in-development version of an SDK member to frozen versions of the same member
-// e.g. libfoo -> libfoo.mysdk.11 and libfoo.mysdk.12
-//
-// The dependency represented by this tag requires that for every APEX variant created for the
-// `from` module that an equivalent APEX variant is created for the 'to' module. This is because an
-// APEX that requires a specific version of an sdk (via the `uses_sdks` property will replace
-// dependencies on the unversioned sdk member with a dependency on the appropriate versioned sdk
-// member. In order for that to work the versioned sdk member needs to have a variant for that APEX.
-// As it is not known at the time that the APEX variants are created which specific APEX variants of
-// a versioned sdk members will be required it is necessary for the versioned sdk members to have
-// variants for any APEX that it could be used within.
-//
-// If the APEX selects a versioned sdk member then it will not have a dependency on the `from`
-// module at all so any dependencies of that module will not affect the APEX. However, if the APEX
-// selects the unversioned sdk member then it must exclude all the versioned sdk members. In no
-// situation would this dependency cause the `to` module to be added to the APEX hence why this tag
-// also excludes the `to` module from being added to the APEX contents.
-type sdkMemberVersionedDepTag struct {
- dependencyTag
- member string
- version string
-}
-
-func (t sdkMemberVersionedDepTag) AlwaysRequireApexVariant() bool {
- return true
-}
-
-// Mark this tag so dependencies that use it are excluded from visibility enforcement.
-func (t sdkMemberVersionedDepTag) ExcludeFromVisibilityEnforcement() {}
-
-var _ android.AlwaysRequireApexVariantTag = sdkMemberVersionedDepTag{}
-
// Step 1: create dependencies from an SDK module to its members.
func memberMutator(mctx android.BottomUpMutatorContext) {
if s, ok := mctx.Module().(*sdk); ok {
@@ -383,22 +350,6 @@
}
}
-// Step 3: create dependencies from the unversioned SDK member to snapshot versions
-// of the same member. By having these dependencies, they are mutated for multiple Mainline modules
-// (apex and apk), each of which might want different sdks to be built with. For example, if both
-// apex A and B are referencing libfoo which is a member of sdk 'mysdk', the two APEXes can be
-// built with libfoo.mysdk.11 and libfoo.mysdk.12, respectively depending on which sdk they are
-// using.
-func memberInterVersionMutator(mctx android.BottomUpMutatorContext) {
- if m, ok := mctx.Module().(android.SdkAware); ok && m.IsInAnySdk() && m.IsVersioned() {
- if !m.ContainingSdk().Unversioned() {
- memberName := m.MemberName()
- tag := sdkMemberVersionedDepTag{member: memberName, version: m.ContainingSdk().Version}
- mctx.AddReverseDependency(mctx.Module(), tag, memberName)
- }
- }
-}
-
// An interface that encapsulates all the functionality needed to manage the sdk dependencies.
//
// It is a mixture of apex and sdk module functionality.
diff --git a/sdk/sdk_test.go b/sdk/sdk_test.go
index ccbeb8d..e230d5c 100644
--- a/sdk/sdk_test.go
+++ b/sdk/sdk_test.go
@@ -119,18 +119,6 @@
// This is auto-generated. DO NOT EDIT.
java_import {
- name: "mysdk_myjavalib@current",
- sdk_member_name: "myjavalib",
- visibility: [
- "//other/foo",
- "//package",
- "//prebuilts/mysdk",
- ],
- apex_available: ["//apex_available:platform"],
- jars: ["java/myjavalib.jar"],
-}
-
-java_import {
name: "myjavalib",
prefer: false,
visibility: [
@@ -143,14 +131,6 @@
}
java_import {
- name: "mysdk_mypublicjavalib@current",
- sdk_member_name: "mypublicjavalib",
- visibility: ["//visibility:public"],
- apex_available: ["//apex_available:platform"],
- jars: ["java/mypublicjavalib.jar"],
-}
-
-java_import {
name: "mypublicjavalib",
prefer: false,
visibility: ["//visibility:public"],
@@ -159,18 +139,6 @@
}
java_import {
- name: "mysdk_mydefaultedjavalib@current",
- sdk_member_name: "mydefaultedjavalib",
- visibility: [
- "//other/bar",
- "//package",
- "//prebuilts/mysdk",
- ],
- apex_available: ["//apex_available:platform"],
- jars: ["java/mydefaultedjavalib.jar"],
-}
-
-java_import {
name: "mydefaultedjavalib",
prefer: false,
visibility: [
@@ -183,17 +151,6 @@
}
java_import {
- name: "mysdk_myprivatejavalib@current",
- sdk_member_name: "myprivatejavalib",
- visibility: [
- "//package",
- "//prebuilts/mysdk",
- ],
- apex_available: ["//apex_available:platform"],
- jars: ["java/myprivatejavalib.jar"],
-}
-
-java_import {
name: "myprivatejavalib",
prefer: false,
visibility: [
@@ -203,20 +160,6 @@
apex_available: ["//apex_available:platform"],
jars: ["java/myprivatejavalib.jar"],
}
-
-sdk_snapshot {
- name: "mysdk@current",
- visibility: [
- "//other/foo",
- "//package:__subpackages__",
- ],
- java_header_libs: [
- "mysdk_myjavalib@current",
- "mysdk_mypublicjavalib@current",
- "mysdk_mydefaultedjavalib@current",
- "mysdk_myprivatejavalib@current",
- ],
-}
`))
}
@@ -450,26 +393,12 @@
// This is auto-generated. DO NOT EDIT.
java_import {
- name: "mysdk_myjavalib@current",
- sdk_member_name: "myjavalib",
- visibility: ["//visibility:public"],
- apex_available: ["//apex_available:platform"],
- jars: ["java/myjavalib.jar"],
-}
-
-java_import {
name: "myjavalib",
prefer: false,
visibility: ["//visibility:public"],
apex_available: ["//apex_available:platform"],
jars: ["java/myjavalib.jar"],
}
-
-sdk_snapshot {
- name: "mysdk@current",
- visibility: ["//visibility:public"],
- java_header_libs: ["mysdk_myjavalib@current"],
-}
`),
)
})
@@ -489,26 +418,12 @@
// This is auto-generated. DO NOT EDIT.
java_import {
- name: "mysdk_myjavalib@current",
- sdk_member_name: "myjavalib",
- visibility: ["//visibility:public"],
- apex_available: ["//apex_available:platform"],
- jars: ["java/myjavalib.jar"],
-}
-
-java_import {
name: "myjavalib",
prefer: true,
visibility: ["//visibility:public"],
apex_available: ["//apex_available:platform"],
jars: ["java/myjavalib.jar"],
}
-
-sdk_snapshot {
- name: "mysdk@current",
- visibility: ["//visibility:public"],
- java_header_libs: ["mysdk_myjavalib@current"],
-}
`),
)
})
@@ -528,14 +443,6 @@
// This is auto-generated. DO NOT EDIT.
java_import {
- name: "mysdk_myjavalib@current",
- sdk_member_name: "myjavalib",
- visibility: ["//visibility:public"],
- apex_available: ["//apex_available:platform"],
- jars: ["java/myjavalib.jar"],
-}
-
-java_import {
name: "myjavalib",
prefer: false,
use_source_config_var: {
@@ -546,113 +453,10 @@
apex_available: ["//apex_available:platform"],
jars: ["java/myjavalib.jar"],
}
-
-sdk_snapshot {
- name: "mysdk@current",
- visibility: ["//visibility:public"],
- java_header_libs: ["mysdk_myjavalib@current"],
-}
`),
)
})
- t.Run("SOONG_SDK_SNAPSHOT_VERSION=unversioned", func(t *testing.T) {
- result := android.GroupFixturePreparers(
- preparer,
- android.FixtureMergeEnv(map[string]string{
- "SOONG_SDK_SNAPSHOT_VERSION": "unversioned",
- }),
- ).RunTest(t)
-
- checkZipFile(t, result, "out/soong/.intermediates/mysdk/common_os/mysdk.zip")
-
- CheckSnapshot(t, result, "mysdk", "",
- checkAndroidBpContents(`
-// This is auto-generated. DO NOT EDIT.
-
-java_import {
- name: "myjavalib",
- prefer: false,
- visibility: ["//visibility:public"],
- apex_available: ["//apex_available:platform"],
- jars: ["java/myjavalib.jar"],
-}
- `),
- )
- })
-
- t.Run("SOONG_SDK_SNAPSHOT_VERSION=current", func(t *testing.T) {
- result := android.GroupFixturePreparers(
- preparer,
- android.FixtureMergeEnv(map[string]string{
- "SOONG_SDK_SNAPSHOT_VERSION": "current",
- }),
- ).RunTest(t)
-
- checkZipFile(t, result, "out/soong/.intermediates/mysdk/common_os/mysdk-current.zip")
-
- CheckSnapshot(t, result, "mysdk", "",
- checkAndroidBpContents(`
-// This is auto-generated. DO NOT EDIT.
-
-java_import {
- name: "mysdk_myjavalib@current",
- sdk_member_name: "myjavalib",
- visibility: ["//visibility:public"],
- apex_available: ["//apex_available:platform"],
- jars: ["java/myjavalib.jar"],
-}
-
-java_import {
- name: "myjavalib",
- prefer: false,
- visibility: ["//visibility:public"],
- apex_available: ["//apex_available:platform"],
- jars: ["java/myjavalib.jar"],
-}
-
-sdk_snapshot {
- name: "mysdk@current",
- visibility: ["//visibility:public"],
- java_header_libs: ["mysdk_myjavalib@current"],
-}
- `),
- )
- })
-
- t.Run("SOONG_SDK_SNAPSHOT_VERSION=2", func(t *testing.T) {
- result := android.GroupFixturePreparers(
- preparer,
- android.FixtureMergeEnv(map[string]string{
- "SOONG_SDK_SNAPSHOT_VERSION": "2",
- }),
- ).RunTest(t)
-
- checkZipFile(t, result, "out/soong/.intermediates/mysdk/common_os/mysdk-2.zip")
-
- CheckSnapshot(t, result, "mysdk", "",
- checkAndroidBpContents(`
-// This is auto-generated. DO NOT EDIT.
-
-java_import {
- name: "mysdk_myjavalib@2",
- sdk_member_name: "myjavalib",
- visibility: ["//visibility:public"],
- apex_available: ["//apex_available:platform"],
- jars: ["java/myjavalib.jar"],
-}
-
-sdk_snapshot {
- name: "mysdk@2",
- visibility: ["//visibility:public"],
- java_header_libs: ["mysdk_myjavalib@2"],
-}
- `),
- // A versioned snapshot cannot be used on its own so add the source back in.
- snapshotTestPreparer(checkSnapshotWithoutSource, android.FixtureWithRootAndroidBp(bp)),
- )
- })
-
t.Run("SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE=S", func(t *testing.T) {
result := android.GroupFixturePreparers(
prepareForSdkTestWithJava,
@@ -685,7 +489,7 @@
).RunTest(t)
CheckSnapshot(t, result, "mysdk", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
prebuilt_bootclasspath_fragment {
diff --git a/sdk/systemserverclasspath_fragment_sdk_test.go b/sdk/systemserverclasspath_fragment_sdk_test.go
index 16e3e7f..01692a3 100644
--- a/sdk/systemserverclasspath_fragment_sdk_test.go
+++ b/sdk/systemserverclasspath_fragment_sdk_test.go
@@ -83,7 +83,7 @@
).RunTest(t)
CheckSnapshot(t, result, "mysdk", "",
- checkUnversionedAndroidBpContents(`
+ checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_sdk_library_import {
@@ -121,51 +121,5 @@
],
}
`),
- checkVersionedAndroidBpContents(`
-// This is auto-generated. DO NOT EDIT.
-
-java_sdk_library_import {
- name: "mysdk_mysdklibrary@current",
- sdk_member_name: "mysdklibrary",
- visibility: ["//visibility:public"],
- apex_available: ["myapex"],
- shared_library: false,
- public: {
- jars: ["sdk_library/public/mysdklibrary-stubs.jar"],
- stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"],
- current_api: "sdk_library/public/mysdklibrary.txt",
- removed_api: "sdk_library/public/mysdklibrary-removed.txt",
- sdk_version: "current",
- },
-}
-
-java_import {
- name: "mysdk_mylib@current",
- sdk_member_name: "mylib",
- visibility: ["//visibility:public"],
- apex_available: ["myapex"],
- jars: ["java_systemserver_libs/snapshot/jars/are/invalid/mylib.jar"],
- permitted_packages: ["mylib"],
-}
-
-prebuilt_systemserverclasspath_fragment {
- name: "mysdk_mysystemserverclasspathfragment@current",
- sdk_member_name: "mysystemserverclasspathfragment",
- visibility: ["//visibility:public"],
- apex_available: ["myapex"],
- contents: [
- "mysdk_mylib@current",
- "mysdk_mysdklibrary@current",
- ],
-}
-
-sdk_snapshot {
- name: "mysdk@current",
- visibility: ["//visibility:public"],
- java_sdk_libs: ["mysdk_mysdklibrary@current"],
- java_systemserver_libs: ["mysdk_mylib@current"],
- systemserverclasspath_fragments: ["mysdk_mysystemserverclasspathfragment@current"],
-}
-`),
)
}
diff --git a/sdk/testing.go b/sdk/testing.go
index 72344de..bed11b2 100644
--- a/sdk/testing.go
+++ b/sdk/testing.go
@@ -122,29 +122,18 @@
}
}
-func pathsToStrings(paths android.Paths) []string {
- var ret []string
- for _, p := range paths {
- ret = append(ret, p.String())
- }
- return ret
-}
-
// Analyse the sdk build rules to extract information about what it is doing.
//
// e.g. find the src/dest pairs from each cp command, the various zip files
// generated, etc.
func getSdkSnapshotBuildInfo(t *testing.T, result *android.TestResult, sdk *sdk) *snapshotBuildInfo {
info := &snapshotBuildInfo{
- t: t,
- r: result,
- version: sdk.builderForTests.version,
- androidBpContents: sdk.GetAndroidBpContentsForTests(),
- androidUnversionedBpContents: sdk.GetUnversionedAndroidBpContentsForTests(),
- androidVersionedBpContents: sdk.GetVersionedAndroidBpContentsForTests(),
- infoContents: sdk.GetInfoContentsForTests(),
- snapshotTestCustomizations: map[snapshotTest]*snapshotTestCustomization{},
- targetBuildRelease: sdk.builderForTests.targetBuildRelease,
+ t: t,
+ r: result,
+ androidBpContents: sdk.GetAndroidBpContentsForTests(),
+ infoContents: sdk.GetInfoContentsForTests(),
+ snapshotTestCustomizations: map[snapshotTest]*snapshotTestCustomization{},
+ targetBuildRelease: sdk.builderForTests.targetBuildRelease,
}
buildParams := sdk.BuildParamsForTests()
@@ -258,10 +247,7 @@
if dir != "" {
dir = filepath.Clean(dir) + "/"
}
- suffix := ""
- if snapshotBuildInfo.version != soongSdkSnapshotVersionUnversioned {
- suffix = "-" + snapshotBuildInfo.version
- }
+ suffix := "-" + soongSdkSnapshotVersionCurrent
expectedZipPath := fmt.Sprintf(".intermediates/%s%s/%s/%s%s.zip", dir, name, variant, name, suffix)
android.AssertStringEquals(t, "Snapshot zip file in wrong place", expectedZipPath, actual)
@@ -345,33 +331,6 @@
}
}
-// Check that the snapshot's unversioned generated Android.bp is correct.
-//
-// This func should be used to check the general snapshot generation code.
-//
-// Both the expected and actual string are both trimmed before comparing.
-func checkUnversionedAndroidBpContents(expected string) snapshotBuildInfoChecker {
- return func(info *snapshotBuildInfo) {
- info.t.Helper()
- android.AssertTrimmedStringEquals(info.t, "unversioned Android.bp contents do not match", expected, info.androidUnversionedBpContents)
- }
-}
-
-// Check that the snapshot's versioned generated Android.bp is correct.
-//
-// This func should only be used to check the version specific snapshot generation code,
-// i.e. the encoding of version into module names and the generation of the _snapshot module. The
-// general snapshot generation code should be checked using the checkUnversionedAndroidBpContents()
-// func.
-//
-// Both the expected and actual string are both trimmed before comparing.
-func checkVersionedAndroidBpContents(expected string) snapshotBuildInfoChecker {
- return func(info *snapshotBuildInfo) {
- info.t.Helper()
- android.AssertTrimmedStringEquals(info.t, "versioned Android.bp contents do not match", expected, info.androidVersionedBpContents)
- }
-}
-
// Check that the snapshot's copy rules are correct.
//
// The copy rules are formatted as <src> -> <dest>, one per line and then compared
@@ -477,20 +436,9 @@
// The result from RunTest()
r *android.TestResult
- // The version of the generated snapshot.
- //
- // See snapshotBuilder.version for more information about this field.
- version string
-
// The contents of the generated Android.bp file
androidBpContents string
- // The contents of the unversioned Android.bp file
- androidUnversionedBpContents string
-
- // The contents of the versioned Android.bp file
- androidVersionedBpContents string
-
// The contents of the info file.
infoContents string
diff --git a/sdk/update.go b/sdk/update.go
index e61ae0d..457828b 100644
--- a/sdk/update.go
+++ b/sdk/update.go
@@ -35,7 +35,7 @@
// ========================================================
//
// SOONG_SDK_SNAPSHOT_PREFER
-// By default every unversioned module in the generated snapshot has prefer: false. Building it
+// By default every module in the generated snapshot has prefer: false. Building it
// with SOONG_SDK_SNAPSHOT_PREFER=true will force them to use prefer: true.
//
// SOONG_SDK_SNAPSHOT_USE_SOURCE_CONFIG_VAR
@@ -69,20 +69,6 @@
// maintainable solution has been implemented.
// TODO(b/174997203): Remove when no longer necessary.
//
-// SOONG_SDK_SNAPSHOT_VERSION
-// This provides control over the version of the generated snapshot.
-//
-// SOONG_SDK_SNAPSHOT_VERSION=current will generate unversioned and versioned prebuilts and a
-// versioned snapshot module. This is the default behavior. The zip file containing the
-// generated snapshot will be <sdk-name>-current.zip.
-//
-// SOONG_SDK_SNAPSHOT_VERSION=unversioned will generate unversioned prebuilts only and the zip
-// file containing the generated snapshot will be <sdk-name>.zip.
-//
-// SOONG_SDK_SNAPSHOT_VERSION=<number> will generate versioned prebuilts and a versioned
-// snapshot module only. The zip file containing the generated snapshot will be
-// <sdk-name>-<number>.zip.
-//
// SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE
// This allows the target build release (i.e. the release version of the build within which
// the snapshot will be used) of the snapshot to be specified. If unspecified then it defaults
@@ -130,8 +116,7 @@
)
const (
- soongSdkSnapshotVersionUnversioned = "unversioned"
- soongSdkSnapshotVersionCurrent = "current"
+ soongSdkSnapshotVersionCurrent = "current"
)
type generatedContents struct {
@@ -163,13 +148,13 @@
// IndentedPrintf will add spaces to indent the line to the appropriate level before printing the
// arguments.
func (gc *generatedContents) IndentedPrintf(format string, args ...interface{}) {
- fmt.Fprintf(&(gc.content), strings.Repeat(" ", gc.indentLevel)+format, args...)
+ _, _ = fmt.Fprintf(&(gc.content), strings.Repeat(" ", gc.indentLevel)+format, args...)
}
// UnindentedPrintf does not add spaces to indent the line to the appropriate level before printing
// the arguments.
func (gc *generatedContents) UnindentedPrintf(format string, args ...interface{}) {
- fmt.Fprintf(&(gc.content), format, args...)
+ _, _ = fmt.Fprintf(&(gc.content), format, args...)
}
func (gf *generatedFile) build(pctx android.PackageContext, ctx android.BuilderContext, implicits android.Paths) {
@@ -268,13 +253,19 @@
member = &sdkMember{memberType: memberType, name: name}
byName[name] = member
byType[memberType] = append(byType[memberType], member)
+ } else if member.memberType != memberType {
+ // validate whether this is the same member type or and overriding member type
+ if memberType.Overrides(member.memberType) {
+ member.memberType = memberType
+ } else if !member.memberType.Overrides(memberType) {
+ ctx.ModuleErrorf("Incompatible member types %q %q", member.memberType, memberType)
+ }
}
// Only append new variants to the list. This is needed because a member can be both
// exported by the sdk and also be a transitive sdk member.
member.variants = appendUniqueVariants(member.variants, variant)
}
-
var members []*sdkMember
for _, memberListProperty := range s.memberTypeListProperties() {
membersOfType := byType[memberListProperty.memberType]
@@ -315,12 +306,6 @@
// <arch>/lib/
// libFoo.so : a stub library
-// A name that uniquely identifies a prebuilt SDK member for a version of SDK snapshot
-// This isn't visible to users, so could be changed in future.
-func versionedSdkMemberName(ctx android.ModuleContext, memberName string, version string) string {
- return ctx.ModuleName() + "_" + memberName + string(android.SdkVersionSeparator) + version
-}
-
// buildSnapshot is the main function in this source file. It creates rules to copy
// the contents (header files, stub libraries, etc) into the zip file.
func (s *sdk) buildSnapshot(ctx android.ModuleContext, sdkVariants []*sdk) {
@@ -372,20 +357,9 @@
}
config := ctx.Config()
- version := config.GetenvWithDefault("SOONG_SDK_SNAPSHOT_VERSION", "current")
- // Generate versioned modules in the snapshot unless an unversioned snapshot has been requested.
- generateVersioned := version != soongSdkSnapshotVersionUnversioned
-
- // Generate unversioned modules in the snapshot unless a numbered snapshot has been requested.
- //
- // Unversioned modules are not required in that case because the numbered version will be a
- // finalized version of the snapshot that is intended to be kept separate from the
- generateUnversioned := version == soongSdkSnapshotVersionUnversioned || version == soongSdkSnapshotVersionCurrent
- snapshotFileSuffix := ""
- if generateVersioned {
- snapshotFileSuffix = "-" + version
- }
+ // Always add -current to the end
+ snapshotFileSuffix := "-current"
currentBuildRelease := latestBuildRelease()
targetBuildReleaseEnv := config.GetenvWithDefault("SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE", currentBuildRelease.name)
@@ -398,7 +372,6 @@
builder := &snapshotBuilder{
ctx: ctx,
sdk: s,
- version: version,
snapshotDir: snapshotDir.OutputPath,
copies: make(map[string]string),
filesToZip: []android.Path{bp.path},
@@ -448,38 +421,19 @@
s.createMemberSnapshot(memberCtx, member, prebuiltModule.(*bpModule))
}
- // Create a transformer that will transform an unversioned module into a versioned module.
- unversionedToVersionedTransformer := unversionedToVersionedTransformation{builder: builder}
-
- // Create a transformer that will transform an unversioned module by replacing any references
+ // Create a transformer that will transform a module by replacing any references
// to internal members with a unique module name and setting prefer: false.
- unversionedTransformer := unversionedTransformation{
+ snapshotTransformer := snapshotTransformation{
builder: builder,
}
- for _, unversioned := range builder.prebuiltOrder {
+ for _, module := range builder.prebuiltOrder {
// Prune any empty property sets.
- unversioned = unversioned.transform(pruneEmptySetTransformer{})
+ module = module.transform(pruneEmptySetTransformer{})
- if generateVersioned {
- // Copy the unversioned module so it can be modified to make it versioned.
- versioned := unversioned.deepCopy()
-
- // Transform the unversioned module into a versioned one.
- versioned.transform(unversionedToVersionedTransformer)
- bpFile.AddModule(versioned)
- }
-
- if generateUnversioned {
- // Transform the unversioned module to make it suitable for use in the snapshot.
- unversioned.transform(unversionedTransformer)
- bpFile.AddModule(unversioned)
- }
- }
-
- if generateVersioned {
- // Add the sdk/module_exports_snapshot module to the bp file.
- s.addSnapshotModule(ctx, builder, sdkVariants, memberVariantDeps)
+ // Transform the module module to make it suitable for use in the snapshot.
+ module.transform(snapshotTransformer)
+ bpFile.AddModule(module)
}
// generate Android.bp
@@ -666,7 +620,7 @@
func filterOutComponents(ctx android.ModuleContext, deps []sdkMemberVariantDep) []sdkMemberVariantDep {
// Collate the set of components that all the modules added to the sdk provide.
components := map[string]*sdkMemberVariantDep{}
- for i, _ := range deps {
+ for i := range deps {
dep := &deps[i]
for _, c := range dep.exportedComponentsInfo.Components {
components[c] = dep
@@ -701,81 +655,6 @@
return filtered
}
-// addSnapshotModule adds the sdk_snapshot/module_exports_snapshot module to the builder.
-func (s *sdk) addSnapshotModule(ctx android.ModuleContext, builder *snapshotBuilder, sdkVariants []*sdk, memberVariantDeps []sdkMemberVariantDep) {
- bpFile := builder.bpFile
-
- snapshotName := ctx.ModuleName() + string(android.SdkVersionSeparator) + builder.version
- var snapshotModuleType string
- if s.properties.Module_exports {
- snapshotModuleType = "module_exports_snapshot"
- } else {
- snapshotModuleType = "sdk_snapshot"
- }
- snapshotModule := bpFile.newModule(snapshotModuleType)
- snapshotModule.AddProperty("name", snapshotName)
-
- // Make sure that the snapshot has the same visibility as the sdk.
- visibility := android.EffectiveVisibilityRules(ctx, s).Strings()
- if len(visibility) != 0 {
- snapshotModule.AddProperty("visibility", visibility)
- }
-
- addHostDeviceSupportedProperties(s.ModuleBase.DeviceSupported(), s.ModuleBase.HostSupported(), snapshotModule)
-
- combinedPropertiesList := s.collateSnapshotModuleInfo(ctx, sdkVariants, memberVariantDeps)
- commonCombinedProperties := s.optimizeSnapshotModuleProperties(ctx, combinedPropertiesList)
-
- s.addSnapshotPropertiesToPropertySet(builder, snapshotModule, commonCombinedProperties)
-
- targetPropertySet := snapshotModule.AddPropertySet("target")
-
- // Create a mapping from osType to combined properties.
- osTypeToCombinedProperties := map[android.OsType]*combinedSnapshotModuleProperties{}
- for _, combined := range combinedPropertiesList {
- osTypeToCombinedProperties[combined.sdkVariant.Os()] = combined
- }
-
- // Iterate over the os types in a fixed order.
- for _, osType := range s.getPossibleOsTypes() {
- if combined, ok := osTypeToCombinedProperties[osType]; ok {
- osPropertySet := targetPropertySet.AddPropertySet(osType.Name)
-
- s.addSnapshotPropertiesToPropertySet(builder, osPropertySet, combined)
- }
- }
-
- // If host is supported and any member is host OS dependent then disable host
- // by default, so that we can enable each host OS variant explicitly. This
- // avoids problems with implicitly enabled OS variants when the snapshot is
- // used, which might be different from this run (e.g. different build OS).
- if s.HostSupported() {
- var supportedHostTargets []string
- for _, memberVariantDep := range memberVariantDeps {
- if memberVariantDep.memberType.IsHostOsDependent() && memberVariantDep.variant.Target().Os.Class == android.Host {
- targetString := memberVariantDep.variant.Target().Os.String() + "_" + memberVariantDep.variant.Target().Arch.ArchType.String()
- if !android.InList(targetString, supportedHostTargets) {
- supportedHostTargets = append(supportedHostTargets, targetString)
- }
- }
- }
- if len(supportedHostTargets) > 0 {
- hostPropertySet := targetPropertySet.AddPropertySet("host")
- hostPropertySet.AddProperty("enabled", false)
- }
- // Enable the <os>_<arch> variant explicitly when we've disabled it by default on host.
- for _, hostTarget := range supportedHostTargets {
- propertySet := targetPropertySet.AddPropertySet(hostTarget)
- propertySet.AddProperty("enabled", true)
- }
- }
-
- // Prune any empty property sets.
- snapshotModule.transform(pruneEmptySetTransformer{})
-
- bpFile.AddModule(snapshotModule)
-}
-
// Check the syntax of the generated Android.bp file contents and if they are
// invalid then log an error with the contents (tagged with line numbers) and the
// errors that were found so that it is easy to see where the problem lies.
@@ -912,92 +791,34 @@
}
}
-func (s *sdk) addSnapshotPropertiesToPropertySet(builder *snapshotBuilder, propertySet android.BpPropertySet, combined *combinedSnapshotModuleProperties) {
- staticProperties := combined.staticProperties
- multilib := staticProperties.Compile_multilib
- if multilib != "" && multilib != "both" {
- // Compile_multilib defaults to both so only needs to be set when it's specified and not both.
- propertySet.AddProperty("compile_multilib", multilib)
- }
-
- dynamicMemberTypeListProperties := combined.dynamicProperties
- for _, memberListProperty := range s.memberTypeListProperties() {
- if memberListProperty.getter == nil {
- continue
- }
- names := memberListProperty.getter(dynamicMemberTypeListProperties)
- if len(names) > 0 {
- propertySet.AddProperty(memberListProperty.propertyName(), builder.versionedSdkMemberNames(names, false))
- }
- }
-}
-
type propertyTag struct {
name string
}
var _ android.BpPropertyTag = propertyTag{}
-// A BpPropertyTag to add to a property that contains references to other sdk members.
+// BpPropertyTag instances 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.
+// These will ensure that the referenced modules are available, if required.
var requiredSdkMemberReferencePropertyTag = propertyTag{"requiredSdkMemberReferencePropertyTag"}
var optionalSdkMemberReferencePropertyTag = propertyTag{"optionalSdkMemberReferencePropertyTag"}
-// 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 snapshotTransformation struct {
identityTransformation
builder *snapshotBuilder
}
-func (t unversionedToVersionedTransformation) transformModule(module *bpModule) *bpModule {
- // Use a versioned name for the module but remember the original name for the
- // snapshot.
- name := module.Name()
- module.setProperty("name", t.builder.versionedSdkMemberName(name, true))
- module.insertAfter("name", "sdk_member_name", name)
- // Remove the prefer property if present as versioned modules never need marking with prefer.
- module.removeProperty("prefer")
- // Ditto for use_source_config_var
- module.removeProperty("use_source_config_var")
- return module
-}
-
-func (t unversionedToVersionedTransformation) transformProperty(name string, value interface{}, tag android.BpPropertyTag) (interface{}, android.BpPropertyTag) {
- if tag == requiredSdkMemberReferencePropertyTag || tag == optionalSdkMemberReferencePropertyTag {
- required := tag == requiredSdkMemberReferencePropertyTag
- return t.builder.versionedSdkMemberNames(value.([]string), required), tag
- } else {
- return value, tag
- }
-}
-
-type unversionedTransformation struct {
- identityTransformation
- builder *snapshotBuilder
-}
-
-func (t unversionedTransformation) transformModule(module *bpModule) *bpModule {
+func (t snapshotTransformation) transformModule(module *bpModule) *bpModule {
// If the module is an internal member then use a unique name for it.
name := module.Name()
- module.setProperty("name", t.builder.unversionedSdkMemberName(name, true))
+ module.setProperty("name", t.builder.snapshotSdkMemberName(name, true))
return module
}
-func (t unversionedTransformation) transformProperty(name string, value interface{}, tag android.BpPropertyTag) (interface{}, android.BpPropertyTag) {
+func (t snapshotTransformation) transformProperty(_ string, value interface{}, tag android.BpPropertyTag) (interface{}, android.BpPropertyTag) {
if tag == requiredSdkMemberReferencePropertyTag || tag == optionalSdkMemberReferencePropertyTag {
required := tag == requiredSdkMemberReferencePropertyTag
- return t.builder.unversionedSdkMemberNames(value.([]string), required), tag
- } else if tag == sdkVersionedOnlyPropertyTag {
- // The property is not allowed in the unversioned module so remove it.
- return nil, nil
+ return t.builder.snapshotSdkMemberNames(value.([]string), required), tag
} else {
return value, tag
}
@@ -1009,7 +830,7 @@
var _ bpTransformer = (*pruneEmptySetTransformer)(nil)
-func (t pruneEmptySetTransformer) transformPropertySetAfterContents(name string, propertySet *bpPropertySet, tag android.BpPropertyTag) (*bpPropertySet, android.BpPropertyTag) {
+func (t pruneEmptySetTransformer) transformPropertySetAfterContents(_ string, propertySet *bpPropertySet, tag android.BpPropertyTag) (*bpPropertySet, android.BpPropertyTag) {
if len(propertySet.properties) == 0 {
return nil, nil
} else {
@@ -1018,20 +839,12 @@
}
func generateBpContents(contents *generatedContents, bpFile *bpFile) {
- generateFilteredBpContents(contents, bpFile, func(*bpModule) bool {
- return true
- })
-}
-
-func generateFilteredBpContents(contents *generatedContents, bpFile *bpFile, moduleFilter func(module *bpModule) bool) {
contents.IndentedPrintf("// This is auto-generated. DO NOT EDIT.\n")
for _, bpModule := range bpFile.order {
- if moduleFilter(bpModule) {
- contents.IndentedPrintf("\n")
- contents.IndentedPrintf("%s {\n", bpModule.moduleType)
- outputPropertySet(contents, bpModule.bpPropertySet)
- contents.IndentedPrintf("}\n")
- }
+ contents.IndentedPrintf("\n")
+ contents.IndentedPrintf("%s {\n", bpModule.moduleType)
+ outputPropertySet(contents, bpModule.bpPropertySet)
+ contents.IndentedPrintf("}\n")
}
}
@@ -1167,36 +980,10 @@
return s.builderForTests.infoContents
}
-func (s *sdk) GetUnversionedAndroidBpContentsForTests() string {
- contents := &generatedContents{}
- generateFilteredBpContents(contents, s.builderForTests.bpFile, func(module *bpModule) bool {
- name := module.Name()
- // Include modules that are either unversioned or have no name.
- return !strings.Contains(name, "@")
- })
- return contents.content.String()
-}
-
-func (s *sdk) GetVersionedAndroidBpContentsForTests() string {
- contents := &generatedContents{}
- generateFilteredBpContents(contents, s.builderForTests.bpFile, func(module *bpModule) bool {
- name := module.Name()
- // Include modules that are either versioned or have no name.
- return name == "" || strings.Contains(name, "@")
- })
- return contents.content.String()
-}
-
type snapshotBuilder struct {
ctx android.ModuleContext
sdk *sdk
- // The version of the generated snapshot.
- //
- // See the documentation of SOONG_SDK_SNAPSHOT_VERSION above for details of the valid values of
- // this field.
- version string
-
snapshotDir android.OutputPath
bpFile *bpFile
@@ -1350,13 +1137,6 @@
addHostDeviceSupportedProperties(deviceSupported, hostSupported, m)
- // 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.prebuiltOrder = append(s.prebuiltOrder, m)
return m
@@ -1389,45 +1169,28 @@
return optionalSdkMemberReferencePropertyTag
}
-// Get a versioned name appropriate for the SDK snapshot version being taken.
-func (s *snapshotBuilder) versionedSdkMemberName(unversionedName string, required bool) string {
- if _, ok := s.allMembersByName[unversionedName]; !ok {
+// Get a name for sdk snapshot member. If the member is private then generate a snapshot specific
+// name. As part of the processing this checks to make sure that any required members are part of
+// the snapshot.
+func (s *snapshotBuilder) snapshotSdkMemberName(name string, required bool) string {
+ if _, ok := s.allMembersByName[name]; !ok {
if required {
- s.ctx.ModuleErrorf("Required member reference %s is not a member of the sdk", unversionedName)
+ s.ctx.ModuleErrorf("Required member reference %s is not a member of the sdk", name)
}
- return unversionedName
- }
- return versionedSdkMemberName(s.ctx, unversionedName, s.version)
-}
-
-func (s *snapshotBuilder) versionedSdkMemberNames(members []string, required bool) []string {
- var references []string = nil
- for _, m := range members {
- references = append(references, s.versionedSdkMemberName(m, required))
- }
- return references
-}
-
-// Get an internal name unique to the sdk.
-func (s *snapshotBuilder) unversionedSdkMemberName(unversionedName string, required bool) string {
- if _, ok := s.allMembersByName[unversionedName]; !ok {
- if required {
- s.ctx.ModuleErrorf("Required member reference %s is not a member of the sdk", unversionedName)
- }
- return unversionedName
+ return name
}
- if s.isInternalMember(unversionedName) {
- return s.ctx.ModuleName() + "_" + unversionedName
+ if s.isInternalMember(name) {
+ return s.ctx.ModuleName() + "_" + name
} else {
- return unversionedName
+ return name
}
}
-func (s *snapshotBuilder) unversionedSdkMemberNames(members []string, required bool) []string {
+func (s *snapshotBuilder) snapshotSdkMemberNames(members []string, required bool) []string {
var references []string = nil
for _, m := range members {
- references = append(references, s.unversionedSdkMemberName(m, required))
+ references = append(references, s.snapshotSdkMemberName(m, required))
}
return references
}
@@ -1783,7 +1546,9 @@
// added.
archInfo.Properties = variantPropertiesFactory()
- if len(archVariants) == 1 {
+ // if there are multiple supported link variants, we want to nest based on linkage even if there
+ // is only one variant, otherwise, if there is only one variant we can populate based on the arch
+ if len(archVariants) == 1 && len(ctx.MemberType().SupportedLinkages()) <= 1 {
archInfo.Properties.PopulateFromVariant(ctx, archVariants[0])
} else {
// Group the variants by image type.
@@ -1910,11 +1675,13 @@
// Create the properties into which the image variant specific properties will be added.
imageInfo.Properties = variantPropertiesFactory()
- if len(imageVariants) == 1 {
+ // if there are multiple supported link variants, we want to nest even if there is only one
+ // variant, otherwise, if there is only one variant we can populate based on the image
+ if len(imageVariants) == 1 && len(ctx.MemberType().SupportedLinkages()) <= 1 {
imageInfo.Properties.PopulateFromVariant(ctx, imageVariants[0])
} else {
// There is more than one variant for this image variant which must be differentiated by link
- // type.
+ // type. Or there are multiple supported linkages and we need to nest based on link type.
for _, linkVariant := range imageVariants {
linkType := getLinkType(linkVariant)
if linkType == "" {
@@ -1958,10 +1725,22 @@
addSdkMemberPropertiesToSet(ctx, imageInfo.Properties, propertySet)
+ usedLinkages := make(map[string]bool, len(imageInfo.linkInfos))
for _, linkInfo := range imageInfo.linkInfos {
+ usedLinkages[linkInfo.linkType] = true
linkInfo.addToPropertySet(ctx, propertySet)
}
+ // If not all supported linkages had existing variants, we need to disable the unsupported variant
+ if len(imageInfo.linkInfos) < len(ctx.MemberType().SupportedLinkages()) {
+ for _, l := range ctx.MemberType().SupportedLinkages() {
+ if _, ok := usedLinkages[l]; !ok {
+ otherLinkagePropertySet := propertySet.AddPropertySet(l)
+ otherLinkagePropertySet.AddProperty("enabled", false)
+ }
+ }
+ }
+
// If this is for a non-core image variant then make sure that the property set does not contain
// any properties as providing non-core image variant specific properties for prebuilts is not
// currently supported.
diff --git a/sh/sh_binary.go b/sh/sh_binary.go
index d1beaba..4de0144 100644
--- a/sh/sh_binary.go
+++ b/sh/sh_binary.go
@@ -323,7 +323,7 @@
ctx.AddFarVariationDependencies(ctx.Target().Variations(), shTestDataBinsTag, s.testProperties.Data_bins...)
ctx.AddFarVariationDependencies(append(ctx.Target().Variations(), sharedLibVariations...),
shTestDataLibsTag, s.testProperties.Data_libs...)
- if (ctx.Target().Os.Class == android.Host || ctx.BazelConversionMode()) && len(ctx.Config().Targets[android.Android]) > 0 {
+ if ctx.Target().Os.Class == android.Host && len(ctx.Config().Targets[android.Android]) > 0 {
deviceVariations := ctx.Config().AndroidFirstDeviceTarget.Variations()
ctx.AddFarVariationDependencies(deviceVariations, shTestDataDeviceBinsTag, s.testProperties.Data_device_bins...)
ctx.AddFarVariationDependencies(append(deviceVariations, sharedLibVariations...),