Merge "Allow platform_bootclasspath to specify contributing fragments"
diff --git a/android/bazel_handler.go b/android/bazel_handler.go
index 5b9d3bf..5ac6924 100644
--- a/android/bazel_handler.go
+++ b/android/bazel_handler.go
@@ -34,10 +34,26 @@
"android/soong/shared"
)
+type cqueryRequest interface {
+ // Name returns a string name for this request type. Such request type names must be unique,
+ // and must only consist of alphanumeric characters.
+ Name() string
+
+ // StarlarkFunctionBody returns a starlark function body to process this request type.
+ // The returned string is the body of a Starlark function which obtains
+ // all request-relevant information about a target and returns a string containing
+ // this information.
+ // The function should have the following properties:
+ // - `target` is the only parameter to this function (a configured target).
+ // - The return value must be a string.
+ // - The function body should not be indented outside of its own scope.
+ StarlarkFunctionBody() string
+}
+
// Map key to describe bazel cquery requests.
type cqueryKey struct {
label string
- requestType cquery.RequestType
+ requestType cqueryRequest
archType ArchType
}
@@ -133,7 +149,7 @@
var ret []string
if ok {
bazelOutput := strings.TrimSpace(rawString)
- ret = cquery.GetOutputFiles.ParseResult(bazelOutput).([]string)
+ ret = cquery.GetOutputFiles.ParseResult(bazelOutput)
}
return ret, ok
}
@@ -145,7 +161,7 @@
result, ok := bazelCtx.cquery(label, cquery.GetOutputFilesAndCcObjectFiles, archType)
if ok {
bazelOutput := strings.TrimSpace(result)
- returnResult := cquery.GetOutputFilesAndCcObjectFiles.ParseResult(bazelOutput).(cquery.GetOutputFilesAndCcObjectFiles_Result)
+ returnResult := cquery.GetOutputFilesAndCcObjectFiles.ParseResult(bazelOutput)
outputFiles = returnResult.OutputFiles
ccObjects = returnResult.CcObjectFiles
}
@@ -231,7 +247,7 @@
// If the given request was already made (and the results are available), then
// returns (result, true). If the request is queued but no results are available,
// then returns ("", false).
-func (context *bazelContext) cquery(label string, requestType cquery.RequestType,
+func (context *bazelContext) cquery(label string, requestType cqueryRequest,
archType ArchType) (string, bool) {
key := cqueryKey{label, requestType, archType}
if result, ok := context.results[key]; ok {
@@ -449,7 +465,7 @@
// and grouped by their request type. The data retrieved for each label depends on its
// request type.
func (context *bazelContext) cqueryStarlarkFileContents() []byte {
- requestTypeToCqueryIdEntries := map[cquery.RequestType][]string{}
+ requestTypeToCqueryIdEntries := map[cqueryRequest][]string{}
for val, _ := range context.requests {
cqueryId := getCqueryId(val)
mapEntryString := fmt.Sprintf("%q : True", cqueryId)
diff --git a/apex/apex_test.go b/apex/apex_test.go
index c507fb0..88aa5f9 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -4605,6 +4605,40 @@
`)
})
+ t.Run("apex_set only", func(t *testing.T) {
+ bp := `
+ apex_set {
+ name: "myapex",
+ set: "myapex.apks",
+ exported_java_libs: ["libfoo", "libbar"],
+ }
+
+ java_import {
+ name: "libfoo",
+ jars: ["libfoo.jar"],
+ apex_available: ["myapex"],
+ }
+
+ java_sdk_library_import {
+ name: "libbar",
+ public: {
+ jars: ["libbar.jar"],
+ },
+ apex_available: ["myapex"],
+ }
+ `
+
+ ctx := testDexpreoptWithApexes(t, bp, "", transform)
+ checkBootDexJarPath(t, ctx, "libfoo", "out/soong/.intermediates/myapex.deapexer/android_common/deapexer/javalib/libfoo.jar")
+ checkBootDexJarPath(t, ctx, "libbar", "out/soong/.intermediates/myapex.deapexer/android_common/deapexer/javalib/libbar.jar")
+
+ // Make sure that the dex file from the apex_set contributes to the hiddenapi index file.
+ checkHiddenAPIIndexInputs(t, ctx, `
+.intermediates/libbar/android_common_myapex/hiddenapi/index.csv
+.intermediates/libfoo/android_common_myapex/hiddenapi/index.csv
+`)
+ })
+
t.Run("prebuilt with source library preferred", func(t *testing.T) {
bp := `
prebuilt_apex {
diff --git a/apex/prebuilt.go b/apex/prebuilt.go
index c8a0c0b..10a70a3 100644
--- a/apex/prebuilt.go
+++ b/apex/prebuilt.go
@@ -668,7 +668,7 @@
// prebuilt_apex imports an `.apex` file into the build graph as if it was built with apex.
func apexSetFactory() android.Module {
module := &ApexSet{}
- module.AddProperties(&module.properties, &module.selectedApexProperties)
+ module.AddProperties(&module.properties, &module.selectedApexProperties, &module.deapexerProperties)
android.InitSingleSourcePrebuiltModule(module, &module.selectedApexProperties, "Selected_apex")
android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon)
@@ -680,6 +680,9 @@
createApexExtractorModule(ctx, apexExtractorModuleName, &module.properties.ApexExtractorProperties)
apexFileSource := ":" + apexExtractorModuleName
+ if len(module.deapexerProperties.Exported_java_libs) != 0 {
+ createDeapexerModule(ctx, deapexerModuleName(baseModuleName), apexFileSource, &module.deapexerProperties)
+ }
// After passing the arch specific src properties to the creating the apex selector module
module.selectedApexProperties.Selected_apex = proptools.StringPtr(apexFileSource)
@@ -705,6 +708,16 @@
return baseModuleName + ".apex.extractor"
}
+func (a *ApexSet) DepsMutator(ctx android.BottomUpMutatorContext) {
+ a.deapexerDeps(ctx)
+}
+
+var _ ApexInfoMutator = (*ApexSet)(nil)
+
+func (a *ApexSet) ApexInfoMutator(mctx android.TopDownMutatorContext) {
+ a.apexInfoMutator(mctx)
+}
+
func (a *ApexSet) GenerateAndroidBuildActions(ctx android.ModuleContext) {
a.installFilename = a.InstallFilename()
if !strings.HasSuffix(a.installFilename, imageApexSuffix) {
diff --git a/bazel/cquery/request_type.go b/bazel/cquery/request_type.go
index affb5ce..4a64c51 100644
--- a/bazel/cquery/request_type.go
+++ b/bazel/cquery/request_type.go
@@ -5,8 +5,8 @@
)
var (
- GetOutputFiles RequestType = &getOutputFilesRequestType{}
- GetOutputFilesAndCcObjectFiles RequestType = &getOutputFilesAndCcObjectFilesType{}
+ GetOutputFiles = &getOutputFilesRequestType{}
+ GetOutputFilesAndCcObjectFiles = &getOutputFilesAndCcObjectFilesType{}
)
type GetOutputFilesAndCcObjectFiles_Result struct {
@@ -14,49 +14,49 @@
CcObjectFiles []string
}
-type RequestType interface {
- // Name returns a string name for this request type. Such request type names must be unique,
- // and must only consist of alphanumeric characters.
- Name() string
-
- // StarlarkFunctionBody returns a straark function body to process this request type.
- // The returned string is the body of a Starlark function which obtains
- // all request-relevant information about a target and returns a string containing
- // this information.
- // The function should have the following properties:
- // - `target` is the only parameter to this function (a configured target).
- // - The return value must be a string.
- // - The function body should not be indented outside of its own scope.
- StarlarkFunctionBody() string
-
- // ParseResult returns a value obtained by parsing the result of the request's Starlark function.
- // The given rawString must correspond to the string output which was created by evaluating the
- // Starlark given in StarlarkFunctionBody.
- // The type of this value depends on the request type; it is up to the caller to
- // cast to the correct type.
- ParseResult(rawString string) interface{}
-}
-
type getOutputFilesRequestType struct{}
+// Name returns a string name for this request type. Such request type names must be unique,
+// and must only consist of alphanumeric characters.
func (g getOutputFilesRequestType) Name() string {
return "getOutputFiles"
}
+// StarlarkFunctionBody returns a starlark function body to process this request type.
+// The returned string is the body of a Starlark function which obtains
+// all request-relevant information about a target and returns a string containing
+// this information.
+// The function should have the following properties:
+// - `target` is the only parameter to this function (a configured target).
+// - The return value must be a string.
+// - The function body should not be indented outside of its own scope.
func (g getOutputFilesRequestType) StarlarkFunctionBody() string {
return "return ', '.join([f.path for f in target.files.to_list()])"
}
-func (g getOutputFilesRequestType) ParseResult(rawString string) interface{} {
+// ParseResult returns a value obtained by parsing the result of the request's Starlark function.
+// The given rawString must correspond to the string output which was created by evaluating the
+// Starlark given in StarlarkFunctionBody.
+func (g getOutputFilesRequestType) ParseResult(rawString string) []string {
return strings.Split(rawString, ", ")
}
type getOutputFilesAndCcObjectFilesType struct{}
+// Name returns a string name for this request type. Such request type names must be unique,
+// and must only consist of alphanumeric characters.
func (g getOutputFilesAndCcObjectFilesType) Name() string {
return "getOutputFilesAndCcObjectFiles"
}
+// StarlarkFunctionBody returns a starlark function body to process this request type.
+// The returned string is the body of a Starlark function which obtains
+// all request-relevant information about a target and returns a string containing
+// this information.
+// The function should have the following properties:
+// - `target` is the only parameter to this function (a configured target).
+// - The return value must be a string.
+// - The function body should not be indented outside of its own scope.
func (g getOutputFilesAndCcObjectFilesType) StarlarkFunctionBody() string {
return `
outputFiles = [f.path for f in target.files.to_list()]
@@ -71,7 +71,10 @@
return ', '.join(outputFiles) + "|" + ', '.join(ccObjectFiles)`
}
-func (g getOutputFilesAndCcObjectFilesType) ParseResult(rawString string) interface{} {
+// ParseResult returns a value obtained by parsing the result of the request's Starlark function.
+// The given rawString must correspond to the string output which was created by evaluating the
+// Starlark given in StarlarkFunctionBody.
+func (g getOutputFilesAndCcObjectFilesType) ParseResult(rawString string) GetOutputFilesAndCcObjectFiles_Result {
var outputFiles []string
var ccObjects []string