summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apex/allowed_deps.txt4
-rw-r--r--apex/builder.go2
-rw-r--r--java/java_test.go13
-rw-r--r--java/sdk.go2
-rw-r--r--java/testing.go2
-rw-r--r--python/python.go12
-rw-r--r--sh/Android.bp1
-rw-r--r--sh/sh_binary.go109
-rw-r--r--sh/sh_binary_test.go114
9 files changed, 257 insertions, 2 deletions
diff --git a/apex/allowed_deps.txt b/apex/allowed_deps.txt
index b73dbc8cd..f76584ea1 100644
--- a/apex/allowed_deps.txt
+++ b/apex/allowed_deps.txt
@@ -165,10 +165,12 @@ crtend_android(minSdkVersion:apex_inherit)
crtend_so(minSdkVersion:apex_inherit)
datastallprotosnano(minSdkVersion:29)
datastallprotosnano(minSdkVersion:current)
+derive_classpath(minSdkVersion:30)
derive_sdk(minSdkVersion:30)
derive_sdk(minSdkVersion:current)
derive_sdk_prefer32(minSdkVersion:30)
derive_sdk_prefer32(minSdkVersion:current)
+dnsresolver_aidl_interface-lateststable-ndk_platform(minSdkVersion:29)
dnsresolver_aidl_interface-ndk_platform(minSdkVersion:29)
dnsresolver_aidl_interface-unstable-ndk_platform(minSdkVersion:29)
DocumentsUI-res-lib(minSdkVersion:29)
@@ -302,6 +304,7 @@ libcrypto_utils(minSdkVersion:(no version))
libcutils(minSdkVersion:29)
libcutils_headers(minSdkVersion:29)
libcutils_sockets(minSdkVersion:29)
+libderive_classpath(minSdkVersion:30)
libderive_sdk(minSdkVersion:30)
libdiagnose_usb(minSdkVersion:(no version))
libdl(minSdkVersion:(no version))
@@ -482,6 +485,7 @@ netd_aidl_interface-unstable-java(minSdkVersion:29)
netd_aidl_interface-V3-java(minSdkVersion:29)
netd_event_listener_interface-java(minSdkVersion:29)
netd_event_listener_interface-lateststable-java(minSdkVersion:29)
+netd_event_listener_interface-lateststable-ndk_platform(minSdkVersion:29)
netd_event_listener_interface-ndk_platform(minSdkVersion:29)
netlink-client(minSdkVersion:29)
netlink-client(minSdkVersion:current)
diff --git a/apex/builder.go b/apex/builder.go
index 8a11fe610..ea69e09ce 100644
--- a/apex/builder.go
+++ b/apex/builder.go
@@ -577,7 +577,7 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
var libNames []string
for _, f := range a.filesInfo {
if f.class == nativeSharedLib {
- libNames = append(libNames, f.stem)
+ libNames = append(libNames, f.Stem())
}
}
apisBackedbyOutputFile := android.PathForModuleOut(ctx, a.Name()+"_backing.txt")
diff --git a/java/java_test.go b/java/java_test.go
index fc8dd7ecb..c93dddee2 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -1303,6 +1303,12 @@ func TestJavaSdkLibrary(t *testing.T) {
libs: ["foo"],
sdk_version: "system_29",
}
+ java_library {
+ name: "baz-module-30",
+ srcs: ["c.java"],
+ libs: ["foo"],
+ sdk_version: "module_30",
+ }
`)
// check the existence of the internal modules
@@ -1349,6 +1355,13 @@ func TestJavaSdkLibrary(t *testing.T) {
"prebuilts/sdk/29/system/foo.jar")
}
+ bazModule30Javac := ctx.ModuleForTests("baz-module-30", "android_common").Rule("javac")
+ // tests if "baz-module-30" is actually linked to the module 30 stubs lib
+ if !strings.Contains(bazModule30Javac.Args["classpath"], "prebuilts/sdk/30/module-lib/foo.jar") {
+ t.Errorf("baz-module-30 javac classpath %v does not contain %q", bazModule30Javac.Args["classpath"],
+ "prebuilts/sdk/30/module-lib/foo.jar")
+ }
+
// test if baz has exported SDK lib names foo and bar to qux
qux := ctx.ModuleForTests("qux", "android_common")
if quxLib, ok := qux.Module().(*Library); ok {
diff --git a/java/sdk.go b/java/sdk.go
index 6c1665180..5a6c53050 100644
--- a/java/sdk.go
+++ b/java/sdk.go
@@ -215,7 +215,7 @@ func (s sdkSpec) usePrebuilt(ctx android.EarlyModuleContext) bool {
return ctx.Config().UnbundledBuildUsePrebuiltSdks()
} else if s.version.isNumbered() {
// sanity check
- if s.kind != sdkPublic && s.kind != sdkSystem && s.kind != sdkTest {
+ if s.kind != sdkPublic && s.kind != sdkSystem && s.kind != sdkTest && s.kind != sdkModule {
panic(fmt.Errorf("prebuilt SDK is not not available for sdkKind=%q", s.kind))
return false
}
diff --git a/java/testing.go b/java/testing.go
index 6b105bdaa..f373d7718 100644
--- a/java/testing.go
+++ b/java/testing.go
@@ -46,6 +46,8 @@ func TestConfig(buildDir string, env map[string]string, bp string, fs map[string
"prebuilts/sdk/30/public/framework.aidl": nil,
"prebuilts/sdk/30/system/android.jar": nil,
"prebuilts/sdk/30/system/foo.jar": nil,
+ "prebuilts/sdk/30/module-lib/android.jar": nil,
+ "prebuilts/sdk/30/module-lib/foo.jar": nil,
"prebuilts/sdk/30/public/core-for-system-modules.jar": nil,
"prebuilts/sdk/current/core/android.jar": nil,
"prebuilts/sdk/current/public/android.jar": nil,
diff --git a/python/python.go b/python/python.go
index 4e15d3a07..83ce42d02 100644
--- a/python/python.go
+++ b/python/python.go
@@ -251,6 +251,18 @@ func (p *Module) HostToolPath() android.OptionalPath {
return android.OptionalPathForPath(p.installer.(*binaryDecorator).path)
}
+func (p *Module) OutputFiles(tag string) (android.Paths, error) {
+ switch tag {
+ case "":
+ if outputFile := p.installSource; outputFile.Valid() {
+ return android.Paths{outputFile.Path()}, nil
+ }
+ return android.Paths{}, nil
+ default:
+ return nil, fmt.Errorf("unsupported module reference tag %q", tag)
+ }
+}
+
func (p *Module) isEmbeddedLauncherEnabled(actual_version string) bool {
switch actual_version {
case pyVersion2:
diff --git a/sh/Android.bp b/sh/Android.bp
index 0f40c5f68..e5ffeefb4 100644
--- a/sh/Android.bp
+++ b/sh/Android.bp
@@ -5,6 +5,7 @@ bootstrap_go_package {
"blueprint",
"soong",
"soong-android",
+ "soong-cc",
"soong-tradefed",
],
srcs: [
diff --git a/sh/sh_binary.go b/sh/sh_binary.go
index d8e324409..5272d41a7 100644
--- a/sh/sh_binary.go
+++ b/sh/sh_binary.go
@@ -17,11 +17,14 @@ package sh
import (
"fmt"
"path/filepath"
+ "sort"
"strings"
+ "github.com/google/blueprint"
"github.com/google/blueprint/proptools"
"android/soong/android"
+ "android/soong/cc"
"android/soong/tradefed"
)
@@ -88,6 +91,20 @@ type TestProperties struct {
// doesn't exist next to the Android.bp, this attribute doesn't need to be set to true
// explicitly.
Auto_gen_config *bool
+
+ // list of binary modules that should be installed alongside the test
+ Data_bins []string `android:"path,arch_variant"`
+
+ // list of library modules that should be installed alongside the test
+ Data_libs []string `android:"path,arch_variant"`
+
+ // list of device binary modules that should be installed alongside the test.
+ // Only available for host sh_test modules.
+ Data_device_bins []string `android:"path,arch_variant"`
+
+ // list of device library modules that should be installed alongside the test.
+ // Only available for host sh_test modules.
+ Data_device_libs []string `android:"path,arch_variant"`
}
type ShBinary struct {
@@ -109,6 +126,8 @@ type ShTest struct {
data android.Paths
testConfig android.Path
+
+ dataModules map[string]android.Path
}
func (s *ShBinary) HostToolPath() android.OptionalPath {
@@ -190,6 +209,50 @@ func (s *ShBinary) customAndroidMkEntries(entries *android.AndroidMkEntries) {
}
}
+type dependencyTag struct {
+ blueprint.BaseDependencyTag
+ name string
+}
+
+var (
+ shTestDataBinsTag = dependencyTag{name: "dataBins"}
+ shTestDataLibsTag = dependencyTag{name: "dataLibs"}
+ shTestDataDeviceBinsTag = dependencyTag{name: "dataDeviceBins"}
+ shTestDataDeviceLibsTag = dependencyTag{name: "dataDeviceLibs"}
+)
+
+var sharedLibVariations = []blueprint.Variation{{Mutator: "link", Variation: "shared"}}
+
+func (s *ShTest) DepsMutator(ctx android.BottomUpMutatorContext) {
+ s.ShBinary.DepsMutator(ctx)
+
+ 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 && len(ctx.Config().Targets[android.Android]) > 0 {
+ deviceVariations := ctx.Config().Targets[android.Android][0].Variations()
+ ctx.AddFarVariationDependencies(deviceVariations, shTestDataDeviceBinsTag, s.testProperties.Data_device_bins...)
+ ctx.AddFarVariationDependencies(append(deviceVariations, sharedLibVariations...),
+ shTestDataDeviceLibsTag, s.testProperties.Data_device_libs...)
+ } else if ctx.Target().Os.Class != android.Host {
+ if len(s.testProperties.Data_device_bins) > 0 {
+ ctx.PropertyErrorf("data_device_bins", "only available for host modules")
+ }
+ if len(s.testProperties.Data_device_libs) > 0 {
+ ctx.PropertyErrorf("data_device_libs", "only available for host modules")
+ }
+ }
+}
+
+func (s *ShTest) addToDataModules(ctx android.ModuleContext, relPath string, path android.Path) {
+ if _, exists := s.dataModules[relPath]; exists {
+ ctx.ModuleErrorf("data modules have a conflicting installation path, %v - %s, %s",
+ relPath, s.dataModules[relPath].String(), path.String())
+ return
+ }
+ s.dataModules[relPath] = path
+}
+
func (s *ShTest) GenerateAndroidBuildActions(ctx android.ModuleContext) {
s.ShBinary.generateAndroidBuildActions(ctx)
testDir := "nativetest"
@@ -215,6 +278,43 @@ func (s *ShTest) GenerateAndroidBuildActions(ctx android.ModuleContext) {
}
s.testConfig = tradefed.AutoGenShellTestConfig(ctx, s.testProperties.Test_config,
s.testProperties.Test_config_template, s.testProperties.Test_suites, configs, s.testProperties.Auto_gen_config, s.outputFilePath.Base())
+
+ s.dataModules = make(map[string]android.Path)
+ ctx.VisitDirectDeps(func(dep android.Module) {
+ depTag := ctx.OtherModuleDependencyTag(dep)
+ switch depTag {
+ case shTestDataBinsTag, shTestDataDeviceBinsTag:
+ path := android.OutputFileForModule(ctx, dep, "")
+ s.addToDataModules(ctx, path.Base(), path)
+ case shTestDataLibsTag, shTestDataDeviceLibsTag:
+ if cc, isCc := dep.(*cc.Module); isCc {
+ // Copy to an intermediate output directory to append "lib[64]" to the path,
+ // so that it's compatible with the default rpath values.
+ var relPath string
+ if cc.Arch().ArchType.Multilib == "lib64" {
+ relPath = filepath.Join("lib64", cc.OutputFile().Path().Base())
+ } else {
+ relPath = filepath.Join("lib", cc.OutputFile().Path().Base())
+ }
+ if _, exist := s.dataModules[relPath]; exist {
+ return
+ }
+ relocatedLib := android.PathForModuleOut(ctx, "relocated", relPath)
+ ctx.Build(pctx, android.BuildParams{
+ Rule: android.Cp,
+ Input: cc.OutputFile().Path(),
+ Output: relocatedLib,
+ })
+ s.addToDataModules(ctx, relPath, relocatedLib)
+ return
+ }
+ property := "data_libs"
+ if depTag == shTestDataDeviceBinsTag {
+ property = "data_device_libs"
+ }
+ ctx.PropertyErrorf(property, "%q of type %q is not supported", dep.Name(), ctx.OtherModuleType(dep))
+ }
+ })
}
func (s *ShTest) InstallInData() bool {
@@ -242,6 +342,15 @@ func (s *ShTest) AndroidMkEntries() []android.AndroidMkEntries {
path = strings.TrimSuffix(path, rel)
entries.AddStrings("LOCAL_TEST_DATA", path+":"+rel)
}
+ relPaths := make([]string, 0)
+ for relPath, _ := range s.dataModules {
+ relPaths = append(relPaths, relPath)
+ }
+ sort.Strings(relPaths)
+ for _, relPath := range relPaths {
+ dir := strings.TrimSuffix(s.dataModules[relPath].String(), relPath)
+ entries.AddStrings("LOCAL_TEST_DATA", dir+":"+relPath)
+ }
},
},
}}
diff --git a/sh/sh_binary_test.go b/sh/sh_binary_test.go
index 6c0d96abe..232a28133 100644
--- a/sh/sh_binary_test.go
+++ b/sh/sh_binary_test.go
@@ -3,10 +3,12 @@ package sh
import (
"io/ioutil"
"os"
+ "path/filepath"
"reflect"
"testing"
"android/soong/android"
+ "android/soong/cc"
)
var buildDir string
@@ -46,6 +48,9 @@ func testShBinary(t *testing.T, bp string) (*android.TestContext, android.Config
ctx := android.NewTestArchContext()
ctx.RegisterModuleType("sh_test", ShTestFactory)
ctx.RegisterModuleType("sh_test_host", ShTestHostFactory)
+
+ cc.RegisterRequiredBuildComponentsForTest(ctx)
+
ctx.Register(config)
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
android.FailIfErrored(t, errs)
@@ -78,6 +83,65 @@ func TestShTestTestData(t *testing.T) {
}
}
+func TestShTest_dataModules(t *testing.T) {
+ ctx, config := testShBinary(t, `
+ sh_test {
+ name: "foo",
+ src: "test.sh",
+ host_supported: true,
+ data_bins: ["bar"],
+ data_libs: ["libbar"],
+ }
+
+ cc_binary {
+ name: "bar",
+ host_supported: true,
+ shared_libs: ["libbar"],
+ no_libcrt: true,
+ nocrt: true,
+ system_shared_libs: [],
+ stl: "none",
+ }
+
+ cc_library {
+ name: "libbar",
+ host_supported: true,
+ no_libcrt: true,
+ nocrt: true,
+ system_shared_libs: [],
+ stl: "none",
+ }
+ `)
+
+ buildOS := android.BuildOs.String()
+ arches := []string{"android_arm64_armv8-a", buildOS + "_x86_64"}
+ for _, arch := range arches {
+ variant := ctx.ModuleForTests("foo", arch)
+
+ libExt := ".so"
+ if arch == "darwin_x86_64" {
+ libExt = ".dylib"
+ }
+ relocated := variant.Output("relocated/lib64/libbar" + libExt)
+ expectedInput := filepath.Join(buildDir, ".intermediates/libbar/"+arch+"_shared/libbar"+libExt)
+ if relocated.Input.String() != expectedInput {
+ t.Errorf("Unexpected relocation input, expected: %q, actual: %q",
+ expectedInput, relocated.Input.String())
+ }
+
+ mod := variant.Module().(*ShTest)
+ entries := android.AndroidMkEntriesForTest(t, config, "", mod)[0]
+ expectedData := []string{
+ filepath.Join(buildDir, ".intermediates/bar", arch, ":bar"),
+ filepath.Join(buildDir, ".intermediates/foo", arch, "relocated/:lib64/libbar"+libExt),
+ }
+ actualData := entries.EntryMap["LOCAL_TEST_DATA"]
+ if !reflect.DeepEqual(expectedData, actualData) {
+ t.Errorf("Unexpected test data, expected: %q, actual: %q", expectedData, actualData)
+ }
+ }
+}
+
func TestShTestHost(t *testing.T) {
ctx, _ := testShBinary(t, `
sh_test_host {
@@ -97,3 +161,53 @@ func TestShTestHost(t *testing.T) {
t.Errorf("host bit is not set for a sh_test_host module.")
}
}
+
+func TestShTestHost_dataDeviceModules(t *testing.T) {
+ ctx, config := testShBinary(t, `
+ sh_test_host {
+ name: "foo",
+ src: "test.sh",
+ data_device_bins: ["bar"],
+ data_device_libs: ["libbar"],
+ }
+
+ cc_binary {
+ name: "bar",
+ shared_libs: ["libbar"],
+ no_libcrt: true,
+ nocrt: true,
+ system_shared_libs: [],
+ stl: "none",
+ }
+
+ cc_library {
+ name: "libbar",
+ no_libcrt: true,
+ nocrt: true,
+ system_shared_libs: [],
+ stl: "none",
+ }
+ `)
+
+ buildOS := android.BuildOs.String()
+ variant := ctx.ModuleForTests("foo", buildOS+"_x86_64")
+
+ relocated := variant.Output("relocated/lib64/libbar.so")
+ expectedInput := filepath.Join(buildDir, ".intermediates/libbar/android_arm64_armv8-a_shared/libbar.so")
+ if relocated.Input.String() != expectedInput {
+ t.Errorf("Unexpected relocation input, expected: %q, actual: %q",
+ expectedInput, relocated.Input.String())
+ }
+
+ mod := variant.Module().(*ShTest)
+ entries := android.AndroidMkEntriesForTest(t, config, "", mod)[0]
+ expectedData := []string{
+ filepath.Join(buildDir, ".intermediates/bar/android_arm64_armv8-a/:bar"),
+ // libbar has been relocated, and so has a variant that matches the host arch.
+ filepath.Join(buildDir, ".intermediates/foo/"+buildOS+"_x86_64/relocated/:lib64/libbar.so"),
+ }
+ actualData := entries.EntryMap["LOCAL_TEST_DATA"]
+ if !reflect.DeepEqual(expectedData, actualData) {
+ t.Errorf("Unexpected test data, expected: %q, actual: %q", expectedData, actualData)
+ }
+}