Expose avb_hash_algorithm as a property. am: f3d1e8c24c
Original change: https://googleplex-android-review.googlesource.com/c/platform/build/soong/+/21142901
Change-Id: I803583f5739d487468746ab38720fbe32f96f003
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/android/arch.go b/android/arch.go
index cbf77c7..3587b46 100644
--- a/android/arch.go
+++ b/android/arch.go
@@ -655,7 +655,8 @@
prefer32 := os == Windows
// Determine the multilib selection for this module.
- multilib, extraMultilib := decodeMultilib(base, os)
+ force_first_on_device := mctx.Config().ForceMultilibFirstOnDevice()
+ multilib, extraMultilib := decodeMultilib(base, os, force_first_on_device)
// Convert the multilib selection into a list of Targets.
targets, err := decodeMultilibTargets(multilib, osTargets, prefer32)
@@ -730,7 +731,7 @@
// multilib from the factory's call to InitAndroidArchModule if none was set. For modules that
// called InitAndroidMultiTargetsArchModule it always returns "common" for multilib, and returns
// the actual multilib in extraMultilib.
-func decodeMultilib(base *ModuleBase, os OsType) (multilib, extraMultilib string) {
+func decodeMultilib(base *ModuleBase, os OsType, force_first_on_device bool) (multilib, extraMultilib string) {
// First check the "android.compile_multilib" or "host.compile_multilib" properties.
switch os.Class {
case Device:
@@ -749,6 +750,13 @@
multilib = base.commonProperties.Default_multilib
}
+ // If a device is configured with multiple targets, this option
+ // force all device targets that prefer32 to be compiled only as
+ // the first target.
+ if force_first_on_device && os.Class == Device && (multilib == "prefer32" || multilib == "first_prefer32") {
+ multilib = "first"
+ }
+
if base.commonProperties.UseTargetVariants {
// Darwin has the concept of "universal binaries" which is implemented in Soong by
// building both x86_64 and arm64 variants, and having select module types know how to
diff --git a/android/config.go b/android/config.go
index ba95c5a..3c99659 100644
--- a/android/config.go
+++ b/android/config.go
@@ -1701,6 +1701,10 @@
return c.config.productVariables.GenerateAidlNdkPlatformBackend
}
+func (c *config) ForceMultilibFirstOnDevice() bool {
+ return c.productVariables.ForceMultilibFirstOnDevice
+}
+
// The ConfiguredJarList struct provides methods for handling a list of (apex, jar) pairs.
// Such lists are used in the build system for things like bootclasspath jars or system server jars.
// The apex part is either an apex name, or a special names "platform" or "system_ext". Jar is a
diff --git a/android/variable.go b/android/variable.go
index 373891a..4420684 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -443,6 +443,8 @@
SepolicyFreezeTestExtraPrebuiltDirs []string `json:",omitempty"`
GenerateAidlNdkPlatformBackend bool `json:",omitempty"`
+
+ ForceMultilibFirstOnDevice bool `json:",omitempty"`
}
func boolPtr(v bool) *bool {
diff --git a/ui/build/build.go b/ui/build/build.go
index ec42b70..aadf4af 100644
--- a/ui/build/build.go
+++ b/ui/build/build.go
@@ -266,7 +266,6 @@
}
if config.StartRBE() {
- cleanupRBELogsDir(ctx, config)
startRBE(ctx, config)
defer DumpRBEMetrics(ctx, config, filepath.Join(config.LogsDir(), "rbe_metrics.pb"))
}
diff --git a/ui/build/config.go b/ui/build/config.go
index 5765f21..e271bfc 100644
--- a/ui/build/config.go
+++ b/ui/build/config.go
@@ -19,14 +19,12 @@
"encoding/json"
"fmt"
"io/ioutil"
- "math/rand"
"os"
"os/exec"
"path/filepath"
"runtime"
"strconv"
"strings"
- "syscall"
"time"
"android/soong/shared"
@@ -44,15 +42,6 @@
envConfigFetchTimeout = 10 * time.Second
)
-var (
- rbeRandPrefix int
-)
-
-func init() {
- rand.Seed(time.Now().UnixNano())
- rbeRandPrefix = rand.Intn(1000)
-}
-
type Config struct{ *configImpl }
type configImpl struct {
@@ -1155,25 +1144,34 @@
return true
}
-func (c *configImpl) rbeProxyLogsDir() string {
- for _, f := range []string{"RBE_proxy_log_dir", "FLAG_output_dir"} {
+func (c *configImpl) rbeLogDir() string {
+ for _, f := range []string{"RBE_log_dir", "FLAG_log_dir"} {
if v, ok := c.environ.Get(f); ok {
return v
}
}
- buildTmpDir := shared.TempDirForOutDir(c.SoongOutDir())
- return filepath.Join(buildTmpDir, "rbe")
+ if c.Dist() {
+ return c.LogsDir()
+ }
+ return c.OutDir()
}
-func (c *configImpl) shouldCleanupRBELogsDir() bool {
- // Perform a log directory cleanup only when the log directory
- // is auto created by the build rather than user-specified.
- for _, f := range []string{"RBE_proxy_log_dir", "FLAG_output_dir"} {
- if _, ok := c.environ.Get(f); ok {
- return false
+func (c *configImpl) rbeStatsOutputDir() string {
+ for _, f := range []string{"RBE_output_dir", "FLAG_output_dir"} {
+ if v, ok := c.environ.Get(f); ok {
+ return v
}
}
- return true
+ return c.rbeLogDir()
+}
+
+func (c *configImpl) rbeLogPath() string {
+ for _, f := range []string{"RBE_log_path", "FLAG_log_path"} {
+ if v, ok := c.environ.Get(f); ok {
+ return v
+ }
+ }
+ return fmt.Sprintf("text://%v/reproxy_log.txt", c.rbeLogDir())
}
func (c *configImpl) rbeExecRoot() string {
@@ -1225,23 +1223,6 @@
return "RBE_use_application_default_credentials", "true"
}
-func (c *configImpl) rbeSockAddr(dir string) (string, error) {
- maxNameLen := len(syscall.RawSockaddrUnix{}.Path)
- base := fmt.Sprintf("reproxy_%v.sock", rbeRandPrefix)
-
- name := filepath.Join(dir, base)
- if len(name) < maxNameLen {
- return name, nil
- }
-
- name = filepath.Join("/tmp", base)
- if len(name) < maxNameLen {
- return name, nil
- }
-
- return "", fmt.Errorf("cannot generate a proxy socket address shorter than the limit of %v", maxNameLen)
-}
-
func (c *configImpl) UseRemoteBuild() bool {
return c.UseGoma() || c.UseRBE()
}
diff --git a/ui/build/rbe.go b/ui/build/rbe.go
index 3e558f7..8f9a699 100644
--- a/ui/build/rbe.go
+++ b/ui/build/rbe.go
@@ -16,9 +16,12 @@
import (
"fmt"
+ "math/rand"
"os"
"path/filepath"
"runtime"
+ "syscall"
+ "time"
"android/soong/ui/metrics"
)
@@ -51,16 +54,34 @@
return cmdPath
}
+func sockAddr(dir string) (string, error) {
+ maxNameLen := len(syscall.RawSockaddrUnix{}.Path)
+ rand.Seed(time.Now().UnixNano())
+ base := fmt.Sprintf("reproxy_%v.sock", rand.Intn(1000))
+
+ name := filepath.Join(dir, base)
+ if len(name) < maxNameLen {
+ return name, nil
+ }
+
+ name = filepath.Join("/tmp", base)
+ if len(name) < maxNameLen {
+ return name, nil
+ }
+
+ return "", fmt.Errorf("cannot generate a proxy socket address shorter than the limit of %v", maxNameLen)
+}
+
func getRBEVars(ctx Context, config Config) map[string]string {
vars := map[string]string{
- "RBE_log_dir": config.rbeProxyLogsDir(),
+ "RBE_log_path": config.rbeLogPath(),
+ "RBE_log_dir": config.rbeLogDir(),
"RBE_re_proxy": config.rbeReproxy(),
"RBE_exec_root": config.rbeExecRoot(),
- "RBE_output_dir": config.rbeProxyLogsDir(),
- "RBE_proxy_log_dir": config.rbeProxyLogsDir(),
+ "RBE_output_dir": config.rbeStatsOutputDir(),
}
if config.StartRBE() {
- name, err := config.rbeSockAddr(absPath(ctx, config.TempDir()))
+ name, err := sockAddr(absPath(ctx, config.TempDir()))
if err != nil {
ctx.Fatalf("Error retrieving socket address: %v", err)
return nil
@@ -79,17 +100,6 @@
return vars
}
-func cleanupRBELogsDir(ctx Context, config Config) {
- if !config.shouldCleanupRBELogsDir() {
- return
- }
-
- rbeTmpDir := config.rbeProxyLogsDir()
- if err := os.RemoveAll(rbeTmpDir); err != nil {
- fmt.Fprintln(ctx.Writer, "\033[33mUnable to remove RBE log directory: ", err, "\033[0m")
- }
-}
-
func startRBE(ctx Context, config Config) {
ctx.BeginTrace(metrics.RunSetupTool, "rbe_bootstrap")
defer ctx.EndTrace()
@@ -100,11 +110,6 @@
if n := ulimitOrFatal(ctx, config, "-n"); n < rbeLeastNFiles {
ctx.Fatalf("max open files is insufficient: %d; want >= %d.\n", n, rbeLeastNFiles)
}
- if _, err := os.Stat(config.rbeProxyLogsDir()); os.IsNotExist(err) {
- if err := os.MkdirAll(config.rbeProxyLogsDir(), 0744); err != nil {
- ctx.Fatalf("Unable to create logs dir (%v) for RBE: %v", config.rbeProxyLogsDir, err)
- }
- }
cmd := Command(ctx, config, "startRBE bootstrap", rbeCommand(ctx, config, bootstrapCmd))
@@ -146,7 +151,7 @@
return
}
- outputDir := config.rbeProxyLogsDir()
+ outputDir := config.rbeStatsOutputDir()
if outputDir == "" {
ctx.Fatal("RBE output dir variable not defined. Aborting metrics dumping.")
}
diff --git a/ui/build/rbe_test.go b/ui/build/rbe_test.go
index 266f76b..8ff96bc 100644
--- a/ui/build/rbe_test.go
+++ b/ui/build/rbe_test.go
@@ -56,8 +56,7 @@
env := Environment(tt.env)
env.Set("OUT_DIR", tmpDir)
env.Set("RBE_DIR", tmpDir)
- env.Set("RBE_output_dir", tmpDir)
- env.Set("RBE_proxy_log_dir", tmpDir)
+ env.Set("RBE_output_dir", t.TempDir())
config := Config{&configImpl{
environ: &env,
}}