apply gofmt am: 26e44b7b78
am: 112f8ce34f
am: 4373a40e61
am: 459cb61263
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/2448682 Change-Id: I82add7b7607f5dd9d10ccc4d999e6fb8f050b32f Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
0b5c844003
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}}
|
||||
Variant: {{.variant}}
|
||||
Type: {{.typeName}}
|
||||
|
@ -4603,7 +4603,7 @@ Factory: {{.goFactory}}
|
|||
Defined: {{.pos}}
|
||||
`
|
||||
|
||||
var singletonHeaderTemplate = `# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
var singletonHeaderTemplate = `# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
Singleton: {{.name}}
|
||||
Factory: {{.goFactory}}
|
||||
`
|
||||
|
|
|
@ -174,11 +174,11 @@ func TestContextParse(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// |===B---D - represents a non-walkable edge
|
||||
// A = represents a walkable edge
|
||||
// |===C===E---G
|
||||
// | | A should not be visited because it's the root node.
|
||||
// |===F===| B, D and E should not be walked.
|
||||
// > |===B---D - represents a non-walkable edge
|
||||
// > A = represents a walkable edge
|
||||
// > |===C===E---G
|
||||
// > | | A should not be visited because it's the root node.
|
||||
// > |===F===| B, D and E should not be walked.
|
||||
func TestWalkDeps(t *testing.T) {
|
||||
ctx := NewContext()
|
||||
ctx.MockFileSystem(map[string][]byte{
|
||||
|
@ -187,31 +187,31 @@ func TestWalkDeps(t *testing.T) {
|
|||
name: "A",
|
||||
deps: ["B", "C"],
|
||||
}
|
||||
|
||||
|
||||
bar_module {
|
||||
name: "B",
|
||||
deps: ["D"],
|
||||
}
|
||||
|
||||
|
||||
foo_module {
|
||||
name: "C",
|
||||
deps: ["E", "F"],
|
||||
}
|
||||
|
||||
|
||||
foo_module {
|
||||
name: "D",
|
||||
}
|
||||
|
||||
|
||||
bar_module {
|
||||
name: "E",
|
||||
deps: ["G"],
|
||||
}
|
||||
|
||||
|
||||
foo_module {
|
||||
name: "F",
|
||||
deps: ["G"],
|
||||
}
|
||||
|
||||
|
||||
foo_module {
|
||||
name: "G",
|
||||
}
|
||||
|
@ -249,12 +249,12 @@ func TestWalkDeps(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// |===B---D - represents a non-walkable edge
|
||||
// A = represents a walkable edge
|
||||
// |===C===E===\ A should not be visited because it's the root node.
|
||||
// | | B, D should not be walked.
|
||||
// |===F===G===H G should be visited multiple times
|
||||
// \===/ H should only be visited once
|
||||
// > |===B---D - represents a non-walkable edge
|
||||
// > A = represents a walkable edge
|
||||
// > |===C===E===\ A should not be visited because it's the root node.
|
||||
// > | | B, D should not be walked.
|
||||
// > |===F===G===H G should be visited multiple times
|
||||
// > \===/ H should only be visited once
|
||||
func TestWalkDepsDuplicates(t *testing.T) {
|
||||
ctx := NewContext()
|
||||
ctx.MockFileSystem(map[string][]byte{
|
||||
|
@ -330,11 +330,11 @@ func TestWalkDepsDuplicates(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// - represents a non-walkable edge
|
||||
// A = represents a walkable edge
|
||||
// |===B-------\ A should not be visited because it's the root node.
|
||||
// | | B -> D should not be walked.
|
||||
// |===C===D===E B -> C -> D -> E should be walked
|
||||
// > - represents a non-walkable edge
|
||||
// > A = represents a walkable edge
|
||||
// > |===B-------\ A should not be visited because it's the root node.
|
||||
// > | | B -> D should not be walked.
|
||||
// > |===C===D===E B -> C -> D -> E should be walked
|
||||
func TestWalkDepsDuplicates_IgnoreFirstPath(t *testing.T) {
|
||||
ctx := NewContext()
|
||||
ctx.MockFileSystem(map[string][]byte{
|
||||
|
@ -589,7 +589,7 @@ func TestParseFailsForModuleWithoutName(t *testing.T) {
|
|||
foo_module {
|
||||
name: "A",
|
||||
}
|
||||
|
||||
|
||||
bar_module {
|
||||
deps: ["A"],
|
||||
}
|
||||
|
@ -1107,24 +1107,24 @@ func TestPackageIncludes(t *testing.T) {
|
|||
"dir1/Android.bp": []byte(dir1_foo_bp),
|
||||
"dir2/Android.bp": []byte(dir2_foo_bp),
|
||||
}
|
||||
testCases := []struct{
|
||||
desc string
|
||||
testCases := []struct {
|
||||
desc string
|
||||
includeTags []string
|
||||
expectedDir string
|
||||
expectedErr string
|
||||
}{
|
||||
{
|
||||
desc: "use_dir1 is set, use dir1 foo",
|
||||
desc: "use_dir1 is set, use dir1 foo",
|
||||
includeTags: []string{"use_dir1"},
|
||||
expectedDir: "dir1",
|
||||
},
|
||||
{
|
||||
desc: "use_dir2 is set, use dir2 foo",
|
||||
desc: "use_dir2 is set, use dir2 foo",
|
||||
includeTags: []string{"use_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"},
|
||||
expectedDir: "",
|
||||
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
|
||||
// look like optional arguments. For example, a simple module might look like:
|
||||
//
|
||||
// cc_library {
|
||||
// name: "cmd",
|
||||
// srcs: [
|
||||
// "main.c",
|
||||
// ],
|
||||
// deps: [
|
||||
// "libc",
|
||||
// ],
|
||||
// }
|
||||
// cc_library {
|
||||
// name: "cmd",
|
||||
// srcs: [
|
||||
// "main.c",
|
||||
// ],
|
||||
// deps: [
|
||||
// "libc",
|
||||
// ],
|
||||
// }
|
||||
//
|
||||
// subdirs = ["subdir1", "subdir2"]
|
||||
// subdirs = ["subdir1", "subdir2"]
|
||||
//
|
||||
// The modules from the top level Blueprints file and recursively through any
|
||||
// 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
|
||||
// be specified as command line options:
|
||||
//
|
||||
// -pkg-path android/soong=build/soong
|
||||
// -pkg-path github.com/google/blueprint=build/blueprint
|
||||
// -pkg-path android/soong=build/soong
|
||||
// -pkg-path github.com/google/blueprint=build/blueprint
|
||||
//
|
||||
// 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
|
||||
|
|
|
@ -58,27 +58,27 @@ import (
|
|||
// that other modules can link against. The library Module might implement the
|
||||
// following interface:
|
||||
//
|
||||
// type LibraryProducer interface {
|
||||
// LibraryFileName() string
|
||||
// }
|
||||
// type LibraryProducer interface {
|
||||
// LibraryFileName() string
|
||||
// }
|
||||
//
|
||||
// func IsLibraryProducer(module blueprint.Module) {
|
||||
// _, ok := module.(LibraryProducer)
|
||||
// return ok
|
||||
// }
|
||||
// func IsLibraryProducer(module blueprint.Module) {
|
||||
// _, ok := module.(LibraryProducer)
|
||||
// return ok
|
||||
// }
|
||||
//
|
||||
// A binary-producing Module that depends on the library Module could then do:
|
||||
//
|
||||
// func (m *myBinaryModule) GenerateBuildActions(ctx blueprint.ModuleContext) {
|
||||
// ...
|
||||
// var libraryFiles []string
|
||||
// ctx.VisitDepsDepthFirstIf(IsLibraryProducer,
|
||||
// func(module blueprint.Module) {
|
||||
// libProducer := module.(LibraryProducer)
|
||||
// libraryFiles = append(libraryFiles, libProducer.LibraryFileName())
|
||||
// })
|
||||
// ...
|
||||
// }
|
||||
// func (m *myBinaryModule) GenerateBuildActions(ctx blueprint.ModuleContext) {
|
||||
// ...
|
||||
// var libraryFiles []string
|
||||
// ctx.VisitDepsDepthFirstIf(IsLibraryProducer,
|
||||
// func(module blueprint.Module) {
|
||||
// libProducer := module.(LibraryProducer)
|
||||
// libraryFiles = append(libraryFiles, libProducer.LibraryFileName())
|
||||
// })
|
||||
// ...
|
||||
// }
|
||||
//
|
||||
// to build the list of library file names that should be included in its link
|
||||
// command.
|
||||
|
|
|
@ -31,29 +31,29 @@ import (
|
|||
// passed to all calls to define module- or singleton-specific Ninja
|
||||
// definitions. For example:
|
||||
//
|
||||
// package blah
|
||||
// package blah
|
||||
//
|
||||
// import (
|
||||
// "blueprint"
|
||||
// )
|
||||
// import (
|
||||
// "blueprint"
|
||||
// )
|
||||
//
|
||||
// var (
|
||||
// pctx = NewPackageContext("path/to/blah")
|
||||
// var (
|
||||
// pctx = NewPackageContext("path/to/blah")
|
||||
//
|
||||
// myPrivateVar = pctx.StaticVariable("myPrivateVar", "abcdef")
|
||||
// MyExportedVar = pctx.StaticVariable("MyExportedVar", "$myPrivateVar 123456!")
|
||||
// myPrivateVar = pctx.StaticVariable("myPrivateVar", "abcdef")
|
||||
// MyExportedVar = pctx.StaticVariable("MyExportedVar", "$myPrivateVar 123456!")
|
||||
//
|
||||
// SomeRule = pctx.StaticRule(...)
|
||||
// )
|
||||
// SomeRule = pctx.StaticRule(...)
|
||||
// )
|
||||
//
|
||||
// // ...
|
||||
// // ...
|
||||
//
|
||||
// func (m *MyModule) GenerateBuildActions(ctx blueprint.Module) {
|
||||
// ctx.Build(pctx, blueprint.BuildParams{
|
||||
// Rule: SomeRule,
|
||||
// Outputs: []string{"$myPrivateVar"},
|
||||
// })
|
||||
// }
|
||||
// func (m *MyModule) GenerateBuildActions(ctx blueprint.Module) {
|
||||
// ctx.Build(pctx, blueprint.BuildParams{
|
||||
// Rule: SomeRule,
|
||||
// Outputs: []string{"$myPrivateVar"},
|
||||
// })
|
||||
// }
|
||||
type PackageContext interface {
|
||||
Import(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
|
||||
// exported Go variables from the package. For example:
|
||||
//
|
||||
// import (
|
||||
// "blueprint"
|
||||
// "foo/bar"
|
||||
// )
|
||||
// import (
|
||||
// "blueprint"
|
||||
// "foo/bar"
|
||||
// )
|
||||
//
|
||||
// var pctx = NewPackagePath("blah")
|
||||
// var pctx = NewPackagePath("blah")
|
||||
//
|
||||
// func init() {
|
||||
// pctx.Import("foo/bar")
|
||||
// }
|
||||
// func init() {
|
||||
// pctx.Import("foo/bar")
|
||||
// }
|
||||
//
|
||||
// ...
|
||||
// ...
|
||||
//
|
||||
// func (m *MyModule) GenerateBuildActions(ctx blueprint.Module) {
|
||||
// ctx.Build(pctx, blueprint.BuildParams{
|
||||
// Rule: bar.SomeRule,
|
||||
// Outputs: []string{"${bar.SomeVariable}"},
|
||||
// })
|
||||
// }
|
||||
// func (m *MyModule) GenerateBuildActions(ctx blueprint.Module) {
|
||||
// ctx.Build(pctx, blueprint.BuildParams{
|
||||
// Rule: bar.SomeRule,
|
||||
// Outputs: []string{"${bar.SomeVariable}"},
|
||||
// })
|
||||
// }
|
||||
//
|
||||
// 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
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
// you may not use this file except in compliance with the License.
|
||||
// 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
|
||||
// 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
|
||||
// from it. See PropertyNameForField for field and property name matching.
|
||||
// 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
|
||||
// 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
|
||||
// (cf. unpack_test.go for further examples)
|
||||
//
|
||||
|
|
|
@ -74,18 +74,18 @@ func visitMutator(ctx TopDownMutatorContext) {
|
|||
}
|
||||
}
|
||||
|
||||
// A
|
||||
// |
|
||||
// B
|
||||
// |\
|
||||
// C \
|
||||
// \|
|
||||
// D
|
||||
// |
|
||||
// E
|
||||
// / \
|
||||
// \ /
|
||||
// F
|
||||
// > A
|
||||
// > |
|
||||
// > B
|
||||
// > |\
|
||||
// > C \
|
||||
// > \|
|
||||
// > D
|
||||
// > |
|
||||
// > E
|
||||
// > / \
|
||||
// > \ /
|
||||
// > F
|
||||
func setupVisitTest(t *testing.T) *Context {
|
||||
ctx := NewContext()
|
||||
ctx.RegisterModuleType("visit_module", newVisitModule)
|
||||
|
@ -98,22 +98,22 @@ func setupVisitTest(t *testing.T) *Context {
|
|||
name: "A",
|
||||
visit: ["B"],
|
||||
}
|
||||
|
||||
|
||||
visit_module {
|
||||
name: "B",
|
||||
visit: ["C", "D"],
|
||||
}
|
||||
|
||||
|
||||
visit_module {
|
||||
name: "C",
|
||||
visit: ["D"],
|
||||
}
|
||||
|
||||
|
||||
visit_module {
|
||||
name: "D",
|
||||
visit: ["E"],
|
||||
}
|
||||
|
||||
|
||||
visit_module {
|
||||
name: "E",
|
||||
visit: ["F", "F"],
|
||||
|
|
Loading…
Reference in a new issue