Loading ui/build/dumpvars.go +13 −1 Original line number Diff line number Diff line Loading @@ -17,6 +17,8 @@ package build import ( "bytes" "fmt" "io/ioutil" "os" "strings" "android/soong/ui/metrics" Loading Loading @@ -51,7 +53,17 @@ func DumpMakeVars(ctx Context, config Config, goals, vars []string) (map[string] var ret map[string]string if len(makeVars) > 0 { var err error tmpDir, err := ioutil.TempDir("", "dumpvars") if err != nil { return nil, err } defer os.RemoveAll(tmpDir) // It's not safe to use the same TMPDIR as the build, as that can be removed. config.Environment().Set("TMPDIR", tmpDir) SetupLitePath(ctx, config) ret, err = dumpMakeVars(ctx, config, goals, makeVars, false) if err != nil { return ret, err Loading ui/build/path.go +46 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ import ( "fmt" "io/ioutil" "os" "os/exec" "path/filepath" "runtime" "strings" Loading Loading @@ -53,6 +54,51 @@ func parsePathDir(dir string) []string { return ret } // A "lite" version of SetupPath used for dumpvars, or other places that need // minimal overhead (but at the expense of logging). func SetupLitePath(ctx Context, config Config) { if config.pathReplaced { return } ctx.BeginTrace(metrics.RunSetupTool, "litepath") defer ctx.EndTrace() origPath, _ := config.Environment().Get("PATH") myPath, _ := config.Environment().Get("TMPDIR") myPath = filepath.Join(myPath, "path") ensureEmptyDirectoriesExist(ctx, myPath) os.Setenv("PATH", origPath) for name, pathConfig := range paths.Configuration { if !pathConfig.Symlink { continue } origExec, err := exec.LookPath(name) if err != nil { continue } origExec, err = filepath.Abs(origExec) if err != nil { continue } err = os.Symlink(origExec, filepath.Join(myPath, name)) if err != nil { ctx.Fatalln("Failed to create symlink:", err) } } myPath, _ = filepath.Abs(myPath) prebuiltsPath, _ := filepath.Abs("prebuilts/build-tools/path/" + runtime.GOOS + "-x86") myPath = prebuiltsPath + string(os.PathListSeparator) + myPath config.Environment().Set("PATH", myPath) config.pathReplaced = true } func SetupPath(ctx Context, config Config) { if config.pathReplaced { return Loading Loading
ui/build/dumpvars.go +13 −1 Original line number Diff line number Diff line Loading @@ -17,6 +17,8 @@ package build import ( "bytes" "fmt" "io/ioutil" "os" "strings" "android/soong/ui/metrics" Loading Loading @@ -51,7 +53,17 @@ func DumpMakeVars(ctx Context, config Config, goals, vars []string) (map[string] var ret map[string]string if len(makeVars) > 0 { var err error tmpDir, err := ioutil.TempDir("", "dumpvars") if err != nil { return nil, err } defer os.RemoveAll(tmpDir) // It's not safe to use the same TMPDIR as the build, as that can be removed. config.Environment().Set("TMPDIR", tmpDir) SetupLitePath(ctx, config) ret, err = dumpMakeVars(ctx, config, goals, makeVars, false) if err != nil { return ret, err Loading
ui/build/path.go +46 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ import ( "fmt" "io/ioutil" "os" "os/exec" "path/filepath" "runtime" "strings" Loading Loading @@ -53,6 +54,51 @@ func parsePathDir(dir string) []string { return ret } // A "lite" version of SetupPath used for dumpvars, or other places that need // minimal overhead (but at the expense of logging). func SetupLitePath(ctx Context, config Config) { if config.pathReplaced { return } ctx.BeginTrace(metrics.RunSetupTool, "litepath") defer ctx.EndTrace() origPath, _ := config.Environment().Get("PATH") myPath, _ := config.Environment().Get("TMPDIR") myPath = filepath.Join(myPath, "path") ensureEmptyDirectoriesExist(ctx, myPath) os.Setenv("PATH", origPath) for name, pathConfig := range paths.Configuration { if !pathConfig.Symlink { continue } origExec, err := exec.LookPath(name) if err != nil { continue } origExec, err = filepath.Abs(origExec) if err != nil { continue } err = os.Symlink(origExec, filepath.Join(myPath, name)) if err != nil { ctx.Fatalln("Failed to create symlink:", err) } } myPath, _ = filepath.Abs(myPath) prebuiltsPath, _ := filepath.Abs("prebuilts/build-tools/path/" + runtime.GOOS + "-x86") myPath = prebuiltsPath + string(os.PathListSeparator) + myPath config.Environment().Set("PATH", myPath) config.pathReplaced = true } func SetupPath(ctx Context, config Config) { if config.pathReplaced { return Loading