2015-01-31 09:27:36 +08: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 06:37:25 +08:00
|
|
|
package android
|
2015-01-31 09:27:36 +08:00
|
|
|
|
|
|
|
import (
|
2015-12-18 08:39:19 +08:00
|
|
|
"fmt"
|
2020-01-11 09:11:46 +08:00
|
|
|
"os"
|
2019-01-18 05:57:45 +08:00
|
|
|
"path"
|
2015-01-31 09:27:36 +08:00
|
|
|
"path/filepath"
|
2015-12-18 08:39:19 +08:00
|
|
|
"strings"
|
2017-11-29 16:27:14 +08:00
|
|
|
"text/scanner"
|
2015-03-25 02:13:38 +08:00
|
|
|
|
|
|
|
"github.com/google/blueprint"
|
2018-09-13 01:02:13 +08:00
|
|
|
"github.com/google/blueprint/proptools"
|
2015-01-31 09:27:36 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
DeviceSharedLibrary = "shared_library"
|
|
|
|
DeviceStaticLibrary = "static_library"
|
|
|
|
DeviceExecutable = "executable"
|
|
|
|
HostSharedLibrary = "host_shared_library"
|
|
|
|
HostStaticLibrary = "host_static_library"
|
|
|
|
HostExecutable = "host_executable"
|
|
|
|
)
|
|
|
|
|
2017-10-24 08:16:14 +08:00
|
|
|
type BuildParams struct {
|
2016-11-04 05:28:31 +08:00
|
|
|
Rule blueprint.Rule
|
2016-11-22 09:23:08 +08:00
|
|
|
Deps blueprint.Deps
|
|
|
|
Depfile WritablePath
|
2017-05-10 04:45:28 +08:00
|
|
|
Description string
|
2016-11-04 05:28:31 +08:00
|
|
|
Output WritablePath
|
|
|
|
Outputs WritablePaths
|
|
|
|
ImplicitOutput WritablePath
|
|
|
|
ImplicitOutputs WritablePaths
|
|
|
|
Input Path
|
|
|
|
Inputs Paths
|
|
|
|
Implicit Path
|
|
|
|
Implicits Paths
|
|
|
|
OrderOnly Paths
|
|
|
|
Default bool
|
|
|
|
Args map[string]string
|
2015-09-24 06:26:20 +08:00
|
|
|
}
|
|
|
|
|
2017-10-24 08:16:14 +08:00
|
|
|
type ModuleBuildParams BuildParams
|
|
|
|
|
2019-12-31 10:43:07 +08: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 {
|
2019-06-07 07:13:11 +08:00
|
|
|
Module() Module
|
2019-06-07 05:33:29 +08:00
|
|
|
ModuleName() string
|
|
|
|
ModuleDir() string
|
|
|
|
ModuleType() string
|
2019-11-23 08:03:51 +08:00
|
|
|
BlueprintsFile() string
|
2019-12-31 10:43:07 +08:00
|
|
|
|
|
|
|
ContainsProperty(name string) bool
|
|
|
|
Errorf(pos scanner.Position, fmt string, args ...interface{})
|
|
|
|
ModuleErrorf(fmt string, args ...interface{})
|
|
|
|
PropertyErrorf(property, fmt string, args ...interface{})
|
|
|
|
Failed() bool
|
|
|
|
|
|
|
|
AddNinjaFileDeps(deps ...string)
|
|
|
|
|
|
|
|
DeviceSpecific() bool
|
|
|
|
SocSpecific() bool
|
|
|
|
ProductSpecific() bool
|
|
|
|
SystemExtSpecific() bool
|
|
|
|
Platform() bool
|
|
|
|
|
2019-06-07 05:33:29 +08:00
|
|
|
Config() Config
|
2019-12-31 10:43:07 +08: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 09:11:46 +08:00
|
|
|
IsSymlink(path Path) bool
|
|
|
|
Readlink(path Path) string
|
2019-12-31 10:43:07 +08: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-07 05:33:29 +08:00
|
|
|
|
2019-06-07 07:13:11 +08:00
|
|
|
OtherModuleName(m blueprint.Module) string
|
|
|
|
OtherModuleDir(m blueprint.Module) string
|
|
|
|
OtherModuleErrorf(m blueprint.Module, fmt string, args ...interface{})
|
|
|
|
OtherModuleDependencyTag(m blueprint.Module) blueprint.DependencyTag
|
|
|
|
OtherModuleExists(name string) bool
|
2019-08-09 19:39:45 +08:00
|
|
|
OtherModuleType(m blueprint.Module) string
|
2019-06-07 07:13:11 +08:00
|
|
|
|
|
|
|
GetDirectDepsWithTag(tag blueprint.DependencyTag) []Module
|
|
|
|
GetDirectDepWithTag(name string, tag blueprint.DependencyTag) blueprint.Module
|
|
|
|
GetDirectDep(name string) (blueprint.Module, blueprint.DependencyTag)
|
|
|
|
|
|
|
|
VisitDirectDepsBlueprint(visit func(blueprint.Module))
|
|
|
|
VisitDirectDeps(visit func(Module))
|
|
|
|
VisitDirectDepsWithTag(tag blueprint.DependencyTag, visit func(Module))
|
|
|
|
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))
|
|
|
|
WalkDeps(visit func(Module, Module) bool)
|
|
|
|
WalkDepsBlueprint(visit func(blueprint.Module, blueprint.Module) bool)
|
|
|
|
// 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
|
|
|
|
|
|
|
|
AddMissingDependencies(missingDeps []string)
|
|
|
|
|
2016-06-02 08:09:44 +08:00
|
|
|
Target() Target
|
2016-09-14 00:59:14 +08:00
|
|
|
TargetPrimary() bool
|
2018-10-03 13:01:37 +08:00
|
|
|
MultiTargets() []Target
|
2015-03-25 02:13:38 +08:00
|
|
|
Arch() Arch
|
2016-06-02 08:09:44 +08:00
|
|
|
Os() OsType
|
2015-03-25 02:13:38 +08:00
|
|
|
Host() bool
|
|
|
|
Device() bool
|
2015-05-01 07:36:18 +08:00
|
|
|
Darwin() bool
|
2019-01-17 04:06:11 +08:00
|
|
|
Fuchsia() bool
|
2017-04-05 03:59:48 +08:00
|
|
|
Windows() bool
|
2015-03-25 02:13:38 +08:00
|
|
|
Debug() bool
|
2016-08-25 06:25:47 +08:00
|
|
|
PrimaryArch() bool
|
2015-03-25 02:13:38 +08:00
|
|
|
}
|
|
|
|
|
2019-12-31 10:43:07 +08:00
|
|
|
// Deprecated: use EarlyModuleContext instead
|
2016-05-19 06:37:25 +08:00
|
|
|
type BaseContext interface {
|
2019-12-31 10:43:07 +08:00
|
|
|
EarlyModuleContext
|
2017-11-29 16:27:14 +08:00
|
|
|
}
|
|
|
|
|
2016-05-19 06:37:25 +08:00
|
|
|
type ModuleContext interface {
|
2017-11-29 16:27:14 +08:00
|
|
|
BaseModuleContext
|
2015-01-31 09:27:36 +08:00
|
|
|
|
2017-10-24 08:16:14 +08:00
|
|
|
// Deprecated: use ModuleContext.Build instead.
|
2017-11-29 09:34:01 +08:00
|
|
|
ModuleBuild(pctx PackageContext, params ModuleBuildParams)
|
2015-09-24 06:26:20 +08:00
|
|
|
|
|
|
|
ExpandSources(srcFiles, excludes []string) Paths
|
2017-12-12 08:29:02 +08:00
|
|
|
ExpandSource(srcFile, prop string) Path
|
2018-02-07 06:40:13 +08:00
|
|
|
ExpandOptionalSource(srcFile *string, prop string) OptionalPath
|
2015-06-18 06:09:06 +08:00
|
|
|
|
2019-10-02 13:05:35 +08:00
|
|
|
InstallExecutable(installPath InstallPath, name string, srcPath Path, deps ...Path) InstallPath
|
|
|
|
InstallFile(installPath InstallPath, name string, srcPath Path, deps ...Path) InstallPath
|
|
|
|
InstallSymlink(installPath InstallPath, name string, srcPath InstallPath) InstallPath
|
|
|
|
InstallAbsoluteSymlink(installPath InstallPath, name string, absPath string) InstallPath
|
2015-09-24 06:26:20 +08:00
|
|
|
CheckbuildFile(srcPath Path)
|
2016-03-11 10:14:25 +08:00
|
|
|
|
2016-08-04 02:57:50 +08:00
|
|
|
InstallInData() bool
|
2019-09-12 01:25:18 +08:00
|
|
|
InstallInTestcases() bool
|
2017-03-30 13:00:18 +08:00
|
|
|
InstallInSanitizerDir() bool
|
2020-01-22 07:53:22 +08:00
|
|
|
InstallInRamdisk() bool
|
2018-01-31 23:54:12 +08:00
|
|
|
InstallInRecovery() bool
|
2019-10-03 02:10:58 +08:00
|
|
|
InstallInRoot() bool
|
2019-07-30 07:44:46 +08:00
|
|
|
InstallBypassMake() bool
|
2017-02-05 09:47:46 +08:00
|
|
|
|
|
|
|
RequiredModuleNames() []string
|
2019-04-02 09:37:36 +08:00
|
|
|
HostRequiredModuleNames() []string
|
|
|
|
TargetRequiredModuleNames() []string
|
2017-10-24 08:10:29 +08:00
|
|
|
|
|
|
|
ModuleSubDir() string
|
|
|
|
|
2017-11-29 09:34:01 +08:00
|
|
|
Variable(pctx PackageContext, name, value string)
|
|
|
|
Rule(pctx PackageContext, name string, params blueprint.RuleParams, argNames ...string) blueprint.Rule
|
2017-10-24 08:16:14 +08:00
|
|
|
// Similar to blueprint.ModuleContext.Build, but takes Paths instead of []string,
|
|
|
|
// and performs more verification.
|
2017-11-29 09:34:01 +08:00
|
|
|
Build(pctx PackageContext, params BuildParams)
|
2017-10-24 08:10:29 +08:00
|
|
|
|
2017-11-29 09:34:01 +08:00
|
|
|
PrimaryModule() Module
|
|
|
|
FinalModule() Module
|
|
|
|
VisitAllModuleVariants(visit func(Module))
|
2017-10-24 08:10:29 +08:00
|
|
|
|
|
|
|
GetMissingDependencies() []string
|
2017-11-30 08:47:17 +08:00
|
|
|
Namespace() blueprint.Namespace
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
2016-05-19 06:37:25 +08:00
|
|
|
type Module interface {
|
2015-01-31 09:27:36 +08:00
|
|
|
blueprint.Module
|
|
|
|
|
2017-09-28 08:01:44 +08: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 06:37:25 +08:00
|
|
|
GenerateAndroidBuildActions(ModuleContext)
|
2017-09-28 08:01:44 +08:00
|
|
|
|
2016-10-13 05:38:15 +08:00
|
|
|
DepsMutator(BottomUpMutatorContext)
|
2015-01-31 09:27:36 +08:00
|
|
|
|
2016-05-19 06:37:25 +08:00
|
|
|
base() *ModuleBase
|
2015-12-01 08:06:01 +08:00
|
|
|
Enabled() bool
|
2016-06-02 08:09:44 +08:00
|
|
|
Target() Target
|
2015-12-22 06:55:28 +08:00
|
|
|
InstallInData() bool
|
2019-09-12 01:25:18 +08:00
|
|
|
InstallInTestcases() bool
|
2017-03-30 13:00:18 +08:00
|
|
|
InstallInSanitizerDir() bool
|
2020-01-22 07:53:22 +08:00
|
|
|
InstallInRamdisk() bool
|
2018-01-31 23:54:12 +08:00
|
|
|
InstallInRecovery() bool
|
2019-10-03 02:10:58 +08:00
|
|
|
InstallInRoot() bool
|
2019-07-30 07:44:46 +08:00
|
|
|
InstallBypassMake() bool
|
2016-11-30 07:16:18 +08:00
|
|
|
SkipInstall()
|
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 17:23:01 +08:00
|
|
|
ExportedToMake() bool
|
2019-03-18 11:01:38 +08:00
|
|
|
NoticeFile() OptionalPath
|
2017-06-24 06:06:31 +08:00
|
|
|
|
|
|
|
AddProperties(props ...interface{})
|
|
|
|
GetProperties() []interface{}
|
2017-07-14 05:43:27 +08:00
|
|
|
|
2017-10-24 08:16:14 +08:00
|
|
|
BuildParamsForTests() []BuildParams
|
2019-02-26 06:54:28 +08:00
|
|
|
RuleParamsForTests() map[blueprint.Rule]blueprint.RuleParams
|
2018-12-13 01:01:34 +08:00
|
|
|
VariablesForTests() map[string]string
|
2019-05-31 21:00:04 +08:00
|
|
|
|
2019-07-02 06:32:45 +08:00
|
|
|
// String returns a string that includes the module name and variants for printing during debugging.
|
|
|
|
String() string
|
|
|
|
|
2019-05-31 21:00:04 +08: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 21:24:38 +08:00
|
|
|
|
|
|
|
// Get the visibility rules that control the visibility of this module.
|
|
|
|
visibility() []string
|
2019-12-30 15:31:09 +08:00
|
|
|
|
|
|
|
RequiredModuleNames() []string
|
|
|
|
HostRequiredModuleNames() []string
|
|
|
|
TargetRequiredModuleNames() []string
|
2019-05-31 21:00:04 +08: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 23:38:08 +08:00
|
|
|
func (q qualifiedModuleName) isRootPackage() bool {
|
|
|
|
return q.pkg == "" && q.name == ""
|
|
|
|
}
|
|
|
|
|
2019-05-31 21:00:04 +08:00
|
|
|
// Get the id for the package containing this module.
|
|
|
|
func (q qualifiedModuleName) getContainingPackageId() qualifiedModuleName {
|
|
|
|
pkg := q.pkg
|
|
|
|
if q.name == "" {
|
2019-06-20 23:38:08 +08: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 21:00:04 +08: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 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
2016-05-18 07:34:16 +08:00
|
|
|
type nameProperties struct {
|
|
|
|
// The name of the module. Must be unique across all modules.
|
2017-11-08 02:57:05 +08:00
|
|
|
Name *string
|
2016-05-18 07:34:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
type commonProperties struct {
|
2015-12-01 08:06:01 +08:00
|
|
|
// emit build rules for this module
|
|
|
|
Enabled *bool `android:"arch_variant"`
|
2015-01-31 09:27:36 +08:00
|
|
|
|
2019-03-28 22:10:57 +08: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.
|
|
|
|
// ["//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 21:00:04 +08: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 23:38:08 +08: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 21:00:04 +08:00
|
|
|
//
|
2019-07-24 20:45:05 +08: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 22:10:57 +08:00
|
|
|
// See https://android.googlesource.com/platform/build/soong/+/master/README.md#visibility for
|
|
|
|
// more details.
|
|
|
|
Visibility []string
|
|
|
|
|
2015-05-12 04:39:40 +08:00
|
|
|
// control whether this module compiles for 32-bit, 64-bit, or both. Possible values
|
2015-01-31 09:27:36 +08: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
|
|
|
|
// platform
|
2017-11-02 01:38:29 +08:00
|
|
|
Compile_multilib *string `android:"arch_variant"`
|
2016-09-07 01:39:07 +08:00
|
|
|
|
|
|
|
Target struct {
|
|
|
|
Host struct {
|
2017-11-02 01:38:29 +08:00
|
|
|
Compile_multilib *string
|
2016-09-07 01:39:07 +08:00
|
|
|
}
|
|
|
|
Android struct {
|
2017-11-02 01:38:29 +08:00
|
|
|
Compile_multilib *string
|
2016-09-07 01:39:07 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-03 13:01:37 +08:00
|
|
|
UseTargetVariants bool `blueprint:"mutated"`
|
|
|
|
Default_multilib string `blueprint:"mutated"`
|
2015-01-31 09:27:36 +08:00
|
|
|
|
2015-12-22 06:55:28 +08:00
|
|
|
// whether this is a proprietary vendor module, and should be installed into /vendor
|
2017-11-02 01:38:29 +08:00
|
|
|
Proprietary *bool
|
2015-12-22 06:55:28 +08:00
|
|
|
|
2017-03-21 04:23:34 +08:00
|
|
|
// vendor who owns this module
|
2017-07-19 10:42:09 +08:00
|
|
|
Owner *string
|
2017-03-21 04:23:34 +08:00
|
|
|
|
2017-11-08 15:03:48 +08: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-02 01:38:29 +08:00
|
|
|
Vendor *bool
|
2017-04-07 03:49:58 +08:00
|
|
|
|
2017-11-08 15:03:48 +08: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 18:00:15 +08: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 15:03:48 +08:00
|
|
|
Product_specific *bool
|
|
|
|
|
2019-06-25 15:47:17 +08: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 23:54:12 +08:00
|
|
|
// Whether this module is installed to recovery partition
|
|
|
|
Recovery *bool
|
|
|
|
|
2020-01-22 07:53:22 +08:00
|
|
|
// Whether this module is installed to ramdisk
|
|
|
|
Ramdisk *bool
|
|
|
|
|
2019-03-26 19:39:31 +08:00
|
|
|
// Whether this module is built for non-native architecures (also known as native bridge binary)
|
|
|
|
Native_bridge_supported *bool `android:"arch_variant"`
|
|
|
|
|
2016-07-26 11:27:39 +08:00
|
|
|
// init.rc files to be installed if this module is installed
|
2019-03-05 14:35:41 +08:00
|
|
|
Init_rc []string `android:"path"`
|
2016-07-26 11:27:39 +08:00
|
|
|
|
2018-04-05 06:42:19 +08:00
|
|
|
// VINTF manifest fragments to be installed if this module is installed
|
2019-03-05 14:35:41 +08:00
|
|
|
Vintf_fragments []string `android:"path"`
|
2018-04-05 06:42:19 +08:00
|
|
|
|
2016-08-16 02:47:23 +08:00
|
|
|
// names of other modules to install if this module is installed
|
2017-05-06 04:36:36 +08:00
|
|
|
Required []string `android:"arch_variant"`
|
2016-08-16 02:47:23 +08:00
|
|
|
|
2019-04-02 09:37:36 +08: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"`
|
|
|
|
|
2017-09-01 06:07:09 +08:00
|
|
|
// relative path to a file to include in the list of notices for the device
|
2019-03-05 14:35:41 +08:00
|
|
|
Notice *string `android:"path"`
|
2017-09-01 06:07:09 +08:00
|
|
|
|
2018-11-20 01:33:29 +08:00
|
|
|
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"`
|
|
|
|
} `android:"arch_variant"`
|
|
|
|
|
2016-06-02 08:09:44 +08:00
|
|
|
// Set by TargetMutator
|
2019-10-17 02:07:20 +08:00
|
|
|
CompileOS OsType `blueprint:"mutated"`
|
2018-10-03 13:01:37 +08:00
|
|
|
CompileTarget Target `blueprint:"mutated"`
|
|
|
|
CompileMultiTargets []Target `blueprint:"mutated"`
|
|
|
|
CompilePrimary bool `blueprint:"mutated"`
|
2015-01-31 09:27:36 +08:00
|
|
|
|
|
|
|
// Set by InitAndroidModule
|
|
|
|
HostOrDeviceSupported HostOrDeviceSupported `blueprint:"mutated"`
|
2016-10-05 06:13:37 +08:00
|
|
|
ArchSpecific bool `blueprint:"mutated"`
|
2016-10-07 07:12:58 +08:00
|
|
|
|
|
|
|
SkipInstall bool `blueprint:"mutated"`
|
2017-11-30 08:47:17 +08:00
|
|
|
|
|
|
|
NamespaceExportedToMake bool `blueprint:"mutated"`
|
2019-06-07 06:41:36 +08:00
|
|
|
|
|
|
|
MissingDeps []string `blueprint:"mutated"`
|
2019-07-02 06:32:45 +08: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 08:00:16 +08:00
|
|
|
|
|
|
|
// set by ImageMutator
|
|
|
|
ImageVariation string `blueprint:"mutated"`
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
type hostAndDeviceProperties struct {
|
2018-11-10 02:36:55 +08: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-13 04:11:25 +08:00
|
|
|
Device_supported *bool
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
2015-03-18 06:06:21 +08:00
|
|
|
type Multilib string
|
|
|
|
|
|
|
|
const (
|
2017-12-06 05:42:45 +08:00
|
|
|
MultilibBoth Multilib = "both"
|
|
|
|
MultilibFirst Multilib = "first"
|
|
|
|
MultilibCommon Multilib = "common"
|
|
|
|
MultilibCommonFirst Multilib = "common_first"
|
|
|
|
MultilibDefault Multilib = ""
|
2015-03-18 06:06:21 +08:00
|
|
|
)
|
|
|
|
|
2016-06-02 08:09:44 +08:00
|
|
|
type HostOrDeviceSupported int
|
|
|
|
|
|
|
|
const (
|
|
|
|
_ HostOrDeviceSupported = iota
|
2018-08-03 04:46:35 +08:00
|
|
|
|
|
|
|
// Host and HostCross are built by default. Device is not supported.
|
2016-06-02 08:09:44 +08:00
|
|
|
HostSupported
|
2018-08-03 04:46:35 +08:00
|
|
|
|
|
|
|
// Host is built by default. HostCross and Device are not supported.
|
2016-10-20 16:36:11 +08:00
|
|
|
HostSupportedNoCross
|
2018-08-03 04:46:35 +08:00
|
|
|
|
|
|
|
// Device is built by default. Host and HostCross are not supported.
|
2016-06-02 08:09:44 +08:00
|
|
|
DeviceSupported
|
2018-08-03 04:46:35 +08:00
|
|
|
|
|
|
|
// Device is built by default. Host and HostCross are supported.
|
2016-06-02 08:09:44 +08:00
|
|
|
HostAndDeviceSupported
|
2018-08-03 04:46:35 +08:00
|
|
|
|
|
|
|
// Host, HostCross, and Device are built by default.
|
2016-06-02 08:09:44 +08:00
|
|
|
HostAndDeviceDefault
|
2018-08-03 04:46:35 +08: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.
|
2016-10-05 06:13:37 +08:00
|
|
|
NeitherHostNorDeviceSupported
|
2016-06-02 08:09:44 +08:00
|
|
|
)
|
|
|
|
|
2017-11-08 15:03:48 +08:00
|
|
|
type moduleKind int
|
|
|
|
|
|
|
|
const (
|
|
|
|
platformModule moduleKind = iota
|
|
|
|
deviceSpecificModule
|
|
|
|
socSpecificModule
|
|
|
|
productSpecificModule
|
2019-06-25 15:47:17 +08:00
|
|
|
systemExtSpecificModule
|
2017-11-08 15:03:48 +08: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 15:47:17 +08:00
|
|
|
case systemExtSpecificModule:
|
|
|
|
return "systemext-specific"
|
2017-11-08 15:03:48 +08:00
|
|
|
default:
|
|
|
|
panic(fmt.Errorf("unknown module kind %d", k))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-23 08:03:51 +08:00
|
|
|
func initAndroidModuleBase(m Module) {
|
|
|
|
m.base().module = m
|
|
|
|
}
|
|
|
|
|
2017-06-24 06:06:31 +08:00
|
|
|
func InitAndroidModule(m Module) {
|
2019-11-23 08:03:51 +08:00
|
|
|
initAndroidModuleBase(m)
|
2015-01-31 09:27:36 +08:00
|
|
|
base := m.base()
|
2015-03-19 04:28:46 +08:00
|
|
|
|
2017-06-24 06:06:31 +08:00
|
|
|
m.AddProperties(
|
2016-05-18 07:34:16 +08:00
|
|
|
&base.nameProperties,
|
2019-09-25 13:19:02 +08:00
|
|
|
&base.commonProperties)
|
|
|
|
|
|
|
|
// Allow tests to override the default product variables
|
|
|
|
if base.variableProperties == nil {
|
2020-02-07 08:57:45 +08:00
|
|
|
base.variableProperties = defaultProductVariables
|
2019-09-25 13:19:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Filter the product variables properties to the ones that exist on this module
|
|
|
|
base.variableProperties = createVariableProperties(m.GetProperties(), base.variableProperties)
|
|
|
|
if base.variableProperties != nil {
|
|
|
|
m.AddProperties(base.variableProperties)
|
|
|
|
}
|
|
|
|
|
2019-03-19 03:24:29 +08:00
|
|
|
base.generalProperties = m.GetProperties()
|
2018-04-18 05:58:42 +08:00
|
|
|
base.customizableProperties = m.GetProperties()
|
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 21:24:38 +08:00
|
|
|
|
|
|
|
// The default_visibility property needs to be checked and parsed by the visibility module during
|
|
|
|
// its checking and parsing phases.
|
|
|
|
base.primaryVisibilityProperty =
|
|
|
|
newVisibilityProperty("visibility", &base.commonProperties.Visibility)
|
|
|
|
base.visibilityPropertyInfo = []visibilityProperty{base.primaryVisibilityProperty}
|
2015-03-19 04:28:46 +08:00
|
|
|
}
|
|
|
|
|
2017-06-24 06:06:31 +08:00
|
|
|
func InitAndroidArchModule(m Module, hod HostOrDeviceSupported, defaultMultilib Multilib) {
|
|
|
|
InitAndroidModule(m)
|
2015-03-19 04:28:46 +08:00
|
|
|
|
|
|
|
base := m.base()
|
2015-01-31 09:27:36 +08:00
|
|
|
base.commonProperties.HostOrDeviceSupported = hod
|
2016-09-07 01:39:07 +08:00
|
|
|
base.commonProperties.Default_multilib = string(defaultMultilib)
|
2016-10-05 06:13:37 +08:00
|
|
|
base.commonProperties.ArchSpecific = true
|
2018-10-03 13:01:37 +08:00
|
|
|
base.commonProperties.UseTargetVariants = true
|
2015-01-31 09:27:36 +08:00
|
|
|
|
2015-07-09 09:13:11 +08:00
|
|
|
switch hod {
|
2017-07-06 01:35:11 +08:00
|
|
|
case HostAndDeviceSupported, HostAndDeviceDefault:
|
2017-06-24 06:06:31 +08:00
|
|
|
m.AddProperties(&base.hostAndDeviceProperties)
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
2017-06-24 06:06:31 +08:00
|
|
|
InitArchModule(m)
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
2018-10-03 13:01:37 +08:00
|
|
|
func InitAndroidMultiTargetsArchModule(m Module, hod HostOrDeviceSupported, defaultMultilib Multilib) {
|
|
|
|
InitAndroidArchModule(m, hod, defaultMultilib)
|
|
|
|
m.base().commonProperties.UseTargetVariants = false
|
|
|
|
}
|
|
|
|
|
2017-02-03 02:46:07 +08:00
|
|
|
// A ModuleBase object contains the properties that are common to all Android
|
2015-01-31 09:27:36 +08: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-03 02:46:07 +08: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-07 05:29:25 +08: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 09:27:36 +08:00
|
|
|
// system including details about the particular build variant that is to be
|
|
|
|
// generated.
|
|
|
|
//
|
|
|
|
// For example:
|
|
|
|
//
|
|
|
|
// import (
|
2017-02-03 02:46:07 +08:00
|
|
|
// "android/soong/android"
|
2015-01-31 09:27:36 +08:00
|
|
|
// )
|
|
|
|
//
|
|
|
|
// type myModule struct {
|
2017-02-03 02:46:07 +08:00
|
|
|
// android.ModuleBase
|
2015-01-31 09:27:36 +08:00
|
|
|
// properties struct {
|
|
|
|
// MyProperty string
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
2017-06-24 06:06:31 +08:00
|
|
|
// func NewMyModule() android.Module) {
|
2015-01-31 09:27:36 +08:00
|
|
|
// m := &myModule{}
|
2017-06-24 06:06:31 +08:00
|
|
|
// m.AddProperties(&m.properties)
|
|
|
|
// android.InitAndroidModule(m)
|
|
|
|
// return m
|
2015-01-31 09:27:36 +08:00
|
|
|
// }
|
|
|
|
//
|
2017-02-03 02:46:07 +08:00
|
|
|
// func (m *myModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
2015-01-31 09:27:36 +08:00
|
|
|
// // Get the CPU architecture for the current build variant.
|
|
|
|
// variantArch := ctx.Arch()
|
|
|
|
//
|
|
|
|
// // ...
|
|
|
|
// }
|
2016-05-19 06:37:25 +08:00
|
|
|
type ModuleBase struct {
|
2015-01-31 09:27:36 +08:00
|
|
|
// Putting the curiously recurring thing pointing to the thing that contains
|
|
|
|
// the thing pattern to good use.
|
2017-06-24 06:06:31 +08:00
|
|
|
// TODO: remove this
|
2016-05-19 06:37:25 +08:00
|
|
|
module Module
|
2015-01-31 09:27:36 +08:00
|
|
|
|
2016-05-18 07:34:16 +08:00
|
|
|
nameProperties nameProperties
|
2015-01-31 09:27:36 +08:00
|
|
|
commonProperties commonProperties
|
2019-09-25 13:19:02 +08:00
|
|
|
variableProperties interface{}
|
2015-01-31 09:27:36 +08:00
|
|
|
hostAndDeviceProperties hostAndDeviceProperties
|
|
|
|
generalProperties []interface{}
|
2018-10-25 03:42:09 +08:00
|
|
|
archProperties [][]interface{}
|
2016-08-20 07:07:38 +08:00
|
|
|
customizableProperties []interface{}
|
2015-01-31 09:27:36 +08: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 21:24:38 +08: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
|
|
|
|
|
2015-01-31 09:27:36 +08:00
|
|
|
noAddressSanitizer bool
|
2015-09-24 06:26:20 +08:00
|
|
|
installFiles Paths
|
|
|
|
checkbuildFiles Paths
|
2019-03-18 11:01:38 +08:00
|
|
|
noticeFile OptionalPath
|
2015-06-17 07:38:17 +08:00
|
|
|
|
|
|
|
// Used by buildTargetSingleton to create checkbuild and per-directory build targets
|
|
|
|
// Only set on the final variant of each module
|
2017-11-29 09:34:01 +08:00
|
|
|
installTarget WritablePath
|
|
|
|
checkbuildTarget WritablePath
|
2015-06-17 07:38:17 +08:00
|
|
|
blueprintDir string
|
2016-08-20 07:07:38 +08:00
|
|
|
|
2016-09-14 04:42:32 +08:00
|
|
|
hooks hooks
|
2017-06-24 06:06:31 +08:00
|
|
|
|
|
|
|
registerProps []interface{}
|
2017-07-14 05:43:27 +08:00
|
|
|
|
|
|
|
// For tests
|
2017-10-24 08:16:14 +08:00
|
|
|
buildParams []BuildParams
|
2019-02-26 06:54:28 +08:00
|
|
|
ruleParams map[blueprint.Rule]blueprint.RuleParams
|
2018-12-13 01:01:34 +08:00
|
|
|
variables map[string]string
|
2018-10-03 04:59:46 +08:00
|
|
|
|
|
|
|
prefer32 func(ctx BaseModuleContext, base *ModuleBase, class OsClass) bool
|
2017-06-24 06:06:31 +08:00
|
|
|
}
|
|
|
|
|
2019-06-07 07:57:04 +08:00
|
|
|
func (m *ModuleBase) DepsMutator(BottomUpMutatorContext) {}
|
2019-02-02 08:53:07 +08:00
|
|
|
|
2019-06-07 07:57:04 +08:00
|
|
|
func (m *ModuleBase) AddProperties(props ...interface{}) {
|
|
|
|
m.registerProps = append(m.registerProps, props...)
|
2017-06-24 06:06:31 +08:00
|
|
|
}
|
|
|
|
|
2019-06-07 07:57:04 +08:00
|
|
|
func (m *ModuleBase) GetProperties() []interface{} {
|
|
|
|
return m.registerProps
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
2019-06-07 07:57:04 +08:00
|
|
|
func (m *ModuleBase) BuildParamsForTests() []BuildParams {
|
|
|
|
return m.buildParams
|
2017-07-14 05:43:27 +08:00
|
|
|
}
|
|
|
|
|
2019-06-07 07:57:04 +08:00
|
|
|
func (m *ModuleBase) RuleParamsForTests() map[blueprint.Rule]blueprint.RuleParams {
|
|
|
|
return m.ruleParams
|
2019-02-26 06:54:28 +08:00
|
|
|
}
|
|
|
|
|
2019-06-07 07:57:04 +08:00
|
|
|
func (m *ModuleBase) VariablesForTests() map[string]string {
|
|
|
|
return m.variables
|
2018-12-13 01:01:34 +08:00
|
|
|
}
|
|
|
|
|
2019-06-07 07:57:04 +08:00
|
|
|
func (m *ModuleBase) Prefer32(prefer32 func(ctx BaseModuleContext, base *ModuleBase, class OsClass) bool) {
|
|
|
|
m.prefer32 = prefer32
|
2018-10-03 04:59:46 +08:00
|
|
|
}
|
|
|
|
|
2016-10-07 07:12:58 +08: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 07:57:04 +08:00
|
|
|
func (m *ModuleBase) Name() string {
|
|
|
|
return String(m.nameProperties.Name)
|
2016-05-18 07:34:16 +08:00
|
|
|
}
|
|
|
|
|
2019-07-02 06:32:45 +08: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 07:12:58 +08:00
|
|
|
// BaseModuleName returns the name of the module as specified in the blueprints file.
|
2019-06-07 07:57:04 +08:00
|
|
|
func (m *ModuleBase) BaseModuleName() string {
|
|
|
|
return String(m.nameProperties.Name)
|
2016-10-07 07:12:58 +08:00
|
|
|
}
|
|
|
|
|
2019-06-07 07:57:04 +08:00
|
|
|
func (m *ModuleBase) base() *ModuleBase {
|
|
|
|
return m
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
2019-05-31 21:00:04 +08: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 21:24:38 +08:00
|
|
|
return m.visibilityPropertyInfo
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *ModuleBase) visibility() []string {
|
|
|
|
// The soong_namespace module does not initialize the primaryVisibilityProperty.
|
|
|
|
if m.primaryVisibilityProperty != nil {
|
|
|
|
return m.primaryVisibilityProperty.getStrings()
|
|
|
|
} else {
|
|
|
|
return nil
|
2019-05-31 21:00:04 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-07 07:57:04 +08:00
|
|
|
func (m *ModuleBase) Target() Target {
|
|
|
|
return m.commonProperties.CompileTarget
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
2019-06-07 07:57:04 +08:00
|
|
|
func (m *ModuleBase) TargetPrimary() bool {
|
|
|
|
return m.commonProperties.CompilePrimary
|
2016-09-14 00:59:14 +08:00
|
|
|
}
|
|
|
|
|
2019-06-07 07:57:04 +08:00
|
|
|
func (m *ModuleBase) MultiTargets() []Target {
|
|
|
|
return m.commonProperties.CompileMultiTargets
|
2018-10-03 13:01:37 +08:00
|
|
|
}
|
|
|
|
|
2019-06-07 07:57:04 +08:00
|
|
|
func (m *ModuleBase) Os() OsType {
|
|
|
|
return m.Target().Os
|
2015-11-25 09:53:15 +08:00
|
|
|
}
|
|
|
|
|
2019-06-07 07:57:04 +08:00
|
|
|
func (m *ModuleBase) Host() bool {
|
|
|
|
return m.Os().Class == Host || m.Os().Class == HostCross
|
2016-02-10 09:43:51 +08:00
|
|
|
}
|
|
|
|
|
2019-06-07 07:57:04 +08:00
|
|
|
func (m *ModuleBase) Arch() Arch {
|
|
|
|
return m.Target().Arch
|
2016-02-10 09:43:51 +08:00
|
|
|
}
|
|
|
|
|
2019-06-07 07:57:04 +08:00
|
|
|
func (m *ModuleBase) ArchSpecific() bool {
|
|
|
|
return m.commonProperties.ArchSpecific
|
2016-10-05 06:13:37 +08:00
|
|
|
}
|
|
|
|
|
2019-06-07 07:57:04 +08:00
|
|
|
func (m *ModuleBase) OsClassSupported() []OsClass {
|
|
|
|
switch m.commonProperties.HostOrDeviceSupported {
|
2016-06-02 08:09:44 +08:00
|
|
|
case HostSupported:
|
|
|
|
return []OsClass{Host, HostCross}
|
2016-10-20 16:36:11 +08:00
|
|
|
case HostSupportedNoCross:
|
|
|
|
return []OsClass{Host}
|
2016-06-02 08:09:44 +08:00
|
|
|
case DeviceSupported:
|
|
|
|
return []OsClass{Device}
|
2018-08-03 04:46:35 +08:00
|
|
|
case HostAndDeviceSupported, HostAndDeviceDefault:
|
2016-06-02 08:09:44 +08:00
|
|
|
var supported []OsClass
|
2019-06-07 07:57:04 +08:00
|
|
|
if Bool(m.hostAndDeviceProperties.Host_supported) ||
|
|
|
|
(m.commonProperties.HostOrDeviceSupported == HostAndDeviceDefault &&
|
|
|
|
m.hostAndDeviceProperties.Host_supported == nil) {
|
2016-06-02 08:09:44 +08:00
|
|
|
supported = append(supported, Host, HostCross)
|
|
|
|
}
|
2019-06-07 07:57:04 +08:00
|
|
|
if m.hostAndDeviceProperties.Device_supported == nil ||
|
|
|
|
*m.hostAndDeviceProperties.Device_supported {
|
2016-06-02 08:09:44 +08:00
|
|
|
supported = append(supported, Device)
|
|
|
|
}
|
|
|
|
return supported
|
|
|
|
default:
|
|
|
|
return nil
|
|
|
|
}
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
2019-06-07 07:57:04 +08:00
|
|
|
func (m *ModuleBase) DeviceSupported() bool {
|
|
|
|
return m.commonProperties.HostOrDeviceSupported == DeviceSupported ||
|
|
|
|
m.commonProperties.HostOrDeviceSupported == HostAndDeviceSupported &&
|
|
|
|
(m.hostAndDeviceProperties.Device_supported == nil ||
|
|
|
|
*m.hostAndDeviceProperties.Device_supported)
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
2019-11-27 02:04:12 +08:00
|
|
|
func (m *ModuleBase) HostSupported() bool {
|
|
|
|
return m.commonProperties.HostOrDeviceSupported == HostSupported ||
|
|
|
|
m.commonProperties.HostOrDeviceSupported == HostAndDeviceSupported &&
|
|
|
|
(m.hostAndDeviceProperties.Host_supported != nil &&
|
|
|
|
*m.hostAndDeviceProperties.Host_supported)
|
|
|
|
}
|
|
|
|
|
2019-06-07 07:57:04 +08:00
|
|
|
func (m *ModuleBase) Platform() bool {
|
2019-06-25 15:47:17 +08:00
|
|
|
return !m.DeviceSpecific() && !m.SocSpecific() && !m.ProductSpecific() && !m.SystemExtSpecific()
|
2018-04-10 12:07:10 +08:00
|
|
|
}
|
|
|
|
|
2019-06-07 07:57:04 +08:00
|
|
|
func (m *ModuleBase) DeviceSpecific() bool {
|
|
|
|
return Bool(m.commonProperties.Device_specific)
|
2018-04-10 12:07:10 +08:00
|
|
|
}
|
|
|
|
|
2019-06-07 07:57:04 +08:00
|
|
|
func (m *ModuleBase) SocSpecific() bool {
|
|
|
|
return Bool(m.commonProperties.Vendor) || Bool(m.commonProperties.Proprietary) || Bool(m.commonProperties.Soc_specific)
|
2018-04-10 12:07:10 +08:00
|
|
|
}
|
|
|
|
|
2019-06-07 07:57:04 +08:00
|
|
|
func (m *ModuleBase) ProductSpecific() bool {
|
|
|
|
return Bool(m.commonProperties.Product_specific)
|
2018-04-10 12:07:10 +08:00
|
|
|
}
|
|
|
|
|
2019-06-25 15:47:17 +08:00
|
|
|
func (m *ModuleBase) SystemExtSpecific() bool {
|
|
|
|
return Bool(m.commonProperties.System_ext_specific)
|
2018-05-29 20:28:54 +08:00
|
|
|
}
|
|
|
|
|
2019-06-07 07:57:04 +08:00
|
|
|
func (m *ModuleBase) Enabled() bool {
|
|
|
|
if m.commonProperties.Enabled == nil {
|
|
|
|
return !m.Os().DefaultDisabled
|
2015-11-25 09:53:15 +08:00
|
|
|
}
|
2019-06-07 07:57:04 +08:00
|
|
|
return *m.commonProperties.Enabled
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
2019-06-07 07:57:04 +08:00
|
|
|
func (m *ModuleBase) SkipInstall() {
|
|
|
|
m.commonProperties.SkipInstall = true
|
2016-10-07 07:12:58 +08:00
|
|
|
}
|
|
|
|
|
2019-06-07 07:57:04 +08: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 17:23:01 +08:00
|
|
|
}
|
|
|
|
|
2019-06-07 07:57:04 +08:00
|
|
|
func (m *ModuleBase) computeInstallDeps(
|
2015-09-24 06:26:20 +08:00
|
|
|
ctx blueprint.ModuleContext) Paths {
|
2015-01-31 09:27:36 +08:00
|
|
|
|
2015-09-24 06:26:20 +08:00
|
|
|
result := Paths{}
|
2018-06-22 04:03:07 +08:00
|
|
|
// TODO(ccross): we need to use WalkDeps and have some way to know which dependencies require installation
|
2015-01-31 09:27:36 +08:00
|
|
|
ctx.VisitDepsDepthFirstIf(isFileInstaller,
|
|
|
|
func(m blueprint.Module) {
|
|
|
|
fileInstaller := m.(fileInstaller)
|
|
|
|
files := fileInstaller.filesToInstall()
|
|
|
|
result = append(result, files...)
|
|
|
|
})
|
|
|
|
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
|
2019-06-07 07:57:04 +08:00
|
|
|
func (m *ModuleBase) filesToInstall() Paths {
|
|
|
|
return m.installFiles
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
2019-06-07 07:57:04 +08:00
|
|
|
func (m *ModuleBase) NoAddressSanitizer() bool {
|
|
|
|
return m.noAddressSanitizer
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
2019-06-07 07:57:04 +08:00
|
|
|
func (m *ModuleBase) InstallInData() bool {
|
2015-12-22 06:55:28 +08:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2019-09-12 01:25:18 +08:00
|
|
|
func (m *ModuleBase) InstallInTestcases() bool {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2019-06-07 07:57:04 +08:00
|
|
|
func (m *ModuleBase) InstallInSanitizerDir() bool {
|
2017-03-30 13:00:18 +08:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2020-01-22 07:53:22 +08:00
|
|
|
func (m *ModuleBase) InstallInRamdisk() bool {
|
|
|
|
return Bool(m.commonProperties.Ramdisk)
|
|
|
|
}
|
|
|
|
|
2019-06-07 07:57:04 +08:00
|
|
|
func (m *ModuleBase) InstallInRecovery() bool {
|
|
|
|
return Bool(m.commonProperties.Recovery)
|
2018-01-31 23:54:12 +08:00
|
|
|
}
|
|
|
|
|
2019-10-03 02:10:58 +08:00
|
|
|
func (m *ModuleBase) InstallInRoot() bool {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2019-07-30 07:44:46 +08:00
|
|
|
func (m *ModuleBase) InstallBypassMake() bool {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2019-06-07 07:57:04 +08:00
|
|
|
func (m *ModuleBase) Owner() string {
|
|
|
|
return String(m.commonProperties.Owner)
|
2018-08-31 17:01:37 +08:00
|
|
|
}
|
|
|
|
|
2019-06-07 07:57:04 +08:00
|
|
|
func (m *ModuleBase) NoticeFile() OptionalPath {
|
|
|
|
return m.noticeFile
|
2019-03-18 11:01:38 +08:00
|
|
|
}
|
|
|
|
|
2019-11-19 08:00:16 +08: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-01-22 07:53:22 +08:00
|
|
|
func (m *ModuleBase) InRamdisk() bool {
|
|
|
|
return m.base().commonProperties.ImageVariation == RamdiskVariation
|
|
|
|
}
|
|
|
|
|
2019-11-19 08:00:16 +08:00
|
|
|
func (m *ModuleBase) InRecovery() bool {
|
|
|
|
return m.base().commonProperties.ImageVariation == RecoveryVariation
|
|
|
|
}
|
|
|
|
|
2019-12-30 15:31:09 +08: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-06-07 07:57:04 +08:00
|
|
|
func (m *ModuleBase) generateModuleTarget(ctx ModuleContext) {
|
2015-09-24 06:26:20 +08:00
|
|
|
allInstalledFiles := Paths{}
|
|
|
|
allCheckbuildFiles := Paths{}
|
2017-11-29 09:34:01 +08:00
|
|
|
ctx.VisitAllModuleVariants(func(module Module) {
|
|
|
|
a := module.base()
|
2015-03-27 07:10:12 +08:00
|
|
|
allInstalledFiles = append(allInstalledFiles, a.installFiles...)
|
|
|
|
allCheckbuildFiles = append(allCheckbuildFiles, a.checkbuildFiles...)
|
2015-01-31 09:27:36 +08:00
|
|
|
})
|
|
|
|
|
2017-11-29 09:34:01 +08:00
|
|
|
var deps Paths
|
2015-03-18 04:24:18 +08:00
|
|
|
|
2017-11-30 08:47:17 +08:00
|
|
|
namespacePrefix := ctx.Namespace().(*Namespace).id
|
|
|
|
if namespacePrefix != "" {
|
|
|
|
namespacePrefix = namespacePrefix + "-"
|
|
|
|
}
|
|
|
|
|
2015-01-31 09:27:36 +08:00
|
|
|
if len(allInstalledFiles) > 0 {
|
2017-11-30 08:47:17 +08:00
|
|
|
name := PathForPhony(ctx, namespacePrefix+ctx.ModuleName()+"-install")
|
2017-11-29 09:34:01 +08:00
|
|
|
ctx.Build(pctx, BuildParams{
|
2015-03-18 04:24:18 +08:00
|
|
|
Rule: blueprint.Phony,
|
2017-11-29 09:34:01 +08:00
|
|
|
Output: name,
|
|
|
|
Implicits: allInstalledFiles,
|
2017-11-29 16:27:14 +08:00
|
|
|
Default: !ctx.Config().EmbeddedInMake(),
|
2015-03-18 04:24:18 +08:00
|
|
|
})
|
|
|
|
deps = append(deps, name)
|
2019-06-07 07:57:04 +08:00
|
|
|
m.installTarget = name
|
2015-03-18 04:24:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if len(allCheckbuildFiles) > 0 {
|
2017-11-30 08:47:17 +08:00
|
|
|
name := PathForPhony(ctx, namespacePrefix+ctx.ModuleName()+"-checkbuild")
|
2017-11-29 09:34:01 +08:00
|
|
|
ctx.Build(pctx, BuildParams{
|
2015-03-18 04:24:18 +08:00
|
|
|
Rule: blueprint.Phony,
|
2017-11-29 09:34:01 +08:00
|
|
|
Output: name,
|
|
|
|
Implicits: allCheckbuildFiles,
|
2015-03-18 04:24:18 +08:00
|
|
|
})
|
|
|
|
deps = append(deps, name)
|
2019-06-07 07:57:04 +08:00
|
|
|
m.checkbuildTarget = name
|
2015-03-18 04:24:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if len(deps) > 0 {
|
2015-12-12 05:51:06 +08:00
|
|
|
suffix := ""
|
2017-11-29 16:27:14 +08:00
|
|
|
if ctx.Config().EmbeddedInMake() {
|
2015-12-12 05:51:06 +08:00
|
|
|
suffix = "-soong"
|
|
|
|
}
|
|
|
|
|
2017-11-30 08:47:17 +08:00
|
|
|
name := PathForPhony(ctx, namespacePrefix+ctx.ModuleName()+suffix)
|
2017-11-29 09:34:01 +08:00
|
|
|
ctx.Build(pctx, BuildParams{
|
2015-03-18 04:24:18 +08:00
|
|
|
Rule: blueprint.Phony,
|
2017-11-30 08:47:17 +08:00
|
|
|
Outputs: []WritablePath{name},
|
2015-03-18 04:24:18 +08:00
|
|
|
Implicits: deps,
|
2015-01-31 09:27:36 +08:00
|
|
|
})
|
2015-06-17 07:38:17 +08:00
|
|
|
|
2019-06-07 07:57:04 +08:00
|
|
|
m.blueprintDir = ctx.ModuleDir()
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-04 07:23:27 +08:00
|
|
|
func determineModuleKind(m *ModuleBase, ctx blueprint.EarlyModuleContext) moduleKind {
|
2019-06-07 07:57:04 +08: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 15:47:17 +08:00
|
|
|
var systemExtSpecific = Bool(m.commonProperties.System_ext_specific)
|
2017-11-08 15:03:48 +08:00
|
|
|
|
2018-05-29 20:28:54 +08: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 07:57:04 +08:00
|
|
|
if Bool(m.commonProperties.Vendor) {
|
2017-11-08 15:03:48 +08:00
|
|
|
ctx.PropertyErrorf("vendor", msg)
|
|
|
|
}
|
2019-06-07 07:57:04 +08:00
|
|
|
if Bool(m.commonProperties.Proprietary) {
|
2017-11-08 15:03:48 +08:00
|
|
|
ctx.PropertyErrorf("proprietary", msg)
|
|
|
|
}
|
2019-06-07 07:57:04 +08:00
|
|
|
if Bool(m.commonProperties.Soc_specific) {
|
2017-11-08 15:03:48 +08:00
|
|
|
ctx.PropertyErrorf("soc_specific", msg)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-25 15:47:17 +08: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 20:28:54 +08:00
|
|
|
}
|
|
|
|
|
2019-06-25 15:47:17 +08:00
|
|
|
if (socSpecific || deviceSpecific) && (productSpecific || systemExtSpecific) {
|
2018-05-29 20:28:54 +08: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 15:47:17 +08: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 20:28:54 +08:00
|
|
|
}
|
|
|
|
if deviceSpecific {
|
|
|
|
ctx.PropertyErrorf("device_specific", msg)
|
|
|
|
} else {
|
2019-06-07 07:57:04 +08:00
|
|
|
if Bool(m.commonProperties.Vendor) {
|
2018-05-29 20:28:54 +08:00
|
|
|
ctx.PropertyErrorf("vendor", msg)
|
|
|
|
}
|
2019-06-07 07:57:04 +08:00
|
|
|
if Bool(m.commonProperties.Proprietary) {
|
2018-05-29 20:28:54 +08:00
|
|
|
ctx.PropertyErrorf("proprietary", msg)
|
|
|
|
}
|
2019-06-07 07:57:04 +08:00
|
|
|
if Bool(m.commonProperties.Soc_specific) {
|
2018-05-29 20:28:54 +08:00
|
|
|
ctx.PropertyErrorf("soc_specific", msg)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-08 15:03:48 +08:00
|
|
|
if productSpecific {
|
|
|
|
return productSpecificModule
|
2019-06-25 15:47:17 +08:00
|
|
|
} else if systemExtSpecific {
|
|
|
|
return systemExtSpecificModule
|
2017-11-08 15:03:48 +08:00
|
|
|
} else if deviceSpecific {
|
|
|
|
return deviceSpecificModule
|
|
|
|
} else if socSpecific {
|
|
|
|
return socSpecificModule
|
|
|
|
} else {
|
|
|
|
return platformModule
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-04 07:23:27 +08:00
|
|
|
func (m *ModuleBase) earlyModuleContextFactory(ctx blueprint.EarlyModuleContext) earlyModuleContext {
|
2019-12-31 10:43:07 +08:00
|
|
|
return earlyModuleContext{
|
2020-01-04 07:23:27 +08:00
|
|
|
EarlyModuleContext: ctx,
|
|
|
|
kind: determineModuleKind(m, ctx),
|
|
|
|
config: ctx.Config().(Config),
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-31 10:43:07 +08: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 07:57:04 +08:00
|
|
|
func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) {
|
2019-06-07 05:29:25 +08:00
|
|
|
ctx := &moduleContext{
|
2019-06-07 05:33:29 +08:00
|
|
|
module: m.module,
|
2019-06-07 07:13:11 +08:00
|
|
|
bp: blueprintCtx,
|
2019-06-07 05:33:29 +08:00
|
|
|
baseModuleContext: m.baseModuleContextFactory(blueprintCtx),
|
|
|
|
installDeps: m.computeInstallDeps(blueprintCtx),
|
|
|
|
installFiles: m.installFiles,
|
|
|
|
variables: make(map[string]string),
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
2019-06-07 06:41:36 +08: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 07:13:11 +08:00
|
|
|
// For the final GenerateAndroidBuildActions pass, require that all visited dependencies Soong modules and
|
|
|
|
// are enabled.
|
|
|
|
ctx.baseModuleContext.strictVisitDeps = true
|
|
|
|
|
2019-02-26 06:54:28 +08:00
|
|
|
if ctx.config.captureBuild {
|
|
|
|
ctx.ruleParams = make(map[blueprint.Rule]blueprint.RuleParams)
|
|
|
|
}
|
|
|
|
|
2017-05-10 04:45:28 +08:00
|
|
|
desc := "//" + ctx.ModuleDir() + ":" + ctx.ModuleName() + " "
|
|
|
|
var suffix []string
|
2017-11-29 09:34:01 +08:00
|
|
|
if ctx.Os().Class != Device && ctx.Os().Class != Generic {
|
|
|
|
suffix = append(suffix, ctx.Os().String())
|
2017-05-10 04:45:28 +08:00
|
|
|
}
|
2017-11-29 09:34:01 +08:00
|
|
|
if !ctx.PrimaryArch() {
|
|
|
|
suffix = append(suffix, ctx.Arch().ArchType.String())
|
2017-05-10 04:45:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ctx.Variable(pctx, "moduleDesc", desc)
|
|
|
|
|
|
|
|
s := ""
|
|
|
|
if len(suffix) > 0 {
|
|
|
|
s = " [" + strings.Join(suffix, " ") + "]"
|
|
|
|
}
|
|
|
|
ctx.Variable(pctx, "moduleDescSuffix", s)
|
|
|
|
|
2018-11-20 01:33:29 +08:00
|
|
|
// Some common property checks for properties that will be used later in androidmk.go
|
2019-06-07 07:57:04 +08:00
|
|
|
if m.commonProperties.Dist.Dest != nil {
|
|
|
|
_, err := validateSafePath(*m.commonProperties.Dist.Dest)
|
2018-11-20 01:33:29 +08:00
|
|
|
if err != nil {
|
|
|
|
ctx.PropertyErrorf("dist.dest", "%s", err.Error())
|
|
|
|
}
|
|
|
|
}
|
2019-06-07 07:57:04 +08:00
|
|
|
if m.commonProperties.Dist.Dir != nil {
|
|
|
|
_, err := validateSafePath(*m.commonProperties.Dist.Dir)
|
2018-11-20 01:33:29 +08:00
|
|
|
if err != nil {
|
|
|
|
ctx.PropertyErrorf("dist.dir", "%s", err.Error())
|
|
|
|
}
|
|
|
|
}
|
2019-06-07 07:57:04 +08:00
|
|
|
if m.commonProperties.Dist.Suffix != nil {
|
|
|
|
if strings.Contains(*m.commonProperties.Dist.Suffix, "/") {
|
2018-11-20 01:33:29 +08:00
|
|
|
ctx.PropertyErrorf("dist.suffix", "Suffix may not contain a '/' character.")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-07 07:57:04 +08:00
|
|
|
if m.Enabled() {
|
2019-08-23 10:18:57 +08:00
|
|
|
// ensure all direct android.Module deps are enabled
|
|
|
|
ctx.VisitDirectDepsBlueprint(func(bm blueprint.Module) {
|
|
|
|
if _, ok := bm.(Module); ok {
|
|
|
|
ctx.validateAndroidModule(bm, ctx.baseModuleContext.strictVisitDeps)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2019-06-07 07:57:04 +08:00
|
|
|
notice := proptools.StringDefault(m.commonProperties.Notice, "NOTICE")
|
|
|
|
if module := SrcIsModule(notice); module != "" {
|
|
|
|
m.noticeFile = ctx.ExpandOptionalSource(¬ice, "notice")
|
2019-03-18 11:01:38 +08:00
|
|
|
} else {
|
|
|
|
noticePath := filepath.Join(ctx.ModuleDir(), notice)
|
2019-06-07 07:57:04 +08:00
|
|
|
m.noticeFile = ExistentPathForSource(ctx, noticePath)
|
2018-11-17 05:26:43 +08:00
|
|
|
}
|
2019-06-18 08:40:56 +08:00
|
|
|
|
|
|
|
m.module.GenerateAndroidBuildActions(ctx)
|
|
|
|
if ctx.Failed() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
m.installFiles = append(m.installFiles, ctx.installFiles...)
|
|
|
|
m.checkbuildFiles = append(m.checkbuildFiles, ctx.checkbuildFiles...)
|
2019-06-07 07:13:11 +08: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 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
2019-06-07 07:57:04 +08:00
|
|
|
if m == ctx.FinalModule().(Module).base() {
|
|
|
|
m.generateModuleTarget(ctx)
|
2016-09-20 06:18:11 +08:00
|
|
|
if ctx.Failed() {
|
|
|
|
return
|
|
|
|
}
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
2017-07-14 05:43:27 +08:00
|
|
|
|
2019-06-07 07:57:04 +08:00
|
|
|
m.buildParams = ctx.buildParams
|
|
|
|
m.ruleParams = ctx.ruleParams
|
|
|
|
m.variables = ctx.variables
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
2019-12-31 10:43:07 +08:00
|
|
|
type earlyModuleContext struct {
|
2020-01-04 07:23:27 +08:00
|
|
|
blueprint.EarlyModuleContext
|
2019-12-31 10:43:07 +08:00
|
|
|
|
|
|
|
kind moduleKind
|
|
|
|
config Config
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e *earlyModuleContext) Glob(globPattern string, excludes []string) Paths {
|
|
|
|
ret, err := e.GlobWithDeps(globPattern, excludes)
|
|
|
|
if err != nil {
|
|
|
|
e.ModuleErrorf("glob: %s", err.Error())
|
|
|
|
}
|
|
|
|
return pathsForModuleSrcFromFullPath(e, ret, true)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e *earlyModuleContext) GlobFiles(globPattern string, excludes []string) Paths {
|
|
|
|
ret, err := e.GlobWithDeps(globPattern, excludes)
|
|
|
|
if err != nil {
|
|
|
|
e.ModuleErrorf("glob: %s", err.Error())
|
|
|
|
}
|
|
|
|
return pathsForModuleSrcFromFullPath(e, ret, false)
|
|
|
|
}
|
|
|
|
|
2020-01-11 09:11:46 +08:00
|
|
|
func (b *earlyModuleContext) IsSymlink(path Path) bool {
|
|
|
|
fileInfo, err := b.config.fs.Lstat(path.String())
|
|
|
|
if err != nil {
|
|
|
|
b.ModuleErrorf("os.Lstat(%q) failed: %s", path.String(), err)
|
|
|
|
}
|
|
|
|
return fileInfo.Mode()&os.ModeSymlink == os.ModeSymlink
|
|
|
|
}
|
|
|
|
|
|
|
|
func (b *earlyModuleContext) Readlink(path Path) string {
|
|
|
|
dest, err := b.config.fs.Readlink(path.String())
|
|
|
|
if err != nil {
|
|
|
|
b.ModuleErrorf("os.Readlink(%q) failed: %s", path.String(), err)
|
|
|
|
}
|
|
|
|
return dest
|
|
|
|
}
|
|
|
|
|
2019-12-31 10:43:07 +08:00
|
|
|
func (e *earlyModuleContext) Module() Module {
|
2020-01-04 07:23:27 +08:00
|
|
|
module, _ := e.EarlyModuleContext.Module().(Module)
|
2019-12-31 10:43:07 +08:00
|
|
|
return module
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e *earlyModuleContext) Config() Config {
|
2020-01-04 07:23:27 +08:00
|
|
|
return e.EarlyModuleContext.Config().(Config)
|
2019-12-31 10:43:07 +08: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
|
|
|
|
}
|
|
|
|
|
|
|
|
type baseModuleContext struct {
|
|
|
|
bp blueprint.BaseModuleContext
|
|
|
|
earlyModuleContext
|
2019-11-21 09:12:35 +08:00
|
|
|
os OsType
|
2016-09-14 00:59:14 +08:00
|
|
|
target Target
|
2018-10-03 13:01:37 +08:00
|
|
|
multiTargets []Target
|
2016-09-14 00:59:14 +08:00
|
|
|
targetPrimary bool
|
|
|
|
debug bool
|
2019-06-07 07:13:11 +08:00
|
|
|
|
|
|
|
walkPath []Module
|
|
|
|
|
|
|
|
strictVisitDeps bool // If true, enforce that all dependencies are enabled
|
2015-03-25 02:13:38 +08:00
|
|
|
}
|
|
|
|
|
2019-12-31 10:43:07 +08: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) }
|
|
|
|
func (b *baseModuleContext) OtherModuleErrorf(m blueprint.Module, fmt string, args ...interface{}) {
|
|
|
|
b.bp.OtherModuleErrorf(m, fmt, args)
|
|
|
|
}
|
|
|
|
func (b *baseModuleContext) OtherModuleDependencyTag(m blueprint.Module) blueprint.DependencyTag {
|
|
|
|
return b.bp.OtherModuleDependencyTag(m)
|
|
|
|
}
|
|
|
|
func (b *baseModuleContext) OtherModuleExists(name string) bool { return b.bp.OtherModuleExists(name) }
|
|
|
|
func (b *baseModuleContext) OtherModuleType(m blueprint.Module) string { return b.bp.OtherModuleType(m) }
|
|
|
|
|
|
|
|
func (b *baseModuleContext) GetDirectDepWithTag(name string, tag blueprint.DependencyTag) blueprint.Module {
|
|
|
|
return b.bp.GetDirectDepWithTag(name, tag)
|
|
|
|
}
|
|
|
|
|
2019-06-07 05:29:25 +08:00
|
|
|
type moduleContext struct {
|
2019-06-07 07:13:11 +08:00
|
|
|
bp blueprint.ModuleContext
|
2019-06-07 05:33:29 +08:00
|
|
|
baseModuleContext
|
2015-09-24 06:26:20 +08:00
|
|
|
installDeps Paths
|
|
|
|
installFiles Paths
|
|
|
|
checkbuildFiles Paths
|
2016-08-04 02:57:50 +08:00
|
|
|
module Module
|
2017-07-14 05:43:27 +08:00
|
|
|
|
|
|
|
// For tests
|
2017-10-24 08:16:14 +08:00
|
|
|
buildParams []BuildParams
|
2019-02-26 06:54:28 +08:00
|
|
|
ruleParams map[blueprint.Rule]blueprint.RuleParams
|
2018-12-13 01:01:34 +08:00
|
|
|
variables map[string]string
|
2015-12-18 08:39:19 +08:00
|
|
|
}
|
|
|
|
|
2019-06-11 06:15:17 +08:00
|
|
|
func (m *moduleContext) ninjaError(params BuildParams, err error) (PackageContext, BuildParams) {
|
|
|
|
return pctx, BuildParams{
|
2019-06-08 04:06:06 +08:00
|
|
|
Rule: ErrorRule,
|
|
|
|
Description: params.Description,
|
|
|
|
Output: params.Output,
|
|
|
|
Outputs: params.Outputs,
|
|
|
|
ImplicitOutput: params.ImplicitOutput,
|
|
|
|
ImplicitOutputs: params.ImplicitOutputs,
|
2015-12-18 08:39:19 +08:00
|
|
|
Args: map[string]string{
|
|
|
|
"error": err.Error(),
|
|
|
|
},
|
2019-06-11 06:15:17 +08:00
|
|
|
}
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
2019-06-07 05:29:25 +08:00
|
|
|
func (m *moduleContext) ModuleBuild(pctx PackageContext, params ModuleBuildParams) {
|
|
|
|
m.Build(pctx, BuildParams(params))
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
2017-11-29 09:34:01 +08:00
|
|
|
func convertBuildParams(params BuildParams) blueprint.BuildParams {
|
2015-09-24 06:26:20 +08:00
|
|
|
bparams := blueprint.BuildParams{
|
2016-11-04 05:28:31 +08:00
|
|
|
Rule: params.Rule,
|
2017-11-29 09:34:01 +08:00
|
|
|
Description: params.Description,
|
2016-11-22 09:23:08 +08:00
|
|
|
Deps: params.Deps,
|
2016-11-04 05:28:31 +08:00
|
|
|
Outputs: params.Outputs.Strings(),
|
|
|
|
ImplicitOutputs: params.ImplicitOutputs.Strings(),
|
|
|
|
Inputs: params.Inputs.Strings(),
|
|
|
|
Implicits: params.Implicits.Strings(),
|
|
|
|
OrderOnly: params.OrderOnly.Strings(),
|
|
|
|
Args: params.Args,
|
|
|
|
Optional: !params.Default,
|
2015-09-24 06:26:20 +08:00
|
|
|
}
|
|
|
|
|
2016-11-22 09:23:08 +08:00
|
|
|
if params.Depfile != nil {
|
|
|
|
bparams.Depfile = params.Depfile.String()
|
|
|
|
}
|
2015-09-24 06:26:20 +08:00
|
|
|
if params.Output != nil {
|
|
|
|
bparams.Outputs = append(bparams.Outputs, params.Output.String())
|
|
|
|
}
|
2016-11-04 05:28:31 +08:00
|
|
|
if params.ImplicitOutput != nil {
|
|
|
|
bparams.ImplicitOutputs = append(bparams.ImplicitOutputs, params.ImplicitOutput.String())
|
|
|
|
}
|
2015-09-24 06:26:20 +08: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())
|
|
|
|
}
|
|
|
|
|
2019-03-01 03:00:01 +08:00
|
|
|
bparams.Outputs = proptools.NinjaEscapeList(bparams.Outputs)
|
|
|
|
bparams.ImplicitOutputs = proptools.NinjaEscapeList(bparams.ImplicitOutputs)
|
|
|
|
bparams.Inputs = proptools.NinjaEscapeList(bparams.Inputs)
|
|
|
|
bparams.Implicits = proptools.NinjaEscapeList(bparams.Implicits)
|
|
|
|
bparams.OrderOnly = proptools.NinjaEscapeList(bparams.OrderOnly)
|
|
|
|
bparams.Depfile = proptools.NinjaEscapeList([]string{bparams.Depfile})[0]
|
2018-09-13 01:02:13 +08:00
|
|
|
|
2017-11-29 09:34:01 +08:00
|
|
|
return bparams
|
|
|
|
}
|
|
|
|
|
2019-06-07 05:29:25 +08:00
|
|
|
func (m *moduleContext) Variable(pctx PackageContext, name, value string) {
|
|
|
|
if m.config.captureBuild {
|
|
|
|
m.variables[name] = value
|
2018-12-13 01:01:34 +08:00
|
|
|
}
|
|
|
|
|
2019-06-07 07:13:11 +08:00
|
|
|
m.bp.Variable(pctx.PackageContext, name, value)
|
2017-11-29 09:34:01 +08:00
|
|
|
}
|
|
|
|
|
2019-06-07 05:29:25 +08:00
|
|
|
func (m *moduleContext) Rule(pctx PackageContext, name string, params blueprint.RuleParams,
|
2017-11-29 09:34:01 +08:00
|
|
|
argNames ...string) blueprint.Rule {
|
|
|
|
|
2019-11-16 05:18:43 +08:00
|
|
|
if m.config.UseRemoteBuild() && params.Pool == nil {
|
2019-11-05 07:16:11 +08:00
|
|
|
// 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
|
2019-09-26 04:31:46 +08:00
|
|
|
params.Pool = localPool
|
|
|
|
}
|
|
|
|
|
2019-06-07 07:13:11 +08:00
|
|
|
rule := m.bp.Rule(pctx.PackageContext, name, params, argNames...)
|
2019-02-26 06:54:28 +08:00
|
|
|
|
2019-06-07 05:29:25 +08:00
|
|
|
if m.config.captureBuild {
|
|
|
|
m.ruleParams[rule] = params
|
2019-02-26 06:54:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return rule
|
2017-11-29 09:34:01 +08:00
|
|
|
}
|
|
|
|
|
2019-06-07 05:29:25 +08:00
|
|
|
func (m *moduleContext) Build(pctx PackageContext, params BuildParams) {
|
2019-06-11 06:15:17 +08:00
|
|
|
if params.Description != "" {
|
|
|
|
params.Description = "${moduleDesc}" + params.Description + "${moduleDescSuffix}"
|
2017-11-29 09:34:01 +08:00
|
|
|
}
|
|
|
|
|
2019-06-11 06:15:17 +08: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 09:34:01 +08:00
|
|
|
}
|
|
|
|
|
2019-06-11 06:15:17 +08:00
|
|
|
if m.config.captureBuild {
|
|
|
|
m.buildParams = append(m.buildParams, params)
|
2015-12-18 08:39:19 +08:00
|
|
|
}
|
|
|
|
|
2019-06-07 07:13:11 +08:00
|
|
|
m.bp.Build(pctx.PackageContext, convertBuildParams(params))
|
|
|
|
}
|
2019-06-07 05:29:25 +08:00
|
|
|
func (m *moduleContext) GetMissingDependencies() []string {
|
2019-06-07 06:41:36 +08:00
|
|
|
var missingDeps []string
|
|
|
|
missingDeps = append(missingDeps, m.Module().base().commonProperties.MissingDeps...)
|
2019-06-07 07:13:11 +08:00
|
|
|
missingDeps = append(missingDeps, m.bp.GetMissingDependencies()...)
|
2019-06-07 06:41:36 +08:00
|
|
|
missingDeps = FirstUniqueStrings(missingDeps)
|
|
|
|
return missingDeps
|
2015-12-18 08:39:19 +08:00
|
|
|
}
|
|
|
|
|
2019-06-07 07:13:11 +08:00
|
|
|
func (b *baseModuleContext) AddMissingDependencies(deps []string) {
|
2016-03-11 10:14:25 +08:00
|
|
|
if deps != nil {
|
2019-06-07 07:13:11 +08:00
|
|
|
missingDeps := &b.Module().base().commonProperties.MissingDeps
|
2019-06-07 06:41:36 +08:00
|
|
|
*missingDeps = append(*missingDeps, deps...)
|
|
|
|
*missingDeps = FirstUniqueStrings(*missingDeps)
|
2016-03-11 10:14:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-07 07:13:11 +08:00
|
|
|
func (b *baseModuleContext) validateAndroidModule(module blueprint.Module, strict bool) Module {
|
2017-10-24 08:59:01 +08:00
|
|
|
aModule, _ := module.(Module)
|
2019-06-07 07:13:11 +08:00
|
|
|
|
|
|
|
if !strict {
|
|
|
|
return aModule
|
|
|
|
}
|
|
|
|
|
2019-06-11 01:49:58 +08:00
|
|
|
if aModule == nil {
|
2019-06-07 07:13:11 +08:00
|
|
|
b.ModuleErrorf("module %q not an android module", b.OtherModuleName(module))
|
2019-06-11 01:49:58 +08:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
if !aModule.Enabled() {
|
2019-06-07 07:13:11 +08:00
|
|
|
if b.Config().AllowMissingDependencies() {
|
|
|
|
b.AddMissingDependencies([]string{b.OtherModuleName(aModule)})
|
2019-06-11 01:49:58 +08:00
|
|
|
} else {
|
2019-06-07 07:13:11 +08:00
|
|
|
b.ModuleErrorf("depends on disabled module %q", b.OtherModuleName(aModule))
|
2019-06-11 01:49:58 +08:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
2017-10-24 08:59:01 +08:00
|
|
|
return aModule
|
|
|
|
}
|
|
|
|
|
2019-06-07 07:13:11 +08:00
|
|
|
func (b *baseModuleContext) getDirectDepInternal(name string, tag blueprint.DependencyTag) (blueprint.Module, blueprint.DependencyTag) {
|
2019-04-17 20:47:37 +08:00
|
|
|
type dep struct {
|
|
|
|
mod blueprint.Module
|
|
|
|
tag blueprint.DependencyTag
|
|
|
|
}
|
|
|
|
var deps []dep
|
2019-06-07 07:13:11 +08:00
|
|
|
b.VisitDirectDepsBlueprint(func(module blueprint.Module) {
|
2019-06-07 05:29:25 +08:00
|
|
|
if aModule, _ := module.(Module); aModule != nil && aModule.base().BaseModuleName() == name {
|
2019-12-31 10:43:07 +08:00
|
|
|
returnedTag := b.bp.OtherModuleDependencyTag(aModule)
|
2019-04-17 20:47:37 +08:00
|
|
|
if tag == nil || returnedTag == tag {
|
|
|
|
deps = append(deps, dep{aModule, returnedTag})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
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 07:13:11 +08:00
|
|
|
name, b.ModuleName()))
|
2019-04-17 20:47:37 +08:00
|
|
|
} else {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-07 07:13:11 +08:00
|
|
|
func (b *baseModuleContext) GetDirectDepsWithTag(tag blueprint.DependencyTag) []Module {
|
2019-05-02 06:50:51 +08:00
|
|
|
var deps []Module
|
2019-06-07 07:13:11 +08:00
|
|
|
b.VisitDirectDepsBlueprint(func(module blueprint.Module) {
|
2019-06-07 05:29:25 +08:00
|
|
|
if aModule, _ := module.(Module); aModule != nil {
|
2019-12-31 10:43:07 +08:00
|
|
|
if b.bp.OtherModuleDependencyTag(aModule) == tag {
|
2019-05-02 06:50:51 +08:00
|
|
|
deps = append(deps, aModule)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
return deps
|
|
|
|
}
|
|
|
|
|
2019-06-07 05:29:25 +08:00
|
|
|
func (m *moduleContext) GetDirectDepWithTag(name string, tag blueprint.DependencyTag) blueprint.Module {
|
|
|
|
module, _ := m.getDirectDepInternal(name, tag)
|
|
|
|
return module
|
2019-04-17 20:47:37 +08:00
|
|
|
}
|
|
|
|
|
2019-06-07 07:13:11 +08:00
|
|
|
func (b *baseModuleContext) GetDirectDep(name string) (blueprint.Module, blueprint.DependencyTag) {
|
|
|
|
return b.getDirectDepInternal(name, nil)
|
2019-04-17 20:47:37 +08:00
|
|
|
}
|
|
|
|
|
2019-06-07 07:13:11 +08:00
|
|
|
func (b *baseModuleContext) VisitDirectDepsBlueprint(visit func(blueprint.Module)) {
|
2019-12-31 10:43:07 +08:00
|
|
|
b.bp.VisitDirectDeps(visit)
|
2017-11-16 16:11:20 +08:00
|
|
|
}
|
|
|
|
|
2019-06-07 07:13:11 +08:00
|
|
|
func (b *baseModuleContext) VisitDirectDeps(visit func(Module)) {
|
2019-12-31 10:43:07 +08:00
|
|
|
b.bp.VisitDirectDeps(func(module blueprint.Module) {
|
2019-06-07 07:13:11 +08:00
|
|
|
if aModule := b.validateAndroidModule(module, b.strictVisitDeps); aModule != nil {
|
2017-10-24 08:59:01 +08:00
|
|
|
visit(aModule)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-06-07 07:13:11 +08:00
|
|
|
func (b *baseModuleContext) VisitDirectDepsWithTag(tag blueprint.DependencyTag, visit func(Module)) {
|
2019-12-31 10:43:07 +08:00
|
|
|
b.bp.VisitDirectDeps(func(module blueprint.Module) {
|
2019-06-07 07:13:11 +08:00
|
|
|
if aModule := b.validateAndroidModule(module, b.strictVisitDeps); aModule != nil {
|
2019-12-31 10:43:07 +08:00
|
|
|
if b.bp.OtherModuleDependencyTag(aModule) == tag {
|
2017-12-31 09:54:27 +08:00
|
|
|
visit(aModule)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-06-07 07:13:11 +08:00
|
|
|
func (b *baseModuleContext) VisitDirectDepsIf(pred func(Module) bool, visit func(Module)) {
|
2019-12-31 10:43:07 +08:00
|
|
|
b.bp.VisitDirectDepsIf(
|
2017-10-24 08:59:01 +08:00
|
|
|
// pred
|
|
|
|
func(module blueprint.Module) bool {
|
2019-06-07 07:13:11 +08:00
|
|
|
if aModule := b.validateAndroidModule(module, b.strictVisitDeps); aModule != nil {
|
2017-10-24 08:59:01 +08:00
|
|
|
return pred(aModule)
|
|
|
|
} else {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// visit
|
|
|
|
func(module blueprint.Module) {
|
|
|
|
visit(module.(Module))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-06-07 07:13:11 +08:00
|
|
|
func (b *baseModuleContext) VisitDepsDepthFirst(visit func(Module)) {
|
2019-12-31 10:43:07 +08:00
|
|
|
b.bp.VisitDepsDepthFirst(func(module blueprint.Module) {
|
2019-06-07 07:13:11 +08:00
|
|
|
if aModule := b.validateAndroidModule(module, b.strictVisitDeps); aModule != nil {
|
2017-10-24 08:59:01 +08:00
|
|
|
visit(aModule)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-06-07 07:13:11 +08:00
|
|
|
func (b *baseModuleContext) VisitDepsDepthFirstIf(pred func(Module) bool, visit func(Module)) {
|
2019-12-31 10:43:07 +08:00
|
|
|
b.bp.VisitDepsDepthFirstIf(
|
2017-10-24 08:59:01 +08:00
|
|
|
// pred
|
|
|
|
func(module blueprint.Module) bool {
|
2019-06-07 07:13:11 +08:00
|
|
|
if aModule := b.validateAndroidModule(module, b.strictVisitDeps); aModule != nil {
|
2017-10-24 08:59:01 +08:00
|
|
|
return pred(aModule)
|
|
|
|
} else {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// visit
|
|
|
|
func(module blueprint.Module) {
|
|
|
|
visit(module.(Module))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-06-07 07:13:11 +08:00
|
|
|
func (b *baseModuleContext) WalkDepsBlueprint(visit func(blueprint.Module, blueprint.Module) bool) {
|
2019-12-31 10:43:07 +08:00
|
|
|
b.bp.WalkDeps(visit)
|
2019-02-28 06:19:50 +08:00
|
|
|
}
|
|
|
|
|
2019-06-07 07:13:11 +08:00
|
|
|
func (b *baseModuleContext) WalkDeps(visit func(Module, Module) bool) {
|
|
|
|
b.walkPath = []Module{b.Module()}
|
2019-12-31 10:43:07 +08:00
|
|
|
b.bp.WalkDeps(func(child, parent blueprint.Module) bool {
|
2019-06-07 07:13:11 +08:00
|
|
|
childAndroidModule, _ := child.(Module)
|
|
|
|
parentAndroidModule, _ := parent.(Module)
|
2017-10-24 08:59:01 +08:00
|
|
|
if childAndroidModule != nil && parentAndroidModule != nil {
|
2019-06-07 07:13:11 +08:00
|
|
|
// record walkPath before visit
|
|
|
|
for b.walkPath[len(b.walkPath)-1] != parentAndroidModule {
|
|
|
|
b.walkPath = b.walkPath[0 : len(b.walkPath)-1]
|
|
|
|
}
|
|
|
|
b.walkPath = append(b.walkPath, childAndroidModule)
|
2017-10-24 08:59:01 +08:00
|
|
|
return visit(childAndroidModule, parentAndroidModule)
|
|
|
|
} else {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-06-07 07:13:11 +08:00
|
|
|
func (b *baseModuleContext) GetWalkPath() []Module {
|
|
|
|
return b.walkPath
|
|
|
|
}
|
|
|
|
|
2019-06-07 05:29:25 +08:00
|
|
|
func (m *moduleContext) VisitAllModuleVariants(visit func(Module)) {
|
2019-06-07 07:13:11 +08:00
|
|
|
m.bp.VisitAllModuleVariants(func(module blueprint.Module) {
|
2017-11-29 09:34:01 +08:00
|
|
|
visit(module.(Module))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-06-07 05:29:25 +08:00
|
|
|
func (m *moduleContext) PrimaryModule() Module {
|
2019-06-07 07:13:11 +08:00
|
|
|
return m.bp.PrimaryModule().(Module)
|
2017-11-29 09:34:01 +08:00
|
|
|
}
|
|
|
|
|
2019-06-07 05:29:25 +08:00
|
|
|
func (m *moduleContext) FinalModule() Module {
|
2019-06-07 07:13:11 +08:00
|
|
|
return m.bp.FinalModule().(Module)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *moduleContext) ModuleSubDir() string {
|
|
|
|
return m.bp.ModuleSubDir()
|
2017-11-29 09:34:01 +08:00
|
|
|
}
|
|
|
|
|
2019-06-07 05:33:29 +08:00
|
|
|
func (b *baseModuleContext) Target() Target {
|
2019-06-07 05:29:25 +08:00
|
|
|
return b.target
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
2019-06-07 05:33:29 +08:00
|
|
|
func (b *baseModuleContext) TargetPrimary() bool {
|
2019-06-07 05:29:25 +08:00
|
|
|
return b.targetPrimary
|
2016-09-14 00:59:14 +08:00
|
|
|
}
|
|
|
|
|
2019-06-07 05:33:29 +08:00
|
|
|
func (b *baseModuleContext) MultiTargets() []Target {
|
2019-06-07 05:29:25 +08:00
|
|
|
return b.multiTargets
|
2018-10-03 13:01:37 +08:00
|
|
|
}
|
|
|
|
|
2019-06-07 05:33:29 +08:00
|
|
|
func (b *baseModuleContext) Arch() Arch {
|
2019-06-07 05:29:25 +08:00
|
|
|
return b.target.Arch
|
2015-05-08 05:11:29 +08:00
|
|
|
}
|
|
|
|
|
2019-06-07 05:33:29 +08:00
|
|
|
func (b *baseModuleContext) Os() OsType {
|
2019-11-21 09:12:35 +08:00
|
|
|
return b.os
|
2015-11-25 09:53:15 +08:00
|
|
|
}
|
|
|
|
|
2019-06-07 05:33:29 +08:00
|
|
|
func (b *baseModuleContext) Host() bool {
|
2019-11-21 09:12:35 +08:00
|
|
|
return b.os.Class == Host || b.os.Class == HostCross
|
2015-03-25 02:13:38 +08:00
|
|
|
}
|
|
|
|
|
2019-06-07 05:33:29 +08:00
|
|
|
func (b *baseModuleContext) Device() bool {
|
2019-11-21 09:12:35 +08:00
|
|
|
return b.os.Class == Device
|
2015-03-25 02:13:38 +08:00
|
|
|
}
|
|
|
|
|
2019-06-07 05:33:29 +08:00
|
|
|
func (b *baseModuleContext) Darwin() bool {
|
2019-11-21 09:12:35 +08:00
|
|
|
return b.os == Darwin
|
2015-05-01 07:36:18 +08:00
|
|
|
}
|
|
|
|
|
2019-06-07 05:33:29 +08:00
|
|
|
func (b *baseModuleContext) Fuchsia() bool {
|
2019-11-21 09:12:35 +08:00
|
|
|
return b.os == Fuchsia
|
2019-01-17 04:06:11 +08:00
|
|
|
}
|
|
|
|
|
2019-06-07 05:33:29 +08:00
|
|
|
func (b *baseModuleContext) Windows() bool {
|
2019-11-21 09:12:35 +08:00
|
|
|
return b.os == Windows
|
2017-04-05 03:59:48 +08:00
|
|
|
}
|
|
|
|
|
2019-06-07 05:33:29 +08:00
|
|
|
func (b *baseModuleContext) Debug() bool {
|
2019-06-07 05:29:25 +08:00
|
|
|
return b.debug
|
2015-03-25 02:13:38 +08:00
|
|
|
}
|
|
|
|
|
2019-06-07 05:33:29 +08:00
|
|
|
func (b *baseModuleContext) PrimaryArch() bool {
|
2019-06-07 05:29:25 +08:00
|
|
|
if len(b.config.Targets[b.target.Os]) <= 1 {
|
2017-05-10 04:45:28 +08:00
|
|
|
return true
|
|
|
|
}
|
2019-06-07 05:29:25 +08:00
|
|
|
return b.target.Arch.ArchType == b.config.Targets[b.target.Os][0].Arch.ArchType
|
2016-08-25 06:25:47 +08:00
|
|
|
}
|
|
|
|
|
2018-08-28 08:55:37 +08:00
|
|
|
// Makes this module a platform module, i.e. not specific to soc, device,
|
2019-06-25 15:47:17 +08:00
|
|
|
// product, or system_ext.
|
2019-06-07 07:57:04 +08: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 15:47:17 +08:00
|
|
|
m.commonProperties.System_ext_specific = boolPtr(false)
|
2018-08-28 08:55:37 +08:00
|
|
|
}
|
|
|
|
|
2019-06-07 07:57:04 +08:00
|
|
|
func (m *ModuleBase) EnableNativeBridgeSupportByDefault() {
|
|
|
|
m.commonProperties.Native_bridge_supported = boolPtr(true)
|
2019-05-09 20:07:34 +08:00
|
|
|
}
|
|
|
|
|
2019-10-08 18:34:03 +08:00
|
|
|
func (m *ModuleBase) MakeAsSystemExt() {
|
2019-11-20 00:49:42 +08: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 18:34:03 +08:00
|
|
|
}
|
|
|
|
|
2019-08-23 10:17:39 +08: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-07 05:29:25 +08:00
|
|
|
func (m *moduleContext) InstallInData() bool {
|
|
|
|
return m.module.InstallInData()
|
2015-12-22 06:55:28 +08:00
|
|
|
}
|
|
|
|
|
2019-09-12 01:25:18 +08:00
|
|
|
func (m *moduleContext) InstallInTestcases() bool {
|
|
|
|
return m.module.InstallInTestcases()
|
|
|
|
}
|
|
|
|
|
2019-06-07 05:29:25 +08:00
|
|
|
func (m *moduleContext) InstallInSanitizerDir() bool {
|
|
|
|
return m.module.InstallInSanitizerDir()
|
2017-03-30 13:00:18 +08:00
|
|
|
}
|
|
|
|
|
2020-01-22 07:53:22 +08:00
|
|
|
func (m *moduleContext) InstallInRamdisk() bool {
|
|
|
|
return m.module.InstallInRamdisk()
|
|
|
|
}
|
|
|
|
|
2019-06-07 05:29:25 +08:00
|
|
|
func (m *moduleContext) InstallInRecovery() bool {
|
|
|
|
return m.module.InstallInRecovery()
|
2018-01-31 23:54:12 +08:00
|
|
|
}
|
|
|
|
|
2019-10-03 02:10:58 +08:00
|
|
|
func (m *moduleContext) InstallInRoot() bool {
|
|
|
|
return m.module.InstallInRoot()
|
|
|
|
}
|
|
|
|
|
2019-07-30 07:44:46 +08:00
|
|
|
func (m *moduleContext) InstallBypassMake() bool {
|
|
|
|
return m.module.InstallBypassMake()
|
|
|
|
}
|
|
|
|
|
2019-10-02 13:05:35 +08:00
|
|
|
func (m *moduleContext) skipInstall(fullInstallPath InstallPath) bool {
|
2019-06-07 05:29:25 +08:00
|
|
|
if m.module.base().commonProperties.SkipInstall {
|
2017-04-27 08:34:03 +08:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2018-05-08 06:28:05 +08: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-07 05:29:25 +08:00
|
|
|
if !m.module.base().commonProperties.NamespaceExportedToMake {
|
2018-05-08 06:28:05 +08:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2019-06-07 05:29:25 +08:00
|
|
|
if m.Device() {
|
2019-07-30 07:44:46 +08:00
|
|
|
if m.Config().EmbeddedInMake() && !m.InstallBypassMake() {
|
2017-04-27 08:34:03 +08:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2019-06-07 05:29:25 +08:00
|
|
|
if m.Config().SkipMegaDeviceInstall(fullInstallPath.String()) {
|
2017-04-27 08:34:03 +08:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2019-10-02 13:05:35 +08:00
|
|
|
func (m *moduleContext) InstallFile(installPath InstallPath, name string, srcPath Path,
|
|
|
|
deps ...Path) InstallPath {
|
2019-06-07 05:29:25 +08:00
|
|
|
return m.installFile(installPath, name, srcPath, Cp, deps)
|
2017-09-01 03:29:17 +08:00
|
|
|
}
|
|
|
|
|
2019-10-02 13:05:35 +08:00
|
|
|
func (m *moduleContext) InstallExecutable(installPath InstallPath, name string, srcPath Path,
|
|
|
|
deps ...Path) InstallPath {
|
2019-06-07 05:29:25 +08:00
|
|
|
return m.installFile(installPath, name, srcPath, CpExecutable, deps)
|
2017-09-01 03:29:17 +08:00
|
|
|
}
|
|
|
|
|
2019-10-02 13:05:35 +08:00
|
|
|
func (m *moduleContext) installFile(installPath InstallPath, name string, srcPath Path,
|
|
|
|
rule blueprint.Rule, deps []Path) InstallPath {
|
2015-04-03 05:37:16 +08:00
|
|
|
|
2019-06-07 05:29:25 +08:00
|
|
|
fullInstallPath := installPath.Join(m, name)
|
|
|
|
m.module.base().hooks.runInstallHooks(m, fullInstallPath, false)
|
2015-01-31 09:27:36 +08:00
|
|
|
|
2019-06-07 05:29:25 +08:00
|
|
|
if !m.skipInstall(fullInstallPath) {
|
2016-10-07 07:12:58 +08:00
|
|
|
|
2019-06-07 05:29:25 +08:00
|
|
|
deps = append(deps, m.installDeps...)
|
2016-01-13 15:07:05 +08:00
|
|
|
|
2016-10-04 08:47:19 +08:00
|
|
|
var implicitDeps, orderOnlyDeps Paths
|
|
|
|
|
2019-06-07 05:29:25 +08:00
|
|
|
if m.Host() {
|
2016-10-04 08:47:19 +08: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
|
|
|
|
}
|
|
|
|
|
2019-06-07 05:29:25 +08:00
|
|
|
m.Build(pctx, BuildParams{
|
2017-09-01 03:29:17 +08:00
|
|
|
Rule: rule,
|
2017-05-10 04:45:28 +08:00
|
|
|
Description: "install " + fullInstallPath.Base(),
|
|
|
|
Output: fullInstallPath,
|
|
|
|
Input: srcPath,
|
|
|
|
Implicits: implicitDeps,
|
|
|
|
OrderOnly: orderOnlyDeps,
|
2019-06-07 05:29:25 +08:00
|
|
|
Default: !m.Config().EmbeddedInMake(),
|
2016-01-13 15:07:05 +08:00
|
|
|
})
|
2015-01-31 09:27:36 +08:00
|
|
|
|
2019-06-07 05:29:25 +08:00
|
|
|
m.installFiles = append(m.installFiles, fullInstallPath)
|
2016-01-13 15:07:05 +08:00
|
|
|
}
|
2019-06-07 05:29:25 +08:00
|
|
|
m.checkbuildFiles = append(m.checkbuildFiles, srcPath)
|
2015-04-03 05:37:16 +08:00
|
|
|
return fullInstallPath
|
|
|
|
}
|
|
|
|
|
2019-10-02 13:05:35 +08:00
|
|
|
func (m *moduleContext) InstallSymlink(installPath InstallPath, name string, srcPath InstallPath) InstallPath {
|
2019-06-07 05:29:25 +08:00
|
|
|
fullInstallPath := installPath.Join(m, name)
|
|
|
|
m.module.base().hooks.runInstallHooks(m, fullInstallPath, true)
|
2016-01-12 04:49:11 +08:00
|
|
|
|
2019-06-07 05:29:25 +08:00
|
|
|
if !m.skipInstall(fullInstallPath) {
|
2016-10-07 07:12:58 +08:00
|
|
|
|
2019-01-18 05:57:45 +08: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))
|
|
|
|
}
|
2019-06-07 05:29:25 +08:00
|
|
|
m.Build(pctx, BuildParams{
|
2017-05-10 04:45:28 +08:00
|
|
|
Rule: Symlink,
|
|
|
|
Description: "install symlink " + fullInstallPath.Base(),
|
|
|
|
Output: fullInstallPath,
|
2020-01-15 07:19:52 +08:00
|
|
|
Input: srcPath,
|
2019-06-07 05:29:25 +08:00
|
|
|
Default: !m.Config().EmbeddedInMake(),
|
2016-01-12 04:49:11 +08:00
|
|
|
Args: map[string]string{
|
2019-01-18 05:57:45 +08:00
|
|
|
"fromPath": relPath,
|
2016-01-12 04:49:11 +08:00
|
|
|
},
|
|
|
|
})
|
2016-01-12 04:49:11 +08:00
|
|
|
|
2019-06-07 05:29:25 +08:00
|
|
|
m.installFiles = append(m.installFiles, fullInstallPath)
|
|
|
|
m.checkbuildFiles = append(m.checkbuildFiles, srcPath)
|
2016-01-12 04:49:11 +08:00
|
|
|
}
|
2016-01-12 04:49:11 +08:00
|
|
|
return fullInstallPath
|
|
|
|
}
|
|
|
|
|
2019-02-25 10:05:47 +08:00
|
|
|
// installPath/name -> absPath where absPath might be a path that is available only at runtime
|
|
|
|
// (e.g. /apex/...)
|
2019-10-02 13:05:35 +08:00
|
|
|
func (m *moduleContext) InstallAbsoluteSymlink(installPath InstallPath, name string, absPath string) InstallPath {
|
2019-06-07 05:29:25 +08:00
|
|
|
fullInstallPath := installPath.Join(m, name)
|
|
|
|
m.module.base().hooks.runInstallHooks(m, fullInstallPath, true)
|
2019-02-25 10:05:47 +08:00
|
|
|
|
2019-06-07 05:29:25 +08:00
|
|
|
if !m.skipInstall(fullInstallPath) {
|
|
|
|
m.Build(pctx, BuildParams{
|
2019-02-25 10:05:47 +08:00
|
|
|
Rule: Symlink,
|
|
|
|
Description: "install symlink " + fullInstallPath.Base() + " -> " + absPath,
|
|
|
|
Output: fullInstallPath,
|
2019-06-07 05:29:25 +08:00
|
|
|
Default: !m.Config().EmbeddedInMake(),
|
2019-02-25 10:05:47 +08:00
|
|
|
Args: map[string]string{
|
|
|
|
"fromPath": absPath,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
2019-06-07 05:29:25 +08:00
|
|
|
m.installFiles = append(m.installFiles, fullInstallPath)
|
2019-02-25 10:05:47 +08:00
|
|
|
}
|
|
|
|
return fullInstallPath
|
|
|
|
}
|
|
|
|
|
2019-06-07 05:29:25 +08:00
|
|
|
func (m *moduleContext) CheckbuildFile(srcPath Path) {
|
|
|
|
m.checkbuildFiles = append(m.checkbuildFiles, srcPath)
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
type fileInstaller interface {
|
2015-09-24 06:26:20 +08:00
|
|
|
filesToInstall() Paths
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func isFileInstaller(m blueprint.Module) bool {
|
|
|
|
_, ok := m.(fileInstaller)
|
|
|
|
return ok
|
|
|
|
}
|
|
|
|
|
|
|
|
func isAndroidModule(m blueprint.Module) bool {
|
2016-05-19 06:37:25 +08:00
|
|
|
_, ok := m.(Module)
|
2015-01-31 09:27:36 +08:00
|
|
|
return ok
|
|
|
|
}
|
2015-04-09 02:21:40 +08:00
|
|
|
|
2015-07-01 09:15:24 +08:00
|
|
|
func findStringInSlice(str string, slice []string) int {
|
|
|
|
for i, s := range slice {
|
|
|
|
if s == str {
|
|
|
|
return i
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1
|
|
|
|
}
|
|
|
|
|
2019-05-30 05:40:35 +08:00
|
|
|
// SrcIsModule decodes module references in the format ":name" into the module name, or empty string if the input
|
|
|
|
// was not a module reference.
|
|
|
|
func SrcIsModule(s string) (module string) {
|
2016-12-14 07:23:47 +08:00
|
|
|
if len(s) > 1 && s[0] == ':' {
|
|
|
|
return s[1:]
|
|
|
|
}
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
2019-05-30 05:40:35 +08:00
|
|
|
// SrcIsModule decodes module references in the format ":name{.tag}" into the module name and tag, ":name" into the
|
|
|
|
// module name and an empty string for the tag, or empty strings if the input was not a module reference.
|
|
|
|
func SrcIsModuleWithTag(s string) (module, tag string) {
|
|
|
|
if len(s) > 1 && s[0] == ':' {
|
|
|
|
module = s[1:]
|
|
|
|
if tagStart := strings.IndexByte(module, '{'); tagStart > 0 {
|
|
|
|
if module[len(module)-1] == '}' {
|
|
|
|
tag = module[tagStart+1 : len(module)-1]
|
|
|
|
module = module[:tagStart]
|
|
|
|
return module, tag
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return module, ""
|
|
|
|
}
|
|
|
|
return "", ""
|
|
|
|
}
|
|
|
|
|
|
|
|
type sourceOrOutputDependencyTag struct {
|
2016-12-14 07:23:47 +08:00
|
|
|
blueprint.BaseDependencyTag
|
2019-05-30 05:40:35 +08:00
|
|
|
tag string
|
2016-12-14 07:23:47 +08:00
|
|
|
}
|
|
|
|
|
2019-05-30 05:40:35 +08:00
|
|
|
func sourceOrOutputDepTag(tag string) blueprint.DependencyTag {
|
|
|
|
return sourceOrOutputDependencyTag{tag: tag}
|
|
|
|
}
|
|
|
|
|
|
|
|
var SourceDepTag = sourceOrOutputDepTag("")
|
2016-12-14 07:23:47 +08:00
|
|
|
|
2017-12-12 08:29:02 +08:00
|
|
|
// Adds necessary dependencies to satisfy filegroup or generated sources modules listed in srcFiles
|
|
|
|
// using ":module" syntax, if any.
|
2019-03-05 14:35:41 +08:00
|
|
|
//
|
|
|
|
// Deprecated: tag the property with `android:"path"` instead.
|
2016-12-14 07:23:47 +08:00
|
|
|
func ExtractSourcesDeps(ctx BottomUpMutatorContext, srcFiles []string) {
|
2017-04-11 02:27:50 +08:00
|
|
|
set := make(map[string]bool)
|
|
|
|
|
2016-12-14 07:23:47 +08:00
|
|
|
for _, s := range srcFiles {
|
2019-05-30 05:40:35 +08:00
|
|
|
if m, t := SrcIsModuleWithTag(s); m != "" {
|
|
|
|
if _, found := set[s]; found {
|
|
|
|
ctx.ModuleErrorf("found source dependency duplicate: %q!", s)
|
2017-04-11 02:27:50 +08:00
|
|
|
} else {
|
2019-05-30 05:40:35 +08:00
|
|
|
set[s] = true
|
|
|
|
ctx.AddDependency(ctx.Module(), sourceOrOutputDepTag(t), m)
|
2017-04-11 02:27:50 +08:00
|
|
|
}
|
2016-12-14 07:23:47 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-12 08:29:02 +08:00
|
|
|
// Adds necessary dependencies to satisfy filegroup or generated sources modules specified in s
|
|
|
|
// using ":module" syntax, if any.
|
2019-03-05 14:35:41 +08:00
|
|
|
//
|
|
|
|
// Deprecated: tag the property with `android:"path"` instead.
|
2017-12-12 08:29:02 +08:00
|
|
|
func ExtractSourceDeps(ctx BottomUpMutatorContext, s *string) {
|
|
|
|
if s != nil {
|
2019-05-30 05:40:35 +08:00
|
|
|
if m, t := SrcIsModuleWithTag(*s); m != "" {
|
|
|
|
ctx.AddDependency(ctx.Module(), sourceOrOutputDepTag(t), m)
|
2017-12-12 08:29:02 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-30 05:40:35 +08: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 07:23:47 +08:00
|
|
|
type SourceFileProducer interface {
|
|
|
|
Srcs() Paths
|
|
|
|
}
|
|
|
|
|
2019-05-30 05:40:35 +08:00
|
|
|
// A module that implements OutputFileProducer can be referenced from any property that is tagged with `android:"path"`
|
2019-11-22 22:20:54 +08: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-30 05:40:35 +08:00
|
|
|
// listed in the property.
|
|
|
|
type OutputFileProducer interface {
|
|
|
|
OutputFiles(tag string) (Paths, error)
|
|
|
|
}
|
|
|
|
|
2019-08-07 04:59:50 +08: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
|
|
|
|
}
|
|
|
|
if len(paths) > 1 {
|
|
|
|
reportPathErrorf(ctx, "got multiple output files from module %q, expected exactly one",
|
|
|
|
pathContextName(ctx, module))
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
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())
|
|
|
|
}
|
|
|
|
if len(paths) == 0 {
|
|
|
|
return nil, fmt.Errorf("failed to get output files from module %q", pathContextName(ctx, module))
|
|
|
|
}
|
|
|
|
return paths, nil
|
|
|
|
} else {
|
|
|
|
return nil, fmt.Errorf("module %q is not an OutputFileProducer", pathContextName(ctx, module))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-29 10:30:56 +08:00
|
|
|
type HostToolProvider interface {
|
|
|
|
HostToolPath() OptionalPath
|
|
|
|
}
|
|
|
|
|
2019-03-05 14:35:41 +08: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 14:25:09 +08:00
|
|
|
//
|
|
|
|
// Deprecated: use PathsForModuleSrc or PathsForModuleSrcExcludes instead.
|
2019-06-07 05:29:25 +08:00
|
|
|
func (m *moduleContext) ExpandSources(srcFiles, excludes []string) Paths {
|
|
|
|
return PathsForModuleSrcExcludes(m, srcFiles, excludes)
|
2015-06-18 06:09:06 +08:00
|
|
|
}
|
|
|
|
|
2019-03-06 04:39:51 +08: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 14:25:09 +08:00
|
|
|
//
|
|
|
|
// Deprecated: use PathForModuleSrc instead.
|
2019-06-07 05:29:25 +08:00
|
|
|
func (m *moduleContext) ExpandSource(srcFile, prop string) Path {
|
|
|
|
return PathForModuleSrc(m, srcFile)
|
2019-03-06 04:39:51 +08: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.
|
2019-06-07 05:29:25 +08:00
|
|
|
func (m *moduleContext) ExpandOptionalSource(srcFile *string, prop string) OptionalPath {
|
2019-03-06 04:39:51 +08:00
|
|
|
if srcFile != nil {
|
2019-06-07 05:29:25 +08:00
|
|
|
return OptionalPathForPath(PathForModuleSrc(m, *srcFile))
|
2019-03-06 04:39:51 +08:00
|
|
|
}
|
|
|
|
return OptionalPath{}
|
|
|
|
}
|
|
|
|
|
2019-06-07 05:29:25 +08:00
|
|
|
func (m *moduleContext) RequiredModuleNames() []string {
|
2019-12-30 15:31:09 +08:00
|
|
|
return m.module.RequiredModuleNames()
|
2017-02-05 09:47:46 +08:00
|
|
|
}
|
|
|
|
|
2019-06-07 05:29:25 +08:00
|
|
|
func (m *moduleContext) HostRequiredModuleNames() []string {
|
2019-12-30 15:31:09 +08:00
|
|
|
return m.module.HostRequiredModuleNames()
|
2019-04-02 09:37:36 +08:00
|
|
|
}
|
|
|
|
|
2019-06-07 05:29:25 +08:00
|
|
|
func (m *moduleContext) TargetRequiredModuleNames() []string {
|
2019-12-30 15:31:09 +08:00
|
|
|
return m.module.TargetRequiredModuleNames()
|
2019-04-02 09:37:36 +08:00
|
|
|
}
|
|
|
|
|
2015-06-18 05:20:06 +08:00
|
|
|
func init() {
|
2016-10-13 05:28:16 +08:00
|
|
|
RegisterSingletonType("buildtarget", BuildTargetSingleton)
|
2015-06-18 05:20:06 +08:00
|
|
|
}
|
|
|
|
|
2017-11-29 09:34:01 +08:00
|
|
|
func BuildTargetSingleton() Singleton {
|
2015-06-17 07:38:17 +08:00
|
|
|
return &buildTargetSingleton{}
|
|
|
|
}
|
|
|
|
|
2017-04-26 01:01:55 +08:00
|
|
|
func parentDir(dir string) string {
|
|
|
|
dir, _ = filepath.Split(dir)
|
|
|
|
return filepath.Clean(dir)
|
|
|
|
}
|
|
|
|
|
2015-06-17 07:38:17 +08:00
|
|
|
type buildTargetSingleton struct{}
|
|
|
|
|
2017-11-29 09:34:01 +08:00
|
|
|
func (c *buildTargetSingleton) GenerateBuildActions(ctx SingletonContext) {
|
|
|
|
var checkbuildDeps Paths
|
2015-06-17 07:38:17 +08:00
|
|
|
|
2017-11-29 09:34:01 +08:00
|
|
|
mmTarget := func(dir string) WritablePath {
|
|
|
|
return PathForPhony(ctx,
|
|
|
|
"MODULES-IN-"+strings.Replace(filepath.Clean(dir), "/", "-", -1))
|
2017-04-26 01:01:55 +08:00
|
|
|
}
|
|
|
|
|
2017-11-29 09:34:01 +08:00
|
|
|
modulesInDir := make(map[string]Paths)
|
2015-06-17 07:38:17 +08:00
|
|
|
|
2017-11-29 09:34:01 +08:00
|
|
|
ctx.VisitAllModules(func(module Module) {
|
|
|
|
blueprintDir := module.base().blueprintDir
|
|
|
|
installTarget := module.base().installTarget
|
|
|
|
checkbuildTarget := module.base().checkbuildTarget
|
2015-06-17 07:38:17 +08:00
|
|
|
|
2017-11-29 09:34:01 +08:00
|
|
|
if checkbuildTarget != nil {
|
|
|
|
checkbuildDeps = append(checkbuildDeps, checkbuildTarget)
|
|
|
|
modulesInDir[blueprintDir] = append(modulesInDir[blueprintDir], checkbuildTarget)
|
|
|
|
}
|
2015-06-17 07:38:17 +08:00
|
|
|
|
2017-11-29 09:34:01 +08:00
|
|
|
if installTarget != nil {
|
|
|
|
modulesInDir[blueprintDir] = append(modulesInDir[blueprintDir], installTarget)
|
2015-06-17 07:38:17 +08:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2015-12-12 05:51:06 +08:00
|
|
|
suffix := ""
|
2017-11-29 16:27:14 +08:00
|
|
|
if ctx.Config().EmbeddedInMake() {
|
2015-12-12 05:51:06 +08:00
|
|
|
suffix = "-soong"
|
|
|
|
}
|
|
|
|
|
2015-06-17 07:38:17 +08:00
|
|
|
// Create a top-level checkbuild target that depends on all modules
|
2017-11-29 09:34:01 +08:00
|
|
|
ctx.Build(pctx, BuildParams{
|
2015-06-17 07:38:17 +08:00
|
|
|
Rule: blueprint.Phony,
|
2017-11-29 09:34:01 +08:00
|
|
|
Output: PathForPhony(ctx, "checkbuild"+suffix),
|
2015-06-17 07:38:17 +08:00
|
|
|
Implicits: checkbuildDeps,
|
|
|
|
})
|
|
|
|
|
2017-09-21 05:30:50 +08:00
|
|
|
// Make will generate the MODULES-IN-* targets
|
2017-11-29 16:27:14 +08:00
|
|
|
if ctx.Config().EmbeddedInMake() {
|
2017-09-21 05:30:50 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-04-26 01:01:55 +08:00
|
|
|
// Ensure ancestor directories are in modulesInDir
|
2019-06-08 14:47:51 +08:00
|
|
|
dirs := SortedStringKeys(modulesInDir)
|
2017-04-26 01:01:55 +08:00
|
|
|
for _, dir := range dirs {
|
|
|
|
dir := parentDir(dir)
|
|
|
|
for dir != "." && dir != "/" {
|
|
|
|
if _, exists := modulesInDir[dir]; exists {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
modulesInDir[dir] = nil
|
|
|
|
dir = parentDir(dir)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Make directories build their direct subdirectories
|
|
|
|
for _, dir := range dirs {
|
|
|
|
p := parentDir(dir)
|
|
|
|
if p != "." && p != "/" {
|
|
|
|
modulesInDir[p] = append(modulesInDir[p], mmTarget(dir))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-21 05:30:50 +08: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 07:38:17 +08:00
|
|
|
for _, dir := range dirs {
|
2017-11-29 09:34:01 +08:00
|
|
|
ctx.Build(pctx, BuildParams{
|
2015-06-17 07:38:17 +08:00
|
|
|
Rule: blueprint.Phony,
|
2017-11-29 09:34:01 +08:00
|
|
|
Output: mmTarget(dir),
|
2017-04-26 01:01:55 +08:00
|
|
|
Implicits: modulesInDir[dir],
|
2015-12-12 05:51:06 +08:00
|
|
|
// HACK: checkbuild should be an optional build, but force it
|
|
|
|
// enabled for now in standalone builds
|
2017-11-29 16:27:14 +08:00
|
|
|
Default: !ctx.Config().EmbeddedInMake(),
|
2015-06-17 07:38:17 +08:00
|
|
|
})
|
|
|
|
}
|
2017-09-21 08:29:08 +08:00
|
|
|
|
|
|
|
// Create (host|host-cross|target)-<OS> phony rules to build a reduced checkbuild.
|
|
|
|
osDeps := map[OsType]Paths{}
|
2017-11-29 09:34:01 +08:00
|
|
|
ctx.VisitAllModules(func(module Module) {
|
|
|
|
if module.Enabled() {
|
|
|
|
os := module.Target().Os
|
|
|
|
osDeps[os] = append(osDeps[os], module.base().checkbuildFiles...)
|
2017-09-21 08:29:08 +08:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2017-11-29 09:34:01 +08:00
|
|
|
osClass := make(map[string]Paths)
|
2017-09-21 08:29:08 +08:00
|
|
|
for os, deps := range osDeps {
|
|
|
|
var className string
|
|
|
|
|
|
|
|
switch os.Class {
|
|
|
|
case Host:
|
|
|
|
className = "host"
|
|
|
|
case HostCross:
|
|
|
|
className = "host-cross"
|
|
|
|
case Device:
|
|
|
|
className = "target"
|
|
|
|
default:
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2017-11-29 09:34:01 +08:00
|
|
|
name := PathForPhony(ctx, className+"-"+os.Name)
|
2017-09-21 08:29:08 +08:00
|
|
|
osClass[className] = append(osClass[className], name)
|
|
|
|
|
2017-11-29 09:34:01 +08:00
|
|
|
ctx.Build(pctx, BuildParams{
|
2017-09-21 08:29:08 +08:00
|
|
|
Rule: blueprint.Phony,
|
2017-11-29 09:34:01 +08:00
|
|
|
Output: name,
|
|
|
|
Implicits: deps,
|
2017-09-21 08:29:08 +08:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// Wrap those into host|host-cross|target phony rules
|
2019-06-08 14:47:51 +08:00
|
|
|
for _, class := range SortedStringKeys(osClass) {
|
2017-11-29 09:34:01 +08:00
|
|
|
ctx.Build(pctx, BuildParams{
|
2017-09-21 08:29:08 +08:00
|
|
|
Rule: blueprint.Phony,
|
2017-11-29 09:34:01 +08:00
|
|
|
Output: PathForPhony(ctx, class),
|
2017-09-21 08:29:08 +08:00
|
|
|
Implicits: osClass[class],
|
|
|
|
})
|
|
|
|
}
|
2015-06-17 07:38:17 +08:00
|
|
|
}
|
2015-12-18 10:00:23 +08:00
|
|
|
|
2018-08-16 06:35:38 +08: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 15:48:50 +08:00
|
|
|
SrcJars []string `json:"srcjars,omitempty"`
|
2018-08-16 06:35:38 +08:00
|
|
|
}
|