summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Colin Cross <ccross@android.com> 2020-01-31 10:07:25 -0800
committer Colin Cross <ccross@android.com> 2020-01-31 18:12:41 +0000
commit37c5cda47c80d5bc018271aca1879cfb00b09ca0 (patch)
tree8f015fc55f36162c2b3fb600d9e007c20ce0fe2f
parent56bcaa6dc1fab98849b212e4ecf553f709426754 (diff)
Fix writing module_bp_cc_deps.json
module_bp_cc_deps.json was not written through android.WriteFileToOuptutDir, so it didn't get the absolute path prepended when sandboxing was turned on. Reuse the implementation from module_bp_java_deps.json. Bug: 147409906 Test: m SOONG_COLLECT_CC_DEPS=1 nothing Change-Id: I3b255bdfd3b4c442db06fe185765414905531410
-rw-r--r--cc/ccdeps.go16
1 files changed, 6 insertions, 10 deletions
diff --git a/cc/ccdeps.go b/cc/ccdeps.go
index 4e23a7bee..225405cb4 100644
--- a/cc/ccdeps.go
+++ b/cc/ccdeps.go
@@ -17,7 +17,6 @@ package cc
import (
"encoding/json"
"fmt"
- "os"
"path"
"sort"
"strings"
@@ -106,7 +105,7 @@ func (c *ccdepsGeneratorSingleton) GenerateBuildActions(ctx android.SingletonCon
moduleDeps.Modules = moduleInfos
- ccfpath := android.PathForOutput(ctx, ccdepsJsonFileName).String()
+ ccfpath := android.PathForOutput(ctx, ccdepsJsonFileName)
err := createJsonFile(moduleDeps, ccfpath)
if err != nil {
ctx.Errorf(err.Error())
@@ -236,17 +235,14 @@ func sortMap(moduleInfos map[string]ccIdeInfo) map[string]ccIdeInfo {
return m
}
-func createJsonFile(moduleDeps ccDeps, ccfpath string) error {
- file, err := os.Create(ccfpath)
+func createJsonFile(moduleDeps ccDeps, ccfpath android.WritablePath) error {
+ buf, err := json.MarshalIndent(moduleDeps, "", "\t")
if err != nil {
- return fmt.Errorf("Failed to create file: %s, relative: %v", ccdepsJsonFileName, err)
+ return fmt.Errorf("JSON marshal of cc deps failed: %s", err)
}
- defer file.Close()
- moduleDeps.Modules = sortMap(moduleDeps.Modules)
- buf, err := json.MarshalIndent(moduleDeps, "", "\t")
+ err = android.WriteFileToOutputDir(ccfpath, buf, 0666)
if err != nil {
- return fmt.Errorf("Write file failed: %s, relative: %v", ccdepsJsonFileName, err)
+ return fmt.Errorf("Writing cc deps to %s failed: %s", ccfpath.String(), err)
}
- fmt.Fprintf(file, string(buf))
return nil
}