aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2024-02-29 00:01:16 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2024-02-29 00:01:16 +0000
commita0897e87d044c542ea61bdba495ca2ae10d6957a (patch)
tree44a9535d45b586391456d438788039a7a7c82949
parentce530f7576229227268b17820c6499ec1151eb46 (diff)
parentc4538a09ef9758488ea3f0e1bf9200b436ccc74e (diff)
Snap for 11510485 from c4538a09ef9758488ea3f0e1bf9200b436ccc74e to 24Q2-release
Change-Id: I4edc66a670cebfee7468d30a500d24dc5fea2605
-rw-r--r--apex/apex.go10
-rw-r--r--apex/apex_test.go1
-rw-r--r--cc/cc.go4
-rw-r--r--cc/config/riscv64_device.go8
-rw-r--r--cc/prebuilt_test.go5
-rw-r--r--java/droiddoc.go2
-rw-r--r--java/droidstubs.go150
-rw-r--r--java/droidstubs_test.go36
8 files changed, 151 insertions, 65 deletions
diff --git a/apex/apex.go b/apex/apex.go
index d181fe705..1954a7eaf 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -841,10 +841,12 @@ func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) {
}
addDependenciesForNativeModules(ctx, deps, target, imageVariation)
- ctx.AddFarVariationDependencies([]blueprint.Variation{
- {Mutator: "os", Variation: target.OsVariation()},
- {Mutator: "arch", Variation: target.ArchVariation()},
- }, shBinaryTag, a.properties.Sh_binaries...)
+ if isPrimaryAbi {
+ ctx.AddFarVariationDependencies([]blueprint.Variation{
+ {Mutator: "os", Variation: target.OsVariation()},
+ {Mutator: "arch", Variation: target.ArchVariation()},
+ }, shBinaryTag, a.properties.Sh_binaries...)
+ }
}
// Common-arch dependencies come next
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 0df0e603c..cc2d4ef17 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -5046,6 +5046,7 @@ func TestApexWithShBinary(t *testing.T) {
key: "myapex.key",
sh_binaries: ["myscript"],
updatable: false,
+ compile_multilib: "both",
}
apex_key {
diff --git a/cc/cc.go b/cc/cc.go
index 39024aa3c..2770fb23b 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -3361,7 +3361,7 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
c.sabi.Properties.ReexportedIncludes, depExporterInfo.IncludeDirs.Strings()...)
}
- makeLibName := MakeLibName(ctx, c, ccDep, depName) + libDepTag.makeSuffix
+ makeLibName := MakeLibName(ctx, c, ccDep, ccDep.BaseModuleName()) + libDepTag.makeSuffix
switch {
case libDepTag.header():
c.Properties.AndroidMkHeaderLibs = append(
@@ -3402,7 +3402,7 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
switch depTag {
case runtimeDepTag:
c.Properties.AndroidMkRuntimeLibs = append(
- c.Properties.AndroidMkRuntimeLibs, MakeLibName(ctx, c, ccDep, depName)+libDepTag.makeSuffix)
+ c.Properties.AndroidMkRuntimeLibs, MakeLibName(ctx, c, ccDep, ccDep.BaseModuleName())+libDepTag.makeSuffix)
// Record BaseLibName for snapshots.
c.Properties.SnapshotRuntimeLibs = append(c.Properties.SnapshotRuntimeLibs, BaseLibName(depName))
case objDepTag:
diff --git a/cc/config/riscv64_device.go b/cc/config/riscv64_device.go
index deb922bd2..6a84fee9f 100644
--- a/cc/config/riscv64_device.go
+++ b/cc/config/riscv64_device.go
@@ -26,9 +26,7 @@ var (
// Help catch common 32/64-bit errors.
"-Werror=implicit-function-declaration",
"-march=rv64gcv_zba_zbb_zbs",
- // Equivalent to "-munaligned-access", but our clang doesn't have that yet.
- "-Xclang -target-feature -Xclang +unaligned-scalar-mem",
- "-Xclang -target-feature -Xclang +unaligned-vector-mem",
+ "-munaligned-access",
// Until https://gitlab.com/qemu-project/qemu/-/issues/1976 is fixed...
"-mno-implicit-float",
// (https://github.com/google/android-riscv64/issues/124)
@@ -40,9 +38,7 @@ var (
riscv64Ldflags = []string{
"-Wl,--hash-style=gnu",
"-march=rv64gcv_zba_zbb_zbs",
- // Equivalent to "-munaligned-access", but our clang doesn't have that yet.
- "-Xclang -target-feature -Xclang +unaligned-scalar-mem",
- "-Xclang -target-feature -Xclang +unaligned-vector-mem",
+ "-munaligned-access",
// We should change the default for this in clang, but for now...
// (https://github.com/google/android-riscv64/issues/124)
"-Wl,-mllvm -Wl,-jump-is-expensive=false",
diff --git a/cc/prebuilt_test.go b/cc/prebuilt_test.go
index 95fb7edfb..f6b5ed56c 100644
--- a/cc/prebuilt_test.go
+++ b/cc/prebuilt_test.go
@@ -595,6 +595,9 @@ func TestMultiplePrebuilts(t *testing.T) {
libfoo := ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_shared").Module()
expectedDependency := ctx.ModuleForTests(tc.expectedDependencyName, "android_arm64_armv8-a_shared").Module()
android.AssertBoolEquals(t, fmt.Sprintf("expected dependency from %s to %s\n", libfoo.Name(), tc.expectedDependencyName), true, hasDep(ctx, libfoo, expectedDependency))
+ // check that LOCAL_SHARED_LIBRARIES contains libbar and not libbar.v<N>
+ entries := android.AndroidMkEntriesForTest(t, ctx, libfoo)[0]
+ android.AssertStringListContains(t, "Version should not be present in LOCAL_SHARED_LIBRARIES", entries.EntryMap["LOCAL_SHARED_LIBRARIES"], "libbar")
// check installation rules
// the selected soong module should be exported to make
@@ -603,7 +606,7 @@ func TestMultiplePrebuilts(t *testing.T) {
// check LOCAL_MODULE of the selected module name
// the prebuilt should have the same LOCAL_MODULE when exported to make
- entries := android.AndroidMkEntriesForTest(t, ctx, libbar)[0]
+ entries = android.AndroidMkEntriesForTest(t, ctx, libbar)[0]
android.AssertStringEquals(t, "unexpected LOCAL_MODULE", "libbar", entries.EntryMap["LOCAL_MODULE"][0])
}
}
diff --git a/java/droiddoc.go b/java/droiddoc.go
index 6a66f45ec..df40d016c 100644
--- a/java/droiddoc.go
+++ b/java/droiddoc.go
@@ -222,6 +222,8 @@ type Javadoc struct {
stubsSrcJar android.WritablePath
exportableStubsSrcJar android.WritablePath
+
+ runtimeStubsSrcJar android.WritablePath
}
func (j *Javadoc) OutputFiles(tag string) (android.Paths, error) {
diff --git a/java/droidstubs.go b/java/droidstubs.go
index 51503f22a..b1126146c 100644
--- a/java/droidstubs.go
+++ b/java/droidstubs.go
@@ -214,6 +214,7 @@ type currentApiTimestampProvider interface {
type annotationFlagsParams struct {
migratingNullability bool
validatingNullability bool
+ extractAnnotations bool
nullabilityWarningsFile android.WritablePath
annotationsZip android.WritablePath
}
@@ -229,16 +230,19 @@ type stubsCommandParams struct {
stubConfig stubsCommandConfigParams
}
type stubsCommandConfigParams struct {
- stubsType StubsType
- javaVersion javaVersion
- deps deps
- checkApi bool
- generateStubs bool
- doApiLint bool
- doCheckReleased bool
- writeSdkValues bool
- migratingNullability bool
- validatingNullability bool
+ stubsType StubsType
+ javaVersion javaVersion
+ deps deps
+ checkApi bool
+ generateStubs bool
+ doApiLint bool
+ doCheckReleased bool
+ writeSdkValues bool
+ migratingNullability bool
+ validatingNullability bool
+ annotationsEnabled bool
+ apiLevelsAnnotationsEnabled bool
+ extractAnnotations bool
}
// droidstubs passes sources files through Metalava to generate stub .java files that only contain the API to be
@@ -508,30 +512,30 @@ func (d *Droidstubs) stubsFlags(ctx android.ModuleContext, cmd *android.RuleBuil
}
func (d *Droidstubs) annotationsFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand, params annotationFlagsParams) {
- if Bool(d.properties.Annotations_enabled) {
- cmd.Flag(config.MetalavaAnnotationsFlags)
+ cmd.Flag(config.MetalavaAnnotationsFlags)
- if params.migratingNullability {
- previousApi := android.PathForModuleSrc(ctx, String(d.properties.Previous_api))
- cmd.FlagWithInput("--migrate-nullness ", previousApi)
- }
+ if params.migratingNullability {
+ previousApi := android.PathForModuleSrc(ctx, String(d.properties.Previous_api))
+ cmd.FlagWithInput("--migrate-nullness ", previousApi)
+ }
- if s := String(d.properties.Validate_nullability_from_list); s != "" {
- cmd.FlagWithInput("--validate-nullability-from-list ", android.PathForModuleSrc(ctx, s))
- }
+ if s := String(d.properties.Validate_nullability_from_list); s != "" {
+ cmd.FlagWithInput("--validate-nullability-from-list ", android.PathForModuleSrc(ctx, s))
+ }
- if params.validatingNullability {
- cmd.FlagWithOutput("--nullability-warnings-txt ", params.nullabilityWarningsFile)
- }
+ if params.validatingNullability {
+ cmd.FlagWithOutput("--nullability-warnings-txt ", params.nullabilityWarningsFile)
+ }
+ if params.extractAnnotations {
cmd.FlagWithOutput("--extract-annotations ", params.annotationsZip)
+ }
- if len(d.properties.Merge_annotations_dirs) != 0 {
- d.mergeAnnoDirFlags(ctx, cmd)
- }
-
- cmd.Flag(config.MetalavaAnnotationsWarningsFlags)
+ if len(d.properties.Merge_annotations_dirs) != 0 {
+ d.mergeAnnoDirFlags(ctx, cmd)
}
+
+ cmd.Flag(config.MetalavaAnnotationsWarningsFlags)
}
func (d *Droidstubs) mergeAnnoDirFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand) {
@@ -556,9 +560,11 @@ func (d *Droidstubs) inclusionAnnotationsFlags(ctx android.ModuleContext, cmd *a
})
}
-func (d *Droidstubs) apiLevelsAnnotationsFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand, stubsType StubsType, apiVersionsXml android.WritablePath) {
+func (d *Droidstubs) apiLevelsAnnotationsFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand, params stubsCommandParams) {
var apiVersions android.Path
- if proptools.Bool(d.properties.Api_levels_annotations_enabled) {
+ stubsType := params.stubConfig.stubsType
+ apiVersionsXml := params.apiVersionsXml
+ if params.stubConfig.apiLevelsAnnotationsEnabled {
d.apiLevelsGenerationFlags(ctx, cmd, stubsType, apiVersionsXml)
apiVersions = apiVersionsXml
} else {
@@ -569,7 +575,9 @@ func (d *Droidstubs) apiLevelsAnnotationsFlags(ctx android.ModuleContext, cmd *a
} else if stubsType == Exportable {
apiVersions = s.exportableArtifacts.apiVersionsXml
} else {
- ctx.ModuleErrorf("%s stubs type does not generate api-versions.xml file", stubsType.String())
+ // if the stubs type does not generate api-versions.xml file, default to using the
+ // everything artifacts
+ apiVersions = s.everythingArtifacts.apiVersionsXml
}
} else {
ctx.PropertyErrorf("api_levels_module",
@@ -803,13 +811,16 @@ func (d *Droidstubs) commonMetalavaStubCmd(ctx android.ModuleContext, rule *andr
annotationParams := annotationFlagsParams{
migratingNullability: params.stubConfig.migratingNullability,
validatingNullability: params.stubConfig.validatingNullability,
+ extractAnnotations: params.stubConfig.extractAnnotations,
nullabilityWarningsFile: params.nullabilityWarningsFile,
annotationsZip: params.annotationsZip,
}
- d.annotationsFlags(ctx, cmd, annotationParams)
+ if params.stubConfig.annotationsEnabled {
+ d.annotationsFlags(ctx, cmd, annotationParams)
+ }
d.inclusionAnnotationsFlags(ctx, cmd)
- d.apiLevelsAnnotationsFlags(ctx, cmd, params.stubConfig.stubsType, params.apiVersionsXml)
+ d.apiLevelsAnnotationsFlags(ctx, cmd, params)
d.expandArgs(ctx, cmd)
@@ -839,13 +850,13 @@ func (d *Droidstubs) everythingStubCmd(ctx android.ModuleContext, params stubsCo
d.everythingArtifacts.metadataZip = android.PathForModuleOut(ctx, Everything.String(), ctx.ModuleName()+"-metadata.zip")
}
- if Bool(d.properties.Annotations_enabled) {
+ if params.annotationsEnabled {
if params.validatingNullability {
d.everythingArtifacts.nullabilityWarningsFile = android.PathForModuleOut(ctx, Everything.String(), ctx.ModuleName()+"_nullability_warnings.txt")
}
d.everythingArtifacts.annotationsZip = android.PathForModuleOut(ctx, Everything.String(), ctx.ModuleName()+"_annotations.zip")
}
- if Bool(d.properties.Api_levels_annotations_enabled) {
+ if params.apiLevelsAnnotationsEnabled {
d.everythingArtifacts.apiVersionsXml = android.PathForModuleOut(ctx, Everything.String(), "api-versions.xml")
}
@@ -1023,7 +1034,7 @@ func (d *Droidstubs) exportableStubCmd(ctx android.ModuleContext, params stubsCo
optionalCmdParams.metadataDir = d.exportableArtifacts.metadataDir
}
- if Bool(d.properties.Annotations_enabled) {
+ if params.annotationsEnabled {
if params.validatingNullability {
d.exportableArtifacts.nullabilityWarningsFile = android.PathForModuleOut(ctx, params.stubsType.String(), ctx.ModuleName()+"_nullability_warnings.txt")
optionalCmdParams.nullabilityWarningsFile = d.exportableArtifacts.nullabilityWarningsFile
@@ -1031,7 +1042,7 @@ func (d *Droidstubs) exportableStubCmd(ctx android.ModuleContext, params stubsCo
d.exportableArtifacts.annotationsZip = android.PathForModuleOut(ctx, params.stubsType.String(), ctx.ModuleName()+"_annotations.zip")
optionalCmdParams.annotationsZip = d.exportableArtifacts.annotationsZip
}
- if Bool(d.properties.Api_levels_annotations_enabled) {
+ if params.apiLevelsAnnotationsEnabled {
d.exportableArtifacts.apiVersionsXml = android.PathForModuleOut(ctx, params.stubsType.String(), "api-versions.xml")
optionalCmdParams.apiVersionsXml = d.exportableArtifacts.apiVersionsXml
}
@@ -1049,6 +1060,38 @@ func (d *Droidstubs) exportableStubCmd(ctx android.ModuleContext, params stubsCo
d.optionalStubCmd(ctx, optionalCmdParams)
}
+// Sandbox rule for generating runtime stubs
+func (d *Droidstubs) runtimeStubCmd(ctx android.ModuleContext, params stubsCommandConfigParams) {
+
+ // We are only interested in generating the stubs srcjar,
+ // not other artifacts for the runtime stubs
+ params.checkApi = false
+ params.writeSdkValues = false
+ params.validatingNullability = false
+ params.extractAnnotations = false
+ params.apiLevelsAnnotationsEnabled = false
+
+ optionalCmdParams := stubsCommandParams{
+ stubConfig: params,
+ }
+
+ d.Javadoc.runtimeStubsSrcJar = android.PathForModuleOut(ctx, params.stubsType.String(), ctx.ModuleName()+"-"+"stubs.srcjar")
+ optionalCmdParams.stubsSrcJar = d.Javadoc.runtimeStubsSrcJar
+
+ // If aconfig_declarations property is not defined, all flagged apis symbols are stripped
+ // as no aconfig flags are enabled. In such case, the runtime stubs are identical to the
+ // exportable stubs, thus no additional metalava invocation is needed.
+ if len(d.properties.Aconfig_declarations) == 0 {
+ rule := android.NewRuleBuilder(pctx, ctx)
+ rule.Command().
+ Text("cp").Flag("-f").
+ Input(d.exportableStubsSrcJar).Output(d.runtimeStubsSrcJar)
+ rule.Build(fmt.Sprintf("metalava_%s", params.stubsType.String()), "metalava merged")
+ } else {
+ d.optionalStubCmd(ctx, optionalCmdParams)
+ }
+}
+
func (d *Droidstubs) optionalStubCmd(ctx android.ModuleContext, params stubsCommandParams) {
params.srcJarDir = android.PathForModuleOut(ctx, params.stubConfig.stubsType.String(), "srcjars")
@@ -1120,6 +1163,8 @@ func (d *Droidstubs) GenerateAndroidBuildActions(ctx android.ModuleContext) {
annotationsEnabled := Bool(d.properties.Annotations_enabled)
+ extractAnnotations := annotationsEnabled
+
migratingNullability := annotationsEnabled && String(d.properties.Previous_api) != ""
validatingNullability := annotationsEnabled && (strings.Contains(String(d.Javadoc.properties.Args), "--validate-nullability-from-merged-stubs") ||
String(d.properties.Validate_nullability_from_list) != "")
@@ -1127,27 +1172,40 @@ func (d *Droidstubs) GenerateAndroidBuildActions(ctx android.ModuleContext) {
checkApi := apiCheckEnabled(ctx, d.properties.Check_api.Current, "current") ||
apiCheckEnabled(ctx, d.properties.Check_api.Last_released, "last_released")
+ apiLevelsAnnotationsEnabled := proptools.Bool(d.properties.Api_levels_annotations_enabled)
+
stubCmdParams := stubsCommandConfigParams{
- javaVersion: javaVersion,
- deps: deps,
- checkApi: checkApi,
- generateStubs: generateStubs,
- doApiLint: doApiLint,
- doCheckReleased: doCheckReleased,
- writeSdkValues: writeSdkValues,
- migratingNullability: migratingNullability,
- validatingNullability: validatingNullability,
+ javaVersion: javaVersion,
+ deps: deps,
+ checkApi: checkApi,
+ generateStubs: generateStubs,
+ doApiLint: doApiLint,
+ doCheckReleased: doCheckReleased,
+ writeSdkValues: writeSdkValues,
+ migratingNullability: migratingNullability,
+ validatingNullability: validatingNullability,
+ annotationsEnabled: annotationsEnabled,
+ apiLevelsAnnotationsEnabled: apiLevelsAnnotationsEnabled,
+ extractAnnotations: extractAnnotations,
}
stubCmdParams.stubsType = Everything
// Create default (i.e. "everything" stubs) rule for metalava
d.everythingStubCmd(ctx, stubCmdParams)
- // The module generates "exportable" (and "runtime" eventually) stubs regardless of whether
+ // The module generates "exportable" stubs regardless of whether
// aconfig_declarations property is defined or not. If the property is not defined, the module simply
// strips all flagged apis to generate the "exportable" stubs
stubCmdParams.stubsType = Exportable
d.exportableStubCmd(ctx, stubCmdParams)
+ // "runtime" stubs do not generate any other artifacts than the stubs.
+ // Therefore, metalava does not have to run for "runtime" configuration
+ // when the module does not generate stubs.
+ if stubCmdParams.generateStubs {
+ stubCmdParams.stubsType = Runtime
+ d.runtimeStubCmd(ctx, stubCmdParams)
+ }
+
if apiCheckEnabled(ctx, d.properties.Check_api.Current, "current") {
if len(d.Javadoc.properties.Out) > 0 {
diff --git a/java/droidstubs_test.go b/java/droidstubs_test.go
index e5ffd2847..ca34e0ef1 100644
--- a/java/droidstubs_test.go
+++ b/java/droidstubs_test.go
@@ -396,23 +396,47 @@ func TestAconfigDeclarations(t *testing.T) {
"bar",
],
}
+ droidstubs {
+ name: "baz",
+ srcs: ["a/A.java"],
+ api_surface: "public",
+ check_api: {
+ current: {
+ api_file: "a/current.txt",
+ removed_api_file: "a/removed.txt",
+ }
+ },
+ }
`)
// Check that droidstubs depend on aconfig_declarations
android.AssertBoolEquals(t, "foo expected to depend on bar",
CheckModuleHasDependency(t, result.TestContext, "foo", "android_common", "bar"), true)
- m := result.ModuleForTests("foo", "android_common")
+ fooModule := result.ModuleForTests("foo", "android_common")
android.AssertStringDoesContain(t, "foo generates revert annotations file",
- strings.Join(m.AllOutputs(), ""), "revert-annotations-exportable.txt")
+ strings.Join(fooModule.AllOutputs(), ""), "revert-annotations-exportable.txt")
// revert-annotations.txt passed to exportable stubs generation metalava command
- manifest := m.Output("metalava_exportable.sbox.textproto")
- cmdline := String(android.RuleBuilderSboxProtoForTests(t, result.TestContext, manifest).Commands[0].Command)
- android.AssertStringDoesContain(t, "flagged api hide command not included", cmdline, "revert-annotations-exportable.txt")
+ exportableManifest := fooModule.Output("metalava_exportable.sbox.textproto")
+ exportableCmdline := String(android.RuleBuilderSboxProtoForTests(t, result.TestContext, exportableManifest).Commands[0].Command)
+ android.AssertStringDoesContain(t, "flagged api hide command not included", exportableCmdline, "revert-annotations-exportable.txt")
android.AssertStringDoesContain(t, "foo generates exportable stubs jar",
- strings.Join(m.AllOutputs(), ""), "exportable/foo-stubs.srcjar")
+ strings.Join(fooModule.AllOutputs(), ""), "exportable/foo-stubs.srcjar")
+
+ // revert-annotations.txt passed to runtime stubs generation metalava command
+ runtimeManifest := fooModule.Output("metalava_runtime.sbox.textproto")
+ runtimeCmdline := String(android.RuleBuilderSboxProtoForTests(t, result.TestContext, runtimeManifest).Commands[0].Command)
+ android.AssertStringDoesContain(t, "flagged api hide command not included", runtimeCmdline, "revert-annotations-runtime.txt")
+
+ android.AssertStringDoesContain(t, "foo generates runtime stubs jar",
+ strings.Join(fooModule.AllOutputs(), ""), "runtime/foo-stubs.srcjar")
+
+ // If aconfig_declarations property is not defined, the runtime stubs is a copy of the exportable stubs
+ bazModule := result.ModuleForTests("baz", "android_common")
+ bazRuntimeCmdline := bazModule.Rule("metalava_runtime").RuleParams.Command
+ android.AssertStringDoesContain(t, "copy command should include the input stub", bazRuntimeCmdline, "exportable/baz-stubs.srcjar")
}
func TestReleaseExportRuntimeApis(t *testing.T) {