Merge "Fix writing module_bp_cc_deps.json" am: 4136c9b9ea
Change-Id: I857d0de1bf6f9aa76cd2b07cf4cdc5a8f5f0adca
This commit is contained in:
18
cc/ccdeps.go
18
cc/ccdeps.go
@@ -17,7 +17,6 @@ package cc
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
|
||||||
"path"
|
"path"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -106,7 +105,7 @@ func (c *ccdepsGeneratorSingleton) GenerateBuildActions(ctx android.SingletonCon
|
|||||||
|
|
||||||
moduleDeps.Modules = moduleInfos
|
moduleDeps.Modules = moduleInfos
|
||||||
|
|
||||||
ccfpath := android.PathForOutput(ctx, ccdepsJsonFileName).String()
|
ccfpath := android.PathForOutput(ctx, ccdepsJsonFileName)
|
||||||
err := createJsonFile(moduleDeps, ccfpath)
|
err := createJsonFile(moduleDeps, ccfpath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Errorf(err.Error())
|
ctx.Errorf(err.Error())
|
||||||
@@ -236,17 +235,14 @@ func sortMap(moduleInfos map[string]ccIdeInfo) map[string]ccIdeInfo {
|
|||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
func createJsonFile(moduleDeps ccDeps, ccfpath string) error {
|
func createJsonFile(moduleDeps ccDeps, ccfpath android.WritablePath) error {
|
||||||
file, err := os.Create(ccfpath)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("Failed to create file: %s, relative: %v", ccdepsJsonFileName, err)
|
|
||||||
}
|
|
||||||
defer file.Close()
|
|
||||||
moduleDeps.Modules = sortMap(moduleDeps.Modules)
|
|
||||||
buf, err := json.MarshalIndent(moduleDeps, "", "\t")
|
buf, err := json.MarshalIndent(moduleDeps, "", "\t")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Write file failed: %s, relative: %v", ccdepsJsonFileName, err)
|
return fmt.Errorf("JSON marshal of cc deps failed: %s", err)
|
||||||
|
}
|
||||||
|
err = android.WriteFileToOutputDir(ccfpath, buf, 0666)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Writing cc deps to %s failed: %s", ccfpath.String(), err)
|
||||||
}
|
}
|
||||||
fmt.Fprintf(file, string(buf))
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user