apply gofmt am: 26e44b7b78
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/2448682 Change-Id: I9627ededb4270842ccc5f205b720c002c30c52a5 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
112f8ce34f
9 changed files with 114 additions and 110 deletions
|
@ -4595,7 +4595,7 @@ they were generated by the following Go packages:
|
||||||
|
|
||||||
`
|
`
|
||||||
|
|
||||||
var moduleHeaderTemplate = `# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
var moduleHeaderTemplate = `# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||||
Module: {{.name}}
|
Module: {{.name}}
|
||||||
Variant: {{.variant}}
|
Variant: {{.variant}}
|
||||||
Type: {{.typeName}}
|
Type: {{.typeName}}
|
||||||
|
@ -4603,7 +4603,7 @@ Factory: {{.goFactory}}
|
||||||
Defined: {{.pos}}
|
Defined: {{.pos}}
|
||||||
`
|
`
|
||||||
|
|
||||||
var singletonHeaderTemplate = `# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
var singletonHeaderTemplate = `# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||||
Singleton: {{.name}}
|
Singleton: {{.name}}
|
||||||
Factory: {{.goFactory}}
|
Factory: {{.goFactory}}
|
||||||
`
|
`
|
||||||
|
|
|
@ -174,11 +174,11 @@ func TestContextParse(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// |===B---D - represents a non-walkable edge
|
// > |===B---D - represents a non-walkable edge
|
||||||
// A = represents a walkable edge
|
// > A = represents a walkable edge
|
||||||
// |===C===E---G
|
// > |===C===E---G
|
||||||
// | | A should not be visited because it's the root node.
|
// > | | A should not be visited because it's the root node.
|
||||||
// |===F===| B, D and E should not be walked.
|
// > |===F===| B, D and E should not be walked.
|
||||||
func TestWalkDeps(t *testing.T) {
|
func TestWalkDeps(t *testing.T) {
|
||||||
ctx := NewContext()
|
ctx := NewContext()
|
||||||
ctx.MockFileSystem(map[string][]byte{
|
ctx.MockFileSystem(map[string][]byte{
|
||||||
|
@ -187,31 +187,31 @@ func TestWalkDeps(t *testing.T) {
|
||||||
name: "A",
|
name: "A",
|
||||||
deps: ["B", "C"],
|
deps: ["B", "C"],
|
||||||
}
|
}
|
||||||
|
|
||||||
bar_module {
|
bar_module {
|
||||||
name: "B",
|
name: "B",
|
||||||
deps: ["D"],
|
deps: ["D"],
|
||||||
}
|
}
|
||||||
|
|
||||||
foo_module {
|
foo_module {
|
||||||
name: "C",
|
name: "C",
|
||||||
deps: ["E", "F"],
|
deps: ["E", "F"],
|
||||||
}
|
}
|
||||||
|
|
||||||
foo_module {
|
foo_module {
|
||||||
name: "D",
|
name: "D",
|
||||||
}
|
}
|
||||||
|
|
||||||
bar_module {
|
bar_module {
|
||||||
name: "E",
|
name: "E",
|
||||||
deps: ["G"],
|
deps: ["G"],
|
||||||
}
|
}
|
||||||
|
|
||||||
foo_module {
|
foo_module {
|
||||||
name: "F",
|
name: "F",
|
||||||
deps: ["G"],
|
deps: ["G"],
|
||||||
}
|
}
|
||||||
|
|
||||||
foo_module {
|
foo_module {
|
||||||
name: "G",
|
name: "G",
|
||||||
}
|
}
|
||||||
|
@ -249,12 +249,12 @@ func TestWalkDeps(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// |===B---D - represents a non-walkable edge
|
// > |===B---D - represents a non-walkable edge
|
||||||
// A = represents a walkable edge
|
// > A = represents a walkable edge
|
||||||
// |===C===E===\ A should not be visited because it's the root node.
|
// > |===C===E===\ A should not be visited because it's the root node.
|
||||||
// | | B, D should not be walked.
|
// > | | B, D should not be walked.
|
||||||
// |===F===G===H G should be visited multiple times
|
// > |===F===G===H G should be visited multiple times
|
||||||
// \===/ H should only be visited once
|
// > \===/ H should only be visited once
|
||||||
func TestWalkDepsDuplicates(t *testing.T) {
|
func TestWalkDepsDuplicates(t *testing.T) {
|
||||||
ctx := NewContext()
|
ctx := NewContext()
|
||||||
ctx.MockFileSystem(map[string][]byte{
|
ctx.MockFileSystem(map[string][]byte{
|
||||||
|
@ -330,11 +330,11 @@ func TestWalkDepsDuplicates(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// - represents a non-walkable edge
|
// > - represents a non-walkable edge
|
||||||
// A = represents a walkable edge
|
// > A = represents a walkable edge
|
||||||
// |===B-------\ A should not be visited because it's the root node.
|
// > |===B-------\ A should not be visited because it's the root node.
|
||||||
// | | B -> D should not be walked.
|
// > | | B -> D should not be walked.
|
||||||
// |===C===D===E B -> C -> D -> E should be walked
|
// > |===C===D===E B -> C -> D -> E should be walked
|
||||||
func TestWalkDepsDuplicates_IgnoreFirstPath(t *testing.T) {
|
func TestWalkDepsDuplicates_IgnoreFirstPath(t *testing.T) {
|
||||||
ctx := NewContext()
|
ctx := NewContext()
|
||||||
ctx.MockFileSystem(map[string][]byte{
|
ctx.MockFileSystem(map[string][]byte{
|
||||||
|
@ -589,7 +589,7 @@ func TestParseFailsForModuleWithoutName(t *testing.T) {
|
||||||
foo_module {
|
foo_module {
|
||||||
name: "A",
|
name: "A",
|
||||||
}
|
}
|
||||||
|
|
||||||
bar_module {
|
bar_module {
|
||||||
deps: ["A"],
|
deps: ["A"],
|
||||||
}
|
}
|
||||||
|
@ -1107,24 +1107,24 @@ func TestPackageIncludes(t *testing.T) {
|
||||||
"dir1/Android.bp": []byte(dir1_foo_bp),
|
"dir1/Android.bp": []byte(dir1_foo_bp),
|
||||||
"dir2/Android.bp": []byte(dir2_foo_bp),
|
"dir2/Android.bp": []byte(dir2_foo_bp),
|
||||||
}
|
}
|
||||||
testCases := []struct{
|
testCases := []struct {
|
||||||
desc string
|
desc string
|
||||||
includeTags []string
|
includeTags []string
|
||||||
expectedDir string
|
expectedDir string
|
||||||
expectedErr string
|
expectedErr string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
desc: "use_dir1 is set, use dir1 foo",
|
desc: "use_dir1 is set, use dir1 foo",
|
||||||
includeTags: []string{"use_dir1"},
|
includeTags: []string{"use_dir1"},
|
||||||
expectedDir: "dir1",
|
expectedDir: "dir1",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
desc: "use_dir2 is set, use dir2 foo",
|
desc: "use_dir2 is set, use dir2 foo",
|
||||||
includeTags: []string{"use_dir2"},
|
includeTags: []string{"use_dir2"},
|
||||||
expectedDir: "dir2",
|
expectedDir: "dir2",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
desc: "duplicate module error if both use_dir1 and use_dir2 are set",
|
desc: "duplicate module error if both use_dir1 and use_dir2 are set",
|
||||||
includeTags: []string{"use_dir1", "use_dir2"},
|
includeTags: []string{"use_dir1", "use_dir2"},
|
||||||
expectedDir: "",
|
expectedDir: "",
|
||||||
expectedErr: `module "foo" already defined`,
|
expectedErr: `module "foo" already defined`,
|
||||||
|
|
20
doc.go
20
doc.go
|
@ -35,17 +35,17 @@
|
||||||
// the module type looks like a function call, and the properties of the module
|
// the module type looks like a function call, and the properties of the module
|
||||||
// look like optional arguments. For example, a simple module might look like:
|
// look like optional arguments. For example, a simple module might look like:
|
||||||
//
|
//
|
||||||
// cc_library {
|
// cc_library {
|
||||||
// name: "cmd",
|
// name: "cmd",
|
||||||
// srcs: [
|
// srcs: [
|
||||||
// "main.c",
|
// "main.c",
|
||||||
// ],
|
// ],
|
||||||
// deps: [
|
// deps: [
|
||||||
// "libc",
|
// "libc",
|
||||||
// ],
|
// ],
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// subdirs = ["subdir1", "subdir2"]
|
// subdirs = ["subdir1", "subdir2"]
|
||||||
//
|
//
|
||||||
// The modules from the top level Blueprints file and recursively through any
|
// The modules from the top level Blueprints file and recursively through any
|
||||||
// subdirectories listed by the "subdirs" variable are read by Blueprint, and
|
// subdirectories listed by the "subdirs" variable are read by Blueprint, and
|
||||||
|
|
|
@ -16,8 +16,8 @@
|
||||||
// to `go install`, but doesn't require a GOPATH. A package->path mapping can
|
// to `go install`, but doesn't require a GOPATH. A package->path mapping can
|
||||||
// be specified as command line options:
|
// be specified as command line options:
|
||||||
//
|
//
|
||||||
// -pkg-path android/soong=build/soong
|
// -pkg-path android/soong=build/soong
|
||||||
// -pkg-path github.com/google/blueprint=build/blueprint
|
// -pkg-path github.com/google/blueprint=build/blueprint
|
||||||
//
|
//
|
||||||
// The paths can be relative to the current working directory, or an absolute
|
// The paths can be relative to the current working directory, or an absolute
|
||||||
// path. Both packages and paths are compared with full directory names, so the
|
// path. Both packages and paths are compared with full directory names, so the
|
||||||
|
|
|
@ -58,27 +58,27 @@ import (
|
||||||
// that other modules can link against. The library Module might implement the
|
// that other modules can link against. The library Module might implement the
|
||||||
// following interface:
|
// following interface:
|
||||||
//
|
//
|
||||||
// type LibraryProducer interface {
|
// type LibraryProducer interface {
|
||||||
// LibraryFileName() string
|
// LibraryFileName() string
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// func IsLibraryProducer(module blueprint.Module) {
|
// func IsLibraryProducer(module blueprint.Module) {
|
||||||
// _, ok := module.(LibraryProducer)
|
// _, ok := module.(LibraryProducer)
|
||||||
// return ok
|
// return ok
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// A binary-producing Module that depends on the library Module could then do:
|
// A binary-producing Module that depends on the library Module could then do:
|
||||||
//
|
//
|
||||||
// func (m *myBinaryModule) GenerateBuildActions(ctx blueprint.ModuleContext) {
|
// func (m *myBinaryModule) GenerateBuildActions(ctx blueprint.ModuleContext) {
|
||||||
// ...
|
// ...
|
||||||
// var libraryFiles []string
|
// var libraryFiles []string
|
||||||
// ctx.VisitDepsDepthFirstIf(IsLibraryProducer,
|
// ctx.VisitDepsDepthFirstIf(IsLibraryProducer,
|
||||||
// func(module blueprint.Module) {
|
// func(module blueprint.Module) {
|
||||||
// libProducer := module.(LibraryProducer)
|
// libProducer := module.(LibraryProducer)
|
||||||
// libraryFiles = append(libraryFiles, libProducer.LibraryFileName())
|
// libraryFiles = append(libraryFiles, libProducer.LibraryFileName())
|
||||||
// })
|
// })
|
||||||
// ...
|
// ...
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// to build the list of library file names that should be included in its link
|
// to build the list of library file names that should be included in its link
|
||||||
// command.
|
// command.
|
||||||
|
|
|
@ -31,29 +31,29 @@ import (
|
||||||
// passed to all calls to define module- or singleton-specific Ninja
|
// passed to all calls to define module- or singleton-specific Ninja
|
||||||
// definitions. For example:
|
// definitions. For example:
|
||||||
//
|
//
|
||||||
// package blah
|
// package blah
|
||||||
//
|
//
|
||||||
// import (
|
// import (
|
||||||
// "blueprint"
|
// "blueprint"
|
||||||
// )
|
// )
|
||||||
//
|
//
|
||||||
// var (
|
// var (
|
||||||
// pctx = NewPackageContext("path/to/blah")
|
// pctx = NewPackageContext("path/to/blah")
|
||||||
//
|
//
|
||||||
// myPrivateVar = pctx.StaticVariable("myPrivateVar", "abcdef")
|
// myPrivateVar = pctx.StaticVariable("myPrivateVar", "abcdef")
|
||||||
// MyExportedVar = pctx.StaticVariable("MyExportedVar", "$myPrivateVar 123456!")
|
// MyExportedVar = pctx.StaticVariable("MyExportedVar", "$myPrivateVar 123456!")
|
||||||
//
|
//
|
||||||
// SomeRule = pctx.StaticRule(...)
|
// SomeRule = pctx.StaticRule(...)
|
||||||
// )
|
// )
|
||||||
//
|
//
|
||||||
// // ...
|
// // ...
|
||||||
//
|
//
|
||||||
// func (m *MyModule) GenerateBuildActions(ctx blueprint.Module) {
|
// func (m *MyModule) GenerateBuildActions(ctx blueprint.Module) {
|
||||||
// ctx.Build(pctx, blueprint.BuildParams{
|
// ctx.Build(pctx, blueprint.BuildParams{
|
||||||
// Rule: SomeRule,
|
// Rule: SomeRule,
|
||||||
// Outputs: []string{"$myPrivateVar"},
|
// Outputs: []string{"$myPrivateVar"},
|
||||||
// })
|
// })
|
||||||
// }
|
// }
|
||||||
type PackageContext interface {
|
type PackageContext interface {
|
||||||
Import(pkgPath string)
|
Import(pkgPath string)
|
||||||
ImportAs(as, pkgPath string)
|
ImportAs(as, pkgPath string)
|
||||||
|
@ -190,25 +190,25 @@ func pkgPathToName(pkgPath string) string {
|
||||||
// "${pkg.Variable}", while the imported rules can simply be accessed as
|
// "${pkg.Variable}", while the imported rules can simply be accessed as
|
||||||
// exported Go variables from the package. For example:
|
// exported Go variables from the package. For example:
|
||||||
//
|
//
|
||||||
// import (
|
// import (
|
||||||
// "blueprint"
|
// "blueprint"
|
||||||
// "foo/bar"
|
// "foo/bar"
|
||||||
// )
|
// )
|
||||||
//
|
//
|
||||||
// var pctx = NewPackagePath("blah")
|
// var pctx = NewPackagePath("blah")
|
||||||
//
|
//
|
||||||
// func init() {
|
// func init() {
|
||||||
// pctx.Import("foo/bar")
|
// pctx.Import("foo/bar")
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// ...
|
// ...
|
||||||
//
|
//
|
||||||
// func (m *MyModule) GenerateBuildActions(ctx blueprint.Module) {
|
// func (m *MyModule) GenerateBuildActions(ctx blueprint.Module) {
|
||||||
// ctx.Build(pctx, blueprint.BuildParams{
|
// ctx.Build(pctx, blueprint.BuildParams{
|
||||||
// Rule: bar.SomeRule,
|
// Rule: bar.SomeRule,
|
||||||
// Outputs: []string{"${bar.SomeVariable}"},
|
// Outputs: []string{"${bar.SomeVariable}"},
|
||||||
// })
|
// })
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// Note that the local name used to refer to the package in Ninja variable names
|
// Note that the local name used to refer to the package in Ninja variable names
|
||||||
// is derived from pkgPath by extracting the last path component. This differs
|
// is derived from pkgPath by extracting the last path component. This differs
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
// You may obtain a copy of the License at
|
// You may obtain a copy of the License at
|
||||||
//
|
//
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
//
|
//
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
|
|
@ -53,9 +53,13 @@ type unpackContext struct {
|
||||||
// If a property a.b.c has a value, a field with the matching name in each runtime value is initialized
|
// If a property a.b.c has a value, a field with the matching name in each runtime value is initialized
|
||||||
// from it. See PropertyNameForField for field and property name matching.
|
// from it. See PropertyNameForField for field and property name matching.
|
||||||
// For instance, if the input contains
|
// For instance, if the input contains
|
||||||
// { foo: "abc", bar: {x: 1},}
|
//
|
||||||
|
// { foo: "abc", bar: {x: 1},}
|
||||||
|
//
|
||||||
// and a runtime value being has been declared as
|
// and a runtime value being has been declared as
|
||||||
// var v struct { Foo string; Bar int }
|
//
|
||||||
|
// var v struct { Foo string; Bar int }
|
||||||
|
//
|
||||||
// then v.Foo will be set to "abc" and v.Bar will be set to 1
|
// then v.Foo will be set to "abc" and v.Bar will be set to 1
|
||||||
// (cf. unpack_test.go for further examples)
|
// (cf. unpack_test.go for further examples)
|
||||||
//
|
//
|
||||||
|
|
|
@ -74,18 +74,18 @@ func visitMutator(ctx TopDownMutatorContext) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// A
|
// > A
|
||||||
// |
|
// > |
|
||||||
// B
|
// > B
|
||||||
// |\
|
// > |\
|
||||||
// C \
|
// > C \
|
||||||
// \|
|
// > \|
|
||||||
// D
|
// > D
|
||||||
// |
|
// > |
|
||||||
// E
|
// > E
|
||||||
// / \
|
// > / \
|
||||||
// \ /
|
// > \ /
|
||||||
// F
|
// > F
|
||||||
func setupVisitTest(t *testing.T) *Context {
|
func setupVisitTest(t *testing.T) *Context {
|
||||||
ctx := NewContext()
|
ctx := NewContext()
|
||||||
ctx.RegisterModuleType("visit_module", newVisitModule)
|
ctx.RegisterModuleType("visit_module", newVisitModule)
|
||||||
|
@ -98,22 +98,22 @@ func setupVisitTest(t *testing.T) *Context {
|
||||||
name: "A",
|
name: "A",
|
||||||
visit: ["B"],
|
visit: ["B"],
|
||||||
}
|
}
|
||||||
|
|
||||||
visit_module {
|
visit_module {
|
||||||
name: "B",
|
name: "B",
|
||||||
visit: ["C", "D"],
|
visit: ["C", "D"],
|
||||||
}
|
}
|
||||||
|
|
||||||
visit_module {
|
visit_module {
|
||||||
name: "C",
|
name: "C",
|
||||||
visit: ["D"],
|
visit: ["D"],
|
||||||
}
|
}
|
||||||
|
|
||||||
visit_module {
|
visit_module {
|
||||||
name: "D",
|
name: "D",
|
||||||
visit: ["E"],
|
visit: ["E"],
|
||||||
}
|
}
|
||||||
|
|
||||||
visit_module {
|
visit_module {
|
||||||
name: "E",
|
name: "E",
|
||||||
visit: ["F", "F"],
|
visit: ["F", "F"],
|
||||||
|
|
Loading…
Reference in a new issue