Loading Android.bp +2 −0 Original line number Diff line number Diff line Loading @@ -70,6 +70,7 @@ bootstrap_go_package { "android/testing.go", "android/util.go", "android/variable.go", "android/visibility.go", "android/vts_config.go", "android/writedocs.go", Loading @@ -90,6 +91,7 @@ bootstrap_go_package { "android/rule_builder_test.go", "android/util_test.go", "android/variable_test.go", "android/visibility_test.go", "android/vts_config_test.go", ], } Loading README.md +72 −0 Original line number Diff line number Diff line Loading @@ -107,6 +107,30 @@ cc_binary { } ``` ### Packages The build is organized into packages where each package is a collection of related files and a specification of the dependencies among them in the form of modules. A package is defined as a directory containing a file named `Android.bp`, residing beneath the top-level directory in the build and its name is its path relative to the top-level directory. A package includes all files in its directory, plus all subdirectories beneath it, except those which themselves contain an `Android.bp` file. The modules in a package's `Android.bp` and included files are part of the module. For example, in the following directory tree (where `.../android/` is the top-level Android directory) there are two packages, `my/app`, and the subpackage `my/app/tests`. Note that `my/app/data` is not a package, but a directory belonging to package `my/app`. .../android/my/app/Android.bp .../android/my/app/app.cc .../android/my/app/data/input.txt .../android/my/app/tests/Android.bp .../android/my/app/tests/test.cc This is based on the Bazel package concept. ### Name resolution Soong provides the ability for modules in different directories to specify Loading Loading @@ -139,6 +163,54 @@ should be a space-separated list of namespaces that Soong export to Make to be built by the `m` command. After we have fully converted from Make to Soong, the details of enabling namespaces could potentially change. ### Visibility The `visibility` property on a module controls whether the module can be used by other packages. Modules are always visible to other modules declared in the same package. This is based on the Bazel visibility mechanism. If specified the `visibility` property must contain at least one rule. Each rule in the property must be in one of the following forms: * `["//visibility:public"]`: Anyone can use this module. * `["//visibility:private"]`: Only rules in the module's package (not its subpackages) can use this module. * `["//some/package:__pkg__", "//other/package:__pkg__"]`: Only modules in `some/package` and `other/package` (defined in `some/package/*.bp` and `other/package/*.bp`) have access to this module. Note that sub-packages do not have access to the rule; for example, `//some/package/foo:bar` or `//other/package/testing:bla` wouldn't have access. `__pkg__` is a special module and must be used verbatim. It represents all of the modules in the package. * `["//project:__subpackages__", "//other:__subpackages__"]`: Only modules in packages `project` or `other` or in one of their sub-packages have access to this module. For example, `//project:rule`, `//project/library:lib` or `//other/testing/internal:munge` are allowed to depend on this rule (but not `//independent:evil`) * `["//project"]`: This is shorthand for `["//project:__pkg__"]` * `[":__subpackages__"]`: This is shorthand for `["//project:__subpackages__"]` where `//project` is the module's package. e.g. using `[":__subpackages__"]` in `packages/apps/Settings/Android.bp` is equivalent to `//packages/apps/Settings:__subpackages__`. * `["//visibility:legacy_public"]`: The default visibility, behaves as `//visibility:public` for now. It is an error if it is used in a module. The visibility rules of `//visibility:public` and `//visibility:private` can not be combined with any other visibility specifications. Packages outside `vendor/` cannot make themselves visible to specific packages in `vendor/`, e.g. a module in `libcore` cannot declare that it is visible to say `vendor/google`, instead it must make itself visible to all packages within `vendor/` using `//vendor:__subpackages__`. If a module does not specify the `visibility` property the module is `//visibility:legacy_public`. Once the build has been completely switched over to soong it is possible that a global refactoring will be done to change this to `//visibility:private` at which point all modules that do not currently specify a `visibility` property will be updated to have `visibility = [//visibility:legacy_public]` added. It will then be the owner's responsibility to replace that with a more appropriate visibility. ### Formatter Soong includes a canonical formatter for blueprint files, similar to Loading android/module.go +27 −0 Original line number Diff line number Diff line Loading @@ -210,6 +210,33 @@ type commonProperties struct { // emit build rules for this module Enabled *bool `android:"arch_variant"` // Controls the visibility of this module to other modules. Allowable values are one or more of // these formats: // // ["//visibility:public"]: Anyone can use this module. // ["//visibility:private"]: Only rules in the module's package (not its subpackages) can use // this module. // ["//some/package:__pkg__", "//other/package:__pkg__"]: Only modules in some/package and // other/package (defined in some/package/*.bp and other/package/*.bp) have access to // this module. Note that sub-packages do not have access to the rule; for example, // //some/package/foo:bar or //other/package/testing:bla wouldn't have access. __pkg__ // is a special module and must be used verbatim. It represents all of the modules in the // package. // ["//project:__subpackages__", "//other:__subpackages__"]: Only modules in packages project // or other or in one of their sub-packages have access to this module. For example, // //project:rule, //project/library:lib or //other/testing/internal:munge are allowed // to depend on this rule (but not //independent:evil) // ["//project"]: This is shorthand for ["//project:__pkg__"] // [":__subpackages__"]: This is shorthand for ["//project:__subpackages__"] where // //project is the module's package. e.g. using [":__subpackages__"] in // packages/apps/Settings/Android.bp is equivalent to // //packages/apps/Settings:__subpackages__. // ["//visibility:legacy_public"]: The default visibility, behaves as //visibility:public // for now. It is an error if it is used in a module. // See https://android.googlesource.com/platform/build/soong/+/master/README.md#visibility for // more details. Visibility []string // control whether this module compiles for 32-bit, 64-bit, or both. Possible values // are "32" (compile for 32-bit only), "64" (compile for 64-bit only), "both" (compile for both // architectures), or "first" (compile for 64-bit on a 64-bit platform, and 32-bit on a 32-bit Loading android/mutator.go +3 −0 Original line number Diff line number Diff line Loading @@ -78,6 +78,7 @@ var preArch = []RegisterMutatorFunc{ RegisterPrebuiltsPreArchMutators, RegisterDefaultsPreArchMutators, RegisterOverridePreArchMutators, registerVisibilityRuleGatherer, } func registerArchMutator(ctx RegisterMutatorsContext) { Loading @@ -92,6 +93,7 @@ var preDeps = []RegisterMutatorFunc{ var postDeps = []RegisterMutatorFunc{ registerPathDepsMutator, RegisterPrebuiltsPostDepsMutators, registerVisibilityRuleEnforcer, registerNeverallowMutator, } Loading @@ -118,6 +120,7 @@ type TopDownMutatorContext interface { Module() Module OtherModuleName(m blueprint.Module) string OtherModuleDir(m blueprint.Module) string OtherModuleErrorf(m blueprint.Module, fmt string, args ...interface{}) OtherModuleDependencyTag(m blueprint.Module) blueprint.DependencyTag Loading android/namespace.go +3 −9 Original line number Diff line number Diff line Loading @@ -26,12 +26,6 @@ import ( "github.com/google/blueprint" ) // This file implements namespaces const ( namespacePrefix = "//" modulePrefix = ":" ) func init() { RegisterModuleType("soong_namespace", NamespaceFactory) } Loading Loading @@ -215,11 +209,11 @@ func (r *NameResolver) AllModules() []blueprint.ModuleGroup { // parses a fully-qualified path (like "//namespace_path:module_name") into a namespace name and a // module name func (r *NameResolver) parseFullyQualifiedName(name string) (namespaceName string, moduleName string, ok bool) { if !strings.HasPrefix(name, namespacePrefix) { if !strings.HasPrefix(name, "//") { return "", "", false } name = strings.TrimPrefix(name, namespacePrefix) components := strings.Split(name, modulePrefix) name = strings.TrimPrefix(name, "//") components := strings.Split(name, ":") if len(components) != 2 { return "", "", false } Loading Loading
Android.bp +2 −0 Original line number Diff line number Diff line Loading @@ -70,6 +70,7 @@ bootstrap_go_package { "android/testing.go", "android/util.go", "android/variable.go", "android/visibility.go", "android/vts_config.go", "android/writedocs.go", Loading @@ -90,6 +91,7 @@ bootstrap_go_package { "android/rule_builder_test.go", "android/util_test.go", "android/variable_test.go", "android/visibility_test.go", "android/vts_config_test.go", ], } Loading
README.md +72 −0 Original line number Diff line number Diff line Loading @@ -107,6 +107,30 @@ cc_binary { } ``` ### Packages The build is organized into packages where each package is a collection of related files and a specification of the dependencies among them in the form of modules. A package is defined as a directory containing a file named `Android.bp`, residing beneath the top-level directory in the build and its name is its path relative to the top-level directory. A package includes all files in its directory, plus all subdirectories beneath it, except those which themselves contain an `Android.bp` file. The modules in a package's `Android.bp` and included files are part of the module. For example, in the following directory tree (where `.../android/` is the top-level Android directory) there are two packages, `my/app`, and the subpackage `my/app/tests`. Note that `my/app/data` is not a package, but a directory belonging to package `my/app`. .../android/my/app/Android.bp .../android/my/app/app.cc .../android/my/app/data/input.txt .../android/my/app/tests/Android.bp .../android/my/app/tests/test.cc This is based on the Bazel package concept. ### Name resolution Soong provides the ability for modules in different directories to specify Loading Loading @@ -139,6 +163,54 @@ should be a space-separated list of namespaces that Soong export to Make to be built by the `m` command. After we have fully converted from Make to Soong, the details of enabling namespaces could potentially change. ### Visibility The `visibility` property on a module controls whether the module can be used by other packages. Modules are always visible to other modules declared in the same package. This is based on the Bazel visibility mechanism. If specified the `visibility` property must contain at least one rule. Each rule in the property must be in one of the following forms: * `["//visibility:public"]`: Anyone can use this module. * `["//visibility:private"]`: Only rules in the module's package (not its subpackages) can use this module. * `["//some/package:__pkg__", "//other/package:__pkg__"]`: Only modules in `some/package` and `other/package` (defined in `some/package/*.bp` and `other/package/*.bp`) have access to this module. Note that sub-packages do not have access to the rule; for example, `//some/package/foo:bar` or `//other/package/testing:bla` wouldn't have access. `__pkg__` is a special module and must be used verbatim. It represents all of the modules in the package. * `["//project:__subpackages__", "//other:__subpackages__"]`: Only modules in packages `project` or `other` or in one of their sub-packages have access to this module. For example, `//project:rule`, `//project/library:lib` or `//other/testing/internal:munge` are allowed to depend on this rule (but not `//independent:evil`) * `["//project"]`: This is shorthand for `["//project:__pkg__"]` * `[":__subpackages__"]`: This is shorthand for `["//project:__subpackages__"]` where `//project` is the module's package. e.g. using `[":__subpackages__"]` in `packages/apps/Settings/Android.bp` is equivalent to `//packages/apps/Settings:__subpackages__`. * `["//visibility:legacy_public"]`: The default visibility, behaves as `//visibility:public` for now. It is an error if it is used in a module. The visibility rules of `//visibility:public` and `//visibility:private` can not be combined with any other visibility specifications. Packages outside `vendor/` cannot make themselves visible to specific packages in `vendor/`, e.g. a module in `libcore` cannot declare that it is visible to say `vendor/google`, instead it must make itself visible to all packages within `vendor/` using `//vendor:__subpackages__`. If a module does not specify the `visibility` property the module is `//visibility:legacy_public`. Once the build has been completely switched over to soong it is possible that a global refactoring will be done to change this to `//visibility:private` at which point all modules that do not currently specify a `visibility` property will be updated to have `visibility = [//visibility:legacy_public]` added. It will then be the owner's responsibility to replace that with a more appropriate visibility. ### Formatter Soong includes a canonical formatter for blueprint files, similar to Loading
android/module.go +27 −0 Original line number Diff line number Diff line Loading @@ -210,6 +210,33 @@ type commonProperties struct { // emit build rules for this module Enabled *bool `android:"arch_variant"` // Controls the visibility of this module to other modules. Allowable values are one or more of // these formats: // // ["//visibility:public"]: Anyone can use this module. // ["//visibility:private"]: Only rules in the module's package (not its subpackages) can use // this module. // ["//some/package:__pkg__", "//other/package:__pkg__"]: Only modules in some/package and // other/package (defined in some/package/*.bp and other/package/*.bp) have access to // this module. Note that sub-packages do not have access to the rule; for example, // //some/package/foo:bar or //other/package/testing:bla wouldn't have access. __pkg__ // is a special module and must be used verbatim. It represents all of the modules in the // package. // ["//project:__subpackages__", "//other:__subpackages__"]: Only modules in packages project // or other or in one of their sub-packages have access to this module. For example, // //project:rule, //project/library:lib or //other/testing/internal:munge are allowed // to depend on this rule (but not //independent:evil) // ["//project"]: This is shorthand for ["//project:__pkg__"] // [":__subpackages__"]: This is shorthand for ["//project:__subpackages__"] where // //project is the module's package. e.g. using [":__subpackages__"] in // packages/apps/Settings/Android.bp is equivalent to // //packages/apps/Settings:__subpackages__. // ["//visibility:legacy_public"]: The default visibility, behaves as //visibility:public // for now. It is an error if it is used in a module. // See https://android.googlesource.com/platform/build/soong/+/master/README.md#visibility for // more details. Visibility []string // control whether this module compiles for 32-bit, 64-bit, or both. Possible values // are "32" (compile for 32-bit only), "64" (compile for 64-bit only), "both" (compile for both // architectures), or "first" (compile for 64-bit on a 64-bit platform, and 32-bit on a 32-bit Loading
android/mutator.go +3 −0 Original line number Diff line number Diff line Loading @@ -78,6 +78,7 @@ var preArch = []RegisterMutatorFunc{ RegisterPrebuiltsPreArchMutators, RegisterDefaultsPreArchMutators, RegisterOverridePreArchMutators, registerVisibilityRuleGatherer, } func registerArchMutator(ctx RegisterMutatorsContext) { Loading @@ -92,6 +93,7 @@ var preDeps = []RegisterMutatorFunc{ var postDeps = []RegisterMutatorFunc{ registerPathDepsMutator, RegisterPrebuiltsPostDepsMutators, registerVisibilityRuleEnforcer, registerNeverallowMutator, } Loading @@ -118,6 +120,7 @@ type TopDownMutatorContext interface { Module() Module OtherModuleName(m blueprint.Module) string OtherModuleDir(m blueprint.Module) string OtherModuleErrorf(m blueprint.Module, fmt string, args ...interface{}) OtherModuleDependencyTag(m blueprint.Module) blueprint.DependencyTag Loading
android/namespace.go +3 −9 Original line number Diff line number Diff line Loading @@ -26,12 +26,6 @@ import ( "github.com/google/blueprint" ) // This file implements namespaces const ( namespacePrefix = "//" modulePrefix = ":" ) func init() { RegisterModuleType("soong_namespace", NamespaceFactory) } Loading Loading @@ -215,11 +209,11 @@ func (r *NameResolver) AllModules() []blueprint.ModuleGroup { // parses a fully-qualified path (like "//namespace_path:module_name") into a namespace name and a // module name func (r *NameResolver) parseFullyQualifiedName(name string) (namespaceName string, moduleName string, ok bool) { if !strings.HasPrefix(name, namespacePrefix) { if !strings.HasPrefix(name, "//") { return "", "", false } name = strings.TrimPrefix(name, namespacePrefix) components := strings.Split(name, modulePrefix) name = strings.TrimPrefix(name, "//") components := strings.Split(name, ":") if len(components) != 2 { return "", "", false } Loading