Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4136c9b9 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Fix writing module_bp_cc_deps.json"

parents d35fcae5 37c5cda4
Loading
Loading
Loading
Loading
+6 −10
Original line number Diff line number Diff line
@@ -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
}