Merge changes Ib104a639,I7905581d into main
* changes:
Always use out/host for host tools
Move build_hostname.txt generation to SetupOutDir
diff --git a/android/test_asserts.go b/android/test_asserts.go
index c33ade5..22472c5 100644
--- a/android/test_asserts.go
+++ b/android/test_asserts.go
@@ -33,6 +33,23 @@
}
}
+// AssertSame checks if the expected and actual values are equal and if they are not then
+// it reports an error prefixed with the supplied message and including a reason for why it failed.
+func AssertSameArray[T comparable](t *testing.T, message string, expected []T, actual []T) {
+ t.Helper()
+ if len(actual) != len(expected) {
+ t.Errorf("%s: expected %d (%v), actual (%d) %v", message, len(expected), expected, len(actual), actual)
+ return
+ }
+ for i := range actual {
+ if actual[i] != expected[i] {
+ t.Errorf("%s: expected %d-th, %v (%v), actual %v (%v)",
+ message, i, expected[i], expected, actual[i], actual)
+ return
+ }
+ }
+}
+
// AssertBoolEquals checks if the expected and actual values are equal and if they are not then it
// reports an error prefixed with the supplied message and including a reason for why it failed.
func AssertBoolEquals(t *testing.T, message string, expected bool, actual bool) {
diff --git a/cc/cc.go b/cc/cc.go
index 97d4533..c9d2926 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -92,6 +92,7 @@
type BinaryDecoratorInfo struct{}
type LibraryDecoratorInfo struct {
ExportIncludeDirs proptools.Configurable[[]string]
+ InjectBsslHash bool
}
type LibraryInfo struct {
@@ -2220,7 +2221,9 @@
case *binaryDecorator:
ccInfo.LinkerInfo.BinaryDecoratorInfo = &BinaryDecoratorInfo{}
case *libraryDecorator:
- ccInfo.LinkerInfo.LibraryDecoratorInfo = &LibraryDecoratorInfo{}
+ ccInfo.LinkerInfo.LibraryDecoratorInfo = &LibraryDecoratorInfo{
+ InjectBsslHash: Bool(c.linker.(*libraryDecorator).Properties.Inject_bssl_hash),
+ }
case *testBinary:
ccInfo.LinkerInfo.TestBinaryInfo = &TestBinaryInfo{
Gtest: decorator.testDecorator.gtest(),
diff --git a/cc/library.go b/cc/library.go
index c9114fd..5c2cb5d 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -1195,7 +1195,7 @@
library.linkSAbiDumpFiles(ctx, deps, objs, fileName, unstrippedOutputFile)
var transitiveStaticLibrariesForOrdering depset.DepSet[android.Path]
- if static := ctx.GetDirectDepsWithTag(staticVariantTag); len(static) > 0 {
+ if static := ctx.GetDirectDepsProxyWithTag(staticVariantTag); len(static) > 0 {
s, _ := android.OtherModuleProvider(ctx, static[0], StaticLibraryInfoProvider)
transitiveStaticLibrariesForOrdering = s.TransitiveStaticLibrariesForOrdering
}
@@ -2409,13 +2409,11 @@
inject *bool, fileName string) android.ModuleOutPath {
// TODO(b/137267623): Remove this in favor of a cc_genrule when they support operating on shared libraries.
injectBoringSSLHash := Bool(inject)
- ctx.VisitDirectDeps(func(dep android.Module) {
+ ctx.VisitDirectDepsProxy(func(dep android.ModuleProxy) {
if tag, ok := ctx.OtherModuleDependencyTag(dep).(libraryDependencyTag); ok && tag.static() {
- if cc, ok := dep.(*Module); ok {
- if library, ok := cc.linker.(*libraryDecorator); ok {
- if Bool(library.Properties.Inject_bssl_hash) {
- injectBoringSSLHash = true
- }
+ if ccInfo, ok := android.OtherModuleProvider(ctx, dep, CcInfoProvider); ok && ccInfo.LinkerInfo.LibraryDecoratorInfo != nil {
+ if ccInfo.LinkerInfo.LibraryDecoratorInfo.InjectBsslHash {
+ injectBoringSSLHash = true
}
}
}
diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go
index 43fd390..6dfbfd1 100644
--- a/filesystem/filesystem.go
+++ b/filesystem/filesystem.go
@@ -751,7 +751,10 @@
}
if timestamp := proptools.String(f.properties.Fake_timestamp); timestamp != "" {
addStr("timestamp", timestamp)
+ } else if ctx.Config().Getenv("USE_FIXED_TIMESTAMP_IMG_FILES") == "true" {
+ addStr("use_fixed_timestamp", "true")
}
+
if uuid := proptools.String(f.properties.Uuid); uuid != "" {
addStr("uuid", uuid)
addStr("hash_seed", uuid)
diff --git a/java/app.go b/java/app.go
index b0dcbb0..d56ea5f 100644
--- a/java/app.go
+++ b/java/app.go
@@ -1565,6 +1565,9 @@
}
a.generateAndroidBuildActions(ctx)
+ for _, c := range a.testProperties.Test_options.Tradefed_options {
+ configs = append(configs, c)
+ }
for _, module := range a.testProperties.Test_mainline_modules {
configs = append(configs, tradefed.Option{Name: "config-descriptor:metadata", Key: "mainline-param", Value: module})
}
diff --git a/java/app_test.go b/java/app_test.go
index 4e915d2..bde801b 100644
--- a/java/app_test.go
+++ b/java/app_test.go
@@ -18,6 +18,7 @@
"fmt"
"path/filepath"
"reflect"
+ "regexp"
"sort"
"strings"
"testing"
@@ -4589,6 +4590,75 @@
assertTestOnlyAndTopLevel(t, ctx, expectedTestOnly, expectedTopLevel)
}
+func TestTestConfigTemplate(t *testing.T) {
+ t.Parallel()
+ ctx := android.GroupFixturePreparers(
+ prepareForJavaTest,
+ ).RunTestWithBp(t, `
+ android_test {
+ name: "android-test",
+ test_config_template: "AndroidTestTemplate.xml",
+ test_options: {
+ tradefed_options: [
+ {
+ name: "name1",
+ key: "key1",
+ value: "value1",
+ },
+ {
+ name: "name2",
+ key: "key2",
+ value: "value2",
+ },
+ ],
+ test_runner_options: [
+ {
+ name: "name3",
+ key: "key3",
+ value: "value3",
+ },
+ {
+ name: "name4",
+ key: "key4",
+ value: "value4",
+ },
+ ],
+ },
+ }
+ `)
+ type option struct {
+ name string
+ key string
+ value string
+ }
+ re := regexp.MustCompile(`<option name="(.*)" key="(.*)" value="(.*)" />`)
+ parse_options := func(optionsString string) []option {
+ lines := strings.Split(optionsString, `\n`)
+ var ret []option
+ for _, l := range lines {
+ sm := re.FindStringSubmatch(l)
+ if sm == nil {
+ continue
+ }
+ ret = append(ret, option{sm[1], sm[2], sm[3]})
+ }
+ return ret
+ }
+ rule := ctx.ModuleForTests("android-test", "android_common").Rule("autogenInstrumentationTest")
+ android.AssertSameArray(t, "extraConfigs mismatch",
+ []option{
+ {"name1", "key1", "value1"},
+ {"name2", "key2", "value2"},
+ },
+ parse_options(rule.Args["extraConfigs"]))
+ android.AssertSameArray(t, "extraTestRunnerConfigs mismatch",
+ []option{
+ {"name3", "key3", "value3"},
+ {"name4", "key4", "value4"},
+ },
+ parse_options(rule.Args["extraTestRunnerConfigs"]))
+}
+
func TestAppStem(t *testing.T) {
ctx := testApp(t, `
android_app {
diff --git a/java/builder.go b/java/builder.go
index 88058e0..8d4d6af 100644
--- a/java/builder.go
+++ b/java/builder.go
@@ -56,7 +56,7 @@
`$zipTemplate${config.SoongZipCmd} -jar -o $out.tmp -C $outDir -D $outDir && ` +
`if ! cmp -s "$out.tmp" "$out"; then mv "$out.tmp" "$out"; fi && ` +
`if ! cmp -s "$annoSrcJar.tmp" "$annoSrcJar"; then mv "$annoSrcJar.tmp" "$annoSrcJar"; fi && ` +
- `if [[ -f "$out.pc_state.new" ]]; then mv "$out.pc_state.new" "$out.pc_state"; fi && ` +
+ `if [ -f "$out.pc_state.new" ]; then mv "$out.pc_state.new" "$out.pc_state"; fi && ` +
`rm -rf "$srcJarDir" "$outDir"`,
CommandDeps: []string{
"${config.FindInputDeltaCmd}",
diff --git a/java/kotlin.go b/java/kotlin.go
index e1a3f71..308bb03 100644
--- a/java/kotlin.go
+++ b/java/kotlin.go
@@ -198,7 +198,7 @@
`$kaptProcessor ` +
`-Xbuild-file=$kotlinBuildFile && ` +
`${config.SoongZipCmd} -jar -write_if_changed -o $out -C $kaptDir/stubs -D $kaptDir/stubs && ` +
- `if [[ -f "$out.pc_state.new" ]]; then mv "$out.pc_state.new" "$out.pc_state"; fi && ` +
+ `if [ -f "$out.pc_state.new" ]; then mv "$out.pc_state.new" "$out.pc_state"; fi && ` +
`rm -rf "$srcJarDir"`,
CommandDeps: []string{
"${config.FindInputDeltaCmd}",
diff --git a/java/lint.go b/java/lint.go
index ac90e19..9c6b93b 100644
--- a/java/lint.go
+++ b/java/lint.go
@@ -470,7 +470,7 @@
cmd := rule.Command()
- cmd.Flag(`JAVA_OPTS="-Xmx3072m --add-opens java.base/java.util=ALL-UNNAMED"`).
+ cmd.Flag(`JAVA_OPTS="-Xmx4096m --add-opens java.base/java.util=ALL-UNNAMED"`).
FlagWithArg("ANDROID_SDK_HOME=", lintPaths.homeDir.String()).
FlagWithInput("SDK_ANNOTATIONS=", annotationsZipPath).
FlagWithInput("LINT_OPTS=-DLINT_API_DATABASE=", apiVersionsXMLPath)