Sandbox soong_build by changing to root directory
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. Fixes: 146437378 Test: m checkbuild Change-Id: I12a0f907753fefd1997ab8b4ea2ac331234093cf
This commit is contained in:
@@ -36,10 +36,11 @@ type globalConfigAndRaw struct {
|
||||
|
||||
func dexpreoptGlobalConfigRaw(ctx android.PathContext) globalConfigAndRaw {
|
||||
return ctx.Config().Once(dexpreoptGlobalConfigKey, func() interface{} {
|
||||
if f := ctx.Config().DexpreoptGlobalConfig(); f != "" {
|
||||
if data, err := ctx.Config().DexpreoptGlobalConfig(ctx); err != nil {
|
||||
panic(err)
|
||||
} else if data != nil {
|
||||
soongConfig := dexpreopt.CreateGlobalSoongConfig(ctx)
|
||||
ctx.AddNinjaFileDeps(f)
|
||||
globalConfig, data, err := dexpreopt.LoadGlobalConfig(ctx, f, soongConfig)
|
||||
globalConfig, err := dexpreopt.LoadGlobalConfig(ctx, data, soongConfig)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@@ -17,7 +17,6 @@ package java
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"android/soong/android"
|
||||
)
|
||||
@@ -92,23 +91,21 @@ func (j *jdepsGeneratorSingleton) GenerateBuildActions(ctx android.SingletonCont
|
||||
moduleInfos[name] = dpInfo
|
||||
})
|
||||
|
||||
jfpath := android.PathForOutput(ctx, jdepsJsonFileName).String()
|
||||
jfpath := android.PathForOutput(ctx, jdepsJsonFileName)
|
||||
err := createJsonFile(moduleInfos, jfpath)
|
||||
if err != nil {
|
||||
ctx.Errorf(err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
func createJsonFile(moduleInfos map[string]android.IdeInfo, jfpath string) error {
|
||||
file, err := os.Create(jfpath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to create file: %s, relative: %v", jdepsJsonFileName, err)
|
||||
}
|
||||
defer file.Close()
|
||||
func createJsonFile(moduleInfos map[string]android.IdeInfo, jfpath android.WritablePath) error {
|
||||
buf, err := json.MarshalIndent(moduleInfos, "", "\t")
|
||||
if err != nil {
|
||||
return fmt.Errorf("Write file failed: %s, relative: %v", jdepsJsonFileName, err)
|
||||
return fmt.Errorf("JSON marshal of java deps failed: %s", err)
|
||||
}
|
||||
err = android.WriteFileToOutputDir(jfpath, buf, 0666)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Writing java deps to %s failed: %s", jfpath.String(), err)
|
||||
}
|
||||
fmt.Fprintf(file, string(buf))
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user