diff options
author | Colin Cross <ccross@android.com> | 2018-10-05 12:23:39 -0700 |
---|---|---|
committer | Colin Cross <ccross@android.com> | 2018-10-05 12:23:39 -0700 |
commit | 70282be791a3d1f326b132d43150569e592fc0c9 (patch) | |
tree | 64fcca9fc8ea3a570e88570432868f7fcbc0dc2b | |
parent | 89a7d24831ea7dbafc53fdffe8124c6a35a2ece8 (diff) | |
parent | d127ba077b606f811db302b5eeb7f7d2448ee49c (diff) | |
download | blueprint-master-cuttlefish-testing-release.tar.gz |
Merge remote-tracking branch 'aosp/upstream' into mastermaster-cuttlefish-testing-release
* aosp/upstream:
Add missing dependencies when linking tests
Allow mutated property structs to contain slices of non-strings
Enable restat for go binaries
Bug: 80095087
Test: m checkbuild
Change-Id: I804970378ea31fbab1a33c34849c2183caa0133c
-rw-r--r-- | bootstrap/bootstrap.go | 32 | ||||
-rw-r--r-- | proptools/clone.go | 3 | ||||
-rw-r--r-- | proptools/clone_test.go | 24 | ||||
-rw-r--r-- | unpack.go | 4 | ||||
-rw-r--r-- | unpack_test.go | 14 |
5 files changed, 56 insertions, 21 deletions
diff --git a/bootstrap/bootstrap.go b/bootstrap/bootstrap.go index 03aead9..be156f9 100644 --- a/bootstrap/bootstrap.go +++ b/bootstrap/bootstrap.go @@ -57,18 +57,22 @@ var ( compile = pctx.StaticRule("compile", blueprint.RuleParams{ - Command: "GOROOT='$goRoot' $compileCmd $parallelCompile -o $out " + - "-p $pkgPath -complete $incFlags -pack $in", + Command: "GOROOT='$goRoot' $compileCmd $parallelCompile -o $out.tmp " + + "-p $pkgPath -complete $incFlags -pack $in && " + + "if cmp --quiet $out.tmp $out; then rm $out.tmp; else mv -f $out.tmp $out; fi", CommandDeps: []string{"$compileCmd"}, Description: "compile $out", + Restat: true, }, "pkgPath", "incFlags") link = pctx.StaticRule("link", blueprint.RuleParams{ - Command: "GOROOT='$goRoot' $linkCmd -o $out $libDirFlags $in", + Command: "GOROOT='$goRoot' $linkCmd -o $out.tmp $libDirFlags $in && " + + "if cmp --quiet $out.tmp $out; then rm $out.tmp; else mv -f $out.tmp $out; fi", CommandDeps: []string{"$linkCmd"}, Description: "link $out", + Restat: true, }, "libDirFlags") @@ -435,10 +439,12 @@ func (g *goBinary) GenerateBuildActions(ctx blueprint.ModuleContext) { buildGoPackage(ctx, objDir, name, archiveFile, srcs, genSrcs) + var linkDeps []string var libDirFlags []string ctx.VisitDepsDepthFirstIf(isGoPackageProducer, func(module blueprint.Module) { dep := module.(goPackageProducer) + linkDeps = append(linkDeps, dep.GoPackageTarget()) libDir := dep.GoPkgRoot() libDirFlags = append(libDirFlags, "-L "+libDir) deps = append(deps, dep.GoTestTargets()...) @@ -450,11 +456,12 @@ func (g *goBinary) GenerateBuildActions(ctx blueprint.ModuleContext) { } ctx.Build(pctx, blueprint.BuildParams{ - Rule: link, - Outputs: []string{aoutFile}, - Inputs: []string{archiveFile}, - Args: linkArgs, - Optional: true, + Rule: link, + Outputs: []string{aoutFile}, + Inputs: []string{archiveFile}, + Implicits: linkDeps, + Args: linkArgs, + Optional: true, }) ctx.Build(pctx, blueprint.BuildParams{ @@ -554,11 +561,13 @@ func buildGoTest(ctx blueprint.ModuleContext, testRoot, testPkgArchive, Optional: true, }) + var linkDeps []string libDirFlags := []string{"-L " + testRoot} testDeps := []string{} ctx.VisitDepsDepthFirstIf(isGoPackageProducer, func(module blueprint.Module) { dep := module.(goPackageProducer) + linkDeps = append(linkDeps, dep.GoPackageTarget()) libDir := dep.GoPkgRoot() libDirFlags = append(libDirFlags, "-L "+libDir) testDeps = append(testDeps, dep.GoTestTargets()...) @@ -577,9 +586,10 @@ func buildGoTest(ctx blueprint.ModuleContext, testRoot, testPkgArchive, }) ctx.Build(pctx, blueprint.BuildParams{ - Rule: link, - Outputs: []string{testFile}, - Inputs: []string{testArchive}, + Rule: link, + Outputs: []string{testFile}, + Inputs: []string{testArchive}, + Implicits: linkDeps, Args: map[string]string{ "libDirFlags": strings.Join(libDirFlags, " "), }, diff --git a/proptools/clone.go b/proptools/clone.go index 9948b9a..dbd72b4 100644 --- a/proptools/clone.go +++ b/proptools/clone.go @@ -52,9 +52,6 @@ func CopyProperties(dstValue, srcValue reflect.Value) { CopyProperties(dstFieldValue, srcFieldValue) case reflect.Slice: if !srcFieldValue.IsNil() { - if field.Type.Elem().Kind() != reflect.String { - panic(fmt.Errorf("can't copy field %q: slice elements are not strings", field.Name)) - } if srcFieldValue != dstFieldValue { newSlice := reflect.MakeSlice(field.Type, srcFieldValue.Len(), srcFieldValue.Len()) diff --git a/proptools/clone_test.go b/proptools/clone_test.go index b6f1bf6..660f1c0 100644 --- a/proptools/clone_test.go +++ b/proptools/clone_test.go @@ -71,6 +71,19 @@ var clonePropertiesTestCases = []struct { out: &struct{ S []string }{}, }, { + // Clone slice of structs + in: &struct{ S []struct{ T string } }{ + S: []struct{ T string }{ + {"string1"}, {"string2"}, + }, + }, + out: &struct{ S []struct{ T string } }{ + S: []struct{ T string }{ + {"string1"}, {"string2"}, + }, + }, + }, + { // Clone pointer to bool in: &struct{ B1, B2 *bool }{ B1: BoolPtr(true), @@ -317,6 +330,17 @@ var cloneEmptyPropertiesTestCases = []struct { out: &struct{ S []string }{}, }, { + // Clone slice of structs + in: &struct{ S []struct{ T string } }{ + S: []struct{ T string }{ + {"string1"}, {"string2"}, + }, + }, + out: &struct{ S []struct{ T string } }{ + S: []struct{ T string }(nil), + }, + }, + { // Clone pointer to bool in: &struct{ B1, B2 *bool }{ B1: BoolPtr(true), @@ -163,7 +163,9 @@ func unpackStructValue(namePrefix string, structValue reflect.Value, case reflect.Slice: elemType := field.Type.Elem() if elemType.Kind() != reflect.String { - panic(fmt.Errorf("field %s is a non-string slice", propertyName)) + if !proptools.HasTag(field, "blueprint", "mutated") { + panic(fmt.Errorf("field %s is a non-string slice", propertyName)) + } } case reflect.Interface: if fieldValue.IsNil() { diff --git a/unpack_test.go b/unpack_test.go index b65fa3f..d6b88ab 100644 --- a/unpack_test.go +++ b/unpack_test.go @@ -111,13 +111,15 @@ var validUnpackTestCases = []struct { `, output: []interface{}{ struct { - Stuff []string - Empty []string - Nil []string + Stuff []string + Empty []string + Nil []string + NonString []struct{ S string } `blueprint:"mutated"` }{ - Stuff: []string{"asdf", "jkl;", "qwert", "uiop", "bnm,"}, - Empty: []string{}, - Nil: nil, + Stuff: []string{"asdf", "jkl;", "qwert", "uiop", "bnm,"}, + Empty: []string{}, + Nil: nil, + NonString: nil, }, }, }, |