Merge changes If90975c8,I2a873fc6
am: 570e18ffaa
Change-Id: Ibc5258da0ebca5f71e53770f4b94600c749f397c
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
@@ -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)
|
||||
}
|
||||
|
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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) {
|
||||
|
Reference in New Issue
Block a user