Sandbox soong_build by changing to root directory
This relands I12a0f907753fefd1997ab8b4ea2ac331234093cf along with a fix to blueprint for absolute paths. Store the current working directory and then change to the root directory so that all file accesses must go through helpers in the android package that properly track dependencies. Change-Id: I24ac485677aa102eec1a2521d16820da6ee1ae77 Fixes: 146437378 Test: m checkbuild Test: m OUT_DIR=/tmp/out nothing
This commit is contained in:
@@ -18,6 +18,7 @@ import (
|
||||
"bytes"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
@@ -41,7 +42,6 @@ type pathContext struct {
|
||||
config android.Config
|
||||
}
|
||||
|
||||
func (x *pathContext) Fs() pathtools.FileSystem { return pathtools.OsFs }
|
||||
func (x *pathContext) Config() android.Config { return x.config }
|
||||
func (x *pathContext) AddNinjaFileDeps(...string) {}
|
||||
|
||||
@@ -76,21 +76,39 @@ func main() {
|
||||
usage("--module configuration file is required")
|
||||
}
|
||||
|
||||
ctx := &pathContext{android.TestConfig(*outDir, nil, "", nil)}
|
||||
ctx := &pathContext{android.NullConfig(*outDir)}
|
||||
|
||||
globalSoongConfig, err := dexpreopt.LoadGlobalSoongConfig(ctx, *globalSoongConfigPath)
|
||||
globalSoongConfigData, err := ioutil.ReadFile(*globalSoongConfigPath)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "error reading global config %q: %s\n", *globalSoongConfigPath, err)
|
||||
os.Exit(2)
|
||||
}
|
||||
|
||||
globalSoongConfig, err := dexpreopt.LoadGlobalSoongConfig(ctx, globalSoongConfigData)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "error loading global config %q: %s\n", *globalSoongConfigPath, err)
|
||||
os.Exit(2)
|
||||
}
|
||||
|
||||
globalConfig, _, err := dexpreopt.LoadGlobalConfig(ctx, *globalConfigPath, globalSoongConfig)
|
||||
globalConfigData, err := ioutil.ReadFile(*globalConfigPath)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "error loading global config %q: %s\n", *globalConfigPath, err)
|
||||
fmt.Fprintf(os.Stderr, "error reading global config %q: %s\n", *globalConfigPath, err)
|
||||
os.Exit(2)
|
||||
}
|
||||
|
||||
moduleConfig, err := dexpreopt.LoadModuleConfig(ctx, *moduleConfigPath)
|
||||
globalConfig, err := dexpreopt.LoadGlobalConfig(ctx, globalConfigData, globalSoongConfig)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "error parse global config %q: %s\n", *globalConfigPath, err)
|
||||
os.Exit(2)
|
||||
}
|
||||
|
||||
moduleConfigData, err := ioutil.ReadFile(*moduleConfigPath)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "error reading module config %q: %s\n", *moduleConfigPath, err)
|
||||
os.Exit(2)
|
||||
}
|
||||
|
||||
moduleConfig, err := dexpreopt.LoadModuleConfig(ctx, moduleConfigData)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "error loading module config %q: %s\n", *moduleConfigPath, err)
|
||||
os.Exit(2)
|
||||
|
||||
Reference in New Issue
Block a user