2015-01-31 02:27:36 +01:00
|
|
|
// Copyright 2015 Google Inc. All rights reserved.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// 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
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
package android
|
2015-01-31 02:27:36 +01:00
|
|
|
|
|
|
|
import (
|
2023-05-15 11:06:31 +02:00
|
|
|
"crypto/md5"
|
|
|
|
"encoding/hex"
|
|
|
|
"encoding/json"
|
2015-12-18 01:39:19 +01:00
|
|
|
"fmt"
|
2022-02-09 20:54:35 +01:00
|
|
|
"net/url"
|
2020-01-11 02:11:46 +01:00
|
|
|
"os"
|
2019-01-17 22:57:45 +01:00
|
|
|
"path"
|
2015-01-31 02:27:36 +01:00
|
|
|
"path/filepath"
|
2022-01-05 19:46:24 +01:00
|
|
|
"reflect"
|
2020-05-07 09:12:13 +02:00
|
|
|
"regexp"
|
2022-02-09 20:54:35 +01:00
|
|
|
"sort"
|
2015-12-18 01:39:19 +01:00
|
|
|
"strings"
|
2017-11-29 09:27:14 +01:00
|
|
|
"text/scanner"
|
2015-03-24 19:13:38 +01:00
|
|
|
|
2021-09-09 17:37:49 +02:00
|
|
|
"android/soong/bazel"
|
2023-06-08 16:28:51 +02:00
|
|
|
"android/soong/ui/metrics/bp2build_metrics_proto"
|
2022-12-19 17:27:25 +01:00
|
|
|
|
2015-03-24 19:13:38 +01:00
|
|
|
"github.com/google/blueprint"
|
2018-09-12 19:02:13 +02:00
|
|
|
"github.com/google/blueprint/proptools"
|
2015-01-31 02:27:36 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
DeviceSharedLibrary = "shared_library"
|
|
|
|
DeviceStaticLibrary = "static_library"
|
|
|
|
)
|
|
|
|
|
2023-03-15 21:50:18 +01:00
|
|
|
// BuildParameters describes the set of potential parameters to build a Ninja rule.
|
|
|
|
// In general, these correspond to a Ninja concept.
|
2017-10-24 02:16:14 +02:00
|
|
|
type BuildParams struct {
|
2023-03-15 21:50:18 +01:00
|
|
|
// A Ninja Rule that will be written to the Ninja file. This allows factoring out common code
|
|
|
|
// among multiple modules to reduce repetition in the Ninja file of action requirements. A rule
|
|
|
|
// can contain variables that should be provided in Args.
|
|
|
|
Rule blueprint.Rule
|
|
|
|
// Deps represents the depfile format. When using RuleBuilder, this defaults to GCC when depfiles
|
|
|
|
// are used.
|
|
|
|
Deps blueprint.Deps
|
|
|
|
// Depfile is a writeable path that allows correct incremental builds when the inputs have not
|
|
|
|
// been fully specified by the Ninja rule. Ninja supports a subset of the Makefile depfile syntax.
|
|
|
|
Depfile WritablePath
|
|
|
|
// A description of the build action.
|
|
|
|
Description string
|
|
|
|
// Output is an output file of the action. When using this field, references to $out in the Ninja
|
|
|
|
// command will refer to this file.
|
|
|
|
Output WritablePath
|
|
|
|
// Outputs is a slice of output file of the action. When using this field, references to $out in
|
|
|
|
// the Ninja command will refer to these files.
|
|
|
|
Outputs WritablePaths
|
|
|
|
// SymlinkOutput is an output file specifically that is a symlink.
|
|
|
|
SymlinkOutput WritablePath
|
|
|
|
// SymlinkOutputs is a slice of output files specifically that is a symlink.
|
|
|
|
SymlinkOutputs WritablePaths
|
|
|
|
// ImplicitOutput is an output file generated by the action. Note: references to `$out` in the
|
|
|
|
// Ninja command will NOT include references to this file.
|
|
|
|
ImplicitOutput WritablePath
|
|
|
|
// ImplicitOutputs is a slice of output files generated by the action. Note: references to `$out`
|
|
|
|
// in the Ninja command will NOT include references to these files.
|
2016-11-03 22:28:31 +01:00
|
|
|
ImplicitOutputs WritablePaths
|
2023-03-15 21:50:18 +01:00
|
|
|
// Input is an input file to the Ninja action. When using this field, references to $in in the
|
|
|
|
// Ninja command will refer to this file.
|
|
|
|
Input Path
|
|
|
|
// Inputs is a slice of input files to the Ninja action. When using this field, references to $in
|
|
|
|
// in the Ninja command will refer to these files.
|
|
|
|
Inputs Paths
|
|
|
|
// Implicit is an input file to the Ninja action. Note: references to `$in` in the Ninja command
|
|
|
|
// will NOT include references to this file.
|
|
|
|
Implicit Path
|
|
|
|
// Implicits is a slice of input files to the Ninja action. Note: references to `$in` in the Ninja
|
|
|
|
// command will NOT include references to these files.
|
|
|
|
Implicits Paths
|
|
|
|
// OrderOnly are Ninja order-only inputs to the action. When these are out of date, the output is
|
|
|
|
// not rebuilt until they are built, but changes in order-only dependencies alone do not cause the
|
|
|
|
// output to be rebuilt.
|
|
|
|
OrderOnly Paths
|
|
|
|
// Validation is an output path for a validation action. Validation outputs imply lower
|
|
|
|
// non-blocking priority to building non-validation outputs.
|
|
|
|
Validation Path
|
|
|
|
// Validations is a slice of output path for a validation action. Validation outputs imply lower
|
|
|
|
// non-blocking priority to building non-validation outputs.
|
|
|
|
Validations Paths
|
|
|
|
// Whether to skip outputting a default target statement which will be built by Ninja when no
|
|
|
|
// targets are specified on Ninja's command line.
|
|
|
|
Default bool
|
|
|
|
// Args is a key value mapping for replacements of variables within the Rule
|
|
|
|
Args map[string]string
|
2015-09-24 00:26:20 +02:00
|
|
|
}
|
|
|
|
|
2017-10-24 02:16:14 +02:00
|
|
|
type ModuleBuildParams BuildParams
|
|
|
|
|
2019-12-31 03:43:07 +01:00
|
|
|
// EarlyModuleContext provides methods that can be called early, as soon as the properties have
|
|
|
|
// been parsed into the module and before any mutators have run.
|
|
|
|
type EarlyModuleContext interface {
|
2020-09-17 04:04:41 +02:00
|
|
|
// Module returns the current module as a Module. It should rarely be necessary, as the module already has a
|
|
|
|
// reference to itself.
|
2019-06-07 01:13:11 +02:00
|
|
|
Module() Module
|
2020-09-17 04:04:41 +02:00
|
|
|
|
|
|
|
// ModuleName returns the name of the module. This is generally the value that was returned by Module.Name() when
|
|
|
|
// the module was created, but may have been modified by calls to BaseMutatorContext.Rename.
|
2019-06-06 23:33:29 +02:00
|
|
|
ModuleName() string
|
2020-09-17 04:04:41 +02:00
|
|
|
|
|
|
|
// ModuleDir returns the path to the directory that contains the definition of the module.
|
2019-06-06 23:33:29 +02:00
|
|
|
ModuleDir() string
|
2020-09-17 04:04:41 +02:00
|
|
|
|
|
|
|
// ModuleType returns the name of the module type that was used to create the module, as specified in
|
|
|
|
// RegisterModuleType.
|
2019-06-06 23:33:29 +02:00
|
|
|
ModuleType() string
|
2020-09-17 04:04:41 +02:00
|
|
|
|
|
|
|
// BlueprintFile returns the name of the blueprint file that contains the definition of this
|
|
|
|
// module.
|
2019-11-23 01:03:51 +01:00
|
|
|
BlueprintsFile() string
|
2019-12-31 03:43:07 +01:00
|
|
|
|
2020-09-17 04:04:41 +02:00
|
|
|
// ContainsProperty returns true if the specified property name was set in the module definition.
|
2019-12-31 03:43:07 +01:00
|
|
|
ContainsProperty(name string) bool
|
2020-09-17 04:04:41 +02:00
|
|
|
|
|
|
|
// Errorf reports an error at the specified position of the module definition file.
|
2019-12-31 03:43:07 +01:00
|
|
|
Errorf(pos scanner.Position, fmt string, args ...interface{})
|
2020-09-17 04:04:41 +02:00
|
|
|
|
|
|
|
// ModuleErrorf reports an error at the line number of the module type in the module definition.
|
2019-12-31 03:43:07 +01:00
|
|
|
ModuleErrorf(fmt string, args ...interface{})
|
2020-09-17 04:04:41 +02:00
|
|
|
|
|
|
|
// PropertyErrorf reports an error at the line number of a property in the module definition.
|
2019-12-31 03:43:07 +01:00
|
|
|
PropertyErrorf(property, fmt string, args ...interface{})
|
2020-09-17 04:04:41 +02:00
|
|
|
|
|
|
|
// Failed returns true if any errors have been reported. In most cases the module can continue with generating
|
|
|
|
// build rules after an error, allowing it to report additional errors in a single run, but in cases where the error
|
|
|
|
// has prevented the module from creating necessary data it can return early when Failed returns true.
|
2019-12-31 03:43:07 +01:00
|
|
|
Failed() bool
|
|
|
|
|
2020-09-17 04:04:41 +02:00
|
|
|
// AddNinjaFileDeps adds dependencies on the specified files to the rule that creates the ninja manifest. The
|
|
|
|
// primary builder will be rerun whenever the specified files are modified.
|
2019-12-31 03:43:07 +01:00
|
|
|
AddNinjaFileDeps(deps ...string)
|
|
|
|
|
|
|
|
DeviceSpecific() bool
|
|
|
|
SocSpecific() bool
|
|
|
|
ProductSpecific() bool
|
|
|
|
SystemExtSpecific() bool
|
|
|
|
Platform() bool
|
|
|
|
|
2019-06-06 23:33:29 +02:00
|
|
|
Config() Config
|
2019-12-31 03:43:07 +01:00
|
|
|
DeviceConfig() DeviceConfig
|
|
|
|
|
|
|
|
// Deprecated: use Config()
|
|
|
|
AConfig() Config
|
|
|
|
|
|
|
|
// GlobWithDeps returns a list of files that match the specified pattern but do not match any
|
|
|
|
// of the patterns in excludes. It also adds efficient dependencies to rerun the primary
|
|
|
|
// builder whenever a file matching the pattern as added or removed, without rerunning if a
|
|
|
|
// file that does not match the pattern is added to a searched directory.
|
|
|
|
GlobWithDeps(pattern string, excludes []string) ([]string, error)
|
|
|
|
|
|
|
|
Glob(globPattern string, excludes []string) Paths
|
|
|
|
GlobFiles(globPattern string, excludes []string) Paths
|
2020-01-11 02:11:46 +01:00
|
|
|
IsSymlink(path Path) bool
|
|
|
|
Readlink(path Path) string
|
2020-08-15 02:38:45 +02:00
|
|
|
|
2020-09-17 04:04:41 +02:00
|
|
|
// Namespace returns the Namespace object provided by the NameInterface set by Context.SetNameInterface, or the
|
|
|
|
// default SimpleNameInterface if Context.SetNameInterface was not called.
|
2020-08-15 02:38:45 +02:00
|
|
|
Namespace() *Namespace
|
2019-12-31 03:43:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// BaseModuleContext is the same as blueprint.BaseModuleContext except that Config() returns
|
|
|
|
// a Config instead of an interface{}, and some methods have been wrapped to use an android.Module
|
|
|
|
// instead of a blueprint.Module, plus some extra methods that return Android-specific information
|
|
|
|
// about the current module.
|
|
|
|
type BaseModuleContext interface {
|
|
|
|
EarlyModuleContext
|
2019-06-06 23:33:29 +02:00
|
|
|
|
2020-05-07 21:21:34 +02:00
|
|
|
blueprintBaseModuleContext() blueprint.BaseModuleContext
|
|
|
|
|
2020-09-17 04:04:41 +02:00
|
|
|
// OtherModuleName returns the name of another Module. See BaseModuleContext.ModuleName for more information.
|
|
|
|
// It is intended for use inside the visit functions of Visit* and WalkDeps.
|
2019-06-07 01:13:11 +02:00
|
|
|
OtherModuleName(m blueprint.Module) string
|
2020-09-17 04:04:41 +02:00
|
|
|
|
|
|
|
// OtherModuleDir returns the directory of another Module. See BaseModuleContext.ModuleDir for more information.
|
|
|
|
// It is intended for use inside the visit functions of Visit* and WalkDeps.
|
2019-06-07 01:13:11 +02:00
|
|
|
OtherModuleDir(m blueprint.Module) string
|
2020-09-17 04:04:41 +02:00
|
|
|
|
|
|
|
// OtherModuleErrorf reports an error on another Module. See BaseModuleContext.ModuleErrorf for more information.
|
|
|
|
// It is intended for use inside the visit functions of Visit* and WalkDeps.
|
2019-06-07 01:13:11 +02:00
|
|
|
OtherModuleErrorf(m blueprint.Module, fmt string, args ...interface{})
|
2020-09-17 04:04:41 +02:00
|
|
|
|
|
|
|
// OtherModuleDependencyTag returns the dependency tag used to depend on a module, or nil if there is no dependency
|
|
|
|
// on the module. When called inside a Visit* method with current module being visited, and there are multiple
|
|
|
|
// dependencies on the module being visited, it returns the dependency tag used for the current dependency.
|
2019-06-07 01:13:11 +02:00
|
|
|
OtherModuleDependencyTag(m blueprint.Module) blueprint.DependencyTag
|
2020-09-17 04:04:41 +02:00
|
|
|
|
|
|
|
// OtherModuleExists returns true if a module with the specified name exists, as determined by the NameInterface
|
|
|
|
// passed to Context.SetNameInterface, or SimpleNameInterface if it was not called.
|
2019-06-07 01:13:11 +02:00
|
|
|
OtherModuleExists(name string) bool
|
2020-09-17 04:04:41 +02:00
|
|
|
|
|
|
|
// OtherModuleDependencyVariantExists returns true if a module with the
|
|
|
|
// specified name and variant exists. The variant must match the given
|
|
|
|
// variations. It must also match all the non-local variations of the current
|
2021-05-05 16:27:31 +02:00
|
|
|
// module. In other words, it checks for the module that AddVariationDependencies
|
2020-09-17 04:04:41 +02:00
|
|
|
// would add a dependency on with the same arguments.
|
2020-03-05 18:34:13 +01:00
|
|
|
OtherModuleDependencyVariantExists(variations []blueprint.Variation, name string) bool
|
2020-09-17 04:04:41 +02:00
|
|
|
|
2021-05-05 16:27:31 +02:00
|
|
|
// OtherModuleFarDependencyVariantExists returns true if a module with the
|
|
|
|
// specified name and variant exists. The variant must match the given
|
|
|
|
// variations, but not the non-local variations of the current module. In
|
|
|
|
// other words, it checks for the module that AddFarVariationDependencies
|
|
|
|
// would add a dependency on with the same arguments.
|
|
|
|
OtherModuleFarDependencyVariantExists(variations []blueprint.Variation, name string) bool
|
|
|
|
|
2020-09-17 04:04:41 +02:00
|
|
|
// OtherModuleReverseDependencyVariantExists returns true if a module with the
|
|
|
|
// specified name exists with the same variations as the current module. In
|
2021-05-05 16:27:31 +02:00
|
|
|
// other words, it checks for the module that AddReverseDependency would add a
|
2020-09-17 04:04:41 +02:00
|
|
|
// dependency on with the same argument.
|
2020-03-05 18:34:13 +01:00
|
|
|
OtherModuleReverseDependencyVariantExists(name string) bool
|
2020-09-17 04:04:41 +02:00
|
|
|
|
|
|
|
// OtherModuleType returns the type of another Module. See BaseModuleContext.ModuleType for more information.
|
|
|
|
// It is intended for use inside the visit functions of Visit* and WalkDeps.
|
2019-08-09 13:39:45 +02:00
|
|
|
OtherModuleType(m blueprint.Module) string
|
2019-06-07 01:13:11 +02:00
|
|
|
|
2020-07-02 20:38:17 +02:00
|
|
|
// OtherModuleProvider returns the value for a provider for the given module. If the value is
|
|
|
|
// not set it returns the zero value of the type of the provider, so the return value can always
|
|
|
|
// be type asserted to the type of the provider. The value returned may be a deep copy of the
|
|
|
|
// value originally passed to SetProvider.
|
|
|
|
OtherModuleProvider(m blueprint.Module, provider blueprint.ProviderKey) interface{}
|
|
|
|
|
|
|
|
// OtherModuleHasProvider returns true if the provider for the given module has been set.
|
|
|
|
OtherModuleHasProvider(m blueprint.Module, provider blueprint.ProviderKey) bool
|
|
|
|
|
|
|
|
// Provider returns the value for a provider for the current module. If the value is
|
|
|
|
// not set it returns the zero value of the type of the provider, so the return value can always
|
|
|
|
// be type asserted to the type of the provider. It panics if called before the appropriate
|
|
|
|
// mutator or GenerateBuildActions pass for the provider. The value returned may be a deep
|
|
|
|
// copy of the value originally passed to SetProvider.
|
|
|
|
Provider(provider blueprint.ProviderKey) interface{}
|
|
|
|
|
|
|
|
// HasProvider returns true if the provider for the current module has been set.
|
|
|
|
HasProvider(provider blueprint.ProviderKey) bool
|
|
|
|
|
|
|
|
// SetProvider sets the value for a provider for the current module. It panics if not called
|
|
|
|
// during the appropriate mutator or GenerateBuildActions pass for the provider, if the value
|
|
|
|
// is not of the appropriate type, or if the value has already been set. The value should not
|
|
|
|
// be modified after being passed to SetProvider.
|
|
|
|
SetProvider(provider blueprint.ProviderKey, value interface{})
|
|
|
|
|
2019-06-07 01:13:11 +02:00
|
|
|
GetDirectDepsWithTag(tag blueprint.DependencyTag) []Module
|
2020-09-17 04:04:41 +02:00
|
|
|
|
|
|
|
// GetDirectDepWithTag returns the Module the direct dependency with the specified name, or nil if
|
|
|
|
// none exists. It panics if the dependency does not have the specified tag. It skips any
|
|
|
|
// dependencies that are not an android.Module.
|
2019-06-07 01:13:11 +02:00
|
|
|
GetDirectDepWithTag(name string, tag blueprint.DependencyTag) blueprint.Module
|
2020-09-17 04:04:41 +02:00
|
|
|
|
|
|
|
// GetDirectDep returns the Module and DependencyTag for the direct dependency with the specified
|
|
|
|
// name, or nil if none exists. If there are multiple dependencies on the same module it returns
|
2021-04-26 21:47:28 +02:00
|
|
|
// the first DependencyTag.
|
2019-06-07 01:13:11 +02:00
|
|
|
GetDirectDep(name string) (blueprint.Module, blueprint.DependencyTag)
|
|
|
|
|
2021-07-21 20:34:58 +02:00
|
|
|
ModuleFromName(name string) (blueprint.Module, bool)
|
|
|
|
|
2020-09-17 04:04:41 +02:00
|
|
|
// VisitDirectDepsBlueprint calls visit for each direct dependency. If there are multiple
|
|
|
|
// direct dependencies on the same module visit will be called multiple times on that module
|
|
|
|
// and OtherModuleDependencyTag will return a different tag for each.
|
|
|
|
//
|
|
|
|
// The Module passed to the visit function should not be retained outside of the visit
|
|
|
|
// function, it may be invalidated by future mutators.
|
2019-06-07 01:13:11 +02:00
|
|
|
VisitDirectDepsBlueprint(visit func(blueprint.Module))
|
2020-09-17 04:04:41 +02:00
|
|
|
|
|
|
|
// VisitDirectDeps calls visit for each direct dependency. If there are multiple
|
|
|
|
// direct dependencies on the same module visit will be called multiple times on that module
|
2021-08-04 22:50:04 +02:00
|
|
|
// and OtherModuleDependencyTag will return a different tag for each. It raises an error if any of the
|
|
|
|
// dependencies are not an android.Module.
|
2020-09-17 04:04:41 +02:00
|
|
|
//
|
|
|
|
// The Module passed to the visit function should not be retained outside of the visit
|
|
|
|
// function, it may be invalidated by future mutators.
|
2019-06-07 01:13:11 +02:00
|
|
|
VisitDirectDeps(visit func(Module))
|
2020-09-17 04:04:41 +02:00
|
|
|
|
2019-06-07 01:13:11 +02:00
|
|
|
VisitDirectDepsWithTag(tag blueprint.DependencyTag, visit func(Module))
|
2020-09-17 04:04:41 +02:00
|
|
|
|
|
|
|
// VisitDirectDepsIf calls pred for each direct dependency, and if pred returns true calls visit. If there are
|
|
|
|
// multiple direct dependencies on the same module pred and visit will be called multiple times on that module and
|
|
|
|
// OtherModuleDependencyTag will return a different tag for each. It skips any
|
|
|
|
// dependencies that are not an android.Module.
|
|
|
|
//
|
|
|
|
// The Module passed to the visit function should not be retained outside of the visit function, it may be
|
|
|
|
// invalidated by future mutators.
|
2019-06-07 01:13:11 +02:00
|
|
|
VisitDirectDepsIf(pred func(Module) bool, visit func(Module))
|
|
|
|
// Deprecated: use WalkDeps instead to support multiple dependency tags on the same module
|
|
|
|
VisitDepsDepthFirst(visit func(Module))
|
|
|
|
// Deprecated: use WalkDeps instead to support multiple dependency tags on the same module
|
|
|
|
VisitDepsDepthFirstIf(pred func(Module) bool, visit func(Module))
|
2020-09-17 04:04:41 +02:00
|
|
|
|
|
|
|
// WalkDeps calls visit for each transitive dependency, traversing the dependency tree in top down order. visit may
|
|
|
|
// be called multiple times for the same (child, parent) pair if there are multiple direct dependencies between the
|
|
|
|
// child and parent with different tags. OtherModuleDependencyTag will return the tag for the currently visited
|
|
|
|
// (child, parent) pair. If visit returns false WalkDeps will not continue recursing down to child. It skips
|
|
|
|
// any dependencies that are not an android.Module.
|
|
|
|
//
|
|
|
|
// The Modules passed to the visit function should not be retained outside of the visit function, they may be
|
|
|
|
// invalidated by future mutators.
|
2021-12-15 18:45:49 +01:00
|
|
|
WalkDeps(visit func(child, parent Module) bool)
|
2020-09-17 04:04:41 +02:00
|
|
|
|
|
|
|
// WalkDepsBlueprint calls visit for each transitive dependency, traversing the dependency
|
|
|
|
// tree in top down order. visit may be called multiple times for the same (child, parent)
|
|
|
|
// pair if there are multiple direct dependencies between the child and parent with different
|
|
|
|
// tags. OtherModuleDependencyTag will return the tag for the currently visited
|
|
|
|
// (child, parent) pair. If visit returns false WalkDeps will not continue recursing down
|
|
|
|
// to child.
|
|
|
|
//
|
|
|
|
// The Modules passed to the visit function should not be retained outside of the visit function, they may be
|
|
|
|
// invalidated by future mutators.
|
2019-06-07 01:13:11 +02:00
|
|
|
WalkDepsBlueprint(visit func(blueprint.Module, blueprint.Module) bool)
|
2020-09-17 04:04:41 +02:00
|
|
|
|
2019-06-07 01:13:11 +02:00
|
|
|
// GetWalkPath is supposed to be called in visit function passed in WalkDeps()
|
|
|
|
// and returns a top-down dependency path from a start module to current child module.
|
|
|
|
GetWalkPath() []Module
|
|
|
|
|
2020-09-17 04:22:27 +02:00
|
|
|
// PrimaryModule returns the first variant of the current module. Variants of a module are always visited in
|
|
|
|
// order by mutators and GenerateBuildActions, so the data created by the current mutator can be read from the
|
|
|
|
// Module returned by PrimaryModule without data races. This can be used to perform singleton actions that are
|
|
|
|
// only done once for all variants of a module.
|
|
|
|
PrimaryModule() Module
|
|
|
|
|
|
|
|
// FinalModule returns the last variant of the current module. Variants of a module are always visited in
|
|
|
|
// order by mutators and GenerateBuildActions, so the data created by the current mutator can be read from all
|
|
|
|
// variants using VisitAllModuleVariants if the current module == FinalModule(). This can be used to perform
|
|
|
|
// singleton actions that are only done once for all variants of a module.
|
|
|
|
FinalModule() Module
|
|
|
|
|
|
|
|
// VisitAllModuleVariants calls visit for each variant of the current module. Variants of a module are always
|
|
|
|
// visited in order by mutators and GenerateBuildActions, so the data created by the current mutator can be read
|
|
|
|
// from all variants if the current module == FinalModule(). Otherwise, care must be taken to not access any
|
|
|
|
// data modified by the current mutator.
|
|
|
|
VisitAllModuleVariants(visit func(Module))
|
|
|
|
|
2020-03-31 12:31:36 +02:00
|
|
|
// GetTagPath is supposed to be called in visit function passed in WalkDeps()
|
|
|
|
// and returns a top-down dependency tags path from a start module to current child module.
|
|
|
|
// It has one less entry than GetWalkPath() as it contains the dependency tags that
|
|
|
|
// exist between each adjacent pair of modules in the GetWalkPath().
|
|
|
|
// GetTagPath()[i] is the tag between GetWalkPath()[i] and GetWalkPath()[i+1]
|
|
|
|
GetTagPath() []blueprint.DependencyTag
|
|
|
|
|
2020-05-07 09:12:13 +02:00
|
|
|
// GetPathString is supposed to be called in visit function passed in WalkDeps()
|
|
|
|
// and returns a multi-line string showing the modules and dependency tags
|
|
|
|
// among them along the top-down dependency path from a start module to current child module.
|
|
|
|
// skipFirst when set to true, the output doesn't include the start module,
|
|
|
|
// which is already printed when this function is used along with ModuleErrorf().
|
|
|
|
GetPathString(skipFirst bool) string
|
|
|
|
|
2019-06-07 01:13:11 +02:00
|
|
|
AddMissingDependencies(missingDeps []string)
|
|
|
|
|
2023-05-17 19:01:48 +02:00
|
|
|
// getMissingDependencies returns the list of missing dependencies.
|
|
|
|
// Calling this function prevents adding new dependencies.
|
|
|
|
getMissingDependencies() []string
|
|
|
|
|
2021-08-26 14:37:59 +02:00
|
|
|
// AddUnconvertedBp2buildDep stores module name of a direct dependency that was not converted via bp2build
|
|
|
|
AddUnconvertedBp2buildDep(dep string)
|
|
|
|
|
2021-12-15 21:35:38 +01:00
|
|
|
// AddMissingBp2buildDep stores the module name of a direct dependency that was not found.
|
|
|
|
AddMissingBp2buildDep(dep string)
|
|
|
|
|
2016-06-02 02:09:44 +02:00
|
|
|
Target() Target
|
2016-09-13 18:59:14 +02:00
|
|
|
TargetPrimary() bool
|
2020-02-25 16:50:49 +01:00
|
|
|
|
|
|
|
// The additional arch specific targets (e.g. 32/64 bit) that this module variant is
|
|
|
|
// responsible for creating.
|
2018-10-03 07:01:37 +02:00
|
|
|
MultiTargets() []Target
|
2015-03-24 19:13:38 +01:00
|
|
|
Arch() Arch
|
2016-06-02 02:09:44 +02:00
|
|
|
Os() OsType
|
2015-03-24 19:13:38 +01:00
|
|
|
Host() bool
|
|
|
|
Device() bool
|
2015-05-01 01:36:18 +02:00
|
|
|
Darwin() bool
|
2017-04-04 21:59:48 +02:00
|
|
|
Windows() bool
|
2015-03-24 19:13:38 +01:00
|
|
|
Debug() bool
|
2016-08-25 00:25:47 +02:00
|
|
|
PrimaryArch() bool
|
2015-03-24 19:13:38 +01:00
|
|
|
}
|
|
|
|
|
2019-12-31 03:43:07 +01:00
|
|
|
// Deprecated: use EarlyModuleContext instead
|
2016-05-19 00:37:25 +02:00
|
|
|
type BaseContext interface {
|
2019-12-31 03:43:07 +01:00
|
|
|
EarlyModuleContext
|
2017-11-29 09:27:14 +01:00
|
|
|
}
|
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
type ModuleContext interface {
|
2017-11-29 09:27:14 +01:00
|
|
|
BaseModuleContext
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2020-11-10 21:27:45 +01:00
|
|
|
blueprintModuleContext() blueprint.ModuleContext
|
|
|
|
|
2017-10-24 02:16:14 +02:00
|
|
|
// Deprecated: use ModuleContext.Build instead.
|
2017-11-29 02:34:01 +01:00
|
|
|
ModuleBuild(pctx PackageContext, params ModuleBuildParams)
|
2015-09-24 00:26:20 +02:00
|
|
|
|
Support customizing behavior around sourceOrOutputDependencyTag
Previously, modules customized behavior around the handling of
sourceOrOutputDependencyTag by comparing them to android.SourceDepTag
and retrieving the module using something like this:
ctx.GetDirectDepWithTag(m, android.SourceDepTag)
The problem with that is it does not allow an output tag to be
specified and does not handle fully qualified names properly.
This adds the following:
* IsSourceDepTag and IsSourceDepTagWithOutputTag to check whether a
blueprint.DependencyTag is a sourceOrOutputDependencyTag. The latter
also checks that it has the correct output tag.
* GetModuleFromPathDep(ctx, moduleName, outputTag) as a replacement for
ctx.GetDirectDepWithTag(m, android.SourceDepTag).
Replaces usages of:
* t == SourceDepTag with IsSourceDepTagWithOutputTag(t, "")
* ctx.GetDirectDepWithTag(m, android.SourceDepTag) with
GetModuleFromPathDep(ctx, m, "")
It also deprecates the following:
* android.SourcDepTag - as a follow up change needs to modify the
sourceOrOutputDependencyTag will make this useless.
* ExpandSources, ExpandsSources - copies existing deprecated messages
from the implementation to the interface so that they can be seen
by users of that interface.
Bug: 193228441
Test: m nothing
Change-Id: I8c397232b8d7dc1f9702c04ad45ea7819d4631ae
2021-07-09 18:38:55 +02:00
|
|
|
// Returns a list of paths expanded from globs and modules referenced using ":module" syntax. The property must
|
|
|
|
// be tagged with `android:"path" to support automatic source module dependency resolution.
|
|
|
|
//
|
|
|
|
// Deprecated: use PathsForModuleSrc or PathsForModuleSrcExcludes instead.
|
2015-09-24 00:26:20 +02:00
|
|
|
ExpandSources(srcFiles, excludes []string) Paths
|
Support customizing behavior around sourceOrOutputDependencyTag
Previously, modules customized behavior around the handling of
sourceOrOutputDependencyTag by comparing them to android.SourceDepTag
and retrieving the module using something like this:
ctx.GetDirectDepWithTag(m, android.SourceDepTag)
The problem with that is it does not allow an output tag to be
specified and does not handle fully qualified names properly.
This adds the following:
* IsSourceDepTag and IsSourceDepTagWithOutputTag to check whether a
blueprint.DependencyTag is a sourceOrOutputDependencyTag. The latter
also checks that it has the correct output tag.
* GetModuleFromPathDep(ctx, moduleName, outputTag) as a replacement for
ctx.GetDirectDepWithTag(m, android.SourceDepTag).
Replaces usages of:
* t == SourceDepTag with IsSourceDepTagWithOutputTag(t, "")
* ctx.GetDirectDepWithTag(m, android.SourceDepTag) with
GetModuleFromPathDep(ctx, m, "")
It also deprecates the following:
* android.SourcDepTag - as a follow up change needs to modify the
sourceOrOutputDependencyTag will make this useless.
* ExpandSources, ExpandsSources - copies existing deprecated messages
from the implementation to the interface so that they can be seen
by users of that interface.
Bug: 193228441
Test: m nothing
Change-Id: I8c397232b8d7dc1f9702c04ad45ea7819d4631ae
2021-07-09 18:38:55 +02:00
|
|
|
|
|
|
|
// Returns a single path expanded from globs and modules referenced using ":module" syntax. The property must
|
|
|
|
// be tagged with `android:"path" to support automatic source module dependency resolution.
|
|
|
|
//
|
|
|
|
// Deprecated: use PathForModuleSrc instead.
|
2017-12-12 01:29:02 +01:00
|
|
|
ExpandSource(srcFile, prop string) Path
|
Support customizing behavior around sourceOrOutputDependencyTag
Previously, modules customized behavior around the handling of
sourceOrOutputDependencyTag by comparing them to android.SourceDepTag
and retrieving the module using something like this:
ctx.GetDirectDepWithTag(m, android.SourceDepTag)
The problem with that is it does not allow an output tag to be
specified and does not handle fully qualified names properly.
This adds the following:
* IsSourceDepTag and IsSourceDepTagWithOutputTag to check whether a
blueprint.DependencyTag is a sourceOrOutputDependencyTag. The latter
also checks that it has the correct output tag.
* GetModuleFromPathDep(ctx, moduleName, outputTag) as a replacement for
ctx.GetDirectDepWithTag(m, android.SourceDepTag).
Replaces usages of:
* t == SourceDepTag with IsSourceDepTagWithOutputTag(t, "")
* ctx.GetDirectDepWithTag(m, android.SourceDepTag) with
GetModuleFromPathDep(ctx, m, "")
It also deprecates the following:
* android.SourcDepTag - as a follow up change needs to modify the
sourceOrOutputDependencyTag will make this useless.
* ExpandSources, ExpandsSources - copies existing deprecated messages
from the implementation to the interface so that they can be seen
by users of that interface.
Bug: 193228441
Test: m nothing
Change-Id: I8c397232b8d7dc1f9702c04ad45ea7819d4631ae
2021-07-09 18:38:55 +02:00
|
|
|
|
2018-02-06 23:40:13 +01:00
|
|
|
ExpandOptionalSource(srcFile *string, prop string) OptionalPath
|
2015-06-18 00:09:06 +02:00
|
|
|
|
2020-12-01 23:00:21 +01:00
|
|
|
// InstallExecutable creates a rule to copy srcPath to name in the installPath directory,
|
|
|
|
// with the given additional dependencies. The file is marked executable after copying.
|
|
|
|
//
|
|
|
|
// The installed file will be returned by FilesToInstall(), and the PackagingSpec for the
|
|
|
|
// installed file will be returned by PackagingSpecs() on this module or by
|
|
|
|
// TransitivePackagingSpecs() on modules that depend on this module through dependency tags
|
|
|
|
// for which IsInstallDepNeeded returns true.
|
2019-10-02 07:05:35 +02:00
|
|
|
InstallExecutable(installPath InstallPath, name string, srcPath Path, deps ...Path) InstallPath
|
2020-12-01 23:00:21 +01:00
|
|
|
|
|
|
|
// InstallFile creates a rule to copy srcPath to name in the installPath directory,
|
|
|
|
// with the given additional dependencies.
|
|
|
|
//
|
|
|
|
// The installed file will be returned by FilesToInstall(), and the PackagingSpec for the
|
|
|
|
// installed file will be returned by PackagingSpecs() on this module or by
|
|
|
|
// TransitivePackagingSpecs() on modules that depend on this module through dependency tags
|
|
|
|
// for which IsInstallDepNeeded returns true.
|
2019-10-02 07:05:35 +02:00
|
|
|
InstallFile(installPath InstallPath, name string, srcPath Path, deps ...Path) InstallPath
|
2020-12-01 23:00:21 +01:00
|
|
|
|
2021-11-13 02:41:02 +01:00
|
|
|
// InstallFileWithExtraFilesZip creates a rule to copy srcPath to name in the installPath
|
|
|
|
// directory, and also unzip a zip file containing extra files to install into the same
|
|
|
|
// directory.
|
|
|
|
//
|
|
|
|
// The installed file will be returned by FilesToInstall(), and the PackagingSpec for the
|
|
|
|
// installed file will be returned by PackagingSpecs() on this module or by
|
|
|
|
// TransitivePackagingSpecs() on modules that depend on this module through dependency tags
|
|
|
|
// for which IsInstallDepNeeded returns true.
|
|
|
|
InstallFileWithExtraFilesZip(installPath InstallPath, name string, srcPath Path, extraZip Path, deps ...Path) InstallPath
|
|
|
|
|
2020-12-01 23:00:21 +01:00
|
|
|
// InstallSymlink creates a rule to create a symlink from src srcPath to name in the installPath
|
|
|
|
// directory.
|
|
|
|
//
|
|
|
|
// The installed symlink will be returned by FilesToInstall(), and the PackagingSpec for the
|
|
|
|
// installed file will be returned by PackagingSpecs() on this module or by
|
|
|
|
// TransitivePackagingSpecs() on modules that depend on this module through dependency tags
|
|
|
|
// for which IsInstallDepNeeded returns true.
|
2019-10-02 07:05:35 +02:00
|
|
|
InstallSymlink(installPath InstallPath, name string, srcPath InstallPath) InstallPath
|
2020-12-01 23:00:21 +01:00
|
|
|
|
|
|
|
// InstallAbsoluteSymlink creates a rule to create an absolute symlink from src srcPath to name
|
|
|
|
// in the installPath directory.
|
|
|
|
//
|
|
|
|
// The installed symlink will be returned by FilesToInstall(), and the PackagingSpec for the
|
|
|
|
// installed file will be returned by PackagingSpecs() on this module or by
|
|
|
|
// TransitivePackagingSpecs() on modules that depend on this module through dependency tags
|
|
|
|
// for which IsInstallDepNeeded returns true.
|
2019-10-02 07:05:35 +02:00
|
|
|
InstallAbsoluteSymlink(installPath InstallPath, name string, absPath string) InstallPath
|
2020-12-01 23:00:21 +01:00
|
|
|
|
|
|
|
// PackageFile creates a PackagingSpec as if InstallFile was called, but without creating
|
|
|
|
// the rule to copy the file. This is useful to define how a module would be packaged
|
|
|
|
// without installing it into the global installation directories.
|
|
|
|
//
|
|
|
|
// The created PackagingSpec for the will be returned by PackagingSpecs() on this module or by
|
|
|
|
// TransitivePackagingSpecs() on modules that depend on this module through dependency tags
|
|
|
|
// for which IsInstallDepNeeded returns true.
|
|
|
|
PackageFile(installPath InstallPath, name string, srcPath Path) PackagingSpec
|
|
|
|
|
2015-09-24 00:26:20 +02:00
|
|
|
CheckbuildFile(srcPath Path)
|
2016-03-11 03:14:25 +01:00
|
|
|
|
2016-08-03 20:57:50 +02:00
|
|
|
InstallInData() bool
|
2019-09-11 19:25:18 +02:00
|
|
|
InstallInTestcases() bool
|
2017-03-30 07:00:18 +02:00
|
|
|
InstallInSanitizerDir() bool
|
2020-01-22 00:53:22 +01:00
|
|
|
InstallInRamdisk() bool
|
2020-10-22 00:17:56 +02:00
|
|
|
InstallInVendorRamdisk() bool
|
2021-04-08 14:13:22 +02:00
|
|
|
InstallInDebugRamdisk() bool
|
2018-01-31 16:54:12 +01:00
|
|
|
InstallInRecovery() bool
|
2019-10-02 20:10:58 +02:00
|
|
|
InstallInRoot() bool
|
2021-07-19 04:38:04 +02:00
|
|
|
InstallInVendor() bool
|
2020-09-01 05:37:45 +02:00
|
|
|
InstallForceOS() (*OsType, *ArchType)
|
2017-02-05 02:47:46 +01:00
|
|
|
|
|
|
|
RequiredModuleNames() []string
|
2019-04-02 03:37:36 +02:00
|
|
|
HostRequiredModuleNames() []string
|
|
|
|
TargetRequiredModuleNames() []string
|
2017-10-24 02:10:29 +02:00
|
|
|
|
|
|
|
ModuleSubDir() string
|
2023-06-16 07:19:33 +02:00
|
|
|
SoongConfigTraceHash() string
|
2017-10-24 02:10:29 +02:00
|
|
|
|
2017-11-29 02:34:01 +01:00
|
|
|
Variable(pctx PackageContext, name, value string)
|
|
|
|
Rule(pctx PackageContext, name string, params blueprint.RuleParams, argNames ...string) blueprint.Rule
|
2017-10-24 02:16:14 +02:00
|
|
|
// Similar to blueprint.ModuleContext.Build, but takes Paths instead of []string,
|
|
|
|
// and performs more verification.
|
2017-11-29 02:34:01 +01:00
|
|
|
Build(pctx PackageContext, params BuildParams)
|
2020-06-04 22:25:17 +02:00
|
|
|
// Phony creates a Make-style phony rule, a rule with no commands that can depend on other
|
|
|
|
// phony rules or real files. Phony can be called on the same name multiple times to add
|
|
|
|
// additional dependencies.
|
|
|
|
Phony(phony string, deps ...Path)
|
2017-10-24 02:10:29 +02:00
|
|
|
|
2020-09-17 04:04:41 +02:00
|
|
|
// GetMissingDependencies returns the list of dependencies that were passed to AddDependencies or related methods,
|
|
|
|
// but do not exist.
|
2017-10-24 02:10:29 +02:00
|
|
|
GetMissingDependencies() []string
|
2022-03-16 01:49:24 +01:00
|
|
|
|
|
|
|
// LicenseMetadataFile returns the path where the license metadata for this module will be
|
|
|
|
// generated.
|
|
|
|
LicenseMetadataFile() Path
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
type Module interface {
|
2015-01-31 02:27:36 +01:00
|
|
|
blueprint.Module
|
|
|
|
|
2017-09-28 02:01:44 +02:00
|
|
|
// GenerateAndroidBuildActions is analogous to Blueprints' GenerateBuildActions,
|
|
|
|
// but GenerateAndroidBuildActions also has access to Android-specific information.
|
|
|
|
// For more information, see Module.GenerateBuildActions within Blueprint's module_ctx.go
|
2016-05-19 00:37:25 +02:00
|
|
|
GenerateAndroidBuildActions(ModuleContext)
|
2017-09-28 02:01:44 +02:00
|
|
|
|
2020-06-26 21:17:02 +02:00
|
|
|
// Add dependencies to the components of a module, i.e. modules that are created
|
|
|
|
// by the module and which are considered to be part of the creating module.
|
|
|
|
//
|
|
|
|
// This is called before prebuilts are renamed so as to allow a dependency to be
|
|
|
|
// added directly to a prebuilt child module instead of depending on a source module
|
|
|
|
// and relying on prebuilt processing to switch to the prebuilt module if preferred.
|
|
|
|
//
|
|
|
|
// A dependency on a prebuilt must include the "prebuilt_" prefix.
|
|
|
|
ComponentDepsMutator(ctx BottomUpMutatorContext)
|
|
|
|
|
2016-10-12 23:38:15 +02:00
|
|
|
DepsMutator(BottomUpMutatorContext)
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
base() *ModuleBase
|
2020-01-22 03:11:29 +01:00
|
|
|
Disable()
|
2015-12-01 01:06:01 +01:00
|
|
|
Enabled() bool
|
2016-06-02 02:09:44 +02:00
|
|
|
Target() Target
|
2021-03-01 13:25:10 +01:00
|
|
|
MultiTargets() []Target
|
2021-09-09 17:37:49 +02:00
|
|
|
|
|
|
|
// ImageVariation returns the image variation of this module.
|
|
|
|
//
|
|
|
|
// The returned structure has its Mutator field set to "image" and its Variation field set to the
|
|
|
|
// image variation, e.g. recovery, ramdisk, etc.. The Variation field is "" for host modules and
|
|
|
|
// device modules that have no image variation.
|
|
|
|
ImageVariation() blueprint.Variation
|
|
|
|
|
2020-06-30 12:51:53 +02:00
|
|
|
Owner() string
|
2015-12-21 23:55:28 +01:00
|
|
|
InstallInData() bool
|
2019-09-11 19:25:18 +02:00
|
|
|
InstallInTestcases() bool
|
2017-03-30 07:00:18 +02:00
|
|
|
InstallInSanitizerDir() bool
|
2020-01-22 00:53:22 +01:00
|
|
|
InstallInRamdisk() bool
|
2020-10-22 00:17:56 +02:00
|
|
|
InstallInVendorRamdisk() bool
|
2021-04-08 14:13:22 +02:00
|
|
|
InstallInDebugRamdisk() bool
|
2018-01-31 16:54:12 +01:00
|
|
|
InstallInRecovery() bool
|
2019-10-02 20:10:58 +02:00
|
|
|
InstallInRoot() bool
|
2021-07-19 04:38:04 +02:00
|
|
|
InstallInVendor() bool
|
2020-09-01 05:37:45 +02:00
|
|
|
InstallForceOS() (*OsType, *ArchType)
|
2023-02-17 10:22:25 +01:00
|
|
|
PartitionTag(DeviceConfig) string
|
2020-12-16 19:20:23 +01:00
|
|
|
HideFromMake()
|
|
|
|
IsHideFromMake() bool
|
2020-12-23 04:50:30 +01:00
|
|
|
IsSkipInstall() bool
|
2023-03-10 17:11:26 +01:00
|
|
|
MakeUninstallable()
|
2020-08-06 00:40:41 +02:00
|
|
|
ReplacedByPrebuilt()
|
|
|
|
IsReplacedByPrebuilt() bool
|
Allow platform modules to link to vendor public libraries
Normally, when building with VNDK, platform modules are not allowed to
link against vendor libraries, because the ABI of the vendor libraries
are not guaranteed to be stable and may differ across multiple vendor
images.
However, the vendor public libraries are the exceptions. Vendor public
libraries are vendor libraries that are exposed to 3rd party apps and
listed in /vendor/etc/public.libraries.txt. Since they are intended to
be exposed to public, their ABI stability is guaranteed (by definition,
though it is up to the vendor to actually guarantee it).
This change provides a way to make a vendor lib as public by defining a
module of type 'vendor_public_library' with a map file that enumerates
public symbols that are publicized:
cc_library {
name: "libvendor",
proprietary: true,
...
}
vendor_public_library {
name: "libvendor",
symbol_file: "libvendor.map.txt",
}
This defines a stub library module named libvendor.vendorpublic from the
map file. `shared_libs: ["libvendor"]` is redirected to the stub library
when it is from the outside of the vendor partition.
Bug: 74275385
Test: m -j
Test: cc_test.go passes
Change-Id: I5bed94d7c4282b777632ab2f0fb63c203ee313ba
2018-03-19 10:23:01 +01:00
|
|
|
ExportedToMake() bool
|
2019-11-15 01:59:12 +01:00
|
|
|
InitRc() Paths
|
|
|
|
VintfFragments() Paths
|
2023-04-07 13:13:19 +02:00
|
|
|
EffectiveLicenseKinds() []string
|
2021-06-29 13:34:53 +02:00
|
|
|
EffectiveLicenseFiles() Paths
|
2017-06-24 00:06:31 +02:00
|
|
|
|
|
|
|
AddProperties(props ...interface{})
|
|
|
|
GetProperties() []interface{}
|
2017-07-13 23:43:27 +02:00
|
|
|
|
2021-08-11 06:17:36 +02:00
|
|
|
// IsConvertedByBp2build returns whether this module was converted via bp2build
|
|
|
|
IsConvertedByBp2build() bool
|
2023-06-08 16:28:51 +02:00
|
|
|
GetUnconvertedReason() *UnconvertedReason
|
|
|
|
|
2021-08-11 06:17:36 +02:00
|
|
|
// Bp2buildTargets returns the target(s) generated for Bazel via bp2build for this module
|
|
|
|
Bp2buildTargets() []bp2buildInfo
|
2021-08-26 14:37:59 +02:00
|
|
|
GetUnconvertedBp2buildDeps() []string
|
2021-12-15 21:35:38 +01:00
|
|
|
GetMissingBp2buildDeps() []string
|
2021-08-11 06:17:36 +02:00
|
|
|
|
2017-10-24 02:16:14 +02:00
|
|
|
BuildParamsForTests() []BuildParams
|
2019-02-25 23:54:28 +01:00
|
|
|
RuleParamsForTests() map[blueprint.Rule]blueprint.RuleParams
|
2018-12-12 18:01:34 +01:00
|
|
|
VariablesForTests() map[string]string
|
2019-05-31 15:00:04 +02:00
|
|
|
|
2019-07-02 00:32:45 +02:00
|
|
|
// String returns a string that includes the module name and variants for printing during debugging.
|
|
|
|
String() string
|
|
|
|
|
2019-05-31 15:00:04 +02:00
|
|
|
// Get the qualified module id for this module.
|
|
|
|
qualifiedModuleId(ctx BaseModuleContext) qualifiedModuleName
|
|
|
|
|
|
|
|
// Get information about the properties that can contain visibility rules.
|
|
|
|
visibilityProperties() []visibilityProperty
|
Refactor visibility to support visibility on defaults modules
Existing modules, either general one or package ones have a single
visibility property, called visibility in general, and
default_visibility on package, that controls access to that module, or
in the case of package sets the default visibility of all modules in
that package. The property is checked and gathered during the similarly
named phases of visibility processing.
The defaults module will be different as it will have two properties.
The first, visibility, will not affect the visibility of the module, it
only affects the visibility of modules that 'extend' the defaults. So,
it will need checking but not parsing. The second property,
defaults_visibility, will affect the visibility of the module and so
will need both checking and parsing.
The current implementation does not handle those cases because:
1) It does not differentiate between the property that affects the
module and those that do not. It checks and gathers all of them with
the last property gathered overriding the rules for the previous
properties.
2) It relies on overriding methods in MethodBase in order to change the
default behavior for the package module. That works because
packageModule embeds ModuleBase but will not work for
DefaultsModuleBase as it does not embed ModuleBase and instead is
embedded alongside it so attempting to override a method in
MethodBase leads to ambiguity.
This change addresses the issues as follows:
1) It adds a new visibility() []string method to get access to the
primary visibility rules, i.e. the ones that affect the module.
2) It adds two fields, 'visibilityPropertyInfo []visibilityProperty'
to provide information about all the properties that need checking,
and 'primaryVisibilityProperty visibilityProperty' to specify the
property that affects the module.
The PackageFactory() and InitAndroidModule(Module) functions are
modified to initialize the fields. The override of the
visibilityProperties() method for packageModule is removed and the
default implementations of visibilityProperties() and visibility()
on ModuleBase return information from the two new fields.
The InitDefaultsModule is updated to also initialize the two new
fields. It uses nil for primaryVisibilityProperty for now but that
will be changed to return defaults_visibility. It also uses the
commonProperties structure created for the defaults directly instead
of having to search for it through properties().
Changed the visibilityProperty to take a pointer to the property that
can be used to retrieve the value rather than a lambda function.
Bug: 130796911
Test: m nothing
Change-Id: Icadd470a5f692a48ec61de02bf3dfde3e2eea2ef
2019-07-24 15:24:38 +02:00
|
|
|
|
2019-12-30 08:31:09 +01:00
|
|
|
RequiredModuleNames() []string
|
|
|
|
HostRequiredModuleNames() []string
|
|
|
|
TargetRequiredModuleNames() []string
|
2020-02-13 22:22:08 +01:00
|
|
|
|
2020-09-28 10:46:22 +02:00
|
|
|
FilesToInstall() InstallPaths
|
add PackagingSpec
Currently, installation of a module is defined as an action of copying
the built artifact of the module to an install path like out/soong/host
(for host modules) and out/target/product/<device>/<partition> (for
device modules). After the modules are installed, the installed files
are further processed to create packages like system.img, vendor.img,
cvd-host-package.tar.gz, etc.
This notion of installation seems to have originated from the old time
when system.img is the primary product of the entire build process
(modulo a few more like root.img). Packaging the installed files as the
filesystem image was considered as a post-build step then.
However, this model doesn't seem to fit well to the current and future
environment where we have a lot more filesystem images (system, vendor,
system_ext, product, ...). The filesystem images themselves are even
grouped together to form a higher-level filesystem image like super.img.
Furthermore, things like cvd-host-package.tar.gz requires us to be able
to group some of the host tools in a format that isn't filesystem image.
Lastly, we are expected to have more filesystem images that are subsets
of system.img (and their friends) for the Android-like mini OS that will
be running on on-device virtual machines. These all imply that the
packaging (which we call installation today) is not a global post-build
step, but a part of the build rules for creating the package-like
modules.
A model better fits to the new sitatuation might be this; a module
specifies its built artifact and the path where it should be placed. The
latter path is not rooted at out/. It's a relative path to the root
directory which will be determined by another module that implements the
packaging. For example, cc_library will have ./lib (or ./lib64), not
out/target/product/<device>/<partition>/lib as the path. Then packages
like system.img, cvd-host-package.tar.gz, etc. are explicitly modeled as
modules and they have deps to other modules. Then the modules are placed
at the relative path under the package root, and the entire root
directory finally is packaged as the output file (be it img, tar.gz, or
whatever).
PackagingSpec is the first step to implement the new model. It abstracts
a request to place a built artifact at a certain path in a package. It
has extra information about whether the path should be a symlink or not,
and whether the path is for an executable. It currently is created when
InstallFiles (and its friends) are called, and can be retrieved via
the new method PackagingSpecs().
In this CL, no one is using PackagingSpec. The installation is still
done by the existing rules created in InstallFiles, etc. and the
structs are not used for the filesystem images like system.img.
Bug: 159685774
Bug: 172414391
Test: m
Change-Id: Ie1dec72d1ac14382fc3b74e5c850472e9320d6a3
2020-11-09 06:08:34 +01:00
|
|
|
PackagingSpecs() []PackagingSpec
|
2020-12-02 00:40:06 +01:00
|
|
|
|
|
|
|
// TransitivePackagingSpecs returns the PackagingSpecs for this module and any transitive
|
|
|
|
// dependencies with dependency tags for which IsInstallDepNeeded() returns true.
|
|
|
|
TransitivePackagingSpecs() []PackagingSpec
|
2019-05-31 15:00:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Qualified id for a module
|
|
|
|
type qualifiedModuleName struct {
|
|
|
|
// The package (i.e. directory) in which the module is defined, without trailing /
|
|
|
|
pkg string
|
|
|
|
|
|
|
|
// The name of the module, empty string if package.
|
|
|
|
name string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (q qualifiedModuleName) String() string {
|
|
|
|
if q.name == "" {
|
|
|
|
return "//" + q.pkg
|
|
|
|
}
|
|
|
|
return "//" + q.pkg + ":" + q.name
|
|
|
|
}
|
|
|
|
|
2019-06-20 17:38:08 +02:00
|
|
|
func (q qualifiedModuleName) isRootPackage() bool {
|
|
|
|
return q.pkg == "" && q.name == ""
|
|
|
|
}
|
|
|
|
|
2019-05-31 15:00:04 +02:00
|
|
|
// Get the id for the package containing this module.
|
|
|
|
func (q qualifiedModuleName) getContainingPackageId() qualifiedModuleName {
|
|
|
|
pkg := q.pkg
|
|
|
|
if q.name == "" {
|
2019-06-20 17:38:08 +02:00
|
|
|
if pkg == "" {
|
|
|
|
panic(fmt.Errorf("Cannot get containing package id of root package"))
|
|
|
|
}
|
|
|
|
|
|
|
|
index := strings.LastIndex(pkg, "/")
|
|
|
|
if index == -1 {
|
|
|
|
pkg = ""
|
|
|
|
} else {
|
|
|
|
pkg = pkg[:index]
|
|
|
|
}
|
2019-05-31 15:00:04 +02:00
|
|
|
}
|
|
|
|
return newPackageId(pkg)
|
|
|
|
}
|
|
|
|
|
|
|
|
func newPackageId(pkg string) qualifiedModuleName {
|
|
|
|
// A qualified id for a package module has no name.
|
|
|
|
return qualifiedModuleName{pkg: pkg, name: ""}
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2020-06-15 07:24:19 +02:00
|
|
|
type Dist struct {
|
|
|
|
// Copy the output of this module to the $DIST_DIR when `dist` is specified on the
|
|
|
|
// command line and any of these targets are also on the command line, or otherwise
|
|
|
|
// built
|
|
|
|
Targets []string `android:"arch_variant"`
|
|
|
|
|
|
|
|
// The name of the output artifact. This defaults to the basename of the output of
|
|
|
|
// the module.
|
|
|
|
Dest *string `android:"arch_variant"`
|
|
|
|
|
|
|
|
// The directory within the dist directory to store the artifact. Defaults to the
|
|
|
|
// top level directory ("").
|
|
|
|
Dir *string `android:"arch_variant"`
|
|
|
|
|
|
|
|
// A suffix to add to the artifact file name (before any extension).
|
|
|
|
Suffix *string `android:"arch_variant"`
|
|
|
|
|
2022-03-21 20:34:02 +01:00
|
|
|
// If true, then the artifact file will be appended with _<product name>. For
|
|
|
|
// example, if the product is coral and the module is an android_app module
|
|
|
|
// of name foo, then the artifact would be foo_coral.apk. If false, there is
|
|
|
|
// no change to the artifact file name.
|
|
|
|
Append_artifact_with_product *bool `android:"arch_variant"`
|
|
|
|
|
2020-11-25 17:37:46 +01:00
|
|
|
// A string tag to select the OutputFiles associated with the tag.
|
|
|
|
//
|
|
|
|
// If no tag is specified then it will select the default dist paths provided
|
|
|
|
// by the module type. If a tag of "" is specified then it will return the
|
|
|
|
// default output files provided by the modules, i.e. the result of calling
|
|
|
|
// OutputFiles("").
|
2020-06-15 07:24:19 +02:00
|
|
|
Tag *string `android:"arch_variant"`
|
|
|
|
}
|
|
|
|
|
2022-02-09 20:54:35 +01:00
|
|
|
// NamedPath associates a path with a name. e.g. a license text path with a package name
|
|
|
|
type NamedPath struct {
|
|
|
|
Path Path
|
|
|
|
Name string
|
|
|
|
}
|
|
|
|
|
|
|
|
// String returns an escaped string representing the `NamedPath`.
|
|
|
|
func (p NamedPath) String() string {
|
|
|
|
if len(p.Name) > 0 {
|
|
|
|
return p.Path.String() + ":" + url.QueryEscape(p.Name)
|
|
|
|
}
|
|
|
|
return p.Path.String()
|
|
|
|
}
|
|
|
|
|
|
|
|
// NamedPaths describes a list of paths each associated with a name.
|
|
|
|
type NamedPaths []NamedPath
|
|
|
|
|
|
|
|
// Strings returns a list of escaped strings representing each `NamedPath` in the list.
|
|
|
|
func (l NamedPaths) Strings() []string {
|
|
|
|
result := make([]string, 0, len(l))
|
|
|
|
for _, p := range l {
|
|
|
|
result = append(result, p.String())
|
|
|
|
}
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
|
|
|
|
// SortedUniqueNamedPaths modifies `l` in place to return the sorted unique subset.
|
|
|
|
func SortedUniqueNamedPaths(l NamedPaths) NamedPaths {
|
|
|
|
if len(l) == 0 {
|
|
|
|
return l
|
|
|
|
}
|
|
|
|
sort.Slice(l, func(i, j int) bool {
|
|
|
|
return l[i].String() < l[j].String()
|
|
|
|
})
|
|
|
|
k := 0
|
|
|
|
for i := 1; i < len(l); i++ {
|
|
|
|
if l[i].String() == l[k].String() {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
k++
|
|
|
|
if k < i {
|
|
|
|
l[k] = l[i]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return l[:k+1]
|
|
|
|
}
|
|
|
|
|
2023-05-15 11:06:31 +02:00
|
|
|
// soongConfigTrace holds all references to VendorVars. Uses []string for blueprint:"mutated"
|
|
|
|
type soongConfigTrace struct {
|
|
|
|
Bools []string `json:",omitempty"`
|
|
|
|
Strings []string `json:",omitempty"`
|
|
|
|
IsSets []string `json:",omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *soongConfigTrace) isEmpty() bool {
|
|
|
|
return len(c.Bools) == 0 && len(c.Strings) == 0 && len(c.IsSets) == 0
|
|
|
|
}
|
|
|
|
|
|
|
|
// Returns hash of serialized trace records (empty string if there's no trace recorded)
|
|
|
|
func (c *soongConfigTrace) hash() string {
|
|
|
|
// Use MD5 for speed. We don't care collision or preimage attack
|
|
|
|
if c.isEmpty() {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
j, err := json.Marshal(c)
|
|
|
|
if err != nil {
|
|
|
|
panic(fmt.Errorf("json marshal of %#v failed: %#v", *c, err))
|
|
|
|
}
|
|
|
|
hash := md5.Sum(j)
|
|
|
|
return hex.EncodeToString(hash[:])
|
|
|
|
}
|
|
|
|
|
2016-05-18 01:34:16 +02:00
|
|
|
type nameProperties struct {
|
|
|
|
// The name of the module. Must be unique across all modules.
|
2017-11-07 19:57:05 +01:00
|
|
|
Name *string
|
2016-05-18 01:34:16 +02:00
|
|
|
}
|
|
|
|
|
2020-11-19 03:33:19 +01:00
|
|
|
type commonProperties struct {
|
2015-12-01 01:06:01 +01:00
|
|
|
// emit build rules for this module
|
2020-02-12 11:20:56 +01:00
|
|
|
//
|
|
|
|
// Disabling a module should only be done for those modules that cannot be built
|
|
|
|
// in the current environment. Modules that can build in the current environment
|
|
|
|
// but are not usually required (e.g. superceded by a prebuilt) should not be
|
|
|
|
// disabled as that will prevent them from being built by the checkbuild target
|
|
|
|
// and so prevent early detection of changes that have broken those modules.
|
2015-12-01 01:06:01 +01:00
|
|
|
Enabled *bool `android:"arch_variant"`
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2019-03-28 15:10:57 +01:00
|
|
|
// 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.
|
2020-05-05 20:19:22 +02:00
|
|
|
// ["//visibility:override"]: Discards any rules inherited from defaults or a creating module.
|
|
|
|
// Can only be used at the beginning of a list of visibility rules.
|
2019-03-28 15:10:57 +01:00
|
|
|
// ["//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.
|
2019-05-31 15:00:04 +02:00
|
|
|
//
|
|
|
|
// If a module does not specify the `visibility` property then it uses the
|
|
|
|
// `default_visibility` property of the `package` module in the module's package.
|
|
|
|
//
|
|
|
|
// If the `default_visibility` property is not set for the module's package then
|
2019-06-20 17:38:08 +02:00
|
|
|
// it will use the `default_visibility` of its closest ancestor package for which
|
|
|
|
// a `default_visibility` property is specified.
|
|
|
|
//
|
|
|
|
// If no `default_visibility` property can be found then the module uses the
|
|
|
|
// global default of `//visibility:legacy_public`.
|
2019-05-31 15:00:04 +02:00
|
|
|
//
|
2019-07-24 14:45:05 +02:00
|
|
|
// The `visibility` property has no effect on a defaults module although it does
|
|
|
|
// apply to any non-defaults module that uses it. To set the visibility of a
|
|
|
|
// defaults module, use the `defaults_visibility` property on the defaults module;
|
|
|
|
// not to be confused with the `default_visibility` property on the package module.
|
|
|
|
//
|
2019-03-28 15:10:57 +01:00
|
|
|
// See https://android.googlesource.com/platform/build/soong/+/master/README.md#visibility for
|
|
|
|
// more details.
|
|
|
|
Visibility []string
|
|
|
|
|
2021-01-07 04:34:31 +01:00
|
|
|
// Describes the licenses applicable to this module. Must reference license modules.
|
|
|
|
Licenses []string
|
|
|
|
|
|
|
|
// Flattened from direct license dependencies. Equal to Licenses unless particular module adds more.
|
|
|
|
Effective_licenses []string `blueprint:"mutated"`
|
|
|
|
// Override of module name when reporting licenses
|
|
|
|
Effective_package_name *string `blueprint:"mutated"`
|
|
|
|
// Notice files
|
2022-02-09 20:54:35 +01:00
|
|
|
Effective_license_text NamedPaths `blueprint:"mutated"`
|
2021-01-07 04:34:31 +01:00
|
|
|
// License names
|
|
|
|
Effective_license_kinds []string `blueprint:"mutated"`
|
|
|
|
// License conditions
|
|
|
|
Effective_license_conditions []string `blueprint:"mutated"`
|
|
|
|
|
2015-05-11 22:39:40 +02:00
|
|
|
// control whether this module compiles for 32-bit, 64-bit, or both. Possible values
|
2015-01-31 02:27:36 +01:00
|
|
|
// 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
|
2020-09-22 13:18:38 +02:00
|
|
|
// platform).
|
2017-11-01 18:38:29 +01:00
|
|
|
Compile_multilib *string `android:"arch_variant"`
|
2016-09-06 19:39:07 +02:00
|
|
|
|
|
|
|
Target struct {
|
|
|
|
Host struct {
|
2017-11-01 18:38:29 +01:00
|
|
|
Compile_multilib *string
|
2016-09-06 19:39:07 +02:00
|
|
|
}
|
|
|
|
Android struct {
|
2017-11-01 18:38:29 +01:00
|
|
|
Compile_multilib *string
|
2016-09-06 19:39:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-25 16:50:49 +01:00
|
|
|
// If set to true then the archMutator will create variants for each arch specific target
|
|
|
|
// (e.g. 32/64) that the module is required to produce. If set to false then it will only
|
|
|
|
// create a variant for the architecture and will list the additional arch specific targets
|
|
|
|
// that the variant needs to produce in the CompileMultiTargets property.
|
2018-10-03 07:01:37 +02:00
|
|
|
UseTargetVariants bool `blueprint:"mutated"`
|
|
|
|
Default_multilib string `blueprint:"mutated"`
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2015-12-21 23:55:28 +01:00
|
|
|
// whether this is a proprietary vendor module, and should be installed into /vendor
|
2017-11-01 18:38:29 +01:00
|
|
|
Proprietary *bool
|
2015-12-21 23:55:28 +01:00
|
|
|
|
2017-03-20 21:23:34 +01:00
|
|
|
// vendor who owns this module
|
2017-07-19 04:42:09 +02:00
|
|
|
Owner *string
|
2017-03-20 21:23:34 +01:00
|
|
|
|
2017-11-08 08:03:48 +01:00
|
|
|
// whether this module is specific to an SoC (System-On-a-Chip). When set to true,
|
|
|
|
// it is installed into /vendor (or /system/vendor if vendor partition does not exist).
|
|
|
|
// Use `soc_specific` instead for better meaning.
|
2017-11-01 18:38:29 +01:00
|
|
|
Vendor *bool
|
2017-04-06 21:49:58 +02:00
|
|
|
|
2017-11-08 08:03:48 +01:00
|
|
|
// whether this module is specific to an SoC (System-On-a-Chip). When set to true,
|
|
|
|
// it is installed into /vendor (or /system/vendor if vendor partition does not exist).
|
|
|
|
Soc_specific *bool
|
|
|
|
|
|
|
|
// whether this module is specific to a device, not only for SoC, but also for off-chip
|
|
|
|
// peripherals. When set to true, it is installed into /odm (or /vendor/odm if odm partition
|
|
|
|
// does not exist, or /system/vendor/odm if both odm and vendor partitions do not exist).
|
|
|
|
// This implies `soc_specific:true`.
|
|
|
|
Device_specific *bool
|
|
|
|
|
|
|
|
// whether this module is specific to a software configuration of a product (e.g. country,
|
2018-01-10 11:00:15 +01:00
|
|
|
// network operator, etc). When set to true, it is installed into /product (or
|
|
|
|
// /system/product if product partition does not exist).
|
2017-11-08 08:03:48 +01:00
|
|
|
Product_specific *bool
|
|
|
|
|
2019-06-25 09:47:17 +02:00
|
|
|
// whether this module extends system. When set to true, it is installed into /system_ext
|
|
|
|
// (or /system/system_ext if system_ext partition does not exist).
|
|
|
|
System_ext_specific *bool
|
|
|
|
|
2018-01-31 16:54:12 +01:00
|
|
|
// Whether this module is installed to recovery partition
|
|
|
|
Recovery *bool
|
|
|
|
|
2020-01-22 00:53:22 +01:00
|
|
|
// Whether this module is installed to ramdisk
|
|
|
|
Ramdisk *bool
|
|
|
|
|
2020-10-22 00:17:56 +02:00
|
|
|
// Whether this module is installed to vendor ramdisk
|
|
|
|
Vendor_ramdisk *bool
|
|
|
|
|
2021-04-08 14:13:22 +02:00
|
|
|
// Whether this module is installed to debug ramdisk
|
|
|
|
Debug_ramdisk *bool
|
|
|
|
|
2021-03-03 01:58:08 +01:00
|
|
|
// Whether this module is built for non-native architectures (also known as native bridge binary)
|
2019-03-26 12:39:31 +01:00
|
|
|
Native_bridge_supported *bool `android:"arch_variant"`
|
|
|
|
|
2016-07-26 05:27:39 +02:00
|
|
|
// init.rc files to be installed if this module is installed
|
2020-09-25 23:01:21 +02:00
|
|
|
Init_rc []string `android:"arch_variant,path"`
|
2016-07-26 05:27:39 +02:00
|
|
|
|
2018-04-05 00:42:19 +02:00
|
|
|
// VINTF manifest fragments to be installed if this module is installed
|
2019-03-05 07:35:41 +01:00
|
|
|
Vintf_fragments []string `android:"path"`
|
2018-04-05 00:42:19 +02:00
|
|
|
|
2016-08-15 20:47:23 +02:00
|
|
|
// names of other modules to install if this module is installed
|
2017-05-05 22:36:36 +02:00
|
|
|
Required []string `android:"arch_variant"`
|
2016-08-15 20:47:23 +02:00
|
|
|
|
2019-04-02 03:37:36 +02:00
|
|
|
// names of other modules to install on host if this module is installed
|
|
|
|
Host_required []string `android:"arch_variant"`
|
|
|
|
|
|
|
|
// names of other modules to install on target if this module is installed
|
|
|
|
Target_required []string `android:"arch_variant"`
|
|
|
|
|
2020-02-25 16:50:49 +01:00
|
|
|
// The OsType of artifacts that this module variant is responsible for creating.
|
|
|
|
//
|
|
|
|
// Set by osMutator
|
|
|
|
CompileOS OsType `blueprint:"mutated"`
|
|
|
|
|
|
|
|
// The Target of artifacts that this module variant is responsible for creating.
|
|
|
|
//
|
|
|
|
// Set by archMutator
|
|
|
|
CompileTarget Target `blueprint:"mutated"`
|
|
|
|
|
|
|
|
// The additional arch specific targets (e.g. 32/64 bit) that this module variant is
|
|
|
|
// responsible for creating.
|
|
|
|
//
|
|
|
|
// By default this is nil as, where necessary, separate variants are created for the
|
|
|
|
// different multilib types supported and that information is encapsulated in the
|
|
|
|
// CompileTarget so the module variant simply needs to create artifacts for that.
|
|
|
|
//
|
|
|
|
// However, if UseTargetVariants is set to false (e.g. by
|
|
|
|
// InitAndroidMultiTargetsArchModule) then no separate variants are created for the
|
|
|
|
// multilib targets. Instead a single variant is created for the architecture and
|
|
|
|
// this contains the multilib specific targets that this variant should create.
|
|
|
|
//
|
|
|
|
// Set by archMutator
|
2018-10-03 07:01:37 +02:00
|
|
|
CompileMultiTargets []Target `blueprint:"mutated"`
|
2020-02-25 16:50:49 +01:00
|
|
|
|
|
|
|
// True if the module variant's CompileTarget is the primary target
|
|
|
|
//
|
|
|
|
// Set by archMutator
|
|
|
|
CompilePrimary bool `blueprint:"mutated"`
|
2015-01-31 02:27:36 +01:00
|
|
|
|
|
|
|
// Set by InitAndroidModule
|
|
|
|
HostOrDeviceSupported HostOrDeviceSupported `blueprint:"mutated"`
|
2016-10-05 00:13:37 +02:00
|
|
|
ArchSpecific bool `blueprint:"mutated"`
|
2016-10-07 01:12:58 +02:00
|
|
|
|
2020-02-25 20:26:33 +01:00
|
|
|
// If set to true then a CommonOS variant will be created which will have dependencies
|
|
|
|
// on all its OsType specific variants. Used by sdk/module_exports to create a snapshot
|
|
|
|
// that covers all os and architecture variants.
|
|
|
|
//
|
|
|
|
// The OsType specific variants can be retrieved by calling
|
|
|
|
// GetOsSpecificVariantsOfCommonOSVariant
|
|
|
|
//
|
|
|
|
// Set at module initialization time by calling InitCommonOSAndroidMultiTargetsArchModule
|
|
|
|
CreateCommonOSVariant bool `blueprint:"mutated"`
|
|
|
|
|
|
|
|
// If set to true then this variant is the CommonOS variant that has dependencies on its
|
|
|
|
// OsType specific variants.
|
|
|
|
//
|
|
|
|
// Set by osMutator.
|
|
|
|
CommonOSVariant bool `blueprint:"mutated"`
|
|
|
|
|
2020-12-16 19:20:23 +01:00
|
|
|
// When HideFromMake is set to true, no entry for this variant will be emitted in the
|
|
|
|
// generated Android.mk file.
|
|
|
|
HideFromMake bool `blueprint:"mutated"`
|
|
|
|
|
|
|
|
// When SkipInstall is set to true, calls to ctx.InstallFile, ctx.InstallExecutable,
|
|
|
|
// ctx.InstallSymlink and ctx.InstallAbsoluteSymlink act like calls to ctx.PackageFile
|
|
|
|
// and don't create a rule to install the file.
|
2016-10-07 01:12:58 +02:00
|
|
|
SkipInstall bool `blueprint:"mutated"`
|
2017-11-30 01:47:17 +01:00
|
|
|
|
2023-04-25 20:30:51 +02:00
|
|
|
// UninstallableApexPlatformVariant is set by MakeUninstallable called by the apex
|
|
|
|
// mutator. MakeUninstallable also sets HideFromMake. UninstallableApexPlatformVariant
|
|
|
|
// is used to avoid adding install or packaging dependencies into libraries provided
|
|
|
|
// by apexes.
|
|
|
|
UninstallableApexPlatformVariant bool `blueprint:"mutated"`
|
|
|
|
|
2020-08-06 00:40:41 +02:00
|
|
|
// Whether the module has been replaced by a prebuilt
|
|
|
|
ReplacedByPrebuilt bool `blueprint:"mutated"`
|
|
|
|
|
2020-07-31 16:07:17 +02:00
|
|
|
// Disabled by mutators. If set to true, it overrides Enabled property.
|
|
|
|
ForcedDisabled bool `blueprint:"mutated"`
|
|
|
|
|
2017-11-30 01:47:17 +01:00
|
|
|
NamespaceExportedToMake bool `blueprint:"mutated"`
|
2019-06-07 00:41:36 +02:00
|
|
|
|
2023-05-17 19:01:48 +02:00
|
|
|
MissingDeps []string `blueprint:"mutated"`
|
|
|
|
CheckedMissingDeps bool `blueprint:"mutated"`
|
2019-07-02 00:32:45 +02:00
|
|
|
|
|
|
|
// Name and variant strings stored by mutators to enable Module.String()
|
|
|
|
DebugName string `blueprint:"mutated"`
|
|
|
|
DebugMutators []string `blueprint:"mutated"`
|
|
|
|
DebugVariations []string `blueprint:"mutated"`
|
2019-11-19 01:00:16 +01:00
|
|
|
|
2020-11-17 00:08:19 +01:00
|
|
|
// ImageVariation is set by ImageMutator to specify which image this variation is for,
|
|
|
|
// for example "" for core or "recovery" for recovery. It will often be set to one of the
|
|
|
|
// constants in image.go, but can also be set to a custom value by individual module types.
|
2019-11-19 01:00:16 +01:00
|
|
|
ImageVariation string `blueprint:"mutated"`
|
2021-08-11 06:17:36 +02:00
|
|
|
|
2022-08-03 03:23:58 +02:00
|
|
|
// Bazel conversion status
|
|
|
|
BazelConversionStatus BazelConversionStatus `blueprint:"mutated"`
|
2023-05-15 11:06:31 +02:00
|
|
|
|
2023-06-16 07:19:33 +02:00
|
|
|
// SoongConfigTrace records accesses to VendorVars (soong_config). The trace will be hashed
|
|
|
|
// and used as a subdir of PathForModuleOut. Note that we mainly focus on incremental
|
|
|
|
// builds among similar products (e.g. aosp_cf_x86_64_phone and aosp_cf_x86_64_foldable),
|
|
|
|
// and there are variables other than soong_config, which isn't captured by soong config
|
|
|
|
// trace, but influence modules among products.
|
2023-05-15 11:06:31 +02:00
|
|
|
SoongConfigTrace soongConfigTrace `blueprint:"mutated"`
|
|
|
|
SoongConfigTraceHash string `blueprint:"mutated"`
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2021-08-31 22:30:36 +02:00
|
|
|
// CommonAttributes represents the common Bazel attributes from which properties
|
|
|
|
// in `commonProperties` are translated/mapped; such properties are annotated in
|
|
|
|
// a list their corresponding attribute. It is embedded within `bp2buildInfo`.
|
|
|
|
type CommonAttributes struct {
|
|
|
|
// Soong nameProperties -> Bazel name
|
|
|
|
Name string
|
2022-09-09 03:38:47 +02:00
|
|
|
|
2021-08-31 22:30:36 +02:00
|
|
|
// Data mapped from: Required
|
|
|
|
Data bazel.LabelListAttribute
|
2022-09-16 04:32:03 +02:00
|
|
|
|
2022-09-09 03:38:47 +02:00
|
|
|
// SkipData is neither a Soong nor Bazel target attribute
|
|
|
|
// If true, this will not fill the data attribute automatically
|
|
|
|
// This is useful for Soong modules that have 1:many Bazel targets
|
|
|
|
// Some of the generated Bazel targets might not have a data attribute
|
|
|
|
SkipData *bool
|
|
|
|
|
2022-09-16 04:32:03 +02:00
|
|
|
Tags bazel.StringListAttribute
|
2022-09-27 03:15:45 +02:00
|
|
|
|
|
|
|
Applicable_licenses bazel.LabelListAttribute
|
2022-10-14 21:20:20 +02:00
|
|
|
|
|
|
|
Testonly *bool
|
2023-08-04 00:33:47 +02:00
|
|
|
|
|
|
|
// Dir is neither a Soong nor Bazel target attribute
|
|
|
|
// If set, the bazel target will be created in this directory
|
|
|
|
// If unset, the bazel target will default to be created in the directory of the visited soong module
|
|
|
|
Dir *string
|
2021-08-31 22:30:36 +02:00
|
|
|
}
|
|
|
|
|
2021-12-10 00:10:18 +01:00
|
|
|
// constraintAttributes represents Bazel attributes pertaining to build constraints,
|
|
|
|
// which make restrict building a Bazel target for some set of platforms.
|
|
|
|
type constraintAttributes struct {
|
|
|
|
// Constraint values this target can be built for.
|
|
|
|
Target_compatible_with bazel.LabelListAttribute
|
|
|
|
}
|
|
|
|
|
2020-09-02 14:08:57 +02:00
|
|
|
type distProperties struct {
|
|
|
|
// configuration to distribute output files from this module to the distribution
|
|
|
|
// directory (default: $OUT/dist, configurable with $DIST_DIR)
|
|
|
|
Dist Dist `android:"arch_variant"`
|
|
|
|
|
|
|
|
// a list of configurations to distribute output files from this module to the
|
|
|
|
// distribution directory (default: $OUT/dist, configurable with $DIST_DIR)
|
|
|
|
Dists []Dist `android:"arch_variant"`
|
|
|
|
}
|
|
|
|
|
2022-08-12 12:49:20 +02:00
|
|
|
// CommonTestOptions represents the common `test_options` properties in
|
|
|
|
// Android.bp.
|
|
|
|
type CommonTestOptions struct {
|
|
|
|
// If the test is a hostside (no device required) unittest that shall be run
|
|
|
|
// during presubmit check.
|
|
|
|
Unit_test *bool
|
2022-08-22 10:00:05 +02:00
|
|
|
|
|
|
|
// Tags provide additional metadata to customize test execution by downstream
|
|
|
|
// test runners. The tags have no special meaning to Soong.
|
|
|
|
Tags []string
|
2022-08-12 12:49:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// SetAndroidMkEntries sets AndroidMkEntries according to the value of base
|
|
|
|
// `test_options`.
|
|
|
|
func (t *CommonTestOptions) SetAndroidMkEntries(entries *AndroidMkEntries) {
|
|
|
|
entries.SetBoolIfTrue("LOCAL_IS_UNIT_TEST", Bool(t.Unit_test))
|
2022-08-22 10:00:05 +02:00
|
|
|
if len(t.Tags) > 0 {
|
|
|
|
entries.AddStrings("LOCAL_TEST_OPTIONS_TAGS", t.Tags...)
|
|
|
|
}
|
2022-08-12 12:49:20 +02:00
|
|
|
}
|
|
|
|
|
2020-11-25 17:37:46 +01:00
|
|
|
// The key to use in TaggedDistFiles when a Dist structure does not specify a
|
|
|
|
// tag property. This intentionally does not use "" as the default because that
|
|
|
|
// would mean that an empty tag would have a different meaning when used in a dist
|
|
|
|
// structure that when used to reference a specific set of output paths using the
|
|
|
|
// :module{tag} syntax, which passes tag to the OutputFiles(tag) method.
|
|
|
|
const DefaultDistTag = "<default-dist-tag>"
|
|
|
|
|
2020-06-15 07:24:19 +02:00
|
|
|
// A map of OutputFile tag keys to Paths, for disting purposes.
|
|
|
|
type TaggedDistFiles map[string]Paths
|
|
|
|
|
2020-11-25 17:37:46 +01:00
|
|
|
// addPathsForTag adds a mapping from the tag to the paths. If the map is nil
|
|
|
|
// then it will create a map, update it and then return it. If a mapping already
|
|
|
|
// exists for the tag then the paths are appended to the end of the current list
|
|
|
|
// of paths, ignoring any duplicates.
|
|
|
|
func (t TaggedDistFiles) addPathsForTag(tag string, paths ...Path) TaggedDistFiles {
|
|
|
|
if t == nil {
|
|
|
|
t = make(TaggedDistFiles)
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, distFile := range paths {
|
|
|
|
if distFile != nil && !t[tag].containsPath(distFile) {
|
|
|
|
t[tag] = append(t[tag], distFile)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return t
|
|
|
|
}
|
|
|
|
|
|
|
|
// merge merges the entries from the other TaggedDistFiles object into this one.
|
|
|
|
// If the TaggedDistFiles is nil then it will create a new instance, merge the
|
|
|
|
// other into it, and then return it.
|
|
|
|
func (t TaggedDistFiles) merge(other TaggedDistFiles) TaggedDistFiles {
|
|
|
|
for tag, paths := range other {
|
|
|
|
t = t.addPathsForTag(tag, paths...)
|
|
|
|
}
|
|
|
|
|
|
|
|
return t
|
|
|
|
}
|
|
|
|
|
2020-06-15 07:24:19 +02:00
|
|
|
func MakeDefaultDistFiles(paths ...Path) TaggedDistFiles {
|
2022-08-04 22:07:02 +02:00
|
|
|
for _, p := range paths {
|
|
|
|
if p == nil {
|
2020-07-24 11:13:49 +02:00
|
|
|
panic("The path to a dist file cannot be nil.")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-15 07:24:19 +02:00
|
|
|
// The default OutputFile tag is the empty "" string.
|
2020-11-25 17:37:46 +01:00
|
|
|
return TaggedDistFiles{DefaultDistTag: paths}
|
2020-06-15 07:24:19 +02:00
|
|
|
}
|
|
|
|
|
2015-01-31 02:27:36 +01:00
|
|
|
type hostAndDeviceProperties struct {
|
2018-11-09 19:36:55 +01:00
|
|
|
// If set to true, build a variant of the module for the host. Defaults to false.
|
|
|
|
Host_supported *bool
|
|
|
|
|
|
|
|
// If set to true, build a variant of the module for the device. Defaults to true.
|
2016-07-12 22:11:25 +02:00
|
|
|
Device_supported *bool
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2015-03-17 23:06:21 +01:00
|
|
|
type Multilib string
|
|
|
|
|
|
|
|
const (
|
2017-12-05 22:42:45 +01:00
|
|
|
MultilibBoth Multilib = "both"
|
|
|
|
MultilibFirst Multilib = "first"
|
|
|
|
MultilibCommon Multilib = "common"
|
|
|
|
MultilibCommonFirst Multilib = "common_first"
|
2015-03-17 23:06:21 +01:00
|
|
|
)
|
|
|
|
|
2016-06-02 02:09:44 +02:00
|
|
|
type HostOrDeviceSupported int
|
|
|
|
|
|
|
|
const (
|
2020-11-17 22:19:17 +01:00
|
|
|
hostSupported = 1 << iota
|
|
|
|
hostCrossSupported
|
|
|
|
deviceSupported
|
|
|
|
hostDefault
|
|
|
|
deviceDefault
|
2018-08-02 22:46:35 +02:00
|
|
|
|
|
|
|
// Host and HostCross are built by default. Device is not supported.
|
2020-11-17 22:19:17 +01:00
|
|
|
HostSupported = hostSupported | hostCrossSupported | hostDefault
|
2018-08-02 22:46:35 +02:00
|
|
|
|
|
|
|
// Host is built by default. HostCross and Device are not supported.
|
2020-11-17 22:19:17 +01:00
|
|
|
HostSupportedNoCross = hostSupported | hostDefault
|
2018-08-02 22:46:35 +02:00
|
|
|
|
|
|
|
// Device is built by default. Host and HostCross are not supported.
|
2020-11-17 22:19:17 +01:00
|
|
|
DeviceSupported = deviceSupported | deviceDefault
|
2018-08-02 22:46:35 +02:00
|
|
|
|
2021-08-23 23:12:07 +02:00
|
|
|
// By default, _only_ device variant is built. Device variant can be disabled with `device_supported: false`
|
Add tidy-soong, tidy-dir-path, module-tidy targets
* When WITH_TIDY=1, these targets allow quick check of C/C++
source code with clang-tidy, without building C/C++ binaries.
* For each module with tidy rules, add a module-tidy target, e.g.,
libart-tidy, libartd-tidy, bionic-benchmarks-tidy, libnativehelper-tidy, etc.
* Add a tidy-soong phony target that depends on all module-tidy targets.
* For each directory X/Y add a tidy-X-Y phony target that depends
on all *-tidy targets in X/Y and tidy-X-Y-Z for all X/Y/Z directories,
e.g., tidy-bionic, tidy-bionic-benchmarks, tidy-libnativehelper, etc.
* Only soong modules are collected for now.
Tidy rules in .mk files will be collected later.
* Some comment lines reformatted by gofmt.
Test: WITH_TIDY=1 make <some_module>-tidy tidy-<some_directory>
Test: WITH_TIDY=1 make tidy-soong
Bug: 199169329
Change-Id: I45aef3875f70288a8e070761e5f083dbbdfa6e94
2021-09-06 05:15:38 +02:00
|
|
|
// Host and HostCross are disabled by default and can be enabled with `host_supported: true`
|
2020-11-17 22:19:17 +01:00
|
|
|
HostAndDeviceSupported = hostSupported | hostCrossSupported | deviceSupported | deviceDefault
|
2018-08-02 22:46:35 +02:00
|
|
|
|
|
|
|
// Host, HostCross, and Device are built by default.
|
Add tidy-soong, tidy-dir-path, module-tidy targets
* When WITH_TIDY=1, these targets allow quick check of C/C++
source code with clang-tidy, without building C/C++ binaries.
* For each module with tidy rules, add a module-tidy target, e.g.,
libart-tidy, libartd-tidy, bionic-benchmarks-tidy, libnativehelper-tidy, etc.
* Add a tidy-soong phony target that depends on all module-tidy targets.
* For each directory X/Y add a tidy-X-Y phony target that depends
on all *-tidy targets in X/Y and tidy-X-Y-Z for all X/Y/Z directories,
e.g., tidy-bionic, tidy-bionic-benchmarks, tidy-libnativehelper, etc.
* Only soong modules are collected for now.
Tidy rules in .mk files will be collected later.
* Some comment lines reformatted by gofmt.
Test: WITH_TIDY=1 make <some_module>-tidy tidy-<some_directory>
Test: WITH_TIDY=1 make tidy-soong
Bug: 199169329
Change-Id: I45aef3875f70288a8e070761e5f083dbbdfa6e94
2021-09-06 05:15:38 +02:00
|
|
|
// Building Device can be disabled with `device_supported: false`
|
|
|
|
// Building Host and HostCross can be disabled with `host_supported: false`
|
2020-11-17 22:19:17 +01:00
|
|
|
HostAndDeviceDefault = hostSupported | hostCrossSupported | hostDefault |
|
|
|
|
deviceSupported | deviceDefault
|
2018-08-02 22:46:35 +02:00
|
|
|
|
|
|
|
// Nothing is supported. This is not exposed to the user, but used to mark a
|
|
|
|
// host only module as unsupported when the module type is not supported on
|
|
|
|
// the host OS. E.g. benchmarks are supported on Linux but not Darwin.
|
2020-11-17 22:19:17 +01:00
|
|
|
NeitherHostNorDeviceSupported = 0
|
2016-06-02 02:09:44 +02:00
|
|
|
)
|
|
|
|
|
2017-11-08 08:03:48 +01:00
|
|
|
type moduleKind int
|
|
|
|
|
|
|
|
const (
|
|
|
|
platformModule moduleKind = iota
|
|
|
|
deviceSpecificModule
|
|
|
|
socSpecificModule
|
|
|
|
productSpecificModule
|
2019-06-25 09:47:17 +02:00
|
|
|
systemExtSpecificModule
|
2017-11-08 08:03:48 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func (k moduleKind) String() string {
|
|
|
|
switch k {
|
|
|
|
case platformModule:
|
|
|
|
return "platform"
|
|
|
|
case deviceSpecificModule:
|
|
|
|
return "device-specific"
|
|
|
|
case socSpecificModule:
|
|
|
|
return "soc-specific"
|
|
|
|
case productSpecificModule:
|
|
|
|
return "product-specific"
|
2019-06-25 09:47:17 +02:00
|
|
|
case systemExtSpecificModule:
|
|
|
|
return "systemext-specific"
|
2017-11-08 08:03:48 +01:00
|
|
|
default:
|
|
|
|
panic(fmt.Errorf("unknown module kind %d", k))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-23 01:03:51 +01:00
|
|
|
func initAndroidModuleBase(m Module) {
|
|
|
|
m.base().module = m
|
|
|
|
}
|
|
|
|
|
2020-11-17 00:08:19 +01:00
|
|
|
// InitAndroidModule initializes the Module as an Android module that is not architecture-specific.
|
|
|
|
// It adds the common properties, for example "name" and "enabled".
|
2017-06-24 00:06:31 +02:00
|
|
|
func InitAndroidModule(m Module) {
|
2019-11-23 01:03:51 +01:00
|
|
|
initAndroidModuleBase(m)
|
2015-01-31 02:27:36 +01:00
|
|
|
base := m.base()
|
2015-03-18 21:28:46 +01:00
|
|
|
|
2017-06-24 00:06:31 +02:00
|
|
|
m.AddProperties(
|
2016-05-18 01:34:16 +02:00
|
|
|
&base.nameProperties,
|
2020-09-02 14:08:57 +02:00
|
|
|
&base.commonProperties,
|
|
|
|
&base.distProperties)
|
2019-09-25 07:19:02 +02:00
|
|
|
|
2020-02-07 02:01:55 +01:00
|
|
|
initProductVariableModule(m)
|
2019-09-25 07:19:02 +02:00
|
|
|
|
Refactor visibility to support visibility on defaults modules
Existing modules, either general one or package ones have a single
visibility property, called visibility in general, and
default_visibility on package, that controls access to that module, or
in the case of package sets the default visibility of all modules in
that package. The property is checked and gathered during the similarly
named phases of visibility processing.
The defaults module will be different as it will have two properties.
The first, visibility, will not affect the visibility of the module, it
only affects the visibility of modules that 'extend' the defaults. So,
it will need checking but not parsing. The second property,
defaults_visibility, will affect the visibility of the module and so
will need both checking and parsing.
The current implementation does not handle those cases because:
1) It does not differentiate between the property that affects the
module and those that do not. It checks and gathers all of them with
the last property gathered overriding the rules for the previous
properties.
2) It relies on overriding methods in MethodBase in order to change the
default behavior for the package module. That works because
packageModule embeds ModuleBase but will not work for
DefaultsModuleBase as it does not embed ModuleBase and instead is
embedded alongside it so attempting to override a method in
MethodBase leads to ambiguity.
This change addresses the issues as follows:
1) It adds a new visibility() []string method to get access to the
primary visibility rules, i.e. the ones that affect the module.
2) It adds two fields, 'visibilityPropertyInfo []visibilityProperty'
to provide information about all the properties that need checking,
and 'primaryVisibilityProperty visibilityProperty' to specify the
property that affects the module.
The PackageFactory() and InitAndroidModule(Module) functions are
modified to initialize the fields. The override of the
visibilityProperties() method for packageModule is removed and the
default implementations of visibilityProperties() and visibility()
on ModuleBase return information from the two new fields.
The InitDefaultsModule is updated to also initialize the two new
fields. It uses nil for primaryVisibilityProperty for now but that
will be changed to return defaults_visibility. It also uses the
commonProperties structure created for the defaults directly instead
of having to search for it through properties().
Changed the visibilityProperty to take a pointer to the property that
can be used to retrieve the value rather than a lambda function.
Bug: 130796911
Test: m nothing
Change-Id: Icadd470a5f692a48ec61de02bf3dfde3e2eea2ef
2019-07-24 15:24:38 +02:00
|
|
|
// The default_visibility property needs to be checked and parsed by the visibility module during
|
2020-05-01 18:52:01 +02:00
|
|
|
// its checking and parsing phases so make it the primary visibility property.
|
|
|
|
setPrimaryVisibilityProperty(m, "visibility", &base.commonProperties.Visibility)
|
2021-01-07 04:34:31 +01:00
|
|
|
|
|
|
|
// The default_applicable_licenses property needs to be checked and parsed by the licenses module during
|
|
|
|
// its checking and parsing phases so make it the primary licenses property.
|
|
|
|
setPrimaryLicensesProperty(m, "licenses", &base.commonProperties.Licenses)
|
2015-03-18 21:28:46 +01:00
|
|
|
}
|
|
|
|
|
2020-11-17 00:08:19 +01:00
|
|
|
// InitAndroidArchModule initializes the Module as an Android module that is architecture-specific.
|
|
|
|
// It adds the common properties, for example "name" and "enabled", as well as runtime generated
|
|
|
|
// property structs for architecture-specific versions of generic properties tagged with
|
|
|
|
// `android:"arch_variant"`.
|
|
|
|
//
|
2022-08-16 19:27:33 +02:00
|
|
|
// InitAndroidModule should not be called if InitAndroidArchModule was called.
|
2017-06-24 00:06:31 +02:00
|
|
|
func InitAndroidArchModule(m Module, hod HostOrDeviceSupported, defaultMultilib Multilib) {
|
|
|
|
InitAndroidModule(m)
|
2015-03-18 21:28:46 +01:00
|
|
|
|
|
|
|
base := m.base()
|
2015-01-31 02:27:36 +01:00
|
|
|
base.commonProperties.HostOrDeviceSupported = hod
|
2016-09-06 19:39:07 +02:00
|
|
|
base.commonProperties.Default_multilib = string(defaultMultilib)
|
2016-10-05 00:13:37 +02:00
|
|
|
base.commonProperties.ArchSpecific = true
|
2018-10-03 07:01:37 +02:00
|
|
|
base.commonProperties.UseTargetVariants = true
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2020-11-17 22:19:17 +01:00
|
|
|
if hod&hostSupported != 0 && hod&deviceSupported != 0 {
|
2017-06-24 00:06:31 +02:00
|
|
|
m.AddProperties(&base.hostAndDeviceProperties)
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2020-11-17 00:08:19 +01:00
|
|
|
initArchModule(m)
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2020-11-17 00:08:19 +01:00
|
|
|
// InitAndroidMultiTargetsArchModule initializes the Module as an Android module that is
|
|
|
|
// architecture-specific, but will only have a single variant per OS that handles all the
|
|
|
|
// architectures simultaneously. The list of Targets that it must handle will be available from
|
|
|
|
// ModuleContext.MultiTargets. It adds the common properties, for example "name" and "enabled", as
|
|
|
|
// well as runtime generated property structs for architecture-specific versions of generic
|
|
|
|
// properties tagged with `android:"arch_variant"`.
|
|
|
|
//
|
|
|
|
// InitAndroidModule or InitAndroidArchModule should not be called if
|
|
|
|
// InitAndroidMultiTargetsArchModule was called.
|
2018-10-03 07:01:37 +02:00
|
|
|
func InitAndroidMultiTargetsArchModule(m Module, hod HostOrDeviceSupported, defaultMultilib Multilib) {
|
|
|
|
InitAndroidArchModule(m, hod, defaultMultilib)
|
|
|
|
m.base().commonProperties.UseTargetVariants = false
|
|
|
|
}
|
|
|
|
|
2020-11-17 00:08:19 +01:00
|
|
|
// InitCommonOSAndroidMultiTargetsArchModule initializes the Module as an Android module that is
|
|
|
|
// architecture-specific, but will only have a single variant per OS that handles all the
|
|
|
|
// architectures simultaneously, and will also have an additional CommonOS variant that has
|
|
|
|
// dependencies on all the OS-specific variants. The list of Targets that it must handle will be
|
|
|
|
// available from ModuleContext.MultiTargets. It adds the common properties, for example "name" and
|
|
|
|
// "enabled", as well as runtime generated property structs for architecture-specific versions of
|
|
|
|
// generic properties tagged with `android:"arch_variant"`.
|
|
|
|
//
|
|
|
|
// InitAndroidModule, InitAndroidArchModule or InitAndroidMultiTargetsArchModule should not be
|
|
|
|
// called if InitCommonOSAndroidMultiTargetsArchModule was called.
|
2020-02-25 20:26:33 +01:00
|
|
|
func InitCommonOSAndroidMultiTargetsArchModule(m Module, hod HostOrDeviceSupported, defaultMultilib Multilib) {
|
|
|
|
InitAndroidArchModule(m, hod, defaultMultilib)
|
|
|
|
m.base().commonProperties.UseTargetVariants = false
|
|
|
|
m.base().commonProperties.CreateCommonOSVariant = true
|
|
|
|
}
|
|
|
|
|
2021-12-10 00:10:18 +01:00
|
|
|
func (attrs *CommonAttributes) fillCommonBp2BuildModuleAttrs(ctx *topDownMutatorContext,
|
|
|
|
enabledPropertyOverrides bazel.BoolAttribute) constraintAttributes {
|
2022-08-04 22:07:02 +02:00
|
|
|
|
|
|
|
mod := ctx.Module().base()
|
2021-08-31 22:30:36 +02:00
|
|
|
// Assert passed-in attributes include Name
|
2022-08-04 22:07:02 +02:00
|
|
|
if len(attrs.Name) == 0 {
|
2022-08-04 20:13:27 +02:00
|
|
|
if ctx.ModuleType() != "package" {
|
|
|
|
ctx.ModuleErrorf("CommonAttributes in fillCommonBp2BuildModuleAttrs expects a `.Name`!")
|
|
|
|
}
|
2021-08-31 22:30:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
depsToLabelList := func(deps []string) bazel.LabelListAttribute {
|
|
|
|
return bazel.MakeLabelListAttribute(BazelLabelForModuleDeps(ctx, deps))
|
|
|
|
}
|
|
|
|
|
2021-12-10 00:10:18 +01:00
|
|
|
var enabledProperty bazel.BoolAttribute
|
2022-05-13 23:20:20 +02:00
|
|
|
|
|
|
|
onlyAndroid := false
|
|
|
|
neitherHostNorDevice := false
|
|
|
|
|
|
|
|
osSupport := map[string]bool{}
|
|
|
|
|
|
|
|
// if the target is enabled and supports arch variance, determine the defaults based on the module
|
|
|
|
// type's host or device property and host_supported/device_supported properties
|
|
|
|
if mod.commonProperties.ArchSpecific {
|
|
|
|
moduleSupportsDevice := mod.DeviceSupported()
|
|
|
|
moduleSupportsHost := mod.HostSupported()
|
|
|
|
if moduleSupportsHost && !moduleSupportsDevice {
|
|
|
|
// for host only, we specify as unsupported on android rather than listing all host osSupport
|
|
|
|
// TODO(b/220874839): consider replacing this with a constraint that covers all host osSupport
|
|
|
|
// instead
|
|
|
|
enabledProperty.SetSelectValue(bazel.OsConfigurationAxis, Android.Name, proptools.BoolPtr(false))
|
|
|
|
} else if moduleSupportsDevice && !moduleSupportsHost {
|
|
|
|
enabledProperty.SetSelectValue(bazel.OsConfigurationAxis, Android.Name, proptools.BoolPtr(true))
|
|
|
|
// specify as a positive to ensure any target-specific enabled can be resolved
|
|
|
|
// also save that a target is only android, as if there is only the positive restriction on
|
|
|
|
// android, it'll be dropped, so we may need to add it back later
|
|
|
|
onlyAndroid = true
|
|
|
|
} else if !moduleSupportsHost && !moduleSupportsDevice {
|
|
|
|
neitherHostNorDevice = true
|
|
|
|
}
|
|
|
|
|
2022-08-04 22:07:02 +02:00
|
|
|
for _, osType := range OsTypeList() {
|
|
|
|
if osType.Class == Host {
|
|
|
|
osSupport[osType.Name] = moduleSupportsHost
|
|
|
|
} else if osType.Class == Device {
|
|
|
|
osSupport[osType.Name] = moduleSupportsDevice
|
2022-05-13 23:20:20 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if neitherHostNorDevice {
|
|
|
|
// we can't build this, disable
|
|
|
|
enabledProperty.Value = proptools.BoolPtr(false)
|
2022-08-04 22:07:02 +02:00
|
|
|
} else if mod.commonProperties.Enabled != nil {
|
|
|
|
enabledProperty.SetValue(mod.commonProperties.Enabled)
|
|
|
|
if !*mod.commonProperties.Enabled {
|
|
|
|
for oss, enabled := range osSupport {
|
|
|
|
if val := enabledProperty.SelectValue(bazel.OsConfigurationAxis, oss); enabled && val != nil && *val {
|
2022-05-13 23:20:20 +02:00
|
|
|
// if this should be disabled by default, clear out any enabling we've done
|
2022-08-04 22:07:02 +02:00
|
|
|
enabledProperty.SetSelectValue(bazel.OsConfigurationAxis, oss, nil)
|
2022-05-13 23:20:20 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-12-10 00:10:18 +01:00
|
|
|
}
|
|
|
|
|
2022-09-27 03:15:45 +02:00
|
|
|
attrs.Applicable_licenses = bazel.MakeLabelListAttribute(BazelLabelForModuleDeps(ctx, mod.commonProperties.Licenses))
|
|
|
|
|
2022-09-21 11:05:37 +02:00
|
|
|
// The required property can contain the module itself. This causes a cycle
|
|
|
|
// when generated as the 'data' label list attribute in Bazel. Remove it if
|
|
|
|
// it exists. See b/247985196.
|
|
|
|
_, requiredWithoutCycles := RemoveFromList(ctx.ModuleName(), mod.commonProperties.Required)
|
2022-10-11 23:38:16 +02:00
|
|
|
requiredWithoutCycles = FirstUniqueStrings(requiredWithoutCycles)
|
2022-09-21 11:05:37 +02:00
|
|
|
required := depsToLabelList(requiredWithoutCycles)
|
2022-08-04 22:07:02 +02:00
|
|
|
archVariantProps := mod.GetArchVariantProperties(ctx, &commonProperties{})
|
2021-08-31 22:30:36 +02:00
|
|
|
for axis, configToProps := range archVariantProps {
|
|
|
|
for config, _props := range configToProps {
|
|
|
|
if archProps, ok := _props.(*commonProperties); ok {
|
2022-09-21 11:05:37 +02:00
|
|
|
_, requiredWithoutCycles := RemoveFromList(ctx.ModuleName(), archProps.Required)
|
2022-10-11 23:38:16 +02:00
|
|
|
requiredWithoutCycles = FirstUniqueStrings(requiredWithoutCycles)
|
2022-09-21 11:05:37 +02:00
|
|
|
required.SetSelectValue(axis, config, depsToLabelList(requiredWithoutCycles).Value)
|
2022-05-13 23:20:20 +02:00
|
|
|
if !neitherHostNorDevice {
|
|
|
|
if archProps.Enabled != nil {
|
|
|
|
if axis != bazel.OsConfigurationAxis || osSupport[config] {
|
|
|
|
enabledProperty.SetSelectValue(axis, config, archProps.Enabled)
|
|
|
|
}
|
|
|
|
}
|
2021-12-10 00:10:18 +01:00
|
|
|
}
|
2021-08-31 22:30:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-12-10 00:10:18 +01:00
|
|
|
|
2022-05-13 23:20:20 +02:00
|
|
|
if !neitherHostNorDevice {
|
|
|
|
if enabledPropertyOverrides.Value != nil {
|
|
|
|
enabledProperty.Value = enabledPropertyOverrides.Value
|
|
|
|
}
|
|
|
|
for _, axis := range enabledPropertyOverrides.SortedConfigurationAxes() {
|
|
|
|
configToBools := enabledPropertyOverrides.ConfigurableValues[axis]
|
|
|
|
for cfg, val := range configToBools {
|
2023-09-01 21:43:56 +02:00
|
|
|
if axis != bazel.OsConfigurationAxis || osSupport[cfg] || val /*If enabled is explicitly requested via overrides */ {
|
2022-05-13 23:20:20 +02:00
|
|
|
enabledProperty.SetSelectValue(axis, cfg, &val)
|
|
|
|
}
|
|
|
|
}
|
2021-12-10 00:10:18 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-31 21:10:12 +02:00
|
|
|
productConfigEnabledAttribute := bazel.LabelListAttribute{}
|
2022-05-13 23:20:20 +02:00
|
|
|
// TODO(b/234497586): Soong config variables and product variables have different overriding behavior, we
|
|
|
|
// should handle it correctly
|
|
|
|
if !proptools.BoolDefault(enabledProperty.Value, true) && !neitherHostNorDevice {
|
2022-01-07 21:39:21 +01:00
|
|
|
// If the module is not enabled by default, then we can check if a
|
|
|
|
// product variable enables it
|
2023-07-31 21:10:12 +02:00
|
|
|
productConfigEnabledAttribute = productVariableConfigEnableAttribute(ctx)
|
2022-01-07 21:39:21 +01:00
|
|
|
|
2023-07-31 21:10:12 +02:00
|
|
|
if len(productConfigEnabledAttribute.ConfigurableValues) > 0 {
|
2022-01-07 21:39:21 +01:00
|
|
|
// In this case, an existing product variable configuration overrides any
|
|
|
|
// module-level `enable: false` definition
|
|
|
|
newValue := true
|
|
|
|
enabledProperty.Value = &newValue
|
|
|
|
}
|
|
|
|
}
|
2021-12-10 00:10:18 +01:00
|
|
|
|
2022-01-07 21:39:21 +01:00
|
|
|
platformEnabledAttribute, err := enabledProperty.ToLabelListAttribute(
|
2022-08-04 22:07:02 +02:00
|
|
|
bazel.LabelList{[]bazel.Label{{Label: "@platforms//:incompatible"}}, nil},
|
2021-12-10 00:10:18 +01:00
|
|
|
bazel.LabelList{[]bazel.Label{}, nil})
|
|
|
|
if err != nil {
|
2022-01-07 21:39:21 +01:00
|
|
|
ctx.ModuleErrorf("Error processing platform enabled attribute: %s", err)
|
2021-12-10 00:10:18 +01:00
|
|
|
}
|
2022-01-07 21:39:21 +01:00
|
|
|
|
2022-05-13 23:20:20 +02:00
|
|
|
// if android is the only arch/os enabled, then add a restriction to only be compatible with android
|
|
|
|
if platformEnabledAttribute.IsNil() && onlyAndroid {
|
|
|
|
l := bazel.LabelAttribute{}
|
|
|
|
l.SetValue(bazel.Label{Label: bazel.OsConfigurationAxis.SelectKey(Android.Name)})
|
|
|
|
platformEnabledAttribute.Add(&l)
|
|
|
|
}
|
|
|
|
|
2022-09-09 03:38:47 +02:00
|
|
|
if !proptools.Bool(attrs.SkipData) {
|
|
|
|
attrs.Data.Append(required)
|
|
|
|
}
|
|
|
|
// SkipData is not an attribute of any Bazel target
|
|
|
|
// Set this to nil so that it does not appear in the generated build file
|
|
|
|
attrs.SkipData = nil
|
2022-01-07 21:39:21 +01:00
|
|
|
|
|
|
|
moduleEnableConstraints := bazel.LabelListAttribute{}
|
|
|
|
moduleEnableConstraints.Append(platformEnabledAttribute)
|
|
|
|
moduleEnableConstraints.Append(productConfigEnabledAttribute)
|
2023-09-05 21:31:12 +02:00
|
|
|
addCompatibilityConstraintForCompileMultilib(ctx, &moduleEnableConstraints)
|
2022-01-07 21:39:21 +01:00
|
|
|
|
2022-08-04 22:07:02 +02:00
|
|
|
return constraintAttributes{Target_compatible_with: moduleEnableConstraints}
|
2021-08-31 22:30:36 +02:00
|
|
|
}
|
|
|
|
|
2023-09-05 21:31:12 +02:00
|
|
|
var (
|
|
|
|
incompatible = bazel.LabelList{[]bazel.Label{{Label: "@platforms//:incompatible"}}, nil}
|
|
|
|
)
|
|
|
|
|
|
|
|
// If compile_mulitilib is set to
|
|
|
|
// 1. 32: Add an incompatibility constraint for non-32 arches
|
|
|
|
// 1. 64: Add an incompatibility constraint for non-64 arches
|
|
|
|
func addCompatibilityConstraintForCompileMultilib(ctx *topDownMutatorContext, enabled *bazel.LabelListAttribute) {
|
|
|
|
mod := ctx.Module().base()
|
|
|
|
multilib, _ := decodeMultilib(mod, mod.commonProperties.CompileOS, ctx.Config().IgnorePrefer32OnDevice())
|
|
|
|
|
|
|
|
switch multilib {
|
|
|
|
case "32":
|
|
|
|
// Add an incompatibility constraint for all known 64-bit arches
|
|
|
|
enabled.SetSelectValue(bazel.ArchConfigurationAxis, "arm64", incompatible)
|
|
|
|
enabled.SetSelectValue(bazel.ArchConfigurationAxis, "x86_64", incompatible)
|
|
|
|
enabled.SetSelectValue(bazel.ArchConfigurationAxis, "riscv64", incompatible)
|
|
|
|
case "64":
|
|
|
|
// Add an incompatibility constraint for all known 32-bit arches
|
|
|
|
enabled.SetSelectValue(bazel.ArchConfigurationAxis, "arm", incompatible)
|
|
|
|
enabled.SetSelectValue(bazel.ArchConfigurationAxis, "x86", incompatible)
|
|
|
|
case "both":
|
|
|
|
// Do nothing: "both" is trivially compatible with 32-bit and 64-bit
|
|
|
|
// The top level rule (e.g. apex/partition) will be responsible for building this module in both variants via an
|
|
|
|
// outgoing_transition.
|
|
|
|
default: // e.g. first, common
|
|
|
|
// TODO - b/299135307: Add bp2build support for these properties.
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-01-07 21:39:21 +01:00
|
|
|
// Check product variables for `enabled: true` flag override.
|
|
|
|
// Returns a list of the constraint_value targets who enable this override.
|
2023-07-31 21:10:12 +02:00
|
|
|
func productVariableConfigEnableAttribute(ctx *topDownMutatorContext) bazel.LabelListAttribute {
|
|
|
|
result := bazel.LabelListAttribute{}
|
2023-03-08 21:29:50 +01:00
|
|
|
productVariableProps := ProductVariableProperties(ctx, ctx.Module())
|
2023-07-31 21:10:12 +02:00
|
|
|
if productConfigProps, exists := productVariableProps["Enabled"]; exists {
|
2022-01-07 21:39:21 +01:00
|
|
|
for productConfigProp, prop := range productConfigProps {
|
|
|
|
flag, ok := prop.(*bool)
|
|
|
|
if !ok {
|
2023-07-31 21:10:12 +02:00
|
|
|
ctx.ModuleErrorf("Could not convert product variable enabled property")
|
2022-01-07 21:39:21 +01:00
|
|
|
}
|
|
|
|
|
2023-08-08 00:43:58 +02:00
|
|
|
if flag == nil {
|
|
|
|
// soong config var is not used to set `enabled`. nothing to do.
|
|
|
|
continue
|
|
|
|
} else if *flag {
|
2022-01-07 21:39:21 +01:00
|
|
|
axis := productConfigProp.ConfigurationAxis()
|
2023-07-31 21:10:12 +02:00
|
|
|
result.SetSelectValue(axis, bazel.ConditionsDefaultConfigKey, bazel.MakeLabelList([]bazel.Label{{Label: "@platforms//:incompatible"}}))
|
|
|
|
result.SetSelectValue(axis, productConfigProp.SelectKey(), bazel.LabelList{Includes: []bazel.Label{}})
|
2023-08-08 04:00:22 +02:00
|
|
|
} else if scp, isSoongConfigProperty := productConfigProp.(SoongConfigProperty); isSoongConfigProperty && scp.value == bazel.ConditionsDefaultConfigKey {
|
|
|
|
// productVariableConfigEnableAttribute runs only if `enabled: false` is set at the top-level outside soong_config_variables
|
|
|
|
// conditions_default { enabled: false} is a no-op in this case
|
|
|
|
continue
|
2022-01-07 21:39:21 +01:00
|
|
|
} else {
|
|
|
|
// TODO(b/210546943): handle negative case where `enabled: false`
|
2023-07-31 21:10:12 +02:00
|
|
|
ctx.ModuleErrorf("`enabled: false` is not currently supported for configuration variables. See b/210546943")
|
2022-01-07 21:39:21 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-31 21:10:12 +02:00
|
|
|
return result
|
2022-01-07 21:39:21 +01:00
|
|
|
}
|
|
|
|
|
2017-02-02 19:46:07 +01:00
|
|
|
// A ModuleBase object contains the properties that are common to all Android
|
2015-01-31 02:27:36 +01:00
|
|
|
// modules. It should be included as an anonymous field in every module
|
|
|
|
// struct definition. InitAndroidModule should then be called from the module's
|
|
|
|
// factory function, and the return values from InitAndroidModule should be
|
|
|
|
// returned from the factory function.
|
|
|
|
//
|
2017-02-02 19:46:07 +01:00
|
|
|
// The ModuleBase type is responsible for implementing the GenerateBuildActions
|
|
|
|
// method to support the blueprint.Module interface. This method will then call
|
|
|
|
// the module's GenerateAndroidBuildActions method once for each build variant
|
2019-06-06 23:29:25 +02:00
|
|
|
// that is to be built. GenerateAndroidBuildActions is passed a ModuleContext
|
|
|
|
// rather than the usual blueprint.ModuleContext.
|
|
|
|
// ModuleContext exposes extra functionality specific to the Android build
|
2015-01-31 02:27:36 +01:00
|
|
|
// system including details about the particular build variant that is to be
|
|
|
|
// generated.
|
|
|
|
//
|
|
|
|
// For example:
|
|
|
|
//
|
2022-08-12 12:49:20 +02:00
|
|
|
// import (
|
|
|
|
// "android/soong/android"
|
|
|
|
// )
|
2015-01-31 02:27:36 +01:00
|
|
|
//
|
2022-08-12 12:49:20 +02:00
|
|
|
// type myModule struct {
|
|
|
|
// android.ModuleBase
|
|
|
|
// properties struct {
|
|
|
|
// MyProperty string
|
|
|
|
// }
|
|
|
|
// }
|
2015-01-31 02:27:36 +01:00
|
|
|
//
|
2022-08-12 12:49:20 +02:00
|
|
|
// func NewMyModule() android.Module {
|
|
|
|
// m := &myModule{}
|
|
|
|
// m.AddProperties(&m.properties)
|
|
|
|
// android.InitAndroidModule(m)
|
|
|
|
// return m
|
|
|
|
// }
|
2015-01-31 02:27:36 +01:00
|
|
|
//
|
2022-08-12 12:49:20 +02:00
|
|
|
// func (m *myModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|
|
|
// // Get the CPU architecture for the current build variant.
|
|
|
|
// variantArch := ctx.Arch()
|
2015-01-31 02:27:36 +01:00
|
|
|
//
|
2022-08-12 12:49:20 +02:00
|
|
|
// // ...
|
|
|
|
// }
|
2016-05-19 00:37:25 +02:00
|
|
|
type ModuleBase struct {
|
2015-01-31 02:27:36 +01:00
|
|
|
// Putting the curiously recurring thing pointing to the thing that contains
|
|
|
|
// the thing pattern to good use.
|
2017-06-24 00:06:31 +02:00
|
|
|
// TODO: remove this
|
2016-05-19 00:37:25 +02:00
|
|
|
module Module
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2016-05-18 01:34:16 +02:00
|
|
|
nameProperties nameProperties
|
2015-01-31 02:27:36 +01:00
|
|
|
commonProperties commonProperties
|
2020-09-02 14:08:57 +02:00
|
|
|
distProperties distProperties
|
2019-09-25 07:19:02 +02:00
|
|
|
variableProperties interface{}
|
2015-01-31 02:27:36 +01:00
|
|
|
hostAndDeviceProperties hostAndDeviceProperties
|
2021-02-24 13:20:12 +01:00
|
|
|
|
2022-01-06 05:42:33 +01:00
|
|
|
// Arch specific versions of structs in GetProperties() prior to
|
|
|
|
// initialization in InitAndroidArchModule, lets call it `generalProperties`.
|
|
|
|
// The outer index has the same order as generalProperties and the inner index
|
|
|
|
// chooses the props specific to the architecture. The interface{} value is an
|
|
|
|
// archPropRoot that is filled with arch specific values by the arch mutator.
|
2021-02-24 13:20:12 +01:00
|
|
|
archProperties [][]interface{}
|
|
|
|
|
2020-12-14 14:25:34 +01:00
|
|
|
// Properties specific to the Blueprint to BUILD migration.
|
|
|
|
bazelTargetModuleProperties bazel.BazelTargetModuleProperties
|
|
|
|
|
Refactor visibility to support visibility on defaults modules
Existing modules, either general one or package ones have a single
visibility property, called visibility in general, and
default_visibility on package, that controls access to that module, or
in the case of package sets the default visibility of all modules in
that package. The property is checked and gathered during the similarly
named phases of visibility processing.
The defaults module will be different as it will have two properties.
The first, visibility, will not affect the visibility of the module, it
only affects the visibility of modules that 'extend' the defaults. So,
it will need checking but not parsing. The second property,
defaults_visibility, will affect the visibility of the module and so
will need both checking and parsing.
The current implementation does not handle those cases because:
1) It does not differentiate between the property that affects the
module and those that do not. It checks and gathers all of them with
the last property gathered overriding the rules for the previous
properties.
2) It relies on overriding methods in MethodBase in order to change the
default behavior for the package module. That works because
packageModule embeds ModuleBase but will not work for
DefaultsModuleBase as it does not embed ModuleBase and instead is
embedded alongside it so attempting to override a method in
MethodBase leads to ambiguity.
This change addresses the issues as follows:
1) It adds a new visibility() []string method to get access to the
primary visibility rules, i.e. the ones that affect the module.
2) It adds two fields, 'visibilityPropertyInfo []visibilityProperty'
to provide information about all the properties that need checking,
and 'primaryVisibilityProperty visibilityProperty' to specify the
property that affects the module.
The PackageFactory() and InitAndroidModule(Module) functions are
modified to initialize the fields. The override of the
visibilityProperties() method for packageModule is removed and the
default implementations of visibilityProperties() and visibility()
on ModuleBase return information from the two new fields.
The InitDefaultsModule is updated to also initialize the two new
fields. It uses nil for primaryVisibilityProperty for now but that
will be changed to return defaults_visibility. It also uses the
commonProperties structure created for the defaults directly instead
of having to search for it through properties().
Changed the visibilityProperty to take a pointer to the property that
can be used to retrieve the value rather than a lambda function.
Bug: 130796911
Test: m nothing
Change-Id: Icadd470a5f692a48ec61de02bf3dfde3e2eea2ef
2019-07-24 15:24:38 +02:00
|
|
|
// Information about all the properties on the module that contains visibility rules that need
|
|
|
|
// checking.
|
|
|
|
visibilityPropertyInfo []visibilityProperty
|
|
|
|
|
|
|
|
// The primary visibility property, may be nil, that controls access to the module.
|
|
|
|
primaryVisibilityProperty visibilityProperty
|
|
|
|
|
2021-01-07 04:34:31 +01:00
|
|
|
// The primary licenses property, may be nil, records license metadata for the module.
|
|
|
|
primaryLicensesProperty applicableLicensesProperty
|
|
|
|
|
2020-12-02 00:40:06 +01:00
|
|
|
noAddressSanitizer bool
|
|
|
|
installFiles InstallPaths
|
2022-04-21 21:50:51 +02:00
|
|
|
installFilesDepSet *DepSet[InstallPath]
|
2020-12-02 00:40:06 +01:00
|
|
|
checkbuildFiles Paths
|
|
|
|
packagingSpecs []PackagingSpec
|
2022-04-21 21:50:51 +02:00
|
|
|
packagingSpecsDepSet *DepSet[PackagingSpec]
|
2021-09-29 02:40:21 +02:00
|
|
|
// katiInstalls tracks the install rules that were created by Soong but are being exported
|
|
|
|
// to Make to convert to ninja rules so that Make can add additional dependencies.
|
|
|
|
katiInstalls katiInstalls
|
|
|
|
katiSymlinks katiInstalls
|
2015-06-17 01:38:17 +02:00
|
|
|
|
2020-11-24 00:32:56 +01:00
|
|
|
// The files to copy to the dist as explicitly specified in the .bp file.
|
|
|
|
distFiles TaggedDistFiles
|
|
|
|
|
2015-06-17 01:38:17 +02:00
|
|
|
// Used by buildTargetSingleton to create checkbuild and per-directory build targets
|
|
|
|
// Only set on the final variant of each module
|
2017-11-29 02:34:01 +01:00
|
|
|
installTarget WritablePath
|
|
|
|
checkbuildTarget WritablePath
|
2015-06-17 01:38:17 +02:00
|
|
|
blueprintDir string
|
2016-08-20 01:07:38 +02:00
|
|
|
|
2016-09-13 22:42:32 +02:00
|
|
|
hooks hooks
|
2017-06-24 00:06:31 +02:00
|
|
|
|
|
|
|
registerProps []interface{}
|
2017-07-13 23:43:27 +02:00
|
|
|
|
|
|
|
// For tests
|
2017-10-24 02:16:14 +02:00
|
|
|
buildParams []BuildParams
|
2019-02-25 23:54:28 +01:00
|
|
|
ruleParams map[blueprint.Rule]blueprint.RuleParams
|
2018-12-12 18:01:34 +01:00
|
|
|
variables map[string]string
|
2018-10-02 22:59:46 +02:00
|
|
|
|
2019-11-15 01:59:12 +01:00
|
|
|
initRcPaths Paths
|
|
|
|
vintfFragmentsPaths Paths
|
2021-12-11 00:05:02 +01:00
|
|
|
|
|
|
|
// set of dependency module:location mappings used to populate the license metadata for
|
|
|
|
// apex containers.
|
|
|
|
licenseInstallMap []string
|
2022-01-28 23:49:24 +01:00
|
|
|
|
|
|
|
// The path to the generated license metadata file for the module.
|
|
|
|
licenseMetadataFile WritablePath
|
2017-06-24 00:06:31 +02:00
|
|
|
}
|
|
|
|
|
2021-08-11 06:17:36 +02:00
|
|
|
// A struct containing all relevant information about a Bazel target converted via bp2build.
|
|
|
|
type bp2buildInfo struct {
|
2021-12-10 00:10:18 +01:00
|
|
|
Dir string
|
|
|
|
BazelProps bazel.BazelTargetModuleProperties
|
|
|
|
CommonAttrs CommonAttributes
|
|
|
|
ConstraintAttrs constraintAttributes
|
|
|
|
Attrs interface{}
|
2021-08-11 06:17:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// TargetName returns the Bazel target name of a bp2build converted target.
|
|
|
|
func (b bp2buildInfo) TargetName() string {
|
2021-08-31 22:30:36 +02:00
|
|
|
return b.CommonAttrs.Name
|
2021-08-11 06:17:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// TargetPackage returns the Bazel package of a bp2build converted target.
|
|
|
|
func (b bp2buildInfo) TargetPackage() string {
|
|
|
|
return b.Dir
|
|
|
|
}
|
|
|
|
|
|
|
|
// BazelRuleClass returns the Bazel rule class of a bp2build converted target.
|
|
|
|
func (b bp2buildInfo) BazelRuleClass() string {
|
|
|
|
return b.BazelProps.Rule_class
|
|
|
|
}
|
|
|
|
|
|
|
|
// BazelRuleLoadLocation returns the location of the Bazel rule of a bp2build converted target.
|
|
|
|
// This may be empty as native Bazel rules do not need to be loaded.
|
|
|
|
func (b bp2buildInfo) BazelRuleLoadLocation() string {
|
|
|
|
return b.BazelProps.Bzl_load_location
|
|
|
|
}
|
|
|
|
|
|
|
|
// BazelAttributes returns the Bazel attributes of a bp2build converted target.
|
2021-08-31 22:30:36 +02:00
|
|
|
func (b bp2buildInfo) BazelAttributes() []interface{} {
|
2021-12-10 00:10:18 +01:00
|
|
|
return []interface{}{&b.CommonAttrs, &b.ConstraintAttrs, b.Attrs}
|
2021-08-11 06:17:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ModuleBase) addBp2buildInfo(info bp2buildInfo) {
|
2023-08-25 11:00:16 +02:00
|
|
|
reason := m.commonProperties.BazelConversionStatus.UnconvertedReason
|
|
|
|
if reason != nil {
|
|
|
|
panic(fmt.Errorf("bp2build: internal error trying to convert module '%s' marked unconvertible. Reason type %d: %s",
|
|
|
|
m.Name(),
|
|
|
|
reason.ReasonType,
|
|
|
|
reason.Detail))
|
2023-06-08 16:28:51 +02:00
|
|
|
}
|
2022-08-03 03:23:58 +02:00
|
|
|
m.commonProperties.BazelConversionStatus.Bp2buildInfo = append(m.commonProperties.BazelConversionStatus.Bp2buildInfo, info)
|
2021-08-11 06:17:36 +02:00
|
|
|
}
|
|
|
|
|
2023-06-08 16:28:51 +02:00
|
|
|
func (m *ModuleBase) setBp2buildUnconvertible(reasonType bp2build_metrics_proto.UnconvertedReasonType, detail string) {
|
|
|
|
if len(m.commonProperties.BazelConversionStatus.Bp2buildInfo) > 0 {
|
2023-08-25 11:00:16 +02:00
|
|
|
fmt.Println(m.commonProperties.BazelConversionStatus.Bp2buildInfo)
|
|
|
|
panic(fmt.Errorf("bp2build: internal error trying to mark converted module '%s' as unconvertible. Reason type %d: %s",
|
|
|
|
m.Name(),
|
|
|
|
reasonType,
|
|
|
|
detail))
|
2023-06-08 16:28:51 +02:00
|
|
|
}
|
|
|
|
m.commonProperties.BazelConversionStatus.UnconvertedReason = &UnconvertedReason{
|
|
|
|
ReasonType: int(reasonType),
|
|
|
|
Detail: detail,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-11 06:17:36 +02:00
|
|
|
// IsConvertedByBp2build returns whether this module was converted via bp2build.
|
|
|
|
func (m *ModuleBase) IsConvertedByBp2build() bool {
|
2022-08-03 03:23:58 +02:00
|
|
|
return len(m.commonProperties.BazelConversionStatus.Bp2buildInfo) > 0
|
2021-08-11 06:17:36 +02:00
|
|
|
}
|
|
|
|
|
2023-06-08 16:28:51 +02:00
|
|
|
func (m *ModuleBase) GetUnconvertedReason() *UnconvertedReason {
|
|
|
|
return m.commonProperties.BazelConversionStatus.UnconvertedReason
|
|
|
|
}
|
|
|
|
|
2021-08-11 06:17:36 +02:00
|
|
|
// Bp2buildTargets returns the Bazel targets bp2build generated for this module.
|
|
|
|
func (m *ModuleBase) Bp2buildTargets() []bp2buildInfo {
|
2022-08-03 03:23:58 +02:00
|
|
|
return m.commonProperties.BazelConversionStatus.Bp2buildInfo
|
2021-08-11 06:17:36 +02:00
|
|
|
}
|
|
|
|
|
2021-08-26 14:37:59 +02:00
|
|
|
// AddUnconvertedBp2buildDep stores module name of a dependency that was not converted to Bazel.
|
|
|
|
func (b *baseModuleContext) AddUnconvertedBp2buildDep(dep string) {
|
2022-08-03 03:23:58 +02:00
|
|
|
unconvertedDeps := &b.Module().base().commonProperties.BazelConversionStatus.UnconvertedDeps
|
2021-08-26 14:37:59 +02:00
|
|
|
*unconvertedDeps = append(*unconvertedDeps, dep)
|
|
|
|
}
|
|
|
|
|
2021-12-15 21:35:38 +01:00
|
|
|
// AddMissingBp2buildDep stores module name of a dependency that was not found in a Android.bp file.
|
|
|
|
func (b *baseModuleContext) AddMissingBp2buildDep(dep string) {
|
2022-08-03 03:23:58 +02:00
|
|
|
missingDeps := &b.Module().base().commonProperties.BazelConversionStatus.MissingDeps
|
2021-12-15 21:35:38 +01:00
|
|
|
*missingDeps = append(*missingDeps, dep)
|
|
|
|
}
|
|
|
|
|
2021-08-26 14:37:59 +02:00
|
|
|
// GetUnconvertedBp2buildDeps returns the list of module names of this module's direct dependencies that
|
|
|
|
// were not converted to Bazel.
|
|
|
|
func (m *ModuleBase) GetUnconvertedBp2buildDeps() []string {
|
2022-08-03 03:23:58 +02:00
|
|
|
return FirstUniqueStrings(m.commonProperties.BazelConversionStatus.UnconvertedDeps)
|
2021-08-26 14:37:59 +02:00
|
|
|
}
|
|
|
|
|
2022-09-24 06:26:47 +02:00
|
|
|
// GetMissingBp2buildDeps returns the list of module names that were not found in Android.bp files.
|
2021-12-15 21:35:38 +01:00
|
|
|
func (m *ModuleBase) GetMissingBp2buildDeps() []string {
|
2022-08-03 03:23:58 +02:00
|
|
|
return FirstUniqueStrings(m.commonProperties.BazelConversionStatus.MissingDeps)
|
2021-12-15 21:35:38 +01:00
|
|
|
}
|
|
|
|
|
2021-06-25 09:11:22 +02:00
|
|
|
func (m *ModuleBase) AddJSONData(d *map[string]interface{}) {
|
2022-01-05 19:46:24 +01:00
|
|
|
(*d)["Android"] = map[string]interface{}{
|
|
|
|
// Properties set in Blueprint or in blueprint of a defaults modules
|
|
|
|
"SetProperties": m.propertiesWithValues(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type propInfo struct {
|
2022-03-22 16:27:26 +01:00
|
|
|
Name string
|
|
|
|
Type string
|
|
|
|
Value string
|
|
|
|
Values []string
|
2022-01-05 19:46:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ModuleBase) propertiesWithValues() []propInfo {
|
|
|
|
var info []propInfo
|
|
|
|
props := m.GetProperties()
|
|
|
|
|
|
|
|
var propsWithValues func(name string, v reflect.Value)
|
|
|
|
propsWithValues = func(name string, v reflect.Value) {
|
|
|
|
kind := v.Kind()
|
|
|
|
switch kind {
|
|
|
|
case reflect.Ptr, reflect.Interface:
|
|
|
|
if v.IsNil() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
propsWithValues(name, v.Elem())
|
|
|
|
case reflect.Struct:
|
|
|
|
if v.IsZero() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
for i := 0; i < v.NumField(); i++ {
|
|
|
|
namePrefix := name
|
|
|
|
sTyp := v.Type().Field(i)
|
|
|
|
if proptools.ShouldSkipProperty(sTyp) {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if name != "" && !strings.HasSuffix(namePrefix, ".") {
|
|
|
|
namePrefix += "."
|
|
|
|
}
|
|
|
|
if !proptools.IsEmbedded(sTyp) {
|
|
|
|
namePrefix += sTyp.Name
|
|
|
|
}
|
|
|
|
sVal := v.Field(i)
|
|
|
|
propsWithValues(namePrefix, sVal)
|
|
|
|
}
|
|
|
|
case reflect.Array, reflect.Slice:
|
|
|
|
if v.IsNil() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
elKind := v.Type().Elem().Kind()
|
2022-03-22 16:27:26 +01:00
|
|
|
info = append(info, propInfo{Name: name, Type: elKind.String() + " " + kind.String(), Values: sliceReflectionValue(v)})
|
2022-01-05 19:46:24 +01:00
|
|
|
default:
|
2022-03-22 16:27:26 +01:00
|
|
|
info = append(info, propInfo{Name: name, Type: kind.String(), Value: reflectionValue(v)})
|
2022-01-05 19:46:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, p := range props {
|
|
|
|
propsWithValues("", reflect.ValueOf(p).Elem())
|
|
|
|
}
|
2022-03-22 16:27:26 +01:00
|
|
|
sort.Slice(info, func(i, j int) bool {
|
|
|
|
return info[i].Name < info[j].Name
|
|
|
|
})
|
2022-01-05 19:46:24 +01:00
|
|
|
return info
|
2021-06-25 09:11:22 +02:00
|
|
|
}
|
|
|
|
|
2022-03-22 16:27:26 +01:00
|
|
|
func reflectionValue(value reflect.Value) string {
|
|
|
|
switch value.Kind() {
|
|
|
|
case reflect.Bool:
|
|
|
|
return fmt.Sprintf("%t", value.Bool())
|
|
|
|
case reflect.Int64:
|
|
|
|
return fmt.Sprintf("%d", value.Int())
|
|
|
|
case reflect.String:
|
|
|
|
return fmt.Sprintf("%s", value.String())
|
|
|
|
case reflect.Struct:
|
|
|
|
if value.IsZero() {
|
|
|
|
return "{}"
|
|
|
|
}
|
|
|
|
length := value.NumField()
|
|
|
|
vals := make([]string, length, length)
|
|
|
|
for i := 0; i < length; i++ {
|
|
|
|
sTyp := value.Type().Field(i)
|
|
|
|
if proptools.ShouldSkipProperty(sTyp) {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
name := sTyp.Name
|
|
|
|
vals[i] = fmt.Sprintf("%s: %s", name, reflectionValue(value.Field(i)))
|
|
|
|
}
|
|
|
|
return fmt.Sprintf("%s{%s}", value.Type(), strings.Join(vals, ", "))
|
|
|
|
case reflect.Array, reflect.Slice:
|
|
|
|
vals := sliceReflectionValue(value)
|
|
|
|
return fmt.Sprintf("[%s]", strings.Join(vals, ", "))
|
|
|
|
}
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
|
|
|
func sliceReflectionValue(value reflect.Value) []string {
|
|
|
|
length := value.Len()
|
|
|
|
vals := make([]string, length, length)
|
|
|
|
for i := 0; i < length; i++ {
|
|
|
|
vals[i] = reflectionValue(value.Index(i))
|
|
|
|
}
|
|
|
|
return vals
|
|
|
|
}
|
|
|
|
|
2020-06-26 21:17:02 +02:00
|
|
|
func (m *ModuleBase) ComponentDepsMutator(BottomUpMutatorContext) {}
|
|
|
|
|
2019-06-07 01:57:04 +02:00
|
|
|
func (m *ModuleBase) DepsMutator(BottomUpMutatorContext) {}
|
2019-02-02 01:53:07 +01:00
|
|
|
|
2021-12-01 21:16:32 +01:00
|
|
|
// AddProperties "registers" the provided props
|
|
|
|
// each value in props MUST be a pointer to a struct
|
2019-06-07 01:57:04 +02:00
|
|
|
func (m *ModuleBase) AddProperties(props ...interface{}) {
|
|
|
|
m.registerProps = append(m.registerProps, props...)
|
2017-06-24 00:06:31 +02:00
|
|
|
}
|
|
|
|
|
2019-06-07 01:57:04 +02:00
|
|
|
func (m *ModuleBase) GetProperties() []interface{} {
|
|
|
|
return m.registerProps
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2019-06-07 01:57:04 +02:00
|
|
|
func (m *ModuleBase) BuildParamsForTests() []BuildParams {
|
2021-09-10 08:20:39 +02:00
|
|
|
// Expand the references to module variables like $flags[0-9]*,
|
|
|
|
// so we do not need to change many existing unit tests.
|
|
|
|
// This looks like undoing the shareFlags optimization in cc's
|
|
|
|
// transformSourceToObj, and should only affects unit tests.
|
|
|
|
vars := m.VariablesForTests()
|
|
|
|
buildParams := append([]BuildParams(nil), m.buildParams...)
|
2022-08-04 22:07:02 +02:00
|
|
|
for i := range buildParams {
|
2021-09-10 08:20:39 +02:00
|
|
|
newArgs := make(map[string]string)
|
|
|
|
for k, v := range buildParams[i].Args {
|
|
|
|
newArgs[k] = v
|
|
|
|
// Replaces both ${flags1} and $flags1 syntax.
|
|
|
|
if strings.HasPrefix(v, "${") && strings.HasSuffix(v, "}") {
|
|
|
|
if value, found := vars[v[2:len(v)-1]]; found {
|
|
|
|
newArgs[k] = value
|
|
|
|
}
|
|
|
|
} else if strings.HasPrefix(v, "$") {
|
|
|
|
if value, found := vars[v[1:]]; found {
|
|
|
|
newArgs[k] = value
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
buildParams[i].Args = newArgs
|
|
|
|
}
|
|
|
|
return buildParams
|
2017-07-13 23:43:27 +02:00
|
|
|
}
|
|
|
|
|
2019-06-07 01:57:04 +02:00
|
|
|
func (m *ModuleBase) RuleParamsForTests() map[blueprint.Rule]blueprint.RuleParams {
|
|
|
|
return m.ruleParams
|
2019-02-25 23:54:28 +01:00
|
|
|
}
|
|
|
|
|
2019-06-07 01:57:04 +02:00
|
|
|
func (m *ModuleBase) VariablesForTests() map[string]string {
|
|
|
|
return m.variables
|
2018-12-12 18:01:34 +01:00
|
|
|
}
|
|
|
|
|
2016-10-07 01:12:58 +02:00
|
|
|
// Name returns the name of the module. It may be overridden by individual module types, for
|
|
|
|
// example prebuilts will prepend prebuilt_ to the name.
|
2019-06-07 01:57:04 +02:00
|
|
|
func (m *ModuleBase) Name() string {
|
|
|
|
return String(m.nameProperties.Name)
|
2016-05-18 01:34:16 +02:00
|
|
|
}
|
|
|
|
|
2019-07-02 00:32:45 +02:00
|
|
|
// String returns a string that includes the module name and variants for printing during debugging.
|
|
|
|
func (m *ModuleBase) String() string {
|
|
|
|
sb := strings.Builder{}
|
|
|
|
sb.WriteString(m.commonProperties.DebugName)
|
|
|
|
sb.WriteString("{")
|
|
|
|
for i := range m.commonProperties.DebugMutators {
|
|
|
|
if i != 0 {
|
|
|
|
sb.WriteString(",")
|
|
|
|
}
|
|
|
|
sb.WriteString(m.commonProperties.DebugMutators[i])
|
|
|
|
sb.WriteString(":")
|
|
|
|
sb.WriteString(m.commonProperties.DebugVariations[i])
|
|
|
|
}
|
|
|
|
sb.WriteString("}")
|
|
|
|
return sb.String()
|
|
|
|
}
|
|
|
|
|
2016-10-07 01:12:58 +02:00
|
|
|
// BaseModuleName returns the name of the module as specified in the blueprints file.
|
2019-06-07 01:57:04 +02:00
|
|
|
func (m *ModuleBase) BaseModuleName() string {
|
|
|
|
return String(m.nameProperties.Name)
|
2016-10-07 01:12:58 +02:00
|
|
|
}
|
|
|
|
|
2019-06-07 01:57:04 +02:00
|
|
|
func (m *ModuleBase) base() *ModuleBase {
|
|
|
|
return m
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2019-05-31 15:00:04 +02:00
|
|
|
func (m *ModuleBase) qualifiedModuleId(ctx BaseModuleContext) qualifiedModuleName {
|
|
|
|
return qualifiedModuleName{pkg: ctx.ModuleDir(), name: ctx.ModuleName()}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ModuleBase) visibilityProperties() []visibilityProperty {
|
Refactor visibility to support visibility on defaults modules
Existing modules, either general one or package ones have a single
visibility property, called visibility in general, and
default_visibility on package, that controls access to that module, or
in the case of package sets the default visibility of all modules in
that package. The property is checked and gathered during the similarly
named phases of visibility processing.
The defaults module will be different as it will have two properties.
The first, visibility, will not affect the visibility of the module, it
only affects the visibility of modules that 'extend' the defaults. So,
it will need checking but not parsing. The second property,
defaults_visibility, will affect the visibility of the module and so
will need both checking and parsing.
The current implementation does not handle those cases because:
1) It does not differentiate between the property that affects the
module and those that do not. It checks and gathers all of them with
the last property gathered overriding the rules for the previous
properties.
2) It relies on overriding methods in MethodBase in order to change the
default behavior for the package module. That works because
packageModule embeds ModuleBase but will not work for
DefaultsModuleBase as it does not embed ModuleBase and instead is
embedded alongside it so attempting to override a method in
MethodBase leads to ambiguity.
This change addresses the issues as follows:
1) It adds a new visibility() []string method to get access to the
primary visibility rules, i.e. the ones that affect the module.
2) It adds two fields, 'visibilityPropertyInfo []visibilityProperty'
to provide information about all the properties that need checking,
and 'primaryVisibilityProperty visibilityProperty' to specify the
property that affects the module.
The PackageFactory() and InitAndroidModule(Module) functions are
modified to initialize the fields. The override of the
visibilityProperties() method for packageModule is removed and the
default implementations of visibilityProperties() and visibility()
on ModuleBase return information from the two new fields.
The InitDefaultsModule is updated to also initialize the two new
fields. It uses nil for primaryVisibilityProperty for now but that
will be changed to return defaults_visibility. It also uses the
commonProperties structure created for the defaults directly instead
of having to search for it through properties().
Changed the visibilityProperty to take a pointer to the property that
can be used to retrieve the value rather than a lambda function.
Bug: 130796911
Test: m nothing
Change-Id: Icadd470a5f692a48ec61de02bf3dfde3e2eea2ef
2019-07-24 15:24:38 +02:00
|
|
|
return m.visibilityPropertyInfo
|
|
|
|
}
|
|
|
|
|
2020-06-15 07:24:19 +02:00
|
|
|
func (m *ModuleBase) Dists() []Dist {
|
2020-09-02 14:08:57 +02:00
|
|
|
if len(m.distProperties.Dist.Targets) > 0 {
|
2020-06-15 07:24:19 +02:00
|
|
|
// Make a copy of the underlying Dists slice to protect against
|
|
|
|
// backing array modifications with repeated calls to this method.
|
2020-09-02 14:08:57 +02:00
|
|
|
distsCopy := append([]Dist(nil), m.distProperties.Dists...)
|
|
|
|
return append(distsCopy, m.distProperties.Dist)
|
2020-06-15 07:24:19 +02:00
|
|
|
} else {
|
2020-09-02 14:08:57 +02:00
|
|
|
return m.distProperties.Dists
|
2020-06-15 07:24:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ModuleBase) GenerateTaggedDistFiles(ctx BaseModuleContext) TaggedDistFiles {
|
2020-11-25 17:37:46 +01:00
|
|
|
var distFiles TaggedDistFiles
|
2020-06-15 07:24:19 +02:00
|
|
|
for _, dist := range m.Dists() {
|
2020-11-25 17:37:46 +01:00
|
|
|
// If no tag is specified then it means to use the default dist paths so use
|
|
|
|
// the special tag name which represents that.
|
|
|
|
tag := proptools.StringDefault(dist.Tag, DefaultDistTag)
|
|
|
|
|
2020-11-24 00:32:56 +01:00
|
|
|
if outputFileProducer, ok := m.module.(OutputFileProducer); ok {
|
|
|
|
// Call the OutputFiles(tag) method to get the paths associated with the tag.
|
|
|
|
distFilesForTag, err := outputFileProducer.OutputFiles(tag)
|
2020-11-25 17:37:46 +01:00
|
|
|
|
2020-11-24 00:32:56 +01:00
|
|
|
// If the tag was not supported and is not DefaultDistTag then it is an error.
|
|
|
|
// Failing to find paths for DefaultDistTag is not an error. It just means
|
|
|
|
// that the module type requires the legacy behavior.
|
|
|
|
if err != nil && tag != DefaultDistTag {
|
|
|
|
ctx.PropertyErrorf("dist.tag", "%s", err.Error())
|
|
|
|
}
|
2020-11-25 17:37:46 +01:00
|
|
|
|
2020-11-24 00:32:56 +01:00
|
|
|
distFiles = distFiles.addPathsForTag(tag, distFilesForTag...)
|
|
|
|
} else if tag != DefaultDistTag {
|
|
|
|
// If the tag was specified then it is an error if the module does not
|
|
|
|
// implement OutputFileProducer because there is no other way of accessing
|
|
|
|
// the paths for the specified tag.
|
|
|
|
ctx.PropertyErrorf("dist.tag",
|
|
|
|
"tag %s not supported because the module does not implement OutputFileProducer", tag)
|
|
|
|
}
|
2020-06-15 07:24:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return distFiles
|
|
|
|
}
|
|
|
|
|
2019-06-07 01:57:04 +02:00
|
|
|
func (m *ModuleBase) Target() Target {
|
|
|
|
return m.commonProperties.CompileTarget
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2019-06-07 01:57:04 +02:00
|
|
|
func (m *ModuleBase) TargetPrimary() bool {
|
|
|
|
return m.commonProperties.CompilePrimary
|
2016-09-13 18:59:14 +02:00
|
|
|
}
|
|
|
|
|
2019-06-07 01:57:04 +02:00
|
|
|
func (m *ModuleBase) MultiTargets() []Target {
|
|
|
|
return m.commonProperties.CompileMultiTargets
|
2018-10-03 07:01:37 +02:00
|
|
|
}
|
|
|
|
|
2019-06-07 01:57:04 +02:00
|
|
|
func (m *ModuleBase) Os() OsType {
|
|
|
|
return m.Target().Os
|
2015-11-25 02:53:15 +01:00
|
|
|
}
|
|
|
|
|
2019-06-07 01:57:04 +02:00
|
|
|
func (m *ModuleBase) Host() bool {
|
2020-09-14 12:43:17 +02:00
|
|
|
return m.Os().Class == Host
|
2016-02-10 02:43:51 +01:00
|
|
|
}
|
|
|
|
|
2020-06-09 10:15:37 +02:00
|
|
|
func (m *ModuleBase) Device() bool {
|
|
|
|
return m.Os().Class == Device
|
|
|
|
}
|
|
|
|
|
2019-06-07 01:57:04 +02:00
|
|
|
func (m *ModuleBase) Arch() Arch {
|
|
|
|
return m.Target().Arch
|
2016-02-10 02:43:51 +01:00
|
|
|
}
|
|
|
|
|
2019-06-07 01:57:04 +02:00
|
|
|
func (m *ModuleBase) ArchSpecific() bool {
|
|
|
|
return m.commonProperties.ArchSpecific
|
2016-10-05 00:13:37 +02:00
|
|
|
}
|
|
|
|
|
2020-02-25 20:26:33 +01:00
|
|
|
// True if the current variant is a CommonOS variant, false otherwise.
|
|
|
|
func (m *ModuleBase) IsCommonOSVariant() bool {
|
|
|
|
return m.commonProperties.CommonOSVariant
|
|
|
|
}
|
|
|
|
|
2020-11-17 22:19:17 +01:00
|
|
|
// supportsTarget returns true if the given Target is supported by the current module.
|
|
|
|
func (m *ModuleBase) supportsTarget(target Target) bool {
|
|
|
|
switch target.Os.Class {
|
|
|
|
case Host:
|
|
|
|
if target.HostCross {
|
|
|
|
return m.HostCrossSupported()
|
|
|
|
} else {
|
|
|
|
return m.HostSupported()
|
2016-06-02 02:09:44 +02:00
|
|
|
}
|
2020-11-17 22:19:17 +01:00
|
|
|
case Device:
|
|
|
|
return m.DeviceSupported()
|
2016-06-02 02:09:44 +02:00
|
|
|
default:
|
2020-09-14 12:43:17 +02:00
|
|
|
return false
|
2016-06-02 02:09:44 +02:00
|
|
|
}
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2020-11-17 22:19:17 +01:00
|
|
|
// DeviceSupported returns true if the current module is supported and enabled for device targets,
|
|
|
|
// i.e. the factory method set the HostOrDeviceSupported value to include device support and
|
|
|
|
// the device support is enabled by default or enabled by the device_supported property.
|
2019-06-07 01:57:04 +02:00
|
|
|
func (m *ModuleBase) DeviceSupported() bool {
|
2020-11-17 22:19:17 +01:00
|
|
|
hod := m.commonProperties.HostOrDeviceSupported
|
|
|
|
// deviceEnabled is true if the device_supported property is true or the HostOrDeviceSupported
|
|
|
|
// value has the deviceDefault bit set.
|
|
|
|
deviceEnabled := proptools.BoolDefault(m.hostAndDeviceProperties.Device_supported, hod&deviceDefault != 0)
|
|
|
|
return hod&deviceSupported != 0 && deviceEnabled
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2020-11-17 22:19:17 +01:00
|
|
|
// HostSupported returns true if the current module is supported and enabled for host targets,
|
|
|
|
// i.e. the factory method set the HostOrDeviceSupported value to include host support and
|
|
|
|
// the host support is enabled by default or enabled by the host_supported property.
|
2019-11-26 19:04:12 +01:00
|
|
|
func (m *ModuleBase) HostSupported() bool {
|
2020-11-17 22:19:17 +01:00
|
|
|
hod := m.commonProperties.HostOrDeviceSupported
|
|
|
|
// hostEnabled is true if the host_supported property is true or the HostOrDeviceSupported
|
|
|
|
// value has the hostDefault bit set.
|
|
|
|
hostEnabled := proptools.BoolDefault(m.hostAndDeviceProperties.Host_supported, hod&hostDefault != 0)
|
|
|
|
return hod&hostSupported != 0 && hostEnabled
|
|
|
|
}
|
|
|
|
|
|
|
|
// HostCrossSupported returns true if the current module is supported and enabled for host cross
|
|
|
|
// targets, i.e. the factory method set the HostOrDeviceSupported value to include host cross
|
|
|
|
// support and the host cross support is enabled by default or enabled by the
|
|
|
|
// host_supported property.
|
|
|
|
func (m *ModuleBase) HostCrossSupported() bool {
|
|
|
|
hod := m.commonProperties.HostOrDeviceSupported
|
|
|
|
// hostEnabled is true if the host_supported property is true or the HostOrDeviceSupported
|
|
|
|
// value has the hostDefault bit set.
|
|
|
|
hostEnabled := proptools.BoolDefault(m.hostAndDeviceProperties.Host_supported, hod&hostDefault != 0)
|
|
|
|
return hod&hostCrossSupported != 0 && hostEnabled
|
2019-11-26 19:04:12 +01:00
|
|
|
}
|
|
|
|
|
2019-06-07 01:57:04 +02:00
|
|
|
func (m *ModuleBase) Platform() bool {
|
2019-06-25 09:47:17 +02:00
|
|
|
return !m.DeviceSpecific() && !m.SocSpecific() && !m.ProductSpecific() && !m.SystemExtSpecific()
|
2018-04-10 06:07:10 +02:00
|
|
|
}
|
|
|
|
|
2019-06-07 01:57:04 +02:00
|
|
|
func (m *ModuleBase) DeviceSpecific() bool {
|
|
|
|
return Bool(m.commonProperties.Device_specific)
|
2018-04-10 06:07:10 +02:00
|
|
|
}
|
|
|
|
|
2019-06-07 01:57:04 +02:00
|
|
|
func (m *ModuleBase) SocSpecific() bool {
|
|
|
|
return Bool(m.commonProperties.Vendor) || Bool(m.commonProperties.Proprietary) || Bool(m.commonProperties.Soc_specific)
|
2018-04-10 06:07:10 +02:00
|
|
|
}
|
|
|
|
|
2019-06-07 01:57:04 +02:00
|
|
|
func (m *ModuleBase) ProductSpecific() bool {
|
|
|
|
return Bool(m.commonProperties.Product_specific)
|
2018-04-10 06:07:10 +02:00
|
|
|
}
|
|
|
|
|
2019-06-25 09:47:17 +02:00
|
|
|
func (m *ModuleBase) SystemExtSpecific() bool {
|
|
|
|
return Bool(m.commonProperties.System_ext_specific)
|
2018-05-29 14:28:54 +02:00
|
|
|
}
|
|
|
|
|
2020-05-13 20:05:02 +02:00
|
|
|
// RequiresStableAPIs returns true if the module will be installed to a partition that may
|
|
|
|
// be updated separately from the system image.
|
|
|
|
func (m *ModuleBase) RequiresStableAPIs(ctx BaseModuleContext) bool {
|
|
|
|
return m.SocSpecific() || m.DeviceSpecific() ||
|
|
|
|
(m.ProductSpecific() && ctx.Config().EnforceProductPartitionInterface())
|
|
|
|
}
|
|
|
|
|
2020-03-21 02:33:20 +01:00
|
|
|
func (m *ModuleBase) PartitionTag(config DeviceConfig) string {
|
|
|
|
partition := "system"
|
|
|
|
if m.SocSpecific() {
|
|
|
|
// A SoC-specific module could be on the vendor partition at
|
|
|
|
// "vendor" or the system partition at "system/vendor".
|
|
|
|
if config.VendorPath() == "vendor" {
|
|
|
|
partition = "vendor"
|
|
|
|
}
|
|
|
|
} else if m.DeviceSpecific() {
|
|
|
|
// A device-specific module could be on the odm partition at
|
|
|
|
// "odm", the vendor partition at "vendor/odm", or the system
|
|
|
|
// partition at "system/vendor/odm".
|
|
|
|
if config.OdmPath() == "odm" {
|
|
|
|
partition = "odm"
|
2020-04-01 04:14:52 +02:00
|
|
|
} else if strings.HasPrefix(config.OdmPath(), "vendor/") {
|
2020-03-21 02:33:20 +01:00
|
|
|
partition = "vendor"
|
|
|
|
}
|
|
|
|
} else if m.ProductSpecific() {
|
|
|
|
// A product-specific module could be on the product partition
|
|
|
|
// at "product" or the system partition at "system/product".
|
|
|
|
if config.ProductPath() == "product" {
|
|
|
|
partition = "product"
|
|
|
|
}
|
|
|
|
} else if m.SystemExtSpecific() {
|
|
|
|
// A system_ext-specific module could be on the system_ext
|
|
|
|
// partition at "system_ext" or the system partition at
|
|
|
|
// "system/system_ext".
|
|
|
|
if config.SystemExtPath() == "system_ext" {
|
|
|
|
partition = "system_ext"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return partition
|
|
|
|
}
|
|
|
|
|
2019-06-07 01:57:04 +02:00
|
|
|
func (m *ModuleBase) Enabled() bool {
|
2020-07-31 16:07:17 +02:00
|
|
|
if m.commonProperties.ForcedDisabled {
|
|
|
|
return false
|
|
|
|
}
|
2020-11-19 03:33:19 +01:00
|
|
|
if m.commonProperties.Enabled == nil {
|
|
|
|
return !m.Os().DefaultDisabled
|
|
|
|
}
|
|
|
|
return *m.commonProperties.Enabled
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2020-01-22 03:11:29 +01:00
|
|
|
func (m *ModuleBase) Disable() {
|
2020-07-31 16:07:17 +02:00
|
|
|
m.commonProperties.ForcedDisabled = true
|
2020-01-22 03:11:29 +01:00
|
|
|
}
|
|
|
|
|
2020-12-16 19:20:23 +01:00
|
|
|
// HideFromMake marks this variant so that it is not emitted in the generated Android.mk file.
|
|
|
|
func (m *ModuleBase) HideFromMake() {
|
|
|
|
m.commonProperties.HideFromMake = true
|
2016-10-07 01:12:58 +02:00
|
|
|
}
|
|
|
|
|
2020-12-16 19:20:23 +01:00
|
|
|
// IsHideFromMake returns true if HideFromMake was previously called.
|
|
|
|
func (m *ModuleBase) IsHideFromMake() bool {
|
|
|
|
return m.commonProperties.HideFromMake == true
|
2020-01-13 16:18:16 +01:00
|
|
|
}
|
|
|
|
|
2020-12-16 19:20:23 +01:00
|
|
|
// SkipInstall marks this variant to not create install rules when ctx.Install* are called.
|
|
|
|
func (m *ModuleBase) SkipInstall() {
|
|
|
|
m.commonProperties.SkipInstall = true
|
|
|
|
}
|
|
|
|
|
2020-12-23 04:50:30 +01:00
|
|
|
// IsSkipInstall returns true if this variant is marked to not create install
|
|
|
|
// rules when ctx.Install* are called.
|
|
|
|
func (m *ModuleBase) IsSkipInstall() bool {
|
|
|
|
return m.commonProperties.SkipInstall
|
|
|
|
}
|
|
|
|
|
2023-03-10 17:11:26 +01:00
|
|
|
// Similar to HideFromMake, but if the AndroidMk entry would set
|
|
|
|
// LOCAL_UNINSTALLABLE_MODULE then this variant may still output that entry
|
|
|
|
// rather than leaving it out altogether. That happens in cases where it would
|
|
|
|
// have other side effects, in particular when it adds a NOTICE file target,
|
|
|
|
// which other install targets might depend on.
|
|
|
|
func (m *ModuleBase) MakeUninstallable() {
|
2023-04-25 20:30:51 +02:00
|
|
|
m.commonProperties.UninstallableApexPlatformVariant = true
|
2023-03-10 17:11:26 +01:00
|
|
|
m.HideFromMake()
|
|
|
|
}
|
|
|
|
|
2020-08-06 00:40:41 +02:00
|
|
|
func (m *ModuleBase) ReplacedByPrebuilt() {
|
|
|
|
m.commonProperties.ReplacedByPrebuilt = true
|
2020-12-16 19:20:23 +01:00
|
|
|
m.HideFromMake()
|
2020-08-06 00:40:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ModuleBase) IsReplacedByPrebuilt() bool {
|
|
|
|
return m.commonProperties.ReplacedByPrebuilt
|
|
|
|
}
|
|
|
|
|
2019-06-07 01:57:04 +02:00
|
|
|
func (m *ModuleBase) ExportedToMake() bool {
|
|
|
|
return m.commonProperties.NamespaceExportedToMake
|
Allow platform modules to link to vendor public libraries
Normally, when building with VNDK, platform modules are not allowed to
link against vendor libraries, because the ABI of the vendor libraries
are not guaranteed to be stable and may differ across multiple vendor
images.
However, the vendor public libraries are the exceptions. Vendor public
libraries are vendor libraries that are exposed to 3rd party apps and
listed in /vendor/etc/public.libraries.txt. Since they are intended to
be exposed to public, their ABI stability is guaranteed (by definition,
though it is up to the vendor to actually guarantee it).
This change provides a way to make a vendor lib as public by defining a
module of type 'vendor_public_library' with a map file that enumerates
public symbols that are publicized:
cc_library {
name: "libvendor",
proprietary: true,
...
}
vendor_public_library {
name: "libvendor",
symbol_file: "libvendor.map.txt",
}
This defines a stub library module named libvendor.vendorpublic from the
map file. `shared_libs: ["libvendor"]` is redirected to the stub library
when it is from the outside of the vendor partition.
Bug: 74275385
Test: m -j
Test: cc_test.go passes
Change-Id: I5bed94d7c4282b777632ab2f0fb63c203ee313ba
2018-03-19 10:23:01 +01:00
|
|
|
}
|
|
|
|
|
2023-04-07 13:13:19 +02:00
|
|
|
func (m *ModuleBase) EffectiveLicenseKinds() []string {
|
|
|
|
return m.commonProperties.Effective_license_kinds
|
|
|
|
}
|
|
|
|
|
2021-06-29 13:34:53 +02:00
|
|
|
func (m *ModuleBase) EffectiveLicenseFiles() Paths {
|
2022-02-09 20:54:35 +01:00
|
|
|
result := make(Paths, 0, len(m.commonProperties.Effective_license_text))
|
|
|
|
for _, p := range m.commonProperties.Effective_license_text {
|
|
|
|
result = append(result, p.Path)
|
|
|
|
}
|
|
|
|
return result
|
2021-06-29 13:34:53 +02:00
|
|
|
}
|
|
|
|
|
2020-11-11 03:12:15 +01:00
|
|
|
// computeInstallDeps finds the installed paths of all dependencies that have a dependency
|
2023-04-25 20:30:51 +02:00
|
|
|
// tag that is annotated as needing installation via the isInstallDepNeeded method.
|
2022-04-21 21:50:51 +02:00
|
|
|
func (m *ModuleBase) computeInstallDeps(ctx ModuleContext) ([]*DepSet[InstallPath], []*DepSet[PackagingSpec]) {
|
|
|
|
var installDeps []*DepSet[InstallPath]
|
|
|
|
var packagingSpecs []*DepSet[PackagingSpec]
|
2020-11-25 01:21:24 +01:00
|
|
|
ctx.VisitDirectDeps(func(dep Module) {
|
2023-04-25 20:30:51 +02:00
|
|
|
if isInstallDepNeeded(dep, ctx.OtherModuleDependencyTag(dep)) {
|
|
|
|
// Installation is still handled by Make, so anything hidden from Make is not
|
|
|
|
// installable.
|
|
|
|
if !dep.IsHideFromMake() && !dep.IsSkipInstall() {
|
|
|
|
installDeps = append(installDeps, dep.base().installFilesDepSet)
|
|
|
|
}
|
|
|
|
// Add packaging deps even when the dependency is not installed so that uninstallable
|
|
|
|
// modules can still be packaged. Often the package will be installed instead.
|
2020-12-02 00:40:06 +01:00
|
|
|
packagingSpecs = append(packagingSpecs, dep.base().packagingSpecsDepSet)
|
2020-02-13 22:22:08 +01:00
|
|
|
}
|
|
|
|
})
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2020-12-02 00:40:06 +01:00
|
|
|
return installDeps, packagingSpecs
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2023-04-25 20:30:51 +02:00
|
|
|
// isInstallDepNeeded returns true if installing the output files of the current module
|
|
|
|
// should also install the output files of the given dependency and dependency tag.
|
|
|
|
func isInstallDepNeeded(dep Module, tag blueprint.DependencyTag) bool {
|
|
|
|
// Don't add a dependency from the platform to a library provided by an apex.
|
|
|
|
if dep.base().commonProperties.UninstallableApexPlatformVariant {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
// Only install modules if the dependency tag is an InstallDepNeeded tag.
|
|
|
|
return IsInstallDepNeededTag(tag)
|
|
|
|
}
|
|
|
|
|
2020-09-28 10:46:22 +02:00
|
|
|
func (m *ModuleBase) FilesToInstall() InstallPaths {
|
2019-06-07 01:57:04 +02:00
|
|
|
return m.installFiles
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
add PackagingSpec
Currently, installation of a module is defined as an action of copying
the built artifact of the module to an install path like out/soong/host
(for host modules) and out/target/product/<device>/<partition> (for
device modules). After the modules are installed, the installed files
are further processed to create packages like system.img, vendor.img,
cvd-host-package.tar.gz, etc.
This notion of installation seems to have originated from the old time
when system.img is the primary product of the entire build process
(modulo a few more like root.img). Packaging the installed files as the
filesystem image was considered as a post-build step then.
However, this model doesn't seem to fit well to the current and future
environment where we have a lot more filesystem images (system, vendor,
system_ext, product, ...). The filesystem images themselves are even
grouped together to form a higher-level filesystem image like super.img.
Furthermore, things like cvd-host-package.tar.gz requires us to be able
to group some of the host tools in a format that isn't filesystem image.
Lastly, we are expected to have more filesystem images that are subsets
of system.img (and their friends) for the Android-like mini OS that will
be running on on-device virtual machines. These all imply that the
packaging (which we call installation today) is not a global post-build
step, but a part of the build rules for creating the package-like
modules.
A model better fits to the new sitatuation might be this; a module
specifies its built artifact and the path where it should be placed. The
latter path is not rooted at out/. It's a relative path to the root
directory which will be determined by another module that implements the
packaging. For example, cc_library will have ./lib (or ./lib64), not
out/target/product/<device>/<partition>/lib as the path. Then packages
like system.img, cvd-host-package.tar.gz, etc. are explicitly modeled as
modules and they have deps to other modules. Then the modules are placed
at the relative path under the package root, and the entire root
directory finally is packaged as the output file (be it img, tar.gz, or
whatever).
PackagingSpec is the first step to implement the new model. It abstracts
a request to place a built artifact at a certain path in a package. It
has extra information about whether the path should be a symlink or not,
and whether the path is for an executable. It currently is created when
InstallFiles (and its friends) are called, and can be retrieved via
the new method PackagingSpecs().
In this CL, no one is using PackagingSpec. The installation is still
done by the existing rules created in InstallFiles, etc. and the
structs are not used for the filesystem images like system.img.
Bug: 159685774
Bug: 172414391
Test: m
Change-Id: Ie1dec72d1ac14382fc3b74e5c850472e9320d6a3
2020-11-09 06:08:34 +01:00
|
|
|
func (m *ModuleBase) PackagingSpecs() []PackagingSpec {
|
|
|
|
return m.packagingSpecs
|
|
|
|
}
|
|
|
|
|
2020-12-02 00:40:06 +01:00
|
|
|
func (m *ModuleBase) TransitivePackagingSpecs() []PackagingSpec {
|
|
|
|
return m.packagingSpecsDepSet.ToList()
|
|
|
|
}
|
|
|
|
|
2019-06-07 01:57:04 +02:00
|
|
|
func (m *ModuleBase) NoAddressSanitizer() bool {
|
|
|
|
return m.noAddressSanitizer
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2019-06-07 01:57:04 +02:00
|
|
|
func (m *ModuleBase) InstallInData() bool {
|
2015-12-21 23:55:28 +01:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2019-09-11 19:25:18 +02:00
|
|
|
func (m *ModuleBase) InstallInTestcases() bool {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2019-06-07 01:57:04 +02:00
|
|
|
func (m *ModuleBase) InstallInSanitizerDir() bool {
|
2017-03-30 07:00:18 +02:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2020-01-22 00:53:22 +01:00
|
|
|
func (m *ModuleBase) InstallInRamdisk() bool {
|
|
|
|
return Bool(m.commonProperties.Ramdisk)
|
|
|
|
}
|
|
|
|
|
2020-10-22 00:17:56 +02:00
|
|
|
func (m *ModuleBase) InstallInVendorRamdisk() bool {
|
|
|
|
return Bool(m.commonProperties.Vendor_ramdisk)
|
|
|
|
}
|
|
|
|
|
2021-04-08 14:13:22 +02:00
|
|
|
func (m *ModuleBase) InstallInDebugRamdisk() bool {
|
|
|
|
return Bool(m.commonProperties.Debug_ramdisk)
|
|
|
|
}
|
|
|
|
|
2019-06-07 01:57:04 +02:00
|
|
|
func (m *ModuleBase) InstallInRecovery() bool {
|
|
|
|
return Bool(m.commonProperties.Recovery)
|
2018-01-31 16:54:12 +01:00
|
|
|
}
|
|
|
|
|
2021-07-19 04:38:04 +02:00
|
|
|
func (m *ModuleBase) InstallInVendor() bool {
|
2022-11-29 02:58:08 +01:00
|
|
|
return Bool(m.commonProperties.Vendor) || Bool(m.commonProperties.Soc_specific) || Bool(m.commonProperties.Proprietary)
|
2021-07-19 04:38:04 +02:00
|
|
|
}
|
|
|
|
|
2019-10-02 20:10:58 +02:00
|
|
|
func (m *ModuleBase) InstallInRoot() bool {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2020-09-01 05:37:45 +02:00
|
|
|
func (m *ModuleBase) InstallForceOS() (*OsType, *ArchType) {
|
|
|
|
return nil, nil
|
2020-02-11 00:29:54 +01:00
|
|
|
}
|
|
|
|
|
2019-06-07 01:57:04 +02:00
|
|
|
func (m *ModuleBase) Owner() string {
|
|
|
|
return String(m.commonProperties.Owner)
|
2018-08-31 11:01:37 +02:00
|
|
|
}
|
|
|
|
|
2019-11-19 01:00:16 +01:00
|
|
|
func (m *ModuleBase) setImageVariation(variant string) {
|
|
|
|
m.commonProperties.ImageVariation = variant
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ModuleBase) ImageVariation() blueprint.Variation {
|
|
|
|
return blueprint.Variation{
|
|
|
|
Mutator: "image",
|
|
|
|
Variation: m.base().commonProperties.ImageVariation,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-12 11:24:35 +01:00
|
|
|
func (m *ModuleBase) getVariationByMutatorName(mutator string) string {
|
|
|
|
for i, v := range m.commonProperties.DebugMutators {
|
|
|
|
if v == mutator {
|
|
|
|
return m.commonProperties.DebugVariations[i]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
2020-01-22 00:53:22 +01:00
|
|
|
func (m *ModuleBase) InRamdisk() bool {
|
|
|
|
return m.base().commonProperties.ImageVariation == RamdiskVariation
|
|
|
|
}
|
|
|
|
|
2020-10-22 00:17:56 +02:00
|
|
|
func (m *ModuleBase) InVendorRamdisk() bool {
|
|
|
|
return m.base().commonProperties.ImageVariation == VendorRamdiskVariation
|
|
|
|
}
|
|
|
|
|
2021-04-08 14:13:22 +02:00
|
|
|
func (m *ModuleBase) InDebugRamdisk() bool {
|
|
|
|
return m.base().commonProperties.ImageVariation == DebugRamdiskVariation
|
|
|
|
}
|
|
|
|
|
2019-11-19 01:00:16 +01:00
|
|
|
func (m *ModuleBase) InRecovery() bool {
|
|
|
|
return m.base().commonProperties.ImageVariation == RecoveryVariation
|
|
|
|
}
|
|
|
|
|
2019-12-30 08:31:09 +01:00
|
|
|
func (m *ModuleBase) RequiredModuleNames() []string {
|
|
|
|
return m.base().commonProperties.Required
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ModuleBase) HostRequiredModuleNames() []string {
|
|
|
|
return m.base().commonProperties.Host_required
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ModuleBase) TargetRequiredModuleNames() []string {
|
|
|
|
return m.base().commonProperties.Target_required
|
|
|
|
}
|
|
|
|
|
2019-11-15 01:59:12 +01:00
|
|
|
func (m *ModuleBase) InitRc() Paths {
|
|
|
|
return append(Paths{}, m.initRcPaths...)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ModuleBase) VintfFragments() Paths {
|
|
|
|
return append(Paths{}, m.vintfFragmentsPaths...)
|
|
|
|
}
|
|
|
|
|
2022-01-06 02:17:23 +01:00
|
|
|
func (m *ModuleBase) CompileMultilib() *string {
|
|
|
|
return m.base().commonProperties.Compile_multilib
|
|
|
|
}
|
|
|
|
|
2021-12-11 00:05:02 +01:00
|
|
|
// SetLicenseInstallMap stores the set of dependency module:location mappings for files in an
|
|
|
|
// apex container for use when generation the license metadata file.
|
|
|
|
func (m *ModuleBase) SetLicenseInstallMap(installMap []string) {
|
|
|
|
m.licenseInstallMap = append(m.licenseInstallMap, installMap...)
|
|
|
|
}
|
|
|
|
|
2019-06-07 01:57:04 +02:00
|
|
|
func (m *ModuleBase) generateModuleTarget(ctx ModuleContext) {
|
2020-02-13 22:22:08 +01:00
|
|
|
var allInstalledFiles InstallPaths
|
|
|
|
var allCheckbuildFiles Paths
|
2017-11-29 02:34:01 +01:00
|
|
|
ctx.VisitAllModuleVariants(func(module Module) {
|
|
|
|
a := module.base()
|
2015-03-27 00:10:12 +01:00
|
|
|
allInstalledFiles = append(allInstalledFiles, a.installFiles...)
|
2021-10-12 01:46:56 +02:00
|
|
|
// A module's -checkbuild phony targets should
|
2021-10-15 05:32:53 +02:00
|
|
|
// not be created if the module is not exported to make.
|
|
|
|
// Those could depend on the build target and fail to compile
|
|
|
|
// for the current build target.
|
|
|
|
if !ctx.Config().KatiEnabled() || !shouldSkipAndroidMkProcessing(a) {
|
|
|
|
allCheckbuildFiles = append(allCheckbuildFiles, a.checkbuildFiles...)
|
|
|
|
}
|
2015-01-31 02:27:36 +01:00
|
|
|
})
|
|
|
|
|
2017-11-29 02:34:01 +01:00
|
|
|
var deps Paths
|
2015-03-17 21:24:18 +01:00
|
|
|
|
2020-08-15 02:38:45 +02:00
|
|
|
namespacePrefix := ctx.Namespace().id
|
2017-11-30 01:47:17 +01:00
|
|
|
if namespacePrefix != "" {
|
|
|
|
namespacePrefix = namespacePrefix + "-"
|
|
|
|
}
|
|
|
|
|
2015-01-31 02:27:36 +01:00
|
|
|
if len(allInstalledFiles) > 0 {
|
2020-06-04 22:25:17 +02:00
|
|
|
name := namespacePrefix + ctx.ModuleName() + "-install"
|
|
|
|
ctx.Phony(name, allInstalledFiles.Paths()...)
|
|
|
|
m.installTarget = PathForPhony(ctx, name)
|
|
|
|
deps = append(deps, m.installTarget)
|
2015-03-17 21:24:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if len(allCheckbuildFiles) > 0 {
|
2020-06-04 22:25:17 +02:00
|
|
|
name := namespacePrefix + ctx.ModuleName() + "-checkbuild"
|
|
|
|
ctx.Phony(name, allCheckbuildFiles...)
|
|
|
|
m.checkbuildTarget = PathForPhony(ctx, name)
|
|
|
|
deps = append(deps, m.checkbuildTarget)
|
2015-03-17 21:24:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if len(deps) > 0 {
|
2015-12-11 22:51:06 +01:00
|
|
|
suffix := ""
|
2020-11-23 06:22:30 +01:00
|
|
|
if ctx.Config().KatiEnabled() {
|
2015-12-11 22:51:06 +01:00
|
|
|
suffix = "-soong"
|
|
|
|
}
|
|
|
|
|
2020-06-04 22:25:17 +02:00
|
|
|
ctx.Phony(namespacePrefix+ctx.ModuleName()+suffix, deps...)
|
2015-06-17 01:38:17 +02:00
|
|
|
|
2019-06-07 01:57:04 +02:00
|
|
|
m.blueprintDir = ctx.ModuleDir()
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-04 00:23:27 +01:00
|
|
|
func determineModuleKind(m *ModuleBase, ctx blueprint.EarlyModuleContext) moduleKind {
|
2019-06-07 01:57:04 +02:00
|
|
|
var socSpecific = Bool(m.commonProperties.Vendor) || Bool(m.commonProperties.Proprietary) || Bool(m.commonProperties.Soc_specific)
|
|
|
|
var deviceSpecific = Bool(m.commonProperties.Device_specific)
|
|
|
|
var productSpecific = Bool(m.commonProperties.Product_specific)
|
2019-06-25 09:47:17 +02:00
|
|
|
var systemExtSpecific = Bool(m.commonProperties.System_ext_specific)
|
2017-11-08 08:03:48 +01:00
|
|
|
|
2018-05-29 14:28:54 +02:00
|
|
|
msg := "conflicting value set here"
|
|
|
|
if socSpecific && deviceSpecific {
|
|
|
|
ctx.PropertyErrorf("device_specific", "a module cannot be specific to SoC and device at the same time.")
|
2019-06-07 01:57:04 +02:00
|
|
|
if Bool(m.commonProperties.Vendor) {
|
2017-11-08 08:03:48 +01:00
|
|
|
ctx.PropertyErrorf("vendor", msg)
|
|
|
|
}
|
2019-06-07 01:57:04 +02:00
|
|
|
if Bool(m.commonProperties.Proprietary) {
|
2017-11-08 08:03:48 +01:00
|
|
|
ctx.PropertyErrorf("proprietary", msg)
|
|
|
|
}
|
2019-06-07 01:57:04 +02:00
|
|
|
if Bool(m.commonProperties.Soc_specific) {
|
2017-11-08 08:03:48 +01:00
|
|
|
ctx.PropertyErrorf("soc_specific", msg)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-25 09:47:17 +02:00
|
|
|
if productSpecific && systemExtSpecific {
|
|
|
|
ctx.PropertyErrorf("product_specific", "a module cannot be specific to product and system_ext at the same time.")
|
|
|
|
ctx.PropertyErrorf("system_ext_specific", msg)
|
2018-05-29 14:28:54 +02:00
|
|
|
}
|
|
|
|
|
2019-06-25 09:47:17 +02:00
|
|
|
if (socSpecific || deviceSpecific) && (productSpecific || systemExtSpecific) {
|
2018-05-29 14:28:54 +02:00
|
|
|
if productSpecific {
|
|
|
|
ctx.PropertyErrorf("product_specific", "a module cannot be specific to SoC or device and product at the same time.")
|
|
|
|
} else {
|
2019-06-25 09:47:17 +02:00
|
|
|
ctx.PropertyErrorf("system_ext_specific", "a module cannot be specific to SoC or device and system_ext at the same time.")
|
2018-05-29 14:28:54 +02:00
|
|
|
}
|
|
|
|
if deviceSpecific {
|
|
|
|
ctx.PropertyErrorf("device_specific", msg)
|
|
|
|
} else {
|
2019-06-07 01:57:04 +02:00
|
|
|
if Bool(m.commonProperties.Vendor) {
|
2018-05-29 14:28:54 +02:00
|
|
|
ctx.PropertyErrorf("vendor", msg)
|
|
|
|
}
|
2019-06-07 01:57:04 +02:00
|
|
|
if Bool(m.commonProperties.Proprietary) {
|
2018-05-29 14:28:54 +02:00
|
|
|
ctx.PropertyErrorf("proprietary", msg)
|
|
|
|
}
|
2019-06-07 01:57:04 +02:00
|
|
|
if Bool(m.commonProperties.Soc_specific) {
|
2018-05-29 14:28:54 +02:00
|
|
|
ctx.PropertyErrorf("soc_specific", msg)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-08 08:03:48 +01:00
|
|
|
if productSpecific {
|
|
|
|
return productSpecificModule
|
2019-06-25 09:47:17 +02:00
|
|
|
} else if systemExtSpecific {
|
|
|
|
return systemExtSpecificModule
|
2017-11-08 08:03:48 +01:00
|
|
|
} else if deviceSpecific {
|
|
|
|
return deviceSpecificModule
|
|
|
|
} else if socSpecific {
|
|
|
|
return socSpecificModule
|
|
|
|
} else {
|
|
|
|
return platformModule
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-04 00:23:27 +01:00
|
|
|
func (m *ModuleBase) earlyModuleContextFactory(ctx blueprint.EarlyModuleContext) earlyModuleContext {
|
2019-12-31 03:43:07 +01:00
|
|
|
return earlyModuleContext{
|
2020-01-04 00:23:27 +01:00
|
|
|
EarlyModuleContext: ctx,
|
|
|
|
kind: determineModuleKind(m, ctx),
|
|
|
|
config: ctx.Config().(Config),
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-31 03:43:07 +01:00
|
|
|
func (m *ModuleBase) baseModuleContextFactory(ctx blueprint.BaseModuleContext) baseModuleContext {
|
|
|
|
return baseModuleContext{
|
|
|
|
bp: ctx,
|
|
|
|
earlyModuleContext: m.earlyModuleContextFactory(ctx),
|
|
|
|
os: m.commonProperties.CompileOS,
|
|
|
|
target: m.commonProperties.CompileTarget,
|
|
|
|
targetPrimary: m.commonProperties.CompilePrimary,
|
|
|
|
multiTargets: m.commonProperties.CompileMultiTargets,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-07 01:57:04 +02:00
|
|
|
func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) {
|
2019-06-06 23:29:25 +02:00
|
|
|
ctx := &moduleContext{
|
2019-06-06 23:33:29 +02:00
|
|
|
module: m.module,
|
2019-06-07 01:13:11 +02:00
|
|
|
bp: blueprintCtx,
|
2019-06-06 23:33:29 +02:00
|
|
|
baseModuleContext: m.baseModuleContextFactory(blueprintCtx),
|
|
|
|
variables: make(map[string]string),
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2022-01-28 23:49:24 +01:00
|
|
|
m.licenseMetadataFile = PathForModuleOut(ctx, "meta_lic")
|
|
|
|
|
2020-12-02 00:40:06 +01:00
|
|
|
dependencyInstallFiles, dependencyPackagingSpecs := m.computeInstallDeps(ctx)
|
2020-11-25 01:21:24 +01:00
|
|
|
// set m.installFilesDepSet to only the transitive dependencies to be used as the dependencies
|
|
|
|
// of installed files of this module. It will be replaced by a depset including the installed
|
|
|
|
// files of this module at the end for use by modules that depend on this one.
|
2022-04-21 21:50:51 +02:00
|
|
|
m.installFilesDepSet = NewDepSet[InstallPath](TOPOLOGICAL, nil, dependencyInstallFiles)
|
2020-11-25 01:21:24 +01:00
|
|
|
|
2019-06-07 00:41:36 +02:00
|
|
|
// Temporarily continue to call blueprintCtx.GetMissingDependencies() to maintain the previous behavior of never
|
|
|
|
// reporting missing dependency errors in Blueprint when AllowMissingDependencies == true.
|
|
|
|
// TODO: This will be removed once defaults modules handle missing dependency errors
|
|
|
|
blueprintCtx.GetMissingDependencies()
|
|
|
|
|
2019-06-07 01:13:11 +02:00
|
|
|
// For the final GenerateAndroidBuildActions pass, require that all visited dependencies Soong modules and
|
2020-02-25 20:26:33 +01:00
|
|
|
// are enabled. Unless the module is a CommonOS variant which may have dependencies on disabled variants
|
|
|
|
// (because the dependencies are added before the modules are disabled). The
|
|
|
|
// GetOsSpecificVariantsOfCommonOSVariant(...) method will ensure that the disabled variants are
|
|
|
|
// ignored.
|
|
|
|
ctx.baseModuleContext.strictVisitDeps = !m.IsCommonOSVariant()
|
2019-06-07 01:13:11 +02:00
|
|
|
|
2019-02-25 23:54:28 +01:00
|
|
|
if ctx.config.captureBuild {
|
|
|
|
ctx.ruleParams = make(map[blueprint.Rule]blueprint.RuleParams)
|
|
|
|
}
|
|
|
|
|
2017-05-09 22:45:28 +02:00
|
|
|
desc := "//" + ctx.ModuleDir() + ":" + ctx.ModuleName() + " "
|
|
|
|
var suffix []string
|
2017-11-29 02:34:01 +01:00
|
|
|
if ctx.Os().Class != Device && ctx.Os().Class != Generic {
|
|
|
|
suffix = append(suffix, ctx.Os().String())
|
2017-05-09 22:45:28 +02:00
|
|
|
}
|
2017-11-29 02:34:01 +01:00
|
|
|
if !ctx.PrimaryArch() {
|
|
|
|
suffix = append(suffix, ctx.Arch().ArchType.String())
|
2017-05-09 22:45:28 +02:00
|
|
|
}
|
2020-09-16 03:30:11 +02:00
|
|
|
if apexInfo := ctx.Provider(ApexInfoProvider).(ApexInfo); !apexInfo.IsForPlatform() {
|
|
|
|
suffix = append(suffix, apexInfo.ApexVariationName)
|
2020-02-14 20:25:54 +01:00
|
|
|
}
|
2017-05-09 22:45:28 +02:00
|
|
|
|
|
|
|
ctx.Variable(pctx, "moduleDesc", desc)
|
|
|
|
|
|
|
|
s := ""
|
|
|
|
if len(suffix) > 0 {
|
|
|
|
s = " [" + strings.Join(suffix, " ") + "]"
|
|
|
|
}
|
|
|
|
ctx.Variable(pctx, "moduleDescSuffix", s)
|
|
|
|
|
2018-11-19 18:33:29 +01:00
|
|
|
// Some common property checks for properties that will be used later in androidmk.go
|
2020-11-23 19:17:03 +01:00
|
|
|
checkDistProperties(ctx, "dist", &m.distProperties.Dist)
|
2022-08-04 22:07:02 +02:00
|
|
|
for i := range m.distProperties.Dists {
|
2020-11-23 19:17:03 +01:00
|
|
|
checkDistProperties(ctx, fmt.Sprintf("dists[%d]", i), &m.distProperties.Dists[i])
|
2018-11-19 18:33:29 +01:00
|
|
|
}
|
|
|
|
|
2019-06-07 01:57:04 +02:00
|
|
|
if m.Enabled() {
|
2019-08-23 04:18:57 +02:00
|
|
|
// ensure all direct android.Module deps are enabled
|
|
|
|
ctx.VisitDirectDepsBlueprint(func(bm blueprint.Module) {
|
2021-05-13 03:38:35 +02:00
|
|
|
if m, ok := bm.(Module); ok {
|
|
|
|
ctx.validateAndroidModule(bm, ctx.OtherModuleDependencyTag(m), ctx.baseModuleContext.strictVisitDeps)
|
2019-08-23 04:18:57 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2021-01-07 04:34:31 +01:00
|
|
|
licensesPropertyFlattener(ctx)
|
|
|
|
if ctx.Failed() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-05-10 19:50:12 +02:00
|
|
|
if mixedBuildMod, handled := m.isHandledByBazel(ctx); handled {
|
|
|
|
mixedBuildMod.ProcessBazelQueryResponse(ctx)
|
|
|
|
} else {
|
|
|
|
m.module.GenerateAndroidBuildActions(ctx)
|
|
|
|
}
|
2019-06-18 02:40:56 +02:00
|
|
|
if ctx.Failed() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-03-03 12:02:42 +01:00
|
|
|
m.initRcPaths = PathsForModuleSrc(ctx, m.commonProperties.Init_rc)
|
|
|
|
rcDir := PathForModuleInstall(ctx, "etc", "init")
|
|
|
|
for _, src := range m.initRcPaths {
|
|
|
|
ctx.PackageFile(rcDir, filepath.Base(src.String()), src)
|
|
|
|
}
|
|
|
|
|
|
|
|
m.vintfFragmentsPaths = PathsForModuleSrc(ctx, m.commonProperties.Vintf_fragments)
|
|
|
|
vintfDir := PathForModuleInstall(ctx, "etc", "vintf", "manifest")
|
|
|
|
for _, src := range m.vintfFragmentsPaths {
|
|
|
|
ctx.PackageFile(vintfDir, filepath.Base(src.String()), src)
|
|
|
|
}
|
|
|
|
|
2020-11-24 00:32:56 +01:00
|
|
|
// Create the set of tagged dist files after calling GenerateAndroidBuildActions
|
|
|
|
// as GenerateTaggedDistFiles() calls OutputFiles(tag) and so relies on the
|
|
|
|
// output paths being set which must be done before or during
|
|
|
|
// GenerateAndroidBuildActions.
|
|
|
|
m.distFiles = m.GenerateTaggedDistFiles(ctx)
|
|
|
|
if ctx.Failed() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2019-06-18 02:40:56 +02:00
|
|
|
m.installFiles = append(m.installFiles, ctx.installFiles...)
|
|
|
|
m.checkbuildFiles = append(m.checkbuildFiles, ctx.checkbuildFiles...)
|
add PackagingSpec
Currently, installation of a module is defined as an action of copying
the built artifact of the module to an install path like out/soong/host
(for host modules) and out/target/product/<device>/<partition> (for
device modules). After the modules are installed, the installed files
are further processed to create packages like system.img, vendor.img,
cvd-host-package.tar.gz, etc.
This notion of installation seems to have originated from the old time
when system.img is the primary product of the entire build process
(modulo a few more like root.img). Packaging the installed files as the
filesystem image was considered as a post-build step then.
However, this model doesn't seem to fit well to the current and future
environment where we have a lot more filesystem images (system, vendor,
system_ext, product, ...). The filesystem images themselves are even
grouped together to form a higher-level filesystem image like super.img.
Furthermore, things like cvd-host-package.tar.gz requires us to be able
to group some of the host tools in a format that isn't filesystem image.
Lastly, we are expected to have more filesystem images that are subsets
of system.img (and their friends) for the Android-like mini OS that will
be running on on-device virtual machines. These all imply that the
packaging (which we call installation today) is not a global post-build
step, but a part of the build rules for creating the package-like
modules.
A model better fits to the new sitatuation might be this; a module
specifies its built artifact and the path where it should be placed. The
latter path is not rooted at out/. It's a relative path to the root
directory which will be determined by another module that implements the
packaging. For example, cc_library will have ./lib (or ./lib64), not
out/target/product/<device>/<partition>/lib as the path. Then packages
like system.img, cvd-host-package.tar.gz, etc. are explicitly modeled as
modules and they have deps to other modules. Then the modules are placed
at the relative path under the package root, and the entire root
directory finally is packaged as the output file (be it img, tar.gz, or
whatever).
PackagingSpec is the first step to implement the new model. It abstracts
a request to place a built artifact at a certain path in a package. It
has extra information about whether the path should be a symlink or not,
and whether the path is for an executable. It currently is created when
InstallFiles (and its friends) are called, and can be retrieved via
the new method PackagingSpecs().
In this CL, no one is using PackagingSpec. The installation is still
done by the existing rules created in InstallFiles, etc. and the
structs are not used for the filesystem images like system.img.
Bug: 159685774
Bug: 172414391
Test: m
Change-Id: Ie1dec72d1ac14382fc3b74e5c850472e9320d6a3
2020-11-09 06:08:34 +01:00
|
|
|
m.packagingSpecs = append(m.packagingSpecs, ctx.packagingSpecs...)
|
2021-09-29 02:40:21 +02:00
|
|
|
m.katiInstalls = append(m.katiInstalls, ctx.katiInstalls...)
|
|
|
|
m.katiSymlinks = append(m.katiSymlinks, ctx.katiSymlinks...)
|
2019-06-07 01:13:11 +02:00
|
|
|
} else if ctx.Config().AllowMissingDependencies() {
|
|
|
|
// If the module is not enabled it will not create any build rules, nothing will call
|
|
|
|
// ctx.GetMissingDependencies(), and blueprint will consider the missing dependencies to be unhandled
|
|
|
|
// and report them as an error even when AllowMissingDependencies = true. Call
|
|
|
|
// ctx.GetMissingDependencies() here to tell blueprint not to handle them.
|
|
|
|
ctx.GetMissingDependencies()
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2019-06-07 01:57:04 +02:00
|
|
|
if m == ctx.FinalModule().(Module).base() {
|
|
|
|
m.generateModuleTarget(ctx)
|
2016-09-20 00:18:11 +02:00
|
|
|
if ctx.Failed() {
|
|
|
|
return
|
|
|
|
}
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
2017-07-13 23:43:27 +02:00
|
|
|
|
2022-04-21 21:50:51 +02:00
|
|
|
m.installFilesDepSet = NewDepSet[InstallPath](TOPOLOGICAL, m.installFiles, dependencyInstallFiles)
|
|
|
|
m.packagingSpecsDepSet = NewDepSet[PackagingSpec](TOPOLOGICAL, m.packagingSpecs, dependencyPackagingSpecs)
|
2020-11-25 01:21:24 +01:00
|
|
|
|
2022-01-28 23:49:24 +01:00
|
|
|
buildLicenseMetadata(ctx, m.licenseMetadataFile)
|
2021-12-11 00:05:02 +01:00
|
|
|
|
2019-06-07 01:57:04 +02:00
|
|
|
m.buildParams = ctx.buildParams
|
|
|
|
m.ruleParams = ctx.ruleParams
|
|
|
|
m.variables = ctx.variables
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2022-05-10 19:50:12 +02:00
|
|
|
func (m *ModuleBase) isHandledByBazel(ctx ModuleContext) (MixedBuildBuildable, bool) {
|
|
|
|
if mixedBuildMod, ok := m.module.(MixedBuildBuildable); ok {
|
2023-04-19 18:47:36 +02:00
|
|
|
if mixedBuildMod.IsMixedBuildSupported(ctx) && (MixedBuildsEnabled(ctx) == MixedBuildEnabled) {
|
2022-05-10 19:50:12 +02:00
|
|
|
return mixedBuildMod, true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil, false
|
|
|
|
}
|
|
|
|
|
2020-11-23 19:17:03 +01:00
|
|
|
// Check the supplied dist structure to make sure that it is valid.
|
|
|
|
//
|
|
|
|
// property - the base property, e.g. dist or dists[1], which is combined with the
|
|
|
|
// name of the nested property to produce the full property, e.g. dist.dest or
|
|
|
|
// dists[1].dir.
|
|
|
|
func checkDistProperties(ctx *moduleContext, property string, dist *Dist) {
|
|
|
|
if dist.Dest != nil {
|
|
|
|
_, err := validateSafePath(*dist.Dest)
|
|
|
|
if err != nil {
|
|
|
|
ctx.PropertyErrorf(property+".dest", "%s", err.Error())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if dist.Dir != nil {
|
|
|
|
_, err := validateSafePath(*dist.Dir)
|
|
|
|
if err != nil {
|
|
|
|
ctx.PropertyErrorf(property+".dir", "%s", err.Error())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if dist.Suffix != nil {
|
|
|
|
if strings.Contains(*dist.Suffix, "/") {
|
|
|
|
ctx.PropertyErrorf(property+".suffix", "Suffix may not contain a '/' character.")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-12-31 03:43:07 +01:00
|
|
|
type earlyModuleContext struct {
|
2020-01-04 00:23:27 +01:00
|
|
|
blueprint.EarlyModuleContext
|
2019-12-31 03:43:07 +01:00
|
|
|
|
|
|
|
kind moduleKind
|
|
|
|
config Config
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e *earlyModuleContext) Glob(globPattern string, excludes []string) Paths {
|
2020-11-10 19:50:34 +01:00
|
|
|
return Glob(e, globPattern, excludes)
|
2019-12-31 03:43:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (e *earlyModuleContext) GlobFiles(globPattern string, excludes []string) Paths {
|
2020-11-10 19:50:34 +01:00
|
|
|
return GlobFiles(e, globPattern, excludes)
|
2019-12-31 03:43:07 +01:00
|
|
|
}
|
|
|
|
|
2021-12-06 21:17:23 +01:00
|
|
|
func (e *earlyModuleContext) IsSymlink(path Path) bool {
|
|
|
|
fileInfo, err := e.config.fs.Lstat(path.String())
|
2020-01-11 02:11:46 +01:00
|
|
|
if err != nil {
|
2021-12-06 21:17:23 +01:00
|
|
|
e.ModuleErrorf("os.Lstat(%q) failed: %s", path.String(), err)
|
2020-01-11 02:11:46 +01:00
|
|
|
}
|
|
|
|
return fileInfo.Mode()&os.ModeSymlink == os.ModeSymlink
|
|
|
|
}
|
|
|
|
|
2021-12-06 21:17:23 +01:00
|
|
|
func (e *earlyModuleContext) Readlink(path Path) string {
|
|
|
|
dest, err := e.config.fs.Readlink(path.String())
|
2020-01-11 02:11:46 +01:00
|
|
|
if err != nil {
|
2021-12-06 21:17:23 +01:00
|
|
|
e.ModuleErrorf("os.Readlink(%q) failed: %s", path.String(), err)
|
2020-01-11 02:11:46 +01:00
|
|
|
}
|
|
|
|
return dest
|
|
|
|
}
|
|
|
|
|
2019-12-31 03:43:07 +01:00
|
|
|
func (e *earlyModuleContext) Module() Module {
|
2020-01-04 00:23:27 +01:00
|
|
|
module, _ := e.EarlyModuleContext.Module().(Module)
|
2019-12-31 03:43:07 +01:00
|
|
|
return module
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e *earlyModuleContext) Config() Config {
|
2020-01-04 00:23:27 +01:00
|
|
|
return e.EarlyModuleContext.Config().(Config)
|
2019-12-31 03:43:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (e *earlyModuleContext) AConfig() Config {
|
|
|
|
return e.config
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e *earlyModuleContext) DeviceConfig() DeviceConfig {
|
|
|
|
return DeviceConfig{e.config.deviceConfig}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e *earlyModuleContext) Platform() bool {
|
|
|
|
return e.kind == platformModule
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e *earlyModuleContext) DeviceSpecific() bool {
|
|
|
|
return e.kind == deviceSpecificModule
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e *earlyModuleContext) SocSpecific() bool {
|
|
|
|
return e.kind == socSpecificModule
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e *earlyModuleContext) ProductSpecific() bool {
|
|
|
|
return e.kind == productSpecificModule
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e *earlyModuleContext) SystemExtSpecific() bool {
|
|
|
|
return e.kind == systemExtSpecificModule
|
|
|
|
}
|
|
|
|
|
2020-08-15 02:38:45 +02:00
|
|
|
func (e *earlyModuleContext) Namespace() *Namespace {
|
|
|
|
return e.EarlyModuleContext.Namespace().(*Namespace)
|
|
|
|
}
|
|
|
|
|
2019-12-31 03:43:07 +01:00
|
|
|
type baseModuleContext struct {
|
|
|
|
bp blueprint.BaseModuleContext
|
|
|
|
earlyModuleContext
|
2019-11-21 02:12:35 +01:00
|
|
|
os OsType
|
2016-09-13 18:59:14 +02:00
|
|
|
target Target
|
2018-10-03 07:01:37 +02:00
|
|
|
multiTargets []Target
|
2016-09-13 18:59:14 +02:00
|
|
|
targetPrimary bool
|
|
|
|
debug bool
|
2019-06-07 01:13:11 +02:00
|
|
|
|
|
|
|
walkPath []Module
|
2020-03-31 12:31:36 +02:00
|
|
|
tagPath []blueprint.DependencyTag
|
2019-06-07 01:13:11 +02:00
|
|
|
|
|
|
|
strictVisitDeps bool // If true, enforce that all dependencies are enabled
|
2021-07-21 20:34:58 +02:00
|
|
|
|
|
|
|
bazelConversionMode bool
|
2015-03-24 19:13:38 +01:00
|
|
|
}
|
|
|
|
|
2022-04-26 15:38:20 +02:00
|
|
|
func (b *baseModuleContext) isBazelConversionMode() bool {
|
2021-07-21 20:34:58 +02:00
|
|
|
return b.bazelConversionMode
|
|
|
|
}
|
2020-02-25 16:50:49 +01:00
|
|
|
func (b *baseModuleContext) OtherModuleName(m blueprint.Module) string {
|
|
|
|
return b.bp.OtherModuleName(m)
|
|
|
|
}
|
|
|
|
func (b *baseModuleContext) OtherModuleDir(m blueprint.Module) string { return b.bp.OtherModuleDir(m) }
|
2019-12-31 03:43:07 +01:00
|
|
|
func (b *baseModuleContext) OtherModuleErrorf(m blueprint.Module, fmt string, args ...interface{}) {
|
2020-02-25 18:05:18 +01:00
|
|
|
b.bp.OtherModuleErrorf(m, fmt, args...)
|
2019-12-31 03:43:07 +01:00
|
|
|
}
|
|
|
|
func (b *baseModuleContext) OtherModuleDependencyTag(m blueprint.Module) blueprint.DependencyTag {
|
|
|
|
return b.bp.OtherModuleDependencyTag(m)
|
|
|
|
}
|
2020-02-25 16:50:49 +01:00
|
|
|
func (b *baseModuleContext) OtherModuleExists(name string) bool { return b.bp.OtherModuleExists(name) }
|
2020-03-05 18:34:13 +01:00
|
|
|
func (b *baseModuleContext) OtherModuleDependencyVariantExists(variations []blueprint.Variation, name string) bool {
|
|
|
|
return b.bp.OtherModuleDependencyVariantExists(variations, name)
|
|
|
|
}
|
2021-05-05 16:27:31 +02:00
|
|
|
func (b *baseModuleContext) OtherModuleFarDependencyVariantExists(variations []blueprint.Variation, name string) bool {
|
|
|
|
return b.bp.OtherModuleFarDependencyVariantExists(variations, name)
|
|
|
|
}
|
2020-03-05 18:34:13 +01:00
|
|
|
func (b *baseModuleContext) OtherModuleReverseDependencyVariantExists(name string) bool {
|
|
|
|
return b.bp.OtherModuleReverseDependencyVariantExists(name)
|
|
|
|
}
|
2020-02-25 16:50:49 +01:00
|
|
|
func (b *baseModuleContext) OtherModuleType(m blueprint.Module) string {
|
|
|
|
return b.bp.OtherModuleType(m)
|
|
|
|
}
|
2020-07-02 20:38:17 +02:00
|
|
|
func (b *baseModuleContext) OtherModuleProvider(m blueprint.Module, provider blueprint.ProviderKey) interface{} {
|
|
|
|
return b.bp.OtherModuleProvider(m, provider)
|
|
|
|
}
|
|
|
|
func (b *baseModuleContext) OtherModuleHasProvider(m blueprint.Module, provider blueprint.ProviderKey) bool {
|
|
|
|
return b.bp.OtherModuleHasProvider(m, provider)
|
|
|
|
}
|
|
|
|
func (b *baseModuleContext) Provider(provider blueprint.ProviderKey) interface{} {
|
|
|
|
return b.bp.Provider(provider)
|
|
|
|
}
|
|
|
|
func (b *baseModuleContext) HasProvider(provider blueprint.ProviderKey) bool {
|
|
|
|
return b.bp.HasProvider(provider)
|
|
|
|
}
|
|
|
|
func (b *baseModuleContext) SetProvider(provider blueprint.ProviderKey, value interface{}) {
|
|
|
|
b.bp.SetProvider(provider, value)
|
|
|
|
}
|
2019-12-31 03:43:07 +01:00
|
|
|
|
|
|
|
func (b *baseModuleContext) GetDirectDepWithTag(name string, tag blueprint.DependencyTag) blueprint.Module {
|
|
|
|
return b.bp.GetDirectDepWithTag(name, tag)
|
|
|
|
}
|
|
|
|
|
2020-05-07 21:21:34 +02:00
|
|
|
func (b *baseModuleContext) blueprintBaseModuleContext() blueprint.BaseModuleContext {
|
|
|
|
return b.bp
|
|
|
|
}
|
|
|
|
|
2019-06-06 23:29:25 +02:00
|
|
|
type moduleContext struct {
|
2019-06-07 01:13:11 +02:00
|
|
|
bp blueprint.ModuleContext
|
2019-06-06 23:33:29 +02:00
|
|
|
baseModuleContext
|
add PackagingSpec
Currently, installation of a module is defined as an action of copying
the built artifact of the module to an install path like out/soong/host
(for host modules) and out/target/product/<device>/<partition> (for
device modules). After the modules are installed, the installed files
are further processed to create packages like system.img, vendor.img,
cvd-host-package.tar.gz, etc.
This notion of installation seems to have originated from the old time
when system.img is the primary product of the entire build process
(modulo a few more like root.img). Packaging the installed files as the
filesystem image was considered as a post-build step then.
However, this model doesn't seem to fit well to the current and future
environment where we have a lot more filesystem images (system, vendor,
system_ext, product, ...). The filesystem images themselves are even
grouped together to form a higher-level filesystem image like super.img.
Furthermore, things like cvd-host-package.tar.gz requires us to be able
to group some of the host tools in a format that isn't filesystem image.
Lastly, we are expected to have more filesystem images that are subsets
of system.img (and their friends) for the Android-like mini OS that will
be running on on-device virtual machines. These all imply that the
packaging (which we call installation today) is not a global post-build
step, but a part of the build rules for creating the package-like
modules.
A model better fits to the new sitatuation might be this; a module
specifies its built artifact and the path where it should be placed. The
latter path is not rooted at out/. It's a relative path to the root
directory which will be determined by another module that implements the
packaging. For example, cc_library will have ./lib (or ./lib64), not
out/target/product/<device>/<partition>/lib as the path. Then packages
like system.img, cvd-host-package.tar.gz, etc. are explicitly modeled as
modules and they have deps to other modules. Then the modules are placed
at the relative path under the package root, and the entire root
directory finally is packaged as the output file (be it img, tar.gz, or
whatever).
PackagingSpec is the first step to implement the new model. It abstracts
a request to place a built artifact at a certain path in a package. It
has extra information about whether the path should be a symlink or not,
and whether the path is for an executable. It currently is created when
InstallFiles (and its friends) are called, and can be retrieved via
the new method PackagingSpecs().
In this CL, no one is using PackagingSpec. The installation is still
done by the existing rules created in InstallFiles, etc. and the
structs are not used for the filesystem images like system.img.
Bug: 159685774
Bug: 172414391
Test: m
Change-Id: Ie1dec72d1ac14382fc3b74e5c850472e9320d6a3
2020-11-09 06:08:34 +01:00
|
|
|
packagingSpecs []PackagingSpec
|
2020-02-13 22:22:08 +01:00
|
|
|
installFiles InstallPaths
|
2015-09-24 00:26:20 +02:00
|
|
|
checkbuildFiles Paths
|
2016-08-03 20:57:50 +02:00
|
|
|
module Module
|
2020-06-04 22:25:17 +02:00
|
|
|
phonies map[string]Paths
|
2017-07-13 23:43:27 +02:00
|
|
|
|
2021-09-29 02:40:21 +02:00
|
|
|
katiInstalls []katiInstall
|
|
|
|
katiSymlinks []katiInstall
|
|
|
|
|
2017-07-13 23:43:27 +02:00
|
|
|
// For tests
|
2017-10-24 02:16:14 +02:00
|
|
|
buildParams []BuildParams
|
2019-02-25 23:54:28 +01:00
|
|
|
ruleParams map[blueprint.Rule]blueprint.RuleParams
|
2018-12-12 18:01:34 +01:00
|
|
|
variables map[string]string
|
2015-12-18 01:39:19 +01:00
|
|
|
}
|
|
|
|
|
2021-09-29 02:40:21 +02:00
|
|
|
// katiInstall stores a request from Soong to Make to create an install rule.
|
|
|
|
type katiInstall struct {
|
|
|
|
from Path
|
|
|
|
to InstallPath
|
|
|
|
implicitDeps Paths
|
|
|
|
orderOnlyDeps Paths
|
|
|
|
executable bool
|
2021-11-13 02:41:02 +01:00
|
|
|
extraFiles *extraFilesZip
|
2021-09-29 02:40:21 +02:00
|
|
|
|
|
|
|
absFrom string
|
|
|
|
}
|
|
|
|
|
2021-11-13 02:41:02 +01:00
|
|
|
type extraFilesZip struct {
|
|
|
|
zip Path
|
|
|
|
dir InstallPath
|
|
|
|
}
|
|
|
|
|
2021-09-29 02:40:21 +02:00
|
|
|
type katiInstalls []katiInstall
|
|
|
|
|
|
|
|
// BuiltInstalled returns the katiInstalls in the form used by $(call copy-many-files) in Make, a
|
|
|
|
// space separated list of from:to tuples.
|
|
|
|
func (installs katiInstalls) BuiltInstalled() string {
|
|
|
|
sb := strings.Builder{}
|
|
|
|
for i, install := range installs {
|
|
|
|
if i != 0 {
|
|
|
|
sb.WriteRune(' ')
|
|
|
|
}
|
|
|
|
sb.WriteString(install.from.String())
|
|
|
|
sb.WriteRune(':')
|
|
|
|
sb.WriteString(install.to.String())
|
|
|
|
}
|
|
|
|
return sb.String()
|
|
|
|
}
|
|
|
|
|
|
|
|
// InstallPaths returns the install path of each entry.
|
|
|
|
func (installs katiInstalls) InstallPaths() InstallPaths {
|
|
|
|
paths := make(InstallPaths, 0, len(installs))
|
|
|
|
for _, install := range installs {
|
|
|
|
paths = append(paths, install.to)
|
|
|
|
}
|
|
|
|
return paths
|
|
|
|
}
|
|
|
|
|
2019-06-11 00:15:17 +02:00
|
|
|
func (m *moduleContext) ninjaError(params BuildParams, err error) (PackageContext, BuildParams) {
|
|
|
|
return pctx, BuildParams{
|
2019-06-07 22:06:06 +02:00
|
|
|
Rule: ErrorRule,
|
|
|
|
Description: params.Description,
|
|
|
|
Output: params.Output,
|
|
|
|
Outputs: params.Outputs,
|
|
|
|
ImplicitOutput: params.ImplicitOutput,
|
|
|
|
ImplicitOutputs: params.ImplicitOutputs,
|
2015-12-18 01:39:19 +01:00
|
|
|
Args: map[string]string{
|
|
|
|
"error": err.Error(),
|
|
|
|
},
|
2019-06-11 00:15:17 +02:00
|
|
|
}
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2019-06-06 23:29:25 +02:00
|
|
|
func (m *moduleContext) ModuleBuild(pctx PackageContext, params ModuleBuildParams) {
|
|
|
|
m.Build(pctx, BuildParams(params))
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2020-09-23 06:30:02 +02:00
|
|
|
func validateBuildParams(params blueprint.BuildParams) error {
|
|
|
|
// Validate that the symlink outputs are declared outputs or implicit outputs
|
|
|
|
allOutputs := map[string]bool{}
|
|
|
|
for _, output := range params.Outputs {
|
|
|
|
allOutputs[output] = true
|
|
|
|
}
|
|
|
|
for _, output := range params.ImplicitOutputs {
|
|
|
|
allOutputs[output] = true
|
|
|
|
}
|
|
|
|
for _, symlinkOutput := range params.SymlinkOutputs {
|
|
|
|
if !allOutputs[symlinkOutput] {
|
|
|
|
return fmt.Errorf(
|
|
|
|
"Symlink output %s is not a declared output or implicit output",
|
|
|
|
symlinkOutput)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Convert build parameters from their concrete Android types into their string representations,
|
|
|
|
// and combine the singular and plural fields of the same type (e.g. Output and Outputs).
|
2017-11-29 02:34:01 +01:00
|
|
|
func convertBuildParams(params BuildParams) blueprint.BuildParams {
|
2015-09-24 00:26:20 +02:00
|
|
|
bparams := blueprint.BuildParams{
|
2016-11-03 22:28:31 +01:00
|
|
|
Rule: params.Rule,
|
2017-11-29 02:34:01 +01:00
|
|
|
Description: params.Description,
|
2016-11-22 02:23:08 +01:00
|
|
|
Deps: params.Deps,
|
2016-11-03 22:28:31 +01:00
|
|
|
Outputs: params.Outputs.Strings(),
|
|
|
|
ImplicitOutputs: params.ImplicitOutputs.Strings(),
|
2020-09-23 06:30:02 +02:00
|
|
|
SymlinkOutputs: params.SymlinkOutputs.Strings(),
|
2016-11-03 22:28:31 +01:00
|
|
|
Inputs: params.Inputs.Strings(),
|
|
|
|
Implicits: params.Implicits.Strings(),
|
|
|
|
OrderOnly: params.OrderOnly.Strings(),
|
2020-07-16 22:07:51 +02:00
|
|
|
Validations: params.Validations.Strings(),
|
2016-11-03 22:28:31 +01:00
|
|
|
Args: params.Args,
|
|
|
|
Optional: !params.Default,
|
2015-09-24 00:26:20 +02:00
|
|
|
}
|
|
|
|
|
2016-11-22 02:23:08 +01:00
|
|
|
if params.Depfile != nil {
|
|
|
|
bparams.Depfile = params.Depfile.String()
|
|
|
|
}
|
2015-09-24 00:26:20 +02:00
|
|
|
if params.Output != nil {
|
|
|
|
bparams.Outputs = append(bparams.Outputs, params.Output.String())
|
|
|
|
}
|
2020-09-23 06:30:02 +02:00
|
|
|
if params.SymlinkOutput != nil {
|
|
|
|
bparams.SymlinkOutputs = append(bparams.SymlinkOutputs, params.SymlinkOutput.String())
|
|
|
|
}
|
2016-11-03 22:28:31 +01:00
|
|
|
if params.ImplicitOutput != nil {
|
|
|
|
bparams.ImplicitOutputs = append(bparams.ImplicitOutputs, params.ImplicitOutput.String())
|
|
|
|
}
|
2015-09-24 00:26:20 +02:00
|
|
|
if params.Input != nil {
|
|
|
|
bparams.Inputs = append(bparams.Inputs, params.Input.String())
|
|
|
|
}
|
|
|
|
if params.Implicit != nil {
|
|
|
|
bparams.Implicits = append(bparams.Implicits, params.Implicit.String())
|
|
|
|
}
|
2020-07-16 22:07:51 +02:00
|
|
|
if params.Validation != nil {
|
|
|
|
bparams.Validations = append(bparams.Validations, params.Validation.String())
|
|
|
|
}
|
2015-09-24 00:26:20 +02:00
|
|
|
|
2019-02-28 20:00:01 +01:00
|
|
|
bparams.Outputs = proptools.NinjaEscapeList(bparams.Outputs)
|
|
|
|
bparams.ImplicitOutputs = proptools.NinjaEscapeList(bparams.ImplicitOutputs)
|
2020-09-23 06:30:02 +02:00
|
|
|
bparams.SymlinkOutputs = proptools.NinjaEscapeList(bparams.SymlinkOutputs)
|
2019-02-28 20:00:01 +01:00
|
|
|
bparams.Inputs = proptools.NinjaEscapeList(bparams.Inputs)
|
|
|
|
bparams.Implicits = proptools.NinjaEscapeList(bparams.Implicits)
|
|
|
|
bparams.OrderOnly = proptools.NinjaEscapeList(bparams.OrderOnly)
|
2020-07-16 22:07:51 +02:00
|
|
|
bparams.Validations = proptools.NinjaEscapeList(bparams.Validations)
|
|
|
|
bparams.Depfile = proptools.NinjaEscape(bparams.Depfile)
|
2018-09-12 19:02:13 +02:00
|
|
|
|
2017-11-29 02:34:01 +01:00
|
|
|
return bparams
|
|
|
|
}
|
|
|
|
|
2019-06-06 23:29:25 +02:00
|
|
|
func (m *moduleContext) Variable(pctx PackageContext, name, value string) {
|
|
|
|
if m.config.captureBuild {
|
|
|
|
m.variables[name] = value
|
2018-12-12 18:01:34 +01:00
|
|
|
}
|
|
|
|
|
2019-06-07 01:13:11 +02:00
|
|
|
m.bp.Variable(pctx.PackageContext, name, value)
|
2017-11-29 02:34:01 +01:00
|
|
|
}
|
|
|
|
|
2019-06-06 23:29:25 +02:00
|
|
|
func (m *moduleContext) Rule(pctx PackageContext, name string, params blueprint.RuleParams,
|
2017-11-29 02:34:01 +01:00
|
|
|
argNames ...string) blueprint.Rule {
|
|
|
|
|
2020-04-01 04:14:52 +02:00
|
|
|
if m.config.UseRemoteBuild() {
|
|
|
|
if params.Pool == nil {
|
|
|
|
// When USE_GOMA=true or USE_RBE=true are set and the rule is not supported by goma/RBE, restrict
|
|
|
|
// jobs to the local parallelism value
|
|
|
|
params.Pool = localPool
|
|
|
|
} else if params.Pool == remotePool {
|
|
|
|
// remotePool is a fake pool used to identify rule that are supported for remoting. If the rule's
|
|
|
|
// pool is the remotePool, replace with nil so that ninja runs it at NINJA_REMOTE_NUM_JOBS
|
|
|
|
// parallelism.
|
|
|
|
params.Pool = nil
|
|
|
|
}
|
2019-09-25 22:31:46 +02:00
|
|
|
}
|
|
|
|
|
2019-06-07 01:13:11 +02:00
|
|
|
rule := m.bp.Rule(pctx.PackageContext, name, params, argNames...)
|
2019-02-25 23:54:28 +01:00
|
|
|
|
2019-06-06 23:29:25 +02:00
|
|
|
if m.config.captureBuild {
|
|
|
|
m.ruleParams[rule] = params
|
2019-02-25 23:54:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return rule
|
2017-11-29 02:34:01 +01:00
|
|
|
}
|
|
|
|
|
2019-06-06 23:29:25 +02:00
|
|
|
func (m *moduleContext) Build(pctx PackageContext, params BuildParams) {
|
2019-06-11 00:15:17 +02:00
|
|
|
if params.Description != "" {
|
|
|
|
params.Description = "${moduleDesc}" + params.Description + "${moduleDescSuffix}"
|
2017-11-29 02:34:01 +01:00
|
|
|
}
|
|
|
|
|
2019-06-11 00:15:17 +02:00
|
|
|
if missingDeps := m.GetMissingDependencies(); len(missingDeps) > 0 {
|
|
|
|
pctx, params = m.ninjaError(params, fmt.Errorf("module %s missing dependencies: %s\n",
|
|
|
|
m.ModuleName(), strings.Join(missingDeps, ", ")))
|
2017-11-29 02:34:01 +01:00
|
|
|
}
|
|
|
|
|
2019-06-11 00:15:17 +02:00
|
|
|
if m.config.captureBuild {
|
|
|
|
m.buildParams = append(m.buildParams, params)
|
2015-12-18 01:39:19 +01:00
|
|
|
}
|
|
|
|
|
2020-09-23 06:30:02 +02:00
|
|
|
bparams := convertBuildParams(params)
|
|
|
|
err := validateBuildParams(bparams)
|
|
|
|
if err != nil {
|
|
|
|
m.ModuleErrorf(
|
|
|
|
"%s: build parameter validation failed: %s",
|
|
|
|
m.ModuleName(),
|
|
|
|
err.Error())
|
|
|
|
}
|
|
|
|
m.bp.Build(pctx.PackageContext, bparams)
|
2019-06-07 01:13:11 +02:00
|
|
|
}
|
2020-06-04 22:25:17 +02:00
|
|
|
|
|
|
|
func (m *moduleContext) Phony(name string, deps ...Path) {
|
|
|
|
addPhony(m.config, name, deps...)
|
|
|
|
}
|
|
|
|
|
2019-06-06 23:29:25 +02:00
|
|
|
func (m *moduleContext) GetMissingDependencies() []string {
|
2019-06-07 00:41:36 +02:00
|
|
|
var missingDeps []string
|
|
|
|
missingDeps = append(missingDeps, m.Module().base().commonProperties.MissingDeps...)
|
2019-06-07 01:13:11 +02:00
|
|
|
missingDeps = append(missingDeps, m.bp.GetMissingDependencies()...)
|
2019-06-07 00:41:36 +02:00
|
|
|
missingDeps = FirstUniqueStrings(missingDeps)
|
|
|
|
return missingDeps
|
2015-12-18 01:39:19 +01:00
|
|
|
}
|
|
|
|
|
2019-06-07 01:13:11 +02:00
|
|
|
func (b *baseModuleContext) AddMissingDependencies(deps []string) {
|
2016-03-11 03:14:25 +01:00
|
|
|
if deps != nil {
|
2019-06-07 01:13:11 +02:00
|
|
|
missingDeps := &b.Module().base().commonProperties.MissingDeps
|
2019-06-07 00:41:36 +02:00
|
|
|
*missingDeps = append(*missingDeps, deps...)
|
|
|
|
*missingDeps = FirstUniqueStrings(*missingDeps)
|
2016-03-11 03:14:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-17 19:01:48 +02:00
|
|
|
func (b *baseModuleContext) checkedMissingDeps() bool {
|
|
|
|
return b.Module().base().commonProperties.CheckedMissingDeps
|
|
|
|
}
|
|
|
|
|
|
|
|
func (b *baseModuleContext) getMissingDependencies() []string {
|
|
|
|
checked := &b.Module().base().commonProperties.CheckedMissingDeps
|
|
|
|
*checked = true
|
|
|
|
var missingDeps []string
|
|
|
|
missingDeps = append(missingDeps, b.Module().base().commonProperties.MissingDeps...)
|
|
|
|
missingDeps = append(missingDeps, b.bp.EarlyGetMissingDependencies()...)
|
|
|
|
missingDeps = FirstUniqueStrings(missingDeps)
|
|
|
|
return missingDeps
|
|
|
|
}
|
|
|
|
|
2021-05-13 03:38:35 +02:00
|
|
|
type AllowDisabledModuleDependency interface {
|
|
|
|
blueprint.DependencyTag
|
|
|
|
AllowDisabledModuleDependency(target Module) bool
|
|
|
|
}
|
|
|
|
|
|
|
|
func (b *baseModuleContext) validateAndroidModule(module blueprint.Module, tag blueprint.DependencyTag, strict bool) Module {
|
2017-10-24 02:59:01 +02:00
|
|
|
aModule, _ := module.(Module)
|
2019-06-07 01:13:11 +02:00
|
|
|
|
|
|
|
if !strict {
|
|
|
|
return aModule
|
|
|
|
}
|
|
|
|
|
2019-06-10 19:49:58 +02:00
|
|
|
if aModule == nil {
|
2022-01-24 22:17:30 +01:00
|
|
|
b.ModuleErrorf("module %q (%#v) not an android module", b.OtherModuleName(module), tag)
|
2019-06-10 19:49:58 +02:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
if !aModule.Enabled() {
|
2021-05-13 03:38:35 +02:00
|
|
|
if t, ok := tag.(AllowDisabledModuleDependency); !ok || !t.AllowDisabledModuleDependency(aModule) {
|
|
|
|
if b.Config().AllowMissingDependencies() {
|
|
|
|
b.AddMissingDependencies([]string{b.OtherModuleName(aModule)})
|
|
|
|
} else {
|
|
|
|
b.ModuleErrorf("depends on disabled module %q", b.OtherModuleName(aModule))
|
|
|
|
}
|
2019-06-10 19:49:58 +02:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
2017-10-24 02:59:01 +02:00
|
|
|
return aModule
|
|
|
|
}
|
|
|
|
|
2021-04-26 21:47:28 +02:00
|
|
|
type dep struct {
|
|
|
|
mod blueprint.Module
|
|
|
|
tag blueprint.DependencyTag
|
|
|
|
}
|
|
|
|
|
|
|
|
func (b *baseModuleContext) getDirectDepsInternal(name string, tag blueprint.DependencyTag) []dep {
|
2019-04-17 14:47:37 +02:00
|
|
|
var deps []dep
|
2019-06-07 01:13:11 +02:00
|
|
|
b.VisitDirectDepsBlueprint(func(module blueprint.Module) {
|
2021-01-26 15:18:53 +01:00
|
|
|
if aModule, _ := module.(Module); aModule != nil {
|
|
|
|
if aModule.base().BaseModuleName() == name {
|
|
|
|
returnedTag := b.bp.OtherModuleDependencyTag(aModule)
|
|
|
|
if tag == nil || returnedTag == tag {
|
|
|
|
deps = append(deps, dep{aModule, returnedTag})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if b.bp.OtherModuleName(module) == name {
|
|
|
|
returnedTag := b.bp.OtherModuleDependencyTag(module)
|
2019-04-17 14:47:37 +02:00
|
|
|
if tag == nil || returnedTag == tag {
|
2021-01-26 15:18:53 +01:00
|
|
|
deps = append(deps, dep{module, returnedTag})
|
2019-04-17 14:47:37 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
2021-04-26 21:47:28 +02:00
|
|
|
return deps
|
|
|
|
}
|
|
|
|
|
|
|
|
func (b *baseModuleContext) getDirectDepInternal(name string, tag blueprint.DependencyTag) (blueprint.Module, blueprint.DependencyTag) {
|
|
|
|
deps := b.getDirectDepsInternal(name, tag)
|
2019-04-17 14:47:37 +02:00
|
|
|
if len(deps) == 1 {
|
|
|
|
return deps[0].mod, deps[0].tag
|
|
|
|
} else if len(deps) >= 2 {
|
|
|
|
panic(fmt.Errorf("Multiple dependencies having same BaseModuleName() %q found from %q",
|
2019-06-07 01:13:11 +02:00
|
|
|
name, b.ModuleName()))
|
2019-04-17 14:47:37 +02:00
|
|
|
} else {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-26 21:47:28 +02:00
|
|
|
func (b *baseModuleContext) getDirectDepFirstTag(name string) (blueprint.Module, blueprint.DependencyTag) {
|
|
|
|
foundDeps := b.getDirectDepsInternal(name, nil)
|
|
|
|
deps := map[blueprint.Module]bool{}
|
|
|
|
for _, dep := range foundDeps {
|
|
|
|
deps[dep.mod] = true
|
|
|
|
}
|
|
|
|
if len(deps) == 1 {
|
|
|
|
return foundDeps[0].mod, foundDeps[0].tag
|
|
|
|
} else if len(deps) >= 2 {
|
|
|
|
// this could happen if two dependencies have the same name in different namespaces
|
|
|
|
// TODO(b/186554727): this should not occur if namespaces are handled within
|
|
|
|
// getDirectDepsInternal.
|
|
|
|
panic(fmt.Errorf("Multiple dependencies having same BaseModuleName() %q found from %q",
|
|
|
|
name, b.ModuleName()))
|
|
|
|
} else {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-07 01:13:11 +02:00
|
|
|
func (b *baseModuleContext) GetDirectDepsWithTag(tag blueprint.DependencyTag) []Module {
|
2019-05-02 00:50:51 +02:00
|
|
|
var deps []Module
|
2019-06-07 01:13:11 +02:00
|
|
|
b.VisitDirectDepsBlueprint(func(module blueprint.Module) {
|
2019-06-06 23:29:25 +02:00
|
|
|
if aModule, _ := module.(Module); aModule != nil {
|
2019-12-31 03:43:07 +01:00
|
|
|
if b.bp.OtherModuleDependencyTag(aModule) == tag {
|
2019-05-02 00:50:51 +02:00
|
|
|
deps = append(deps, aModule)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
return deps
|
|
|
|
}
|
|
|
|
|
2019-06-06 23:29:25 +02:00
|
|
|
func (m *moduleContext) GetDirectDepWithTag(name string, tag blueprint.DependencyTag) blueprint.Module {
|
|
|
|
module, _ := m.getDirectDepInternal(name, tag)
|
|
|
|
return module
|
2019-04-17 14:47:37 +02:00
|
|
|
}
|
|
|
|
|
2021-04-26 21:47:28 +02:00
|
|
|
// GetDirectDep returns the Module and DependencyTag for the direct dependency with the specified
|
|
|
|
// name, or nil if none exists. If there are multiple dependencies on the same module it returns the
|
|
|
|
// first DependencyTag.
|
2019-06-07 01:13:11 +02:00
|
|
|
func (b *baseModuleContext) GetDirectDep(name string) (blueprint.Module, blueprint.DependencyTag) {
|
2021-04-26 21:47:28 +02:00
|
|
|
return b.getDirectDepFirstTag(name)
|
2019-04-17 14:47:37 +02:00
|
|
|
}
|
|
|
|
|
2021-07-21 20:34:58 +02:00
|
|
|
func (b *baseModuleContext) ModuleFromName(name string) (blueprint.Module, bool) {
|
2022-04-26 15:38:20 +02:00
|
|
|
if !b.isBazelConversionMode() {
|
2021-07-21 20:34:58 +02:00
|
|
|
panic("cannot call ModuleFromName if not in bazel conversion mode")
|
|
|
|
}
|
2021-07-23 17:02:07 +02:00
|
|
|
if moduleName, _ := SrcIsModuleWithTag(name); moduleName != "" {
|
2021-07-21 20:34:58 +02:00
|
|
|
return b.bp.ModuleFromName(moduleName)
|
|
|
|
} else {
|
|
|
|
return b.bp.ModuleFromName(name)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-07 01:13:11 +02:00
|
|
|
func (b *baseModuleContext) VisitDirectDepsBlueprint(visit func(blueprint.Module)) {
|
2019-12-31 03:43:07 +01:00
|
|
|
b.bp.VisitDirectDeps(visit)
|
2017-11-16 09:11:20 +01:00
|
|
|
}
|
|
|
|
|
2019-06-07 01:13:11 +02:00
|
|
|
func (b *baseModuleContext) VisitDirectDeps(visit func(Module)) {
|
2019-12-31 03:43:07 +01:00
|
|
|
b.bp.VisitDirectDeps(func(module blueprint.Module) {
|
2021-05-13 03:38:35 +02:00
|
|
|
if aModule := b.validateAndroidModule(module, b.bp.OtherModuleDependencyTag(module), b.strictVisitDeps); aModule != nil {
|
2017-10-24 02:59:01 +02:00
|
|
|
visit(aModule)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-06-07 01:13:11 +02:00
|
|
|
func (b *baseModuleContext) VisitDirectDepsWithTag(tag blueprint.DependencyTag, visit func(Module)) {
|
2019-12-31 03:43:07 +01:00
|
|
|
b.bp.VisitDirectDeps(func(module blueprint.Module) {
|
2022-01-24 22:17:30 +01:00
|
|
|
if b.bp.OtherModuleDependencyTag(module) == tag {
|
|
|
|
if aModule := b.validateAndroidModule(module, b.bp.OtherModuleDependencyTag(module), b.strictVisitDeps); aModule != nil {
|
2017-12-31 02:54:27 +01:00
|
|
|
visit(aModule)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-06-07 01:13:11 +02:00
|
|
|
func (b *baseModuleContext) VisitDirectDepsIf(pred func(Module) bool, visit func(Module)) {
|
2019-12-31 03:43:07 +01:00
|
|
|
b.bp.VisitDirectDepsIf(
|
2017-10-24 02:59:01 +02:00
|
|
|
// pred
|
|
|
|
func(module blueprint.Module) bool {
|
2021-05-13 03:38:35 +02:00
|
|
|
if aModule := b.validateAndroidModule(module, b.bp.OtherModuleDependencyTag(module), b.strictVisitDeps); aModule != nil {
|
2017-10-24 02:59:01 +02:00
|
|
|
return pred(aModule)
|
|
|
|
} else {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// visit
|
|
|
|
func(module blueprint.Module) {
|
|
|
|
visit(module.(Module))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-06-07 01:13:11 +02:00
|
|
|
func (b *baseModuleContext) VisitDepsDepthFirst(visit func(Module)) {
|
2019-12-31 03:43:07 +01:00
|
|
|
b.bp.VisitDepsDepthFirst(func(module blueprint.Module) {
|
2021-05-13 03:38:35 +02:00
|
|
|
if aModule := b.validateAndroidModule(module, b.bp.OtherModuleDependencyTag(module), b.strictVisitDeps); aModule != nil {
|
2017-10-24 02:59:01 +02:00
|
|
|
visit(aModule)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-06-07 01:13:11 +02:00
|
|
|
func (b *baseModuleContext) VisitDepsDepthFirstIf(pred func(Module) bool, visit func(Module)) {
|
2019-12-31 03:43:07 +01:00
|
|
|
b.bp.VisitDepsDepthFirstIf(
|
2017-10-24 02:59:01 +02:00
|
|
|
// pred
|
|
|
|
func(module blueprint.Module) bool {
|
2021-05-13 03:38:35 +02:00
|
|
|
if aModule := b.validateAndroidModule(module, b.bp.OtherModuleDependencyTag(module), b.strictVisitDeps); aModule != nil {
|
2017-10-24 02:59:01 +02:00
|
|
|
return pred(aModule)
|
|
|
|
} else {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// visit
|
|
|
|
func(module blueprint.Module) {
|
|
|
|
visit(module.(Module))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-06-07 01:13:11 +02:00
|
|
|
func (b *baseModuleContext) WalkDepsBlueprint(visit func(blueprint.Module, blueprint.Module) bool) {
|
2019-12-31 03:43:07 +01:00
|
|
|
b.bp.WalkDeps(visit)
|
2019-02-27 23:19:50 +01:00
|
|
|
}
|
|
|
|
|
2019-06-07 01:13:11 +02:00
|
|
|
func (b *baseModuleContext) WalkDeps(visit func(Module, Module) bool) {
|
|
|
|
b.walkPath = []Module{b.Module()}
|
2020-03-31 12:31:36 +02:00
|
|
|
b.tagPath = []blueprint.DependencyTag{}
|
2019-12-31 03:43:07 +01:00
|
|
|
b.bp.WalkDeps(func(child, parent blueprint.Module) bool {
|
2019-06-07 01:13:11 +02:00
|
|
|
childAndroidModule, _ := child.(Module)
|
|
|
|
parentAndroidModule, _ := parent.(Module)
|
2017-10-24 02:59:01 +02:00
|
|
|
if childAndroidModule != nil && parentAndroidModule != nil {
|
2019-06-07 01:13:11 +02:00
|
|
|
// record walkPath before visit
|
|
|
|
for b.walkPath[len(b.walkPath)-1] != parentAndroidModule {
|
|
|
|
b.walkPath = b.walkPath[0 : len(b.walkPath)-1]
|
2020-03-31 12:31:36 +02:00
|
|
|
b.tagPath = b.tagPath[0 : len(b.tagPath)-1]
|
2019-06-07 01:13:11 +02:00
|
|
|
}
|
|
|
|
b.walkPath = append(b.walkPath, childAndroidModule)
|
2020-03-31 12:31:36 +02:00
|
|
|
b.tagPath = append(b.tagPath, b.OtherModuleDependencyTag(childAndroidModule))
|
2017-10-24 02:59:01 +02:00
|
|
|
return visit(childAndroidModule, parentAndroidModule)
|
|
|
|
} else {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-06-07 01:13:11 +02:00
|
|
|
func (b *baseModuleContext) GetWalkPath() []Module {
|
|
|
|
return b.walkPath
|
|
|
|
}
|
|
|
|
|
2020-03-31 12:31:36 +02:00
|
|
|
func (b *baseModuleContext) GetTagPath() []blueprint.DependencyTag {
|
|
|
|
return b.tagPath
|
|
|
|
}
|
|
|
|
|
2020-09-17 04:22:27 +02:00
|
|
|
func (b *baseModuleContext) VisitAllModuleVariants(visit func(Module)) {
|
|
|
|
b.bp.VisitAllModuleVariants(func(module blueprint.Module) {
|
|
|
|
visit(module.(Module))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func (b *baseModuleContext) PrimaryModule() Module {
|
|
|
|
return b.bp.PrimaryModule().(Module)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (b *baseModuleContext) FinalModule() Module {
|
|
|
|
return b.bp.FinalModule().(Module)
|
|
|
|
}
|
|
|
|
|
2021-02-06 04:59:11 +01:00
|
|
|
// IsMetaDependencyTag returns true for cross-cutting metadata dependencies.
|
|
|
|
func IsMetaDependencyTag(tag blueprint.DependencyTag) bool {
|
|
|
|
if tag == licenseKindTag {
|
|
|
|
return true
|
|
|
|
} else if tag == licensesTag {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2020-05-07 09:12:13 +02:00
|
|
|
// A regexp for removing boilerplate from BaseDependencyTag from the string representation of
|
|
|
|
// a dependency tag.
|
2020-07-28 06:26:48 +02:00
|
|
|
var tagCleaner = regexp.MustCompile(`\QBaseDependencyTag:{}\E(, )?`)
|
2020-05-07 09:12:13 +02:00
|
|
|
|
|
|
|
// PrettyPrintTag returns string representation of the tag, but prefers
|
|
|
|
// custom String() method if available.
|
|
|
|
func PrettyPrintTag(tag blueprint.DependencyTag) string {
|
|
|
|
// Use tag's custom String() method if available.
|
|
|
|
if stringer, ok := tag.(fmt.Stringer); ok {
|
|
|
|
return stringer.String()
|
|
|
|
}
|
|
|
|
|
|
|
|
// Otherwise, get a default string representation of the tag's struct.
|
2020-07-28 06:26:48 +02:00
|
|
|
tagString := fmt.Sprintf("%T: %+v", tag, tag)
|
2020-05-07 09:12:13 +02:00
|
|
|
|
|
|
|
// Remove the boilerplate from BaseDependencyTag as it adds no value.
|
|
|
|
tagString = tagCleaner.ReplaceAllString(tagString, "")
|
|
|
|
return tagString
|
|
|
|
}
|
|
|
|
|
|
|
|
func (b *baseModuleContext) GetPathString(skipFirst bool) string {
|
|
|
|
sb := strings.Builder{}
|
|
|
|
tagPath := b.GetTagPath()
|
|
|
|
walkPath := b.GetWalkPath()
|
|
|
|
if !skipFirst {
|
|
|
|
sb.WriteString(walkPath[0].String())
|
|
|
|
}
|
|
|
|
for i, m := range walkPath[1:] {
|
|
|
|
sb.WriteString("\n")
|
|
|
|
sb.WriteString(fmt.Sprintf(" via tag %s\n", PrettyPrintTag(tagPath[i])))
|
|
|
|
sb.WriteString(fmt.Sprintf(" -> %s", m.String()))
|
|
|
|
}
|
|
|
|
return sb.String()
|
|
|
|
}
|
|
|
|
|
2019-06-07 01:13:11 +02:00
|
|
|
func (m *moduleContext) ModuleSubDir() string {
|
|
|
|
return m.bp.ModuleSubDir()
|
2017-11-29 02:34:01 +01:00
|
|
|
}
|
|
|
|
|
2023-06-16 07:19:33 +02:00
|
|
|
func (m *moduleContext) SoongConfigTraceHash() string {
|
2023-05-15 11:06:31 +02:00
|
|
|
return m.module.base().commonProperties.SoongConfigTraceHash
|
|
|
|
}
|
|
|
|
|
2019-06-06 23:33:29 +02:00
|
|
|
func (b *baseModuleContext) Target() Target {
|
2019-06-06 23:29:25 +02:00
|
|
|
return b.target
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2019-06-06 23:33:29 +02:00
|
|
|
func (b *baseModuleContext) TargetPrimary() bool {
|
2019-06-06 23:29:25 +02:00
|
|
|
return b.targetPrimary
|
2016-09-13 18:59:14 +02:00
|
|
|
}
|
|
|
|
|
2019-06-06 23:33:29 +02:00
|
|
|
func (b *baseModuleContext) MultiTargets() []Target {
|
2019-06-06 23:29:25 +02:00
|
|
|
return b.multiTargets
|
2018-10-03 07:01:37 +02:00
|
|
|
}
|
|
|
|
|
2019-06-06 23:33:29 +02:00
|
|
|
func (b *baseModuleContext) Arch() Arch {
|
2019-06-06 23:29:25 +02:00
|
|
|
return b.target.Arch
|
2015-05-07 23:11:29 +02:00
|
|
|
}
|
|
|
|
|
2019-06-06 23:33:29 +02:00
|
|
|
func (b *baseModuleContext) Os() OsType {
|
2019-11-21 02:12:35 +01:00
|
|
|
return b.os
|
2015-11-25 02:53:15 +01:00
|
|
|
}
|
|
|
|
|
2019-06-06 23:33:29 +02:00
|
|
|
func (b *baseModuleContext) Host() bool {
|
2020-09-14 12:43:17 +02:00
|
|
|
return b.os.Class == Host
|
2015-03-24 19:13:38 +01:00
|
|
|
}
|
|
|
|
|
2019-06-06 23:33:29 +02:00
|
|
|
func (b *baseModuleContext) Device() bool {
|
2019-11-21 02:12:35 +01:00
|
|
|
return b.os.Class == Device
|
2015-03-24 19:13:38 +01:00
|
|
|
}
|
|
|
|
|
2019-06-06 23:33:29 +02:00
|
|
|
func (b *baseModuleContext) Darwin() bool {
|
2019-11-21 02:12:35 +01:00
|
|
|
return b.os == Darwin
|
2015-05-01 01:36:18 +02:00
|
|
|
}
|
|
|
|
|
2019-06-06 23:33:29 +02:00
|
|
|
func (b *baseModuleContext) Windows() bool {
|
2019-11-21 02:12:35 +01:00
|
|
|
return b.os == Windows
|
2017-04-04 21:59:48 +02:00
|
|
|
}
|
|
|
|
|
2019-06-06 23:33:29 +02:00
|
|
|
func (b *baseModuleContext) Debug() bool {
|
2019-06-06 23:29:25 +02:00
|
|
|
return b.debug
|
2015-03-24 19:13:38 +01:00
|
|
|
}
|
|
|
|
|
2019-06-06 23:33:29 +02:00
|
|
|
func (b *baseModuleContext) PrimaryArch() bool {
|
2019-06-06 23:29:25 +02:00
|
|
|
if len(b.config.Targets[b.target.Os]) <= 1 {
|
2017-05-09 22:45:28 +02:00
|
|
|
return true
|
|
|
|
}
|
2019-06-06 23:29:25 +02:00
|
|
|
return b.target.Arch.ArchType == b.config.Targets[b.target.Os][0].Arch.ArchType
|
2016-08-25 00:25:47 +02:00
|
|
|
}
|
|
|
|
|
2018-08-28 02:55:37 +02:00
|
|
|
// Makes this module a platform module, i.e. not specific to soc, device,
|
2019-06-25 09:47:17 +02:00
|
|
|
// product, or system_ext.
|
2019-06-07 01:57:04 +02:00
|
|
|
func (m *ModuleBase) MakeAsPlatform() {
|
|
|
|
m.commonProperties.Vendor = boolPtr(false)
|
|
|
|
m.commonProperties.Proprietary = boolPtr(false)
|
|
|
|
m.commonProperties.Soc_specific = boolPtr(false)
|
|
|
|
m.commonProperties.Product_specific = boolPtr(false)
|
2019-06-25 09:47:17 +02:00
|
|
|
m.commonProperties.System_ext_specific = boolPtr(false)
|
2018-08-28 02:55:37 +02:00
|
|
|
}
|
|
|
|
|
2019-10-08 12:34:03 +02:00
|
|
|
func (m *ModuleBase) MakeAsSystemExt() {
|
2019-11-19 17:49:42 +01:00
|
|
|
m.commonProperties.Vendor = boolPtr(false)
|
|
|
|
m.commonProperties.Proprietary = boolPtr(false)
|
|
|
|
m.commonProperties.Soc_specific = boolPtr(false)
|
|
|
|
m.commonProperties.Product_specific = boolPtr(false)
|
|
|
|
m.commonProperties.System_ext_specific = boolPtr(true)
|
2019-10-08 12:34:03 +02:00
|
|
|
}
|
|
|
|
|
2019-08-23 04:17:39 +02:00
|
|
|
// IsNativeBridgeSupported returns true if "native_bridge_supported" is explicitly set as "true"
|
|
|
|
func (m *ModuleBase) IsNativeBridgeSupported() bool {
|
|
|
|
return proptools.Bool(m.commonProperties.Native_bridge_supported)
|
|
|
|
}
|
|
|
|
|
2019-06-06 23:29:25 +02:00
|
|
|
func (m *moduleContext) InstallInData() bool {
|
|
|
|
return m.module.InstallInData()
|
2015-12-21 23:55:28 +01:00
|
|
|
}
|
|
|
|
|
2019-09-11 19:25:18 +02:00
|
|
|
func (m *moduleContext) InstallInTestcases() bool {
|
|
|
|
return m.module.InstallInTestcases()
|
|
|
|
}
|
|
|
|
|
2019-06-06 23:29:25 +02:00
|
|
|
func (m *moduleContext) InstallInSanitizerDir() bool {
|
|
|
|
return m.module.InstallInSanitizerDir()
|
2017-03-30 07:00:18 +02:00
|
|
|
}
|
|
|
|
|
2020-01-22 00:53:22 +01:00
|
|
|
func (m *moduleContext) InstallInRamdisk() bool {
|
|
|
|
return m.module.InstallInRamdisk()
|
|
|
|
}
|
|
|
|
|
2020-10-22 00:17:56 +02:00
|
|
|
func (m *moduleContext) InstallInVendorRamdisk() bool {
|
|
|
|
return m.module.InstallInVendorRamdisk()
|
|
|
|
}
|
|
|
|
|
2021-04-08 14:13:22 +02:00
|
|
|
func (m *moduleContext) InstallInDebugRamdisk() bool {
|
|
|
|
return m.module.InstallInDebugRamdisk()
|
|
|
|
}
|
|
|
|
|
2019-06-06 23:29:25 +02:00
|
|
|
func (m *moduleContext) InstallInRecovery() bool {
|
|
|
|
return m.module.InstallInRecovery()
|
2018-01-31 16:54:12 +01:00
|
|
|
}
|
|
|
|
|
2019-10-02 20:10:58 +02:00
|
|
|
func (m *moduleContext) InstallInRoot() bool {
|
|
|
|
return m.module.InstallInRoot()
|
|
|
|
}
|
|
|
|
|
2020-09-01 05:37:45 +02:00
|
|
|
func (m *moduleContext) InstallForceOS() (*OsType, *ArchType) {
|
2020-02-11 00:29:54 +01:00
|
|
|
return m.module.InstallForceOS()
|
|
|
|
}
|
|
|
|
|
2021-07-19 04:38:04 +02:00
|
|
|
func (m *moduleContext) InstallInVendor() bool {
|
|
|
|
return m.module.InstallInVendor()
|
|
|
|
}
|
|
|
|
|
2020-12-16 19:20:23 +01:00
|
|
|
func (m *moduleContext) skipInstall() bool {
|
2019-06-06 23:29:25 +02:00
|
|
|
if m.module.base().commonProperties.SkipInstall {
|
2017-04-27 02:34:03 +02:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2020-12-16 19:20:23 +01:00
|
|
|
if m.module.base().commonProperties.HideFromMake {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2018-05-08 00:28:05 +02:00
|
|
|
// We'll need a solution for choosing which of modules with the same name in different
|
|
|
|
// namespaces to install. For now, reuse the list of namespaces exported to Make as the
|
|
|
|
// list of namespaces to install in a Soong-only build.
|
2019-06-06 23:29:25 +02:00
|
|
|
if !m.module.base().commonProperties.NamespaceExportedToMake {
|
2018-05-08 00:28:05 +02:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2017-04-27 02:34:03 +02:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2019-10-02 07:05:35 +02:00
|
|
|
func (m *moduleContext) InstallFile(installPath InstallPath, name string, srcPath Path,
|
|
|
|
deps ...Path) InstallPath {
|
2021-11-13 02:41:02 +01:00
|
|
|
return m.installFile(installPath, name, srcPath, deps, false, nil)
|
2017-08-31 21:29:17 +02:00
|
|
|
}
|
|
|
|
|
2019-10-02 07:05:35 +02:00
|
|
|
func (m *moduleContext) InstallExecutable(installPath InstallPath, name string, srcPath Path,
|
|
|
|
deps ...Path) InstallPath {
|
2021-11-13 02:41:02 +01:00
|
|
|
return m.installFile(installPath, name, srcPath, deps, true, nil)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *moduleContext) InstallFileWithExtraFilesZip(installPath InstallPath, name string, srcPath Path,
|
|
|
|
extraZip Path, deps ...Path) InstallPath {
|
|
|
|
return m.installFile(installPath, name, srcPath, deps, false, &extraFilesZip{
|
|
|
|
zip: extraZip,
|
|
|
|
dir: installPath,
|
|
|
|
})
|
2017-08-31 21:29:17 +02:00
|
|
|
}
|
|
|
|
|
2020-12-01 23:00:21 +01:00
|
|
|
func (m *moduleContext) PackageFile(installPath InstallPath, name string, srcPath Path) PackagingSpec {
|
|
|
|
fullInstallPath := installPath.Join(m, name)
|
|
|
|
return m.packageFile(fullInstallPath, srcPath, false)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *moduleContext) packageFile(fullInstallPath InstallPath, srcPath Path, executable bool) PackagingSpec {
|
2021-07-14 06:52:04 +02:00
|
|
|
licenseFiles := m.Module().EffectiveLicenseFiles()
|
2020-12-01 23:00:21 +01:00
|
|
|
spec := PackagingSpec{
|
2021-07-14 06:52:04 +02:00
|
|
|
relPathInPackage: Rel(m, fullInstallPath.PartitionDir(), fullInstallPath.String()),
|
|
|
|
srcPath: srcPath,
|
|
|
|
symlinkTarget: "",
|
|
|
|
executable: executable,
|
|
|
|
effectiveLicenseFiles: &licenseFiles,
|
2022-03-21 07:13:38 +01:00
|
|
|
partition: fullInstallPath.partition,
|
2020-12-01 23:00:21 +01:00
|
|
|
}
|
|
|
|
m.packagingSpecs = append(m.packagingSpecs, spec)
|
|
|
|
return spec
|
|
|
|
}
|
|
|
|
|
2021-11-13 02:41:02 +01:00
|
|
|
func (m *moduleContext) installFile(installPath InstallPath, name string, srcPath Path, deps []Path,
|
|
|
|
executable bool, extraZip *extraFilesZip) InstallPath {
|
2015-04-02 23:37:16 +02:00
|
|
|
|
2019-06-06 23:29:25 +02:00
|
|
|
fullInstallPath := installPath.Join(m, name)
|
2020-06-04 02:26:16 +02:00
|
|
|
m.module.base().hooks.runInstallHooks(m, srcPath, fullInstallPath, false)
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2020-12-16 19:20:23 +01:00
|
|
|
if !m.skipInstall() {
|
2022-04-21 21:50:51 +02:00
|
|
|
deps = append(deps, InstallPaths(m.module.base().installFilesDepSet.ToList()).Paths()...)
|
2016-01-13 08:07:05 +01:00
|
|
|
|
2016-10-04 02:47:19 +02:00
|
|
|
var implicitDeps, orderOnlyDeps Paths
|
|
|
|
|
2019-06-06 23:29:25 +02:00
|
|
|
if m.Host() {
|
2016-10-04 02:47:19 +02:00
|
|
|
// Installed host modules might be used during the build, depend directly on their
|
|
|
|
// dependencies so their timestamp is updated whenever their dependency is updated
|
|
|
|
implicitDeps = deps
|
|
|
|
} else {
|
|
|
|
orderOnlyDeps = deps
|
|
|
|
}
|
|
|
|
|
2021-11-12 03:59:15 +01:00
|
|
|
if m.Config().KatiEnabled() {
|
2021-09-29 02:40:21 +02:00
|
|
|
// When creating the install rule in Soong but embedding in Make, write the rule to a
|
|
|
|
// makefile instead of directly to the ninja file so that main.mk can add the
|
|
|
|
// dependencies from the `required` property that are hard to resolve in Soong.
|
|
|
|
m.katiInstalls = append(m.katiInstalls, katiInstall{
|
|
|
|
from: srcPath,
|
|
|
|
to: fullInstallPath,
|
|
|
|
implicitDeps: implicitDeps,
|
|
|
|
orderOnlyDeps: orderOnlyDeps,
|
|
|
|
executable: executable,
|
2021-11-13 02:41:02 +01:00
|
|
|
extraFiles: extraZip,
|
2021-09-29 02:40:21 +02:00
|
|
|
})
|
|
|
|
} else {
|
|
|
|
rule := Cp
|
|
|
|
if executable {
|
|
|
|
rule = CpExecutable
|
|
|
|
}
|
add PackagingSpec
Currently, installation of a module is defined as an action of copying
the built artifact of the module to an install path like out/soong/host
(for host modules) and out/target/product/<device>/<partition> (for
device modules). After the modules are installed, the installed files
are further processed to create packages like system.img, vendor.img,
cvd-host-package.tar.gz, etc.
This notion of installation seems to have originated from the old time
when system.img is the primary product of the entire build process
(modulo a few more like root.img). Packaging the installed files as the
filesystem image was considered as a post-build step then.
However, this model doesn't seem to fit well to the current and future
environment where we have a lot more filesystem images (system, vendor,
system_ext, product, ...). The filesystem images themselves are even
grouped together to form a higher-level filesystem image like super.img.
Furthermore, things like cvd-host-package.tar.gz requires us to be able
to group some of the host tools in a format that isn't filesystem image.
Lastly, we are expected to have more filesystem images that are subsets
of system.img (and their friends) for the Android-like mini OS that will
be running on on-device virtual machines. These all imply that the
packaging (which we call installation today) is not a global post-build
step, but a part of the build rules for creating the package-like
modules.
A model better fits to the new sitatuation might be this; a module
specifies its built artifact and the path where it should be placed. The
latter path is not rooted at out/. It's a relative path to the root
directory which will be determined by another module that implements the
packaging. For example, cc_library will have ./lib (or ./lib64), not
out/target/product/<device>/<partition>/lib as the path. Then packages
like system.img, cvd-host-package.tar.gz, etc. are explicitly modeled as
modules and they have deps to other modules. Then the modules are placed
at the relative path under the package root, and the entire root
directory finally is packaged as the output file (be it img, tar.gz, or
whatever).
PackagingSpec is the first step to implement the new model. It abstracts
a request to place a built artifact at a certain path in a package. It
has extra information about whether the path should be a symlink or not,
and whether the path is for an executable. It currently is created when
InstallFiles (and its friends) are called, and can be retrieved via
the new method PackagingSpecs().
In this CL, no one is using PackagingSpec. The installation is still
done by the existing rules created in InstallFiles, etc. and the
structs are not used for the filesystem images like system.img.
Bug: 159685774
Bug: 172414391
Test: m
Change-Id: Ie1dec72d1ac14382fc3b74e5c850472e9320d6a3
2020-11-09 06:08:34 +01:00
|
|
|
|
2021-11-13 02:41:02 +01:00
|
|
|
extraCmds := ""
|
|
|
|
if extraZip != nil {
|
2022-05-19 17:11:51 +02:00
|
|
|
extraCmds += fmt.Sprintf(" && ( unzip -qDD -d '%s' '%s' 2>&1 | grep -v \"zipfile is empty\"; exit $${PIPESTATUS[0]} )",
|
2021-11-13 02:41:02 +01:00
|
|
|
extraZip.dir.String(), extraZip.zip.String())
|
2022-05-19 17:11:51 +02:00
|
|
|
extraCmds += " || ( code=$$?; if [ $$code -ne 0 -a $$code -ne 1 ]; then exit $$code; fi )"
|
2021-11-13 02:41:02 +01:00
|
|
|
implicitDeps = append(implicitDeps, extraZip.zip)
|
|
|
|
}
|
|
|
|
|
2021-09-29 02:40:21 +02:00
|
|
|
m.Build(pctx, BuildParams{
|
|
|
|
Rule: rule,
|
|
|
|
Description: "install " + fullInstallPath.Base(),
|
|
|
|
Output: fullInstallPath,
|
|
|
|
Input: srcPath,
|
|
|
|
Implicits: implicitDeps,
|
|
|
|
OrderOnly: orderOnlyDeps,
|
|
|
|
Default: !m.Config().KatiEnabled(),
|
2021-11-13 02:41:02 +01:00
|
|
|
Args: map[string]string{
|
|
|
|
"extraCmds": extraCmds,
|
|
|
|
},
|
2021-09-29 02:40:21 +02:00
|
|
|
})
|
|
|
|
}
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2019-06-06 23:29:25 +02:00
|
|
|
m.installFiles = append(m.installFiles, fullInstallPath)
|
2016-01-13 08:07:05 +01:00
|
|
|
}
|
add PackagingSpec
Currently, installation of a module is defined as an action of copying
the built artifact of the module to an install path like out/soong/host
(for host modules) and out/target/product/<device>/<partition> (for
device modules). After the modules are installed, the installed files
are further processed to create packages like system.img, vendor.img,
cvd-host-package.tar.gz, etc.
This notion of installation seems to have originated from the old time
when system.img is the primary product of the entire build process
(modulo a few more like root.img). Packaging the installed files as the
filesystem image was considered as a post-build step then.
However, this model doesn't seem to fit well to the current and future
environment where we have a lot more filesystem images (system, vendor,
system_ext, product, ...). The filesystem images themselves are even
grouped together to form a higher-level filesystem image like super.img.
Furthermore, things like cvd-host-package.tar.gz requires us to be able
to group some of the host tools in a format that isn't filesystem image.
Lastly, we are expected to have more filesystem images that are subsets
of system.img (and their friends) for the Android-like mini OS that will
be running on on-device virtual machines. These all imply that the
packaging (which we call installation today) is not a global post-build
step, but a part of the build rules for creating the package-like
modules.
A model better fits to the new sitatuation might be this; a module
specifies its built artifact and the path where it should be placed. The
latter path is not rooted at out/. It's a relative path to the root
directory which will be determined by another module that implements the
packaging. For example, cc_library will have ./lib (or ./lib64), not
out/target/product/<device>/<partition>/lib as the path. Then packages
like system.img, cvd-host-package.tar.gz, etc. are explicitly modeled as
modules and they have deps to other modules. Then the modules are placed
at the relative path under the package root, and the entire root
directory finally is packaged as the output file (be it img, tar.gz, or
whatever).
PackagingSpec is the first step to implement the new model. It abstracts
a request to place a built artifact at a certain path in a package. It
has extra information about whether the path should be a symlink or not,
and whether the path is for an executable. It currently is created when
InstallFiles (and its friends) are called, and can be retrieved via
the new method PackagingSpecs().
In this CL, no one is using PackagingSpec. The installation is still
done by the existing rules created in InstallFiles, etc. and the
structs are not used for the filesystem images like system.img.
Bug: 159685774
Bug: 172414391
Test: m
Change-Id: Ie1dec72d1ac14382fc3b74e5c850472e9320d6a3
2020-11-09 06:08:34 +01:00
|
|
|
|
2020-12-01 23:00:21 +01:00
|
|
|
m.packageFile(fullInstallPath, srcPath, executable)
|
add PackagingSpec
Currently, installation of a module is defined as an action of copying
the built artifact of the module to an install path like out/soong/host
(for host modules) and out/target/product/<device>/<partition> (for
device modules). After the modules are installed, the installed files
are further processed to create packages like system.img, vendor.img,
cvd-host-package.tar.gz, etc.
This notion of installation seems to have originated from the old time
when system.img is the primary product of the entire build process
(modulo a few more like root.img). Packaging the installed files as the
filesystem image was considered as a post-build step then.
However, this model doesn't seem to fit well to the current and future
environment where we have a lot more filesystem images (system, vendor,
system_ext, product, ...). The filesystem images themselves are even
grouped together to form a higher-level filesystem image like super.img.
Furthermore, things like cvd-host-package.tar.gz requires us to be able
to group some of the host tools in a format that isn't filesystem image.
Lastly, we are expected to have more filesystem images that are subsets
of system.img (and their friends) for the Android-like mini OS that will
be running on on-device virtual machines. These all imply that the
packaging (which we call installation today) is not a global post-build
step, but a part of the build rules for creating the package-like
modules.
A model better fits to the new sitatuation might be this; a module
specifies its built artifact and the path where it should be placed. The
latter path is not rooted at out/. It's a relative path to the root
directory which will be determined by another module that implements the
packaging. For example, cc_library will have ./lib (or ./lib64), not
out/target/product/<device>/<partition>/lib as the path. Then packages
like system.img, cvd-host-package.tar.gz, etc. are explicitly modeled as
modules and they have deps to other modules. Then the modules are placed
at the relative path under the package root, and the entire root
directory finally is packaged as the output file (be it img, tar.gz, or
whatever).
PackagingSpec is the first step to implement the new model. It abstracts
a request to place a built artifact at a certain path in a package. It
has extra information about whether the path should be a symlink or not,
and whether the path is for an executable. It currently is created when
InstallFiles (and its friends) are called, and can be retrieved via
the new method PackagingSpecs().
In this CL, no one is using PackagingSpec. The installation is still
done by the existing rules created in InstallFiles, etc. and the
structs are not used for the filesystem images like system.img.
Bug: 159685774
Bug: 172414391
Test: m
Change-Id: Ie1dec72d1ac14382fc3b74e5c850472e9320d6a3
2020-11-09 06:08:34 +01:00
|
|
|
|
2019-06-06 23:29:25 +02:00
|
|
|
m.checkbuildFiles = append(m.checkbuildFiles, srcPath)
|
2020-12-16 19:20:23 +01:00
|
|
|
|
2015-04-02 23:37:16 +02:00
|
|
|
return fullInstallPath
|
|
|
|
}
|
|
|
|
|
2019-10-02 07:05:35 +02:00
|
|
|
func (m *moduleContext) InstallSymlink(installPath InstallPath, name string, srcPath InstallPath) InstallPath {
|
2019-06-06 23:29:25 +02:00
|
|
|
fullInstallPath := installPath.Join(m, name)
|
2020-06-04 02:26:16 +02:00
|
|
|
m.module.base().hooks.runInstallHooks(m, srcPath, fullInstallPath, true)
|
2016-01-11 21:49:11 +01:00
|
|
|
|
add PackagingSpec
Currently, installation of a module is defined as an action of copying
the built artifact of the module to an install path like out/soong/host
(for host modules) and out/target/product/<device>/<partition> (for
device modules). After the modules are installed, the installed files
are further processed to create packages like system.img, vendor.img,
cvd-host-package.tar.gz, etc.
This notion of installation seems to have originated from the old time
when system.img is the primary product of the entire build process
(modulo a few more like root.img). Packaging the installed files as the
filesystem image was considered as a post-build step then.
However, this model doesn't seem to fit well to the current and future
environment where we have a lot more filesystem images (system, vendor,
system_ext, product, ...). The filesystem images themselves are even
grouped together to form a higher-level filesystem image like super.img.
Furthermore, things like cvd-host-package.tar.gz requires us to be able
to group some of the host tools in a format that isn't filesystem image.
Lastly, we are expected to have more filesystem images that are subsets
of system.img (and their friends) for the Android-like mini OS that will
be running on on-device virtual machines. These all imply that the
packaging (which we call installation today) is not a global post-build
step, but a part of the build rules for creating the package-like
modules.
A model better fits to the new sitatuation might be this; a module
specifies its built artifact and the path where it should be placed. The
latter path is not rooted at out/. It's a relative path to the root
directory which will be determined by another module that implements the
packaging. For example, cc_library will have ./lib (or ./lib64), not
out/target/product/<device>/<partition>/lib as the path. Then packages
like system.img, cvd-host-package.tar.gz, etc. are explicitly modeled as
modules and they have deps to other modules. Then the modules are placed
at the relative path under the package root, and the entire root
directory finally is packaged as the output file (be it img, tar.gz, or
whatever).
PackagingSpec is the first step to implement the new model. It abstracts
a request to place a built artifact at a certain path in a package. It
has extra information about whether the path should be a symlink or not,
and whether the path is for an executable. It currently is created when
InstallFiles (and its friends) are called, and can be retrieved via
the new method PackagingSpecs().
In this CL, no one is using PackagingSpec. The installation is still
done by the existing rules created in InstallFiles, etc. and the
structs are not used for the filesystem images like system.img.
Bug: 159685774
Bug: 172414391
Test: m
Change-Id: Ie1dec72d1ac14382fc3b74e5c850472e9320d6a3
2020-11-09 06:08:34 +01:00
|
|
|
relPath, err := filepath.Rel(path.Dir(fullInstallPath.String()), srcPath.String())
|
|
|
|
if err != nil {
|
|
|
|
panic(fmt.Sprintf("Unable to generate symlink between %q and %q: %s", fullInstallPath.Base(), srcPath.Base(), err))
|
|
|
|
}
|
2020-12-16 19:20:23 +01:00
|
|
|
if !m.skipInstall() {
|
2016-10-07 01:12:58 +02:00
|
|
|
|
2021-11-12 03:59:15 +01:00
|
|
|
if m.Config().KatiEnabled() {
|
2021-09-29 02:40:21 +02:00
|
|
|
// When creating the symlink rule in Soong but embedding in Make, write the rule to a
|
|
|
|
// makefile instead of directly to the ninja file so that main.mk can add the
|
|
|
|
// dependencies from the `required` property that are hard to resolve in Soong.
|
|
|
|
m.katiSymlinks = append(m.katiSymlinks, katiInstall{
|
|
|
|
from: srcPath,
|
|
|
|
to: fullInstallPath,
|
|
|
|
})
|
|
|
|
} else {
|
2021-11-10 01:37:52 +01:00
|
|
|
// The symlink doesn't need updating when the target is modified, but we sometimes
|
|
|
|
// have a dependency on a symlink to a binary instead of to the binary directly, and
|
|
|
|
// the mtime of the symlink must be updated when the binary is modified, so use a
|
|
|
|
// normal dependency here instead of an order-only dependency.
|
2021-09-29 02:40:21 +02:00
|
|
|
m.Build(pctx, BuildParams{
|
|
|
|
Rule: Symlink,
|
|
|
|
Description: "install symlink " + fullInstallPath.Base(),
|
|
|
|
Output: fullInstallPath,
|
|
|
|
Input: srcPath,
|
|
|
|
Default: !m.Config().KatiEnabled(),
|
|
|
|
Args: map[string]string{
|
|
|
|
"fromPath": relPath,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
2016-01-11 21:49:11 +01:00
|
|
|
|
2019-06-06 23:29:25 +02:00
|
|
|
m.installFiles = append(m.installFiles, fullInstallPath)
|
|
|
|
m.checkbuildFiles = append(m.checkbuildFiles, srcPath)
|
2016-01-11 21:49:11 +01:00
|
|
|
}
|
add PackagingSpec
Currently, installation of a module is defined as an action of copying
the built artifact of the module to an install path like out/soong/host
(for host modules) and out/target/product/<device>/<partition> (for
device modules). After the modules are installed, the installed files
are further processed to create packages like system.img, vendor.img,
cvd-host-package.tar.gz, etc.
This notion of installation seems to have originated from the old time
when system.img is the primary product of the entire build process
(modulo a few more like root.img). Packaging the installed files as the
filesystem image was considered as a post-build step then.
However, this model doesn't seem to fit well to the current and future
environment where we have a lot more filesystem images (system, vendor,
system_ext, product, ...). The filesystem images themselves are even
grouped together to form a higher-level filesystem image like super.img.
Furthermore, things like cvd-host-package.tar.gz requires us to be able
to group some of the host tools in a format that isn't filesystem image.
Lastly, we are expected to have more filesystem images that are subsets
of system.img (and their friends) for the Android-like mini OS that will
be running on on-device virtual machines. These all imply that the
packaging (which we call installation today) is not a global post-build
step, but a part of the build rules for creating the package-like
modules.
A model better fits to the new sitatuation might be this; a module
specifies its built artifact and the path where it should be placed. The
latter path is not rooted at out/. It's a relative path to the root
directory which will be determined by another module that implements the
packaging. For example, cc_library will have ./lib (or ./lib64), not
out/target/product/<device>/<partition>/lib as the path. Then packages
like system.img, cvd-host-package.tar.gz, etc. are explicitly modeled as
modules and they have deps to other modules. Then the modules are placed
at the relative path under the package root, and the entire root
directory finally is packaged as the output file (be it img, tar.gz, or
whatever).
PackagingSpec is the first step to implement the new model. It abstracts
a request to place a built artifact at a certain path in a package. It
has extra information about whether the path should be a symlink or not,
and whether the path is for an executable. It currently is created when
InstallFiles (and its friends) are called, and can be retrieved via
the new method PackagingSpecs().
In this CL, no one is using PackagingSpec. The installation is still
done by the existing rules created in InstallFiles, etc. and the
structs are not used for the filesystem images like system.img.
Bug: 159685774
Bug: 172414391
Test: m
Change-Id: Ie1dec72d1ac14382fc3b74e5c850472e9320d6a3
2020-11-09 06:08:34 +01:00
|
|
|
|
|
|
|
m.packagingSpecs = append(m.packagingSpecs, PackagingSpec{
|
|
|
|
relPathInPackage: Rel(m, fullInstallPath.PartitionDir(), fullInstallPath.String()),
|
|
|
|
srcPath: nil,
|
|
|
|
symlinkTarget: relPath,
|
|
|
|
executable: false,
|
2022-03-21 07:13:38 +01:00
|
|
|
partition: fullInstallPath.partition,
|
add PackagingSpec
Currently, installation of a module is defined as an action of copying
the built artifact of the module to an install path like out/soong/host
(for host modules) and out/target/product/<device>/<partition> (for
device modules). After the modules are installed, the installed files
are further processed to create packages like system.img, vendor.img,
cvd-host-package.tar.gz, etc.
This notion of installation seems to have originated from the old time
when system.img is the primary product of the entire build process
(modulo a few more like root.img). Packaging the installed files as the
filesystem image was considered as a post-build step then.
However, this model doesn't seem to fit well to the current and future
environment where we have a lot more filesystem images (system, vendor,
system_ext, product, ...). The filesystem images themselves are even
grouped together to form a higher-level filesystem image like super.img.
Furthermore, things like cvd-host-package.tar.gz requires us to be able
to group some of the host tools in a format that isn't filesystem image.
Lastly, we are expected to have more filesystem images that are subsets
of system.img (and their friends) for the Android-like mini OS that will
be running on on-device virtual machines. These all imply that the
packaging (which we call installation today) is not a global post-build
step, but a part of the build rules for creating the package-like
modules.
A model better fits to the new sitatuation might be this; a module
specifies its built artifact and the path where it should be placed. The
latter path is not rooted at out/. It's a relative path to the root
directory which will be determined by another module that implements the
packaging. For example, cc_library will have ./lib (or ./lib64), not
out/target/product/<device>/<partition>/lib as the path. Then packages
like system.img, cvd-host-package.tar.gz, etc. are explicitly modeled as
modules and they have deps to other modules. Then the modules are placed
at the relative path under the package root, and the entire root
directory finally is packaged as the output file (be it img, tar.gz, or
whatever).
PackagingSpec is the first step to implement the new model. It abstracts
a request to place a built artifact at a certain path in a package. It
has extra information about whether the path should be a symlink or not,
and whether the path is for an executable. It currently is created when
InstallFiles (and its friends) are called, and can be retrieved via
the new method PackagingSpecs().
In this CL, no one is using PackagingSpec. The installation is still
done by the existing rules created in InstallFiles, etc. and the
structs are not used for the filesystem images like system.img.
Bug: 159685774
Bug: 172414391
Test: m
Change-Id: Ie1dec72d1ac14382fc3b74e5c850472e9320d6a3
2020-11-09 06:08:34 +01:00
|
|
|
})
|
|
|
|
|
2016-01-11 21:49:11 +01:00
|
|
|
return fullInstallPath
|
|
|
|
}
|
|
|
|
|
2019-02-25 03:05:47 +01:00
|
|
|
// installPath/name -> absPath where absPath might be a path that is available only at runtime
|
|
|
|
// (e.g. /apex/...)
|
2019-10-02 07:05:35 +02:00
|
|
|
func (m *moduleContext) InstallAbsoluteSymlink(installPath InstallPath, name string, absPath string) InstallPath {
|
2019-06-06 23:29:25 +02:00
|
|
|
fullInstallPath := installPath.Join(m, name)
|
2020-06-04 02:26:16 +02:00
|
|
|
m.module.base().hooks.runInstallHooks(m, nil, fullInstallPath, true)
|
2019-02-25 03:05:47 +01:00
|
|
|
|
2020-12-16 19:20:23 +01:00
|
|
|
if !m.skipInstall() {
|
2021-11-12 03:59:15 +01:00
|
|
|
if m.Config().KatiEnabled() {
|
2021-09-29 02:40:21 +02:00
|
|
|
// When creating the symlink rule in Soong but embedding in Make, write the rule to a
|
|
|
|
// makefile instead of directly to the ninja file so that main.mk can add the
|
|
|
|
// dependencies from the `required` property that are hard to resolve in Soong.
|
|
|
|
m.katiSymlinks = append(m.katiSymlinks, katiInstall{
|
|
|
|
absFrom: absPath,
|
|
|
|
to: fullInstallPath,
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
m.Build(pctx, BuildParams{
|
|
|
|
Rule: Symlink,
|
|
|
|
Description: "install symlink " + fullInstallPath.Base() + " -> " + absPath,
|
|
|
|
Output: fullInstallPath,
|
|
|
|
Default: !m.Config().KatiEnabled(),
|
|
|
|
Args: map[string]string{
|
|
|
|
"fromPath": absPath,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
2019-02-25 03:05:47 +01:00
|
|
|
|
2019-06-06 23:29:25 +02:00
|
|
|
m.installFiles = append(m.installFiles, fullInstallPath)
|
2019-02-25 03:05:47 +01:00
|
|
|
}
|
add PackagingSpec
Currently, installation of a module is defined as an action of copying
the built artifact of the module to an install path like out/soong/host
(for host modules) and out/target/product/<device>/<partition> (for
device modules). After the modules are installed, the installed files
are further processed to create packages like system.img, vendor.img,
cvd-host-package.tar.gz, etc.
This notion of installation seems to have originated from the old time
when system.img is the primary product of the entire build process
(modulo a few more like root.img). Packaging the installed files as the
filesystem image was considered as a post-build step then.
However, this model doesn't seem to fit well to the current and future
environment where we have a lot more filesystem images (system, vendor,
system_ext, product, ...). The filesystem images themselves are even
grouped together to form a higher-level filesystem image like super.img.
Furthermore, things like cvd-host-package.tar.gz requires us to be able
to group some of the host tools in a format that isn't filesystem image.
Lastly, we are expected to have more filesystem images that are subsets
of system.img (and their friends) for the Android-like mini OS that will
be running on on-device virtual machines. These all imply that the
packaging (which we call installation today) is not a global post-build
step, but a part of the build rules for creating the package-like
modules.
A model better fits to the new sitatuation might be this; a module
specifies its built artifact and the path where it should be placed. The
latter path is not rooted at out/. It's a relative path to the root
directory which will be determined by another module that implements the
packaging. For example, cc_library will have ./lib (or ./lib64), not
out/target/product/<device>/<partition>/lib as the path. Then packages
like system.img, cvd-host-package.tar.gz, etc. are explicitly modeled as
modules and they have deps to other modules. Then the modules are placed
at the relative path under the package root, and the entire root
directory finally is packaged as the output file (be it img, tar.gz, or
whatever).
PackagingSpec is the first step to implement the new model. It abstracts
a request to place a built artifact at a certain path in a package. It
has extra information about whether the path should be a symlink or not,
and whether the path is for an executable. It currently is created when
InstallFiles (and its friends) are called, and can be retrieved via
the new method PackagingSpecs().
In this CL, no one is using PackagingSpec. The installation is still
done by the existing rules created in InstallFiles, etc. and the
structs are not used for the filesystem images like system.img.
Bug: 159685774
Bug: 172414391
Test: m
Change-Id: Ie1dec72d1ac14382fc3b74e5c850472e9320d6a3
2020-11-09 06:08:34 +01:00
|
|
|
|
|
|
|
m.packagingSpecs = append(m.packagingSpecs, PackagingSpec{
|
|
|
|
relPathInPackage: Rel(m, fullInstallPath.PartitionDir(), fullInstallPath.String()),
|
|
|
|
srcPath: nil,
|
|
|
|
symlinkTarget: absPath,
|
|
|
|
executable: false,
|
2022-03-21 07:13:38 +01:00
|
|
|
partition: fullInstallPath.partition,
|
add PackagingSpec
Currently, installation of a module is defined as an action of copying
the built artifact of the module to an install path like out/soong/host
(for host modules) and out/target/product/<device>/<partition> (for
device modules). After the modules are installed, the installed files
are further processed to create packages like system.img, vendor.img,
cvd-host-package.tar.gz, etc.
This notion of installation seems to have originated from the old time
when system.img is the primary product of the entire build process
(modulo a few more like root.img). Packaging the installed files as the
filesystem image was considered as a post-build step then.
However, this model doesn't seem to fit well to the current and future
environment where we have a lot more filesystem images (system, vendor,
system_ext, product, ...). The filesystem images themselves are even
grouped together to form a higher-level filesystem image like super.img.
Furthermore, things like cvd-host-package.tar.gz requires us to be able
to group some of the host tools in a format that isn't filesystem image.
Lastly, we are expected to have more filesystem images that are subsets
of system.img (and their friends) for the Android-like mini OS that will
be running on on-device virtual machines. These all imply that the
packaging (which we call installation today) is not a global post-build
step, but a part of the build rules for creating the package-like
modules.
A model better fits to the new sitatuation might be this; a module
specifies its built artifact and the path where it should be placed. The
latter path is not rooted at out/. It's a relative path to the root
directory which will be determined by another module that implements the
packaging. For example, cc_library will have ./lib (or ./lib64), not
out/target/product/<device>/<partition>/lib as the path. Then packages
like system.img, cvd-host-package.tar.gz, etc. are explicitly modeled as
modules and they have deps to other modules. Then the modules are placed
at the relative path under the package root, and the entire root
directory finally is packaged as the output file (be it img, tar.gz, or
whatever).
PackagingSpec is the first step to implement the new model. It abstracts
a request to place a built artifact at a certain path in a package. It
has extra information about whether the path should be a symlink or not,
and whether the path is for an executable. It currently is created when
InstallFiles (and its friends) are called, and can be retrieved via
the new method PackagingSpecs().
In this CL, no one is using PackagingSpec. The installation is still
done by the existing rules created in InstallFiles, etc. and the
structs are not used for the filesystem images like system.img.
Bug: 159685774
Bug: 172414391
Test: m
Change-Id: Ie1dec72d1ac14382fc3b74e5c850472e9320d6a3
2020-11-09 06:08:34 +01:00
|
|
|
})
|
|
|
|
|
2019-02-25 03:05:47 +01:00
|
|
|
return fullInstallPath
|
|
|
|
}
|
|
|
|
|
2019-06-06 23:29:25 +02:00
|
|
|
func (m *moduleContext) CheckbuildFile(srcPath Path) {
|
|
|
|
m.checkbuildFiles = append(m.checkbuildFiles, srcPath)
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2020-11-10 21:27:45 +01:00
|
|
|
func (m *moduleContext) blueprintModuleContext() blueprint.ModuleContext {
|
|
|
|
return m.bp
|
|
|
|
}
|
|
|
|
|
2022-03-16 01:49:24 +01:00
|
|
|
func (m *moduleContext) LicenseMetadataFile() Path {
|
|
|
|
return m.module.base().licenseMetadataFile
|
|
|
|
}
|
|
|
|
|
2021-07-12 21:12:12 +02:00
|
|
|
// SrcIsModule decodes module references in the format ":unqualified-name" or "//namespace:name"
|
|
|
|
// into the module name, or empty string if the input was not a module reference.
|
2019-05-29 23:40:35 +02:00
|
|
|
func SrcIsModule(s string) (module string) {
|
2021-07-12 21:12:12 +02:00
|
|
|
if len(s) > 1 {
|
|
|
|
if s[0] == ':' {
|
|
|
|
module = s[1:]
|
|
|
|
if !isUnqualifiedModuleName(module) {
|
|
|
|
// The module name should be unqualified but is not so do not treat it as a module.
|
|
|
|
module = ""
|
|
|
|
}
|
|
|
|
} else if s[0] == '/' && s[1] == '/' {
|
|
|
|
module = s
|
|
|
|
}
|
2016-12-14 00:23:47 +01:00
|
|
|
}
|
2021-07-12 21:12:12 +02:00
|
|
|
return module
|
2016-12-14 00:23:47 +01:00
|
|
|
}
|
|
|
|
|
2021-07-15 11:18:21 +02:00
|
|
|
// SrcIsModuleWithTag decodes module references in the format ":unqualified-name{.tag}" or
|
|
|
|
// "//namespace:name{.tag}" into the module name and tag, ":unqualified-name" or "//namespace:name"
|
|
|
|
// into the module name and an empty string for the tag, or empty strings if the input was not a
|
|
|
|
// module reference.
|
2019-05-29 23:40:35 +02:00
|
|
|
func SrcIsModuleWithTag(s string) (module, tag string) {
|
2021-07-12 21:12:12 +02:00
|
|
|
if len(s) > 1 {
|
|
|
|
if s[0] == ':' {
|
|
|
|
module = s[1:]
|
|
|
|
} else if s[0] == '/' && s[1] == '/' {
|
|
|
|
module = s
|
|
|
|
}
|
|
|
|
|
|
|
|
if module != "" {
|
|
|
|
if tagStart := strings.IndexByte(module, '{'); tagStart > 0 {
|
|
|
|
if module[len(module)-1] == '}' {
|
|
|
|
tag = module[tagStart+1 : len(module)-1]
|
|
|
|
module = module[:tagStart]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if s[0] == ':' && !isUnqualifiedModuleName(module) {
|
|
|
|
// The module name should be unqualified but is not so do not treat it as a module.
|
|
|
|
module = ""
|
|
|
|
tag = ""
|
2019-05-29 23:40:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-07-12 21:12:12 +02:00
|
|
|
|
|
|
|
return module, tag
|
|
|
|
}
|
|
|
|
|
|
|
|
// isUnqualifiedModuleName makes sure that the supplied module is an unqualified module name, i.e.
|
|
|
|
// does not contain any /.
|
|
|
|
func isUnqualifiedModuleName(module string) bool {
|
|
|
|
return strings.IndexByte(module, '/') == -1
|
2019-05-29 23:40:35 +02:00
|
|
|
}
|
|
|
|
|
2021-07-09 18:10:35 +02:00
|
|
|
// sourceOrOutputDependencyTag is the dependency tag added automatically by pathDepsMutator for any
|
|
|
|
// module reference in a property annotated with `android:"path"` or passed to ExtractSourceDeps
|
|
|
|
// or ExtractSourcesDeps.
|
|
|
|
//
|
|
|
|
// If uniquely identifies the dependency that was added as it contains both the module name used to
|
|
|
|
// add the dependency as well as the tag. That makes it very simple to find the matching dependency
|
|
|
|
// in GetModuleFromPathDep as all it needs to do is find the dependency whose tag matches the tag
|
|
|
|
// used to add it. It does not need to check that the module name as returned by one of
|
|
|
|
// Module.Name(), BaseModuleContext.OtherModuleName() or ModuleBase.BaseModuleName() matches the
|
|
|
|
// name supplied in the tag. That means it does not need to handle differences in module names
|
|
|
|
// caused by prebuilt_ prefix, or fully qualified module names.
|
2019-05-29 23:40:35 +02:00
|
|
|
type sourceOrOutputDependencyTag struct {
|
2016-12-14 00:23:47 +01:00
|
|
|
blueprint.BaseDependencyTag
|
2021-07-09 18:10:35 +02:00
|
|
|
|
|
|
|
// The name of the module.
|
|
|
|
moduleName string
|
|
|
|
|
|
|
|
// The tag that will be passed to the module's OutputFileProducer.OutputFiles(tag) method.
|
2019-05-29 23:40:35 +02:00
|
|
|
tag string
|
2016-12-14 00:23:47 +01:00
|
|
|
}
|
|
|
|
|
2021-07-09 18:10:35 +02:00
|
|
|
func sourceOrOutputDepTag(moduleName, tag string) blueprint.DependencyTag {
|
|
|
|
return sourceOrOutputDependencyTag{moduleName: moduleName, tag: tag}
|
2019-05-29 23:40:35 +02:00
|
|
|
}
|
|
|
|
|
Support customizing behavior around sourceOrOutputDependencyTag
Previously, modules customized behavior around the handling of
sourceOrOutputDependencyTag by comparing them to android.SourceDepTag
and retrieving the module using something like this:
ctx.GetDirectDepWithTag(m, android.SourceDepTag)
The problem with that is it does not allow an output tag to be
specified and does not handle fully qualified names properly.
This adds the following:
* IsSourceDepTag and IsSourceDepTagWithOutputTag to check whether a
blueprint.DependencyTag is a sourceOrOutputDependencyTag. The latter
also checks that it has the correct output tag.
* GetModuleFromPathDep(ctx, moduleName, outputTag) as a replacement for
ctx.GetDirectDepWithTag(m, android.SourceDepTag).
Replaces usages of:
* t == SourceDepTag with IsSourceDepTagWithOutputTag(t, "")
* ctx.GetDirectDepWithTag(m, android.SourceDepTag) with
GetModuleFromPathDep(ctx, m, "")
It also deprecates the following:
* android.SourcDepTag - as a follow up change needs to modify the
sourceOrOutputDependencyTag will make this useless.
* ExpandSources, ExpandsSources - copies existing deprecated messages
from the implementation to the interface so that they can be seen
by users of that interface.
Bug: 193228441
Test: m nothing
Change-Id: I8c397232b8d7dc1f9702c04ad45ea7819d4631ae
2021-07-09 18:38:55 +02:00
|
|
|
// IsSourceDepTagWithOutputTag returns true if the supplied blueprint.DependencyTag is one that was
|
|
|
|
// used to add dependencies by either ExtractSourceDeps, ExtractSourcesDeps or automatically for
|
|
|
|
// properties tagged with `android:"path"` AND it was added using a module reference of
|
|
|
|
// :moduleName{outputTag}.
|
|
|
|
func IsSourceDepTagWithOutputTag(depTag blueprint.DependencyTag, outputTag string) bool {
|
|
|
|
t, ok := depTag.(sourceOrOutputDependencyTag)
|
|
|
|
return ok && t.tag == outputTag
|
|
|
|
}
|
|
|
|
|
2017-12-12 01:29:02 +01:00
|
|
|
// Adds necessary dependencies to satisfy filegroup or generated sources modules listed in srcFiles
|
|
|
|
// using ":module" syntax, if any.
|
2019-03-05 07:35:41 +01:00
|
|
|
//
|
|
|
|
// Deprecated: tag the property with `android:"path"` instead.
|
2016-12-14 00:23:47 +01:00
|
|
|
func ExtractSourcesDeps(ctx BottomUpMutatorContext, srcFiles []string) {
|
2017-04-10 20:27:50 +02:00
|
|
|
set := make(map[string]bool)
|
|
|
|
|
2016-12-14 00:23:47 +01:00
|
|
|
for _, s := range srcFiles {
|
2019-05-29 23:40:35 +02:00
|
|
|
if m, t := SrcIsModuleWithTag(s); m != "" {
|
|
|
|
if _, found := set[s]; found {
|
|
|
|
ctx.ModuleErrorf("found source dependency duplicate: %q!", s)
|
2017-04-10 20:27:50 +02:00
|
|
|
} else {
|
2019-05-29 23:40:35 +02:00
|
|
|
set[s] = true
|
2021-07-09 18:10:35 +02:00
|
|
|
ctx.AddDependency(ctx.Module(), sourceOrOutputDepTag(m, t), m)
|
2017-04-10 20:27:50 +02:00
|
|
|
}
|
2016-12-14 00:23:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-12 01:29:02 +01:00
|
|
|
// Adds necessary dependencies to satisfy filegroup or generated sources modules specified in s
|
|
|
|
// using ":module" syntax, if any.
|
2019-03-05 07:35:41 +01:00
|
|
|
//
|
|
|
|
// Deprecated: tag the property with `android:"path"` instead.
|
2017-12-12 01:29:02 +01:00
|
|
|
func ExtractSourceDeps(ctx BottomUpMutatorContext, s *string) {
|
|
|
|
if s != nil {
|
2019-05-29 23:40:35 +02:00
|
|
|
if m, t := SrcIsModuleWithTag(*s); m != "" {
|
2021-07-09 18:10:35 +02:00
|
|
|
ctx.AddDependency(ctx.Module(), sourceOrOutputDepTag(m, t), m)
|
2017-12-12 01:29:02 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-29 23:40:35 +02:00
|
|
|
// A module that implements SourceFileProducer can be referenced from any property that is tagged with `android:"path"`
|
|
|
|
// using the ":module" syntax and provides a list of paths to be used as if they were listed in the property.
|
2016-12-14 00:23:47 +01:00
|
|
|
type SourceFileProducer interface {
|
|
|
|
Srcs() Paths
|
|
|
|
}
|
|
|
|
|
2019-05-29 23:40:35 +02:00
|
|
|
// A module that implements OutputFileProducer can be referenced from any property that is tagged with `android:"path"`
|
2019-11-22 15:20:54 +01:00
|
|
|
// using the ":module" syntax or ":module{.tag}" syntax and provides a list of output files to be used as if they were
|
2019-05-29 23:40:35 +02:00
|
|
|
// listed in the property.
|
|
|
|
type OutputFileProducer interface {
|
|
|
|
OutputFiles(tag string) (Paths, error)
|
|
|
|
}
|
|
|
|
|
2019-08-06 22:59:50 +02:00
|
|
|
// OutputFilesForModule returns the paths from an OutputFileProducer with the given tag. On error, including if the
|
|
|
|
// module produced zero paths, it reports errors to the ctx and returns nil.
|
|
|
|
func OutputFilesForModule(ctx PathContext, module blueprint.Module, tag string) Paths {
|
|
|
|
paths, err := outputFilesForModule(ctx, module, tag)
|
|
|
|
if err != nil {
|
|
|
|
reportPathError(ctx, err)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return paths
|
|
|
|
}
|
|
|
|
|
|
|
|
// OutputFileForModule returns the path from an OutputFileProducer with the given tag. On error, including if the
|
|
|
|
// module produced zero or multiple paths, it reports errors to the ctx and returns nil.
|
|
|
|
func OutputFileForModule(ctx PathContext, module blueprint.Module, tag string) Path {
|
|
|
|
paths, err := outputFilesForModule(ctx, module, tag)
|
|
|
|
if err != nil {
|
|
|
|
reportPathError(ctx, err)
|
|
|
|
return nil
|
|
|
|
}
|
2022-10-04 06:02:27 +02:00
|
|
|
if len(paths) == 0 {
|
|
|
|
type addMissingDependenciesIntf interface {
|
|
|
|
AddMissingDependencies([]string)
|
|
|
|
OtherModuleName(blueprint.Module) string
|
|
|
|
}
|
|
|
|
if mctx, ok := ctx.(addMissingDependenciesIntf); ok && ctx.Config().AllowMissingDependencies() {
|
|
|
|
mctx.AddMissingDependencies([]string{mctx.OtherModuleName(module)})
|
|
|
|
} else {
|
|
|
|
ReportPathErrorf(ctx, "failed to get output files from module %q", pathContextName(ctx, module))
|
|
|
|
}
|
|
|
|
// Return a fake output file to avoid nil dereferences of Path objects later.
|
|
|
|
// This should never get used for an actual build as the error or missing
|
|
|
|
// dependency has already been reported.
|
|
|
|
p, err := pathForSource(ctx, filepath.Join("missing_output_file", pathContextName(ctx, module)))
|
|
|
|
if err != nil {
|
|
|
|
reportPathError(ctx, err)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return p
|
|
|
|
}
|
2019-08-06 22:59:50 +02:00
|
|
|
if len(paths) > 1 {
|
2020-08-25 13:45:15 +02:00
|
|
|
ReportPathErrorf(ctx, "got multiple output files from module %q, expected exactly one",
|
2019-08-06 22:59:50 +02:00
|
|
|
pathContextName(ctx, module))
|
|
|
|
}
|
|
|
|
return paths[0]
|
|
|
|
}
|
|
|
|
|
|
|
|
func outputFilesForModule(ctx PathContext, module blueprint.Module, tag string) (Paths, error) {
|
|
|
|
if outputFileProducer, ok := module.(OutputFileProducer); ok {
|
|
|
|
paths, err := outputFileProducer.OutputFiles(tag)
|
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("failed to get output file from module %q: %s",
|
|
|
|
pathContextName(ctx, module), err.Error())
|
|
|
|
}
|
2020-11-23 05:23:02 +01:00
|
|
|
return paths, nil
|
|
|
|
} else if sourceFileProducer, ok := module.(SourceFileProducer); ok {
|
|
|
|
if tag != "" {
|
|
|
|
return nil, fmt.Errorf("module %q is a SourceFileProducer, not an OutputFileProducer, and so does not support tag %q", pathContextName(ctx, module), tag)
|
|
|
|
}
|
|
|
|
paths := sourceFileProducer.Srcs()
|
2019-08-06 22:59:50 +02:00
|
|
|
return paths, nil
|
|
|
|
} else {
|
|
|
|
return nil, fmt.Errorf("module %q is not an OutputFileProducer", pathContextName(ctx, module))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-01 23:00:21 +01:00
|
|
|
// Modules can implement HostToolProvider and return a valid OptionalPath from HostToolPath() to
|
|
|
|
// specify that they can be used as a tool by a genrule module.
|
2019-03-29 03:30:56 +01:00
|
|
|
type HostToolProvider interface {
|
2020-11-25 01:32:22 +01:00
|
|
|
Module
|
2020-12-01 23:00:21 +01:00
|
|
|
// HostToolPath returns the path to the host tool for the module if it is one, or an invalid
|
|
|
|
// OptionalPath.
|
2019-03-29 03:30:56 +01:00
|
|
|
HostToolPath() OptionalPath
|
|
|
|
}
|
|
|
|
|
2019-03-05 07:35:41 +01:00
|
|
|
// Returns a list of paths expanded from globs and modules referenced using ":module" syntax. The property must
|
|
|
|
// be tagged with `android:"path" to support automatic source module dependency resolution.
|
2019-03-06 07:25:09 +01:00
|
|
|
//
|
|
|
|
// Deprecated: use PathsForModuleSrc or PathsForModuleSrcExcludes instead.
|
2019-06-06 23:29:25 +02:00
|
|
|
func (m *moduleContext) ExpandSources(srcFiles, excludes []string) Paths {
|
|
|
|
return PathsForModuleSrcExcludes(m, srcFiles, excludes)
|
2015-06-18 00:09:06 +02:00
|
|
|
}
|
|
|
|
|
2019-03-05 21:39:51 +01:00
|
|
|
// Returns a single path expanded from globs and modules referenced using ":module" syntax. The property must
|
|
|
|
// be tagged with `android:"path" to support automatic source module dependency resolution.
|
2019-03-06 07:25:09 +01:00
|
|
|
//
|
|
|
|
// Deprecated: use PathForModuleSrc instead.
|
2022-08-04 22:07:02 +02:00
|
|
|
func (m *moduleContext) ExpandSource(srcFile, _ string) Path {
|
2019-06-06 23:29:25 +02:00
|
|
|
return PathForModuleSrc(m, srcFile)
|
2019-03-05 21:39:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Returns an optional single path expanded from globs and modules referenced using ":module" syntax if
|
|
|
|
// the srcFile is non-nil. The property must be tagged with `android:"path" to support automatic source module
|
|
|
|
// dependency resolution.
|
2022-08-04 22:07:02 +02:00
|
|
|
func (m *moduleContext) ExpandOptionalSource(srcFile *string, _ string) OptionalPath {
|
2019-03-05 21:39:51 +01:00
|
|
|
if srcFile != nil {
|
2019-06-06 23:29:25 +02:00
|
|
|
return OptionalPathForPath(PathForModuleSrc(m, *srcFile))
|
2019-03-05 21:39:51 +01:00
|
|
|
}
|
|
|
|
return OptionalPath{}
|
|
|
|
}
|
|
|
|
|
2019-06-06 23:29:25 +02:00
|
|
|
func (m *moduleContext) RequiredModuleNames() []string {
|
2019-12-30 08:31:09 +01:00
|
|
|
return m.module.RequiredModuleNames()
|
2017-02-05 02:47:46 +01:00
|
|
|
}
|
|
|
|
|
2019-06-06 23:29:25 +02:00
|
|
|
func (m *moduleContext) HostRequiredModuleNames() []string {
|
2019-12-30 08:31:09 +01:00
|
|
|
return m.module.HostRequiredModuleNames()
|
2019-04-02 03:37:36 +02:00
|
|
|
}
|
|
|
|
|
2019-06-06 23:29:25 +02:00
|
|
|
func (m *moduleContext) TargetRequiredModuleNames() []string {
|
2019-12-30 08:31:09 +01:00
|
|
|
return m.module.TargetRequiredModuleNames()
|
2019-04-02 03:37:36 +02:00
|
|
|
}
|
|
|
|
|
2015-06-17 23:20:06 +02:00
|
|
|
func init() {
|
2023-05-16 02:58:37 +02:00
|
|
|
RegisterParallelSingletonType("buildtarget", BuildTargetSingleton)
|
2023-05-15 11:06:31 +02:00
|
|
|
RegisterParallelSingletonType("soongconfigtrace", soongConfigTraceSingletonFunc)
|
|
|
|
FinalDepsMutators(registerSoongConfigTraceMutator)
|
2015-06-17 23:20:06 +02:00
|
|
|
}
|
|
|
|
|
2017-11-29 02:34:01 +01:00
|
|
|
func BuildTargetSingleton() Singleton {
|
2015-06-17 01:38:17 +02:00
|
|
|
return &buildTargetSingleton{}
|
|
|
|
}
|
|
|
|
|
2017-04-25 19:01:55 +02:00
|
|
|
func parentDir(dir string) string {
|
|
|
|
dir, _ = filepath.Split(dir)
|
|
|
|
return filepath.Clean(dir)
|
|
|
|
}
|
|
|
|
|
2015-06-17 01:38:17 +02:00
|
|
|
type buildTargetSingleton struct{}
|
|
|
|
|
2021-10-12 01:46:56 +02:00
|
|
|
func AddAncestors(ctx SingletonContext, dirMap map[string]Paths, mmName func(string) string) ([]string, []string) {
|
Add tidy-soong, tidy-dir-path, module-tidy targets
* When WITH_TIDY=1, these targets allow quick check of C/C++
source code with clang-tidy, without building C/C++ binaries.
* For each module with tidy rules, add a module-tidy target, e.g.,
libart-tidy, libartd-tidy, bionic-benchmarks-tidy, libnativehelper-tidy, etc.
* Add a tidy-soong phony target that depends on all module-tidy targets.
* For each directory X/Y add a tidy-X-Y phony target that depends
on all *-tidy targets in X/Y and tidy-X-Y-Z for all X/Y/Z directories,
e.g., tidy-bionic, tidy-bionic-benchmarks, tidy-libnativehelper, etc.
* Only soong modules are collected for now.
Tidy rules in .mk files will be collected later.
* Some comment lines reformatted by gofmt.
Test: WITH_TIDY=1 make <some_module>-tidy tidy-<some_directory>
Test: WITH_TIDY=1 make tidy-soong
Bug: 199169329
Change-Id: I45aef3875f70288a8e070761e5f083dbbdfa6e94
2021-09-06 05:15:38 +02:00
|
|
|
// Ensure ancestor directories are in dirMap
|
|
|
|
// Make directories build their direct subdirectories
|
2021-10-12 01:46:56 +02:00
|
|
|
// Returns a slice of all directories and a slice of top-level directories.
|
2023-03-01 01:02:16 +01:00
|
|
|
dirs := SortedKeys(dirMap)
|
Add tidy-soong, tidy-dir-path, module-tidy targets
* When WITH_TIDY=1, these targets allow quick check of C/C++
source code with clang-tidy, without building C/C++ binaries.
* For each module with tidy rules, add a module-tidy target, e.g.,
libart-tidy, libartd-tidy, bionic-benchmarks-tidy, libnativehelper-tidy, etc.
* Add a tidy-soong phony target that depends on all module-tidy targets.
* For each directory X/Y add a tidy-X-Y phony target that depends
on all *-tidy targets in X/Y and tidy-X-Y-Z for all X/Y/Z directories,
e.g., tidy-bionic, tidy-bionic-benchmarks, tidy-libnativehelper, etc.
* Only soong modules are collected for now.
Tidy rules in .mk files will be collected later.
* Some comment lines reformatted by gofmt.
Test: WITH_TIDY=1 make <some_module>-tidy tidy-<some_directory>
Test: WITH_TIDY=1 make tidy-soong
Bug: 199169329
Change-Id: I45aef3875f70288a8e070761e5f083dbbdfa6e94
2021-09-06 05:15:38 +02:00
|
|
|
for _, dir := range dirs {
|
|
|
|
dir := parentDir(dir)
|
|
|
|
for dir != "." && dir != "/" {
|
|
|
|
if _, exists := dirMap[dir]; exists {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
dirMap[dir] = nil
|
|
|
|
dir = parentDir(dir)
|
|
|
|
}
|
|
|
|
}
|
2023-03-01 01:02:16 +01:00
|
|
|
dirs = SortedKeys(dirMap)
|
2021-10-12 01:46:56 +02:00
|
|
|
var topDirs []string
|
Add tidy-soong, tidy-dir-path, module-tidy targets
* When WITH_TIDY=1, these targets allow quick check of C/C++
source code with clang-tidy, without building C/C++ binaries.
* For each module with tidy rules, add a module-tidy target, e.g.,
libart-tidy, libartd-tidy, bionic-benchmarks-tidy, libnativehelper-tidy, etc.
* Add a tidy-soong phony target that depends on all module-tidy targets.
* For each directory X/Y add a tidy-X-Y phony target that depends
on all *-tidy targets in X/Y and tidy-X-Y-Z for all X/Y/Z directories,
e.g., tidy-bionic, tidy-bionic-benchmarks, tidy-libnativehelper, etc.
* Only soong modules are collected for now.
Tidy rules in .mk files will be collected later.
* Some comment lines reformatted by gofmt.
Test: WITH_TIDY=1 make <some_module>-tidy tidy-<some_directory>
Test: WITH_TIDY=1 make tidy-soong
Bug: 199169329
Change-Id: I45aef3875f70288a8e070761e5f083dbbdfa6e94
2021-09-06 05:15:38 +02:00
|
|
|
for _, dir := range dirs {
|
|
|
|
p := parentDir(dir)
|
|
|
|
if p != "." && p != "/" {
|
|
|
|
dirMap[p] = append(dirMap[p], PathForPhony(ctx, mmName(dir)))
|
2021-10-12 01:46:56 +02:00
|
|
|
} else if dir != "." && dir != "/" && dir != "" {
|
|
|
|
topDirs = append(topDirs, dir)
|
Add tidy-soong, tidy-dir-path, module-tidy targets
* When WITH_TIDY=1, these targets allow quick check of C/C++
source code with clang-tidy, without building C/C++ binaries.
* For each module with tidy rules, add a module-tidy target, e.g.,
libart-tidy, libartd-tidy, bionic-benchmarks-tidy, libnativehelper-tidy, etc.
* Add a tidy-soong phony target that depends on all module-tidy targets.
* For each directory X/Y add a tidy-X-Y phony target that depends
on all *-tidy targets in X/Y and tidy-X-Y-Z for all X/Y/Z directories,
e.g., tidy-bionic, tidy-bionic-benchmarks, tidy-libnativehelper, etc.
* Only soong modules are collected for now.
Tidy rules in .mk files will be collected later.
* Some comment lines reformatted by gofmt.
Test: WITH_TIDY=1 make <some_module>-tidy tidy-<some_directory>
Test: WITH_TIDY=1 make tidy-soong
Bug: 199169329
Change-Id: I45aef3875f70288a8e070761e5f083dbbdfa6e94
2021-09-06 05:15:38 +02:00
|
|
|
}
|
|
|
|
}
|
2023-03-01 01:02:16 +01:00
|
|
|
return SortedKeys(dirMap), topDirs
|
Add tidy-soong, tidy-dir-path, module-tidy targets
* When WITH_TIDY=1, these targets allow quick check of C/C++
source code with clang-tidy, without building C/C++ binaries.
* For each module with tidy rules, add a module-tidy target, e.g.,
libart-tidy, libartd-tidy, bionic-benchmarks-tidy, libnativehelper-tidy, etc.
* Add a tidy-soong phony target that depends on all module-tidy targets.
* For each directory X/Y add a tidy-X-Y phony target that depends
on all *-tidy targets in X/Y and tidy-X-Y-Z for all X/Y/Z directories,
e.g., tidy-bionic, tidy-bionic-benchmarks, tidy-libnativehelper, etc.
* Only soong modules are collected for now.
Tidy rules in .mk files will be collected later.
* Some comment lines reformatted by gofmt.
Test: WITH_TIDY=1 make <some_module>-tidy tidy-<some_directory>
Test: WITH_TIDY=1 make tidy-soong
Bug: 199169329
Change-Id: I45aef3875f70288a8e070761e5f083dbbdfa6e94
2021-09-06 05:15:38 +02:00
|
|
|
}
|
|
|
|
|
2017-11-29 02:34:01 +01:00
|
|
|
func (c *buildTargetSingleton) GenerateBuildActions(ctx SingletonContext) {
|
|
|
|
var checkbuildDeps Paths
|
2015-06-17 01:38:17 +02:00
|
|
|
|
2020-06-04 22:25:17 +02:00
|
|
|
mmTarget := func(dir string) string {
|
|
|
|
return "MODULES-IN-" + strings.Replace(filepath.Clean(dir), "/", "-", -1)
|
2017-04-25 19:01:55 +02:00
|
|
|
}
|
|
|
|
|
2017-11-29 02:34:01 +01:00
|
|
|
modulesInDir := make(map[string]Paths)
|
2015-06-17 01:38:17 +02:00
|
|
|
|
2017-11-29 02:34:01 +01:00
|
|
|
ctx.VisitAllModules(func(module Module) {
|
|
|
|
blueprintDir := module.base().blueprintDir
|
|
|
|
installTarget := module.base().installTarget
|
|
|
|
checkbuildTarget := module.base().checkbuildTarget
|
2015-06-17 01:38:17 +02:00
|
|
|
|
2017-11-29 02:34:01 +01:00
|
|
|
if checkbuildTarget != nil {
|
|
|
|
checkbuildDeps = append(checkbuildDeps, checkbuildTarget)
|
|
|
|
modulesInDir[blueprintDir] = append(modulesInDir[blueprintDir], checkbuildTarget)
|
|
|
|
}
|
2015-06-17 01:38:17 +02:00
|
|
|
|
2017-11-29 02:34:01 +01:00
|
|
|
if installTarget != nil {
|
|
|
|
modulesInDir[blueprintDir] = append(modulesInDir[blueprintDir], installTarget)
|
2015-06-17 01:38:17 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2015-12-11 22:51:06 +01:00
|
|
|
suffix := ""
|
2020-11-23 06:22:30 +01:00
|
|
|
if ctx.Config().KatiEnabled() {
|
2015-12-11 22:51:06 +01:00
|
|
|
suffix = "-soong"
|
|
|
|
}
|
|
|
|
|
2015-06-17 01:38:17 +02:00
|
|
|
// Create a top-level checkbuild target that depends on all modules
|
2020-06-04 22:25:17 +02:00
|
|
|
ctx.Phony("checkbuild"+suffix, checkbuildDeps...)
|
2015-06-17 01:38:17 +02:00
|
|
|
|
Add tidy-soong, tidy-dir-path, module-tidy targets
* When WITH_TIDY=1, these targets allow quick check of C/C++
source code with clang-tidy, without building C/C++ binaries.
* For each module with tidy rules, add a module-tidy target, e.g.,
libart-tidy, libartd-tidy, bionic-benchmarks-tidy, libnativehelper-tidy, etc.
* Add a tidy-soong phony target that depends on all module-tidy targets.
* For each directory X/Y add a tidy-X-Y phony target that depends
on all *-tidy targets in X/Y and tidy-X-Y-Z for all X/Y/Z directories,
e.g., tidy-bionic, tidy-bionic-benchmarks, tidy-libnativehelper, etc.
* Only soong modules are collected for now.
Tidy rules in .mk files will be collected later.
* Some comment lines reformatted by gofmt.
Test: WITH_TIDY=1 make <some_module>-tidy tidy-<some_directory>
Test: WITH_TIDY=1 make tidy-soong
Bug: 199169329
Change-Id: I45aef3875f70288a8e070761e5f083dbbdfa6e94
2021-09-06 05:15:38 +02:00
|
|
|
// Make will generate the MODULES-IN-* targets
|
|
|
|
if ctx.Config().KatiEnabled() {
|
|
|
|
return
|
2017-04-25 19:01:55 +02:00
|
|
|
}
|
|
|
|
|
2021-10-12 01:46:56 +02:00
|
|
|
dirs, _ := AddAncestors(ctx, modulesInDir, mmTarget)
|
Add tidy-soong, tidy-dir-path, module-tidy targets
* When WITH_TIDY=1, these targets allow quick check of C/C++
source code with clang-tidy, without building C/C++ binaries.
* For each module with tidy rules, add a module-tidy target, e.g.,
libart-tidy, libartd-tidy, bionic-benchmarks-tidy, libnativehelper-tidy, etc.
* Add a tidy-soong phony target that depends on all module-tidy targets.
* For each directory X/Y add a tidy-X-Y phony target that depends
on all *-tidy targets in X/Y and tidy-X-Y-Z for all X/Y/Z directories,
e.g., tidy-bionic, tidy-bionic-benchmarks, tidy-libnativehelper, etc.
* Only soong modules are collected for now.
Tidy rules in .mk files will be collected later.
* Some comment lines reformatted by gofmt.
Test: WITH_TIDY=1 make <some_module>-tidy tidy-<some_directory>
Test: WITH_TIDY=1 make tidy-soong
Bug: 199169329
Change-Id: I45aef3875f70288a8e070761e5f083dbbdfa6e94
2021-09-06 05:15:38 +02:00
|
|
|
|
2017-09-20 23:30:50 +02:00
|
|
|
// Create a MODULES-IN-<directory> target that depends on all modules in a directory, and
|
|
|
|
// depends on the MODULES-IN-* targets of all of its subdirectories that contain Android.bp
|
|
|
|
// files.
|
2015-06-17 01:38:17 +02:00
|
|
|
for _, dir := range dirs {
|
2020-06-04 22:25:17 +02:00
|
|
|
ctx.Phony(mmTarget(dir), modulesInDir[dir]...)
|
2015-06-17 01:38:17 +02:00
|
|
|
}
|
2017-09-21 02:29:08 +02:00
|
|
|
|
|
|
|
// Create (host|host-cross|target)-<OS> phony rules to build a reduced checkbuild.
|
2020-09-14 12:43:17 +02:00
|
|
|
type osAndCross struct {
|
|
|
|
os OsType
|
|
|
|
hostCross bool
|
|
|
|
}
|
|
|
|
osDeps := map[osAndCross]Paths{}
|
2017-11-29 02:34:01 +01:00
|
|
|
ctx.VisitAllModules(func(module Module) {
|
|
|
|
if module.Enabled() {
|
2020-09-14 12:43:17 +02:00
|
|
|
key := osAndCross{os: module.Target().Os, hostCross: module.Target().HostCross}
|
|
|
|
osDeps[key] = append(osDeps[key], module.base().checkbuildFiles...)
|
2017-09-21 02:29:08 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2017-11-29 02:34:01 +01:00
|
|
|
osClass := make(map[string]Paths)
|
2020-09-14 12:43:17 +02:00
|
|
|
for key, deps := range osDeps {
|
2017-09-21 02:29:08 +02:00
|
|
|
var className string
|
|
|
|
|
2020-09-14 12:43:17 +02:00
|
|
|
switch key.os.Class {
|
2017-09-21 02:29:08 +02:00
|
|
|
case Host:
|
2020-09-14 12:43:17 +02:00
|
|
|
if key.hostCross {
|
|
|
|
className = "host-cross"
|
|
|
|
} else {
|
|
|
|
className = "host"
|
|
|
|
}
|
2017-09-21 02:29:08 +02:00
|
|
|
case Device:
|
|
|
|
className = "target"
|
|
|
|
default:
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2020-09-14 12:43:17 +02:00
|
|
|
name := className + "-" + key.os.Name
|
2020-06-04 22:25:17 +02:00
|
|
|
osClass[className] = append(osClass[className], PathForPhony(ctx, name))
|
2017-09-21 02:29:08 +02:00
|
|
|
|
2020-06-04 22:25:17 +02:00
|
|
|
ctx.Phony(name, deps...)
|
2017-09-21 02:29:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Wrap those into host|host-cross|target phony rules
|
2023-03-01 01:02:16 +01:00
|
|
|
for _, class := range SortedKeys(osClass) {
|
2020-06-04 22:25:17 +02:00
|
|
|
ctx.Phony(class, osClass[class]...)
|
2017-09-21 02:29:08 +02:00
|
|
|
}
|
2015-06-17 01:38:17 +02:00
|
|
|
}
|
2015-12-18 03:00:23 +01:00
|
|
|
|
2018-08-16 00:35:38 +02:00
|
|
|
// Collect information for opening IDE project files in java/jdeps.go.
|
|
|
|
type IDEInfo interface {
|
|
|
|
IDEInfo(ideInfo *IdeInfo)
|
|
|
|
BaseModuleName() string
|
|
|
|
}
|
|
|
|
|
|
|
|
// Extract the base module name from the Import name.
|
|
|
|
// Often the Import name has a prefix "prebuilt_".
|
|
|
|
// Remove the prefix explicitly if needed
|
|
|
|
// until we find a better solution to get the Import name.
|
|
|
|
type IDECustomizedModuleName interface {
|
|
|
|
IDECustomizedModuleName() string
|
|
|
|
}
|
|
|
|
|
|
|
|
type IdeInfo struct {
|
|
|
|
Deps []string `json:"dependencies,omitempty"`
|
|
|
|
Srcs []string `json:"srcs,omitempty"`
|
|
|
|
Aidl_include_dirs []string `json:"aidl_include_dirs,omitempty"`
|
|
|
|
Jarjar_rules []string `json:"jarjar_rules,omitempty"`
|
|
|
|
Jars []string `json:"jars,omitempty"`
|
|
|
|
Classes []string `json:"class,omitempty"`
|
|
|
|
Installed_paths []string `json:"installed,omitempty"`
|
2019-05-10 09:48:50 +02:00
|
|
|
SrcJars []string `json:"srcjars,omitempty"`
|
2020-05-21 04:11:59 +02:00
|
|
|
Paths []string `json:"path,omitempty"`
|
2022-04-13 14:41:01 +02:00
|
|
|
Static_libs []string `json:"static_libs,omitempty"`
|
|
|
|
Libs []string `json:"libs,omitempty"`
|
2018-08-16 00:35:38 +02:00
|
|
|
}
|
2020-05-07 21:21:34 +02:00
|
|
|
|
|
|
|
func CheckBlueprintSyntax(ctx BaseModuleContext, filename string, contents string) []error {
|
|
|
|
bpctx := ctx.blueprintBaseModuleContext()
|
|
|
|
return blueprint.CheckBlueprintSyntax(bpctx.ModuleFactories(), filename, contents)
|
|
|
|
}
|
2020-11-25 01:21:24 +01:00
|
|
|
|
2023-05-15 11:06:31 +02:00
|
|
|
func registerSoongConfigTraceMutator(ctx RegisterMutatorsContext) {
|
|
|
|
ctx.BottomUp("soongconfigtrace", soongConfigTraceMutator).Parallel()
|
|
|
|
}
|
|
|
|
|
|
|
|
// soongConfigTraceMutator accumulates recorded soong_config trace from children. Also it normalizes
|
|
|
|
// SoongConfigTrace to make it consistent.
|
|
|
|
func soongConfigTraceMutator(ctx BottomUpMutatorContext) {
|
|
|
|
trace := &ctx.Module().base().commonProperties.SoongConfigTrace
|
|
|
|
ctx.VisitDirectDeps(func(m Module) {
|
|
|
|
childTrace := &m.base().commonProperties.SoongConfigTrace
|
|
|
|
trace.Bools = append(trace.Bools, childTrace.Bools...)
|
|
|
|
trace.Strings = append(trace.Strings, childTrace.Strings...)
|
|
|
|
trace.IsSets = append(trace.IsSets, childTrace.IsSets...)
|
|
|
|
})
|
|
|
|
trace.Bools = SortedUniqueStrings(trace.Bools)
|
|
|
|
trace.Strings = SortedUniqueStrings(trace.Strings)
|
|
|
|
trace.IsSets = SortedUniqueStrings(trace.IsSets)
|
|
|
|
|
|
|
|
ctx.Module().base().commonProperties.SoongConfigTraceHash = trace.hash()
|
|
|
|
}
|
|
|
|
|
|
|
|
// soongConfigTraceSingleton writes a map from each module's config hash value to trace data.
|
|
|
|
func soongConfigTraceSingletonFunc() Singleton {
|
|
|
|
return &soongConfigTraceSingleton{}
|
|
|
|
}
|
|
|
|
|
|
|
|
type soongConfigTraceSingleton struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *soongConfigTraceSingleton) GenerateBuildActions(ctx SingletonContext) {
|
|
|
|
outFile := PathForOutput(ctx, "soong_config_trace.json")
|
|
|
|
|
|
|
|
traces := make(map[string]*soongConfigTrace)
|
|
|
|
ctx.VisitAllModules(func(module Module) {
|
|
|
|
trace := &module.base().commonProperties.SoongConfigTrace
|
|
|
|
if !trace.isEmpty() {
|
|
|
|
hash := module.base().commonProperties.SoongConfigTraceHash
|
|
|
|
traces[hash] = trace
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
j, err := json.Marshal(traces)
|
|
|
|
if err != nil {
|
|
|
|
ctx.Errorf("json marshal to %q failed: %#v", outFile, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
WriteFileRule(ctx, outFile, string(j))
|
|
|
|
ctx.Phony("soong_config_trace", outFile)
|
|
|
|
}
|
2023-06-01 00:03:33 +02:00
|
|
|
|
|
|
|
// Interface implemented by xsd_config which has 1:many mappings in bp2build workspace
|
|
|
|
// This interface exists because we want to
|
|
|
|
// 1. Determine the name of the additional targets generated by the primary soong module
|
|
|
|
// 2. Enable distinguishing an xsd_config module from other Soong modules using type assertion
|
|
|
|
type XsdConfigBp2buildTargets interface {
|
|
|
|
CppBp2buildTargetName() string
|
|
|
|
JavaBp2buildTargetName() string
|
|
|
|
}
|
|
|
|
|
2023-07-17 23:44:08 +02:00
|
|
|
// XsdModuleToTargetName is a function that takes an XsdConfigBp2buildTarget
|
|
|
|
type XsdModuleToTargetName func(xsd XsdConfigBp2buildTargets) string
|
|
|
|
|
|
|
|
// XsdLabelMapper returns a bazel.LabelMapper for partitioning XSD sources/headers given an
|
|
|
|
// XsdModuleToTargetName function.
|
|
|
|
func XsdLabelMapper(targetName XsdModuleToTargetName) bazel.LabelMapper {
|
|
|
|
return func(ctx bazel.OtherModuleContext, label bazel.Label) (string, bool) {
|
|
|
|
mod, exists := ctx.ModuleFromName(label.OriginalModuleName)
|
2023-06-01 00:03:33 +02:00
|
|
|
if !exists {
|
2023-07-17 23:44:08 +02:00
|
|
|
return label.Label, false
|
2023-06-01 00:03:33 +02:00
|
|
|
}
|
2023-07-17 23:44:08 +02:00
|
|
|
xsdMod, isXsd := mod.(XsdConfigBp2buildTargets)
|
|
|
|
if !isXsd {
|
|
|
|
return label.Label, false
|
2023-06-01 00:03:33 +02:00
|
|
|
}
|
|
|
|
|
2023-07-17 23:44:08 +02:00
|
|
|
// Remove the base module name
|
|
|
|
ret := strings.TrimSuffix(label.Label, mod.Name())
|
|
|
|
// Append the language specific target name
|
|
|
|
ret += targetName(xsdMod)
|
|
|
|
return ret, true
|
2023-06-01 00:03:33 +02:00
|
|
|
}
|
|
|
|
}
|