aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--android/paths.go22
-rw-r--r--cc/builder.go49
-rw-r--r--cc/cc_test.go17
-rw-r--r--cc/cmakelists.go6
4 files changed, 59 insertions, 35 deletions
diff --git a/android/paths.go b/android/paths.go
index 75e5980e..0d26dc02 100644
--- a/android/paths.go
+++ b/android/paths.go
@@ -721,3 +721,25 @@ func validatePath(ctx PathContext, paths ...string) string {
}
return validateSafePath(ctx, paths...)
}
+
+type testPath struct {
+ basePath
+}
+
+func (p testPath) String() string {
+ return p.path
+}
+
+func PathForTesting(paths ...string) Path {
+ p := validateSafePath(nil, paths...)
+ return testPath{basePath{path: p, rel: p}}
+}
+
+func PathsForTesting(strs []string) Paths {
+ p := make(Paths, len(strs))
+ for i, s := range strs {
+ p[i] = PathForTesting(s)
+ }
+
+ return p
+}
diff --git a/cc/builder.go b/cc/builder.go
index 71445084..8a0c7f4c 100644
--- a/cc/builder.go
+++ b/cc/builder.go
@@ -468,7 +468,7 @@ func TransformObjToStaticLib(ctx android.ModuleContext, objFiles android.Paths,
// very small command line length limit, so we have to split the ar into multiple
// steps, each appending to the previous one.
func transformDarwinObjToStaticLib(ctx android.ModuleContext, objFiles android.Paths,
- flags builderFlags, outputPath android.ModuleOutPath, deps android.Paths) {
+ flags builderFlags, outputFile android.ModuleOutPath, deps android.Paths) {
arFlags := "cqs"
@@ -493,7 +493,7 @@ func transformDarwinObjToStaticLib(ctx android.ModuleContext, objFiles android.P
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
Rule: darwinAppendAr,
- Output: outputPath,
+ Output: outputFile,
Input: dummy,
Args: map[string]string{
"arFlags": "d",
@@ -505,42 +505,33 @@ func transformDarwinObjToStaticLib(ctx android.ModuleContext, objFiles android.P
}
// ARG_MAX on darwin is 262144, use half that to be safe
- objFilesLists, err := splitListForSize(objFiles.Strings(), 131072)
+ objFilesLists, err := splitListForSize(objFiles, 131072)
if err != nil {
ctx.ModuleErrorf("%s", err.Error())
}
- outputFile := outputPath.String()
-
- var in, out string
+ var in, out android.WritablePath
for i, l := range objFilesLists {
in = out
out = outputFile
if i != len(objFilesLists)-1 {
- out += "." + strconv.Itoa(i)
+ out = android.PathForModuleOut(ctx, outputFile.Base()+strconv.Itoa(i))
}
- if in == "" {
- ctx.Build(pctx, blueprint.BuildParams{
- Rule: darwinAr,
- Outputs: []string{out},
- Inputs: l,
- Implicits: deps.Strings(),
- Args: map[string]string{
- "arFlags": arFlags,
- },
- })
- } else {
- ctx.Build(pctx, blueprint.BuildParams{
- Rule: darwinAppendAr,
- Outputs: []string{out},
- Inputs: l,
- Args: map[string]string{
- "arFlags": arFlags,
- "inAr": in,
- },
- })
+ build := android.ModuleBuildParams{
+ Rule: darwinAr,
+ Output: out,
+ Inputs: l,
+ Implicits: deps,
+ Args: map[string]string{
+ "arFlags": arFlags,
+ },
+ }
+ if i != 0 {
+ build.Rule = darwinAppendAr
+ build.Args["inAr"] = in.String()
}
+ ctx.ModuleBuild(pctx, build)
}
}
@@ -779,13 +770,13 @@ func gccCmd(toolchain config.Toolchain, cmd string) string {
return filepath.Join(toolchain.GccRoot(), "bin", toolchain.GccTriple()+"-"+cmd)
}
-func splitListForSize(list []string, limit int) (lists [][]string, err error) {
+func splitListForSize(list android.Paths, limit int) (lists []android.Paths, err error) {
var i int
start := 0
bytes := 0
for i = range list {
- l := len(list[i])
+ l := len(list[i].String())
if l > limit {
return nil, fmt.Errorf("list element greater than size limit (%d)", limit)
}
diff --git a/cc/cc_test.go b/cc/cc_test.go
index ec7da90b..6e779e75 100644
--- a/cc/cc_test.go
+++ b/cc/cc_test.go
@@ -1,6 +1,7 @@
package cc
import (
+ "android/soong/android"
"reflect"
"testing"
)
@@ -142,13 +143,23 @@ var splitListForSizeTestCases = []struct {
func TestSplitListForSize(t *testing.T) {
for _, testCase := range splitListForSizeTestCases {
- out, _ := splitListForSize(testCase.in, testCase.size)
- if !reflect.DeepEqual(out, testCase.out) {
+ out, _ := splitListForSize(android.PathsForTesting(testCase.in), testCase.size)
+
+ var outStrings [][]string
+
+ if len(out) > 0 {
+ outStrings = make([][]string, len(out))
+ for i, o := range out {
+ outStrings[i] = o.Strings()
+ }
+ }
+
+ if !reflect.DeepEqual(outStrings, testCase.out) {
t.Errorf("incorrect output:")
t.Errorf(" input: %#v", testCase.in)
t.Errorf(" size: %d", testCase.size)
t.Errorf(" expected: %#v", testCase.out)
- t.Errorf(" got: %#v", out)
+ t.Errorf(" got: %#v", outStrings)
}
}
}
diff --git a/cc/cmakelists.go b/cc/cmakelists.go
index 4df9ece9..c353f440 100644
--- a/cc/cmakelists.go
+++ b/cc/cmakelists.go
@@ -205,7 +205,7 @@ func writeAllIncludeDirectories(includes []string, f *os.File, isSystem bool) {
}
system := ""
- if isSystem {
+ if isSystem {
system = "SYSTEM"
}
@@ -217,12 +217,12 @@ func writeAllIncludeDirectories(includes []string, f *os.File, isSystem bool) {
f.WriteString(")\n\n")
// Also add all headers to source files.
- f.WriteString("file (GLOB_RECURSE TMP_HEADERS\n");
+ f.WriteString("file (GLOB_RECURSE TMP_HEADERS\n")
for _, include := range includes {
f.WriteString(fmt.Sprintf(" \"%s/**/*.h\"\n", buildCMakePath(include)))
}
f.WriteString(")\n")
- f.WriteString("list (APPEND SOURCE_FILES ${TMP_HEADERS})\n\n");
+ f.WriteString("list (APPEND SOURCE_FILES ${TMP_HEADERS})\n\n")
}
func writeAllFlags(flags []string, f *os.File, tag string) {