Start using the toybox prebuilt
Prepend the toybox symlink directory to $PATH, and stop generating
symlinks into out/.path for tools used from toybox.
We don't (yet?) have toybox prebuilts for darwin, so apply the above only to Linux, and preserve existing behavior on Darwin.
Test: check the build banner for uname results
Test: m
Change-Id: I37fc380381e65a628cdc131d462fd4441eacfe9d
diff --git a/ui/build/path.go b/ui/build/path.go
index 52658ef..8260ff9 100644
--- a/ui/build/path.go
+++ b/ui/build/path.go
@@ -19,6 +19,7 @@
"io/ioutil"
"os"
"path/filepath"
+ "runtime"
"strings"
"github.com/google/blueprint/microfactory"
@@ -144,6 +145,13 @@
}
myPath, _ = filepath.Abs(myPath)
+
+ // Use the toybox prebuilts on linux
+ if runtime.GOOS == "linux" {
+ toyboxPath, _ := filepath.Abs("prebuilts/build-tools/toybox/linux-x86")
+ myPath = toyboxPath + string(os.PathListSeparator) + myPath
+ }
+
config.Environment().Set("PATH", myPath)
config.pathReplaced = true
}
diff --git a/ui/build/paths/config.go b/ui/build/paths/config.go
index e846b03..b4d76c4 100644
--- a/ui/build/paths/config.go
+++ b/ui/build/paths/config.go
@@ -25,6 +25,10 @@
// Whether to exit with an error instead of invoking the underlying tool.
Error bool
+
+ // Whether we use a toybox prebuilt for this tool. Since we don't have
+ // toybox for Darwin, we'll use the host version instead.
+ Toybox bool
}
var Allowed = PathConfig{
@@ -55,6 +59,13 @@
Error: true,
}
+var Toybox = PathConfig{
+ Symlink: false,
+ Log: true,
+ Error: true,
+ Toybox: true,
+}
+
func GetConfig(name string) PathConfig {
if config, ok := Configuration[name]; ok {
return config
@@ -138,8 +149,6 @@
"todos": Allowed,
"touch": Allowed,
"tr": Allowed,
- "true": Allowed,
- "uname": Allowed,
"uniq": Allowed,
"unix2dos": Allowed,
"unzip": Allowed,
@@ -166,10 +175,9 @@
"ld.gold": Forbidden,
"pkg-config": Forbidden,
- // We've got prebuilts of these
- //"dtc": Forbidden,
- //"lz4": Forbidden,
- //"lz4c": Forbidden,
+ // On linux we'll use the toybox version of these instead
+ "true": Toybox,
+ "uname": Toybox,
}
func init() {
@@ -177,5 +185,13 @@
Configuration["md5"] = Allowed
Configuration["sw_vers"] = Allowed
Configuration["xcrun"] = Allowed
+
+ // We don't have toybox prebuilts for darwin, so allow the
+ // host versions.
+ for name, config := range Configuration {
+ if config.Toybox {
+ Configuration[name] = Allowed
+ }
+ }
}
}