2015-01-31 02:27:36 +01:00
|
|
|
// Copyright 2015 Google Inc. All rights reserved.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
package android
|
2015-01-31 02:27:36 +01:00
|
|
|
|
|
|
|
import (
|
2015-12-18 01:39:19 +01:00
|
|
|
"fmt"
|
2019-01-17 22:57:45 +01:00
|
|
|
"path"
|
2015-01-31 02:27:36 +01:00
|
|
|
"path/filepath"
|
2017-11-29 02:34:01 +01:00
|
|
|
"sort"
|
2015-12-18 01:39:19 +01:00
|
|
|
"strings"
|
2017-11-29 09:27:14 +01:00
|
|
|
"text/scanner"
|
2015-03-24 19:13:38 +01:00
|
|
|
|
|
|
|
"github.com/google/blueprint"
|
2016-11-01 19:10:25 +01:00
|
|
|
"github.com/google/blueprint/pathtools"
|
2018-09-12 19:02:13 +02:00
|
|
|
"github.com/google/blueprint/proptools"
|
2015-01-31 02:27:36 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
DeviceSharedLibrary = "shared_library"
|
|
|
|
DeviceStaticLibrary = "static_library"
|
|
|
|
DeviceExecutable = "executable"
|
|
|
|
HostSharedLibrary = "host_shared_library"
|
|
|
|
HostStaticLibrary = "host_static_library"
|
|
|
|
HostExecutable = "host_executable"
|
|
|
|
)
|
|
|
|
|
2017-10-24 02:16:14 +02:00
|
|
|
type BuildParams struct {
|
2016-11-03 22:28:31 +01:00
|
|
|
Rule blueprint.Rule
|
2016-11-22 02:23:08 +01:00
|
|
|
Deps blueprint.Deps
|
|
|
|
Depfile WritablePath
|
2017-05-09 22:45:28 +02:00
|
|
|
Description string
|
2016-11-03 22:28:31 +01: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 00:26:20 +02:00
|
|
|
}
|
|
|
|
|
2017-10-24 02:16:14 +02:00
|
|
|
type ModuleBuildParams BuildParams
|
|
|
|
|
2015-03-24 19:13:38 +01:00
|
|
|
type androidBaseContext interface {
|
2016-06-02 02:09:44 +02:00
|
|
|
Target() Target
|
2016-09-13 18:59:14 +02:00
|
|
|
TargetPrimary() bool
|
2018-10-03 07:01:37 +02:00
|
|
|
MultiTargets() []Target
|
2015-03-24 19:13:38 +01:00
|
|
|
Arch() Arch
|
2016-06-02 02:09:44 +02:00
|
|
|
Os() OsType
|
2015-03-24 19:13:38 +01:00
|
|
|
Host() bool
|
|
|
|
Device() bool
|
2015-05-01 01:36:18 +02:00
|
|
|
Darwin() bool
|
2019-01-16 21:06:11 +01:00
|
|
|
Fuchsia() bool
|
2017-04-04 21:59:48 +02:00
|
|
|
Windows() bool
|
2015-03-24 19:13:38 +01:00
|
|
|
Debug() bool
|
2016-08-25 00:25:47 +02:00
|
|
|
PrimaryArch() bool
|
2017-11-08 08:03:48 +01:00
|
|
|
Platform() bool
|
|
|
|
DeviceSpecific() bool
|
|
|
|
SocSpecific() bool
|
|
|
|
ProductSpecific() bool
|
2018-05-29 14:28:54 +02:00
|
|
|
ProductServicesSpecific() bool
|
2015-04-08 02:11:30 +02:00
|
|
|
AConfig() Config
|
2016-08-18 00:24:12 +02:00
|
|
|
DeviceConfig() DeviceConfig
|
2015-03-24 19:13:38 +01:00
|
|
|
}
|
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
type BaseContext interface {
|
2017-11-29 09:27:14 +01:00
|
|
|
BaseModuleContext
|
2015-03-24 19:13:38 +01:00
|
|
|
androidBaseContext
|
|
|
|
}
|
|
|
|
|
2017-11-29 09:27:14 +01:00
|
|
|
// BaseModuleContext is the same as blueprint.BaseModuleContext except that Config() returns
|
|
|
|
// a Config instead of an interface{}.
|
|
|
|
type BaseModuleContext interface {
|
|
|
|
ModuleName() string
|
|
|
|
ModuleDir() string
|
2019-03-01 22:46:24 +01:00
|
|
|
ModuleType() string
|
2017-11-29 09:27:14 +01:00
|
|
|
Config() Config
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
// 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)
|
|
|
|
|
|
|
|
Fs() pathtools.FileSystem
|
|
|
|
AddNinjaFileDeps(deps ...string)
|
|
|
|
}
|
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
type ModuleContext interface {
|
2015-03-24 19:13:38 +01:00
|
|
|
androidBaseContext
|
2017-11-29 09:27:14 +01:00
|
|
|
BaseModuleContext
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2017-10-24 02:16:14 +02:00
|
|
|
// Deprecated: use ModuleContext.Build instead.
|
2017-11-29 02:34:01 +01:00
|
|
|
ModuleBuild(pctx PackageContext, params ModuleBuildParams)
|
2015-09-24 00:26:20 +02:00
|
|
|
|
|
|
|
ExpandSources(srcFiles, excludes []string) Paths
|
2017-12-12 01:29:02 +01:00
|
|
|
ExpandSource(srcFile, prop string) Path
|
2018-02-06 23:40:13 +01:00
|
|
|
ExpandOptionalSource(srcFile *string, prop string) OptionalPath
|
2016-11-01 19:10:25 +01:00
|
|
|
Glob(globPattern string, excludes []string) Paths
|
2018-01-11 01:06:12 +01:00
|
|
|
GlobFiles(globPattern string, excludes []string) Paths
|
2015-06-18 00:09:06 +02:00
|
|
|
|
2017-08-31 21:29:17 +02:00
|
|
|
InstallExecutable(installPath OutputPath, name string, srcPath Path, deps ...Path) OutputPath
|
|
|
|
InstallFile(installPath OutputPath, name string, srcPath Path, deps ...Path) OutputPath
|
2016-01-11 21:49:11 +01:00
|
|
|
InstallSymlink(installPath OutputPath, name string, srcPath OutputPath) OutputPath
|
2019-02-25 03:05:47 +01:00
|
|
|
InstallAbsoluteSymlink(installPath OutputPath, name string, absPath string) OutputPath
|
2015-09-24 00:26:20 +02:00
|
|
|
CheckbuildFile(srcPath Path)
|
2016-03-11 03:14:25 +01:00
|
|
|
|
|
|
|
AddMissingDependencies(deps []string)
|
2016-08-03 20:57:50 +02:00
|
|
|
|
|
|
|
InstallInData() bool
|
2017-03-30 07:00:18 +02:00
|
|
|
InstallInSanitizerDir() bool
|
2018-01-31 16:54:12 +01:00
|
|
|
InstallInRecovery() bool
|
2017-02-05 02:47:46 +01:00
|
|
|
|
|
|
|
RequiredModuleNames() []string
|
2017-10-24 02:10:29 +02:00
|
|
|
|
|
|
|
// android.ModuleContext methods
|
|
|
|
// These are duplicated instead of embedded so that can eventually be wrapped to take an
|
|
|
|
// android.Module instead of a blueprint.Module
|
|
|
|
OtherModuleName(m blueprint.Module) string
|
|
|
|
OtherModuleErrorf(m blueprint.Module, fmt string, args ...interface{})
|
|
|
|
OtherModuleDependencyTag(m blueprint.Module) blueprint.DependencyTag
|
|
|
|
|
|
|
|
GetDirectDepWithTag(name string, tag blueprint.DependencyTag) blueprint.Module
|
|
|
|
GetDirectDep(name string) (blueprint.Module, blueprint.DependencyTag)
|
|
|
|
|
|
|
|
ModuleSubDir() string
|
|
|
|
|
2017-11-16 09:11:20 +01:00
|
|
|
VisitDirectDepsBlueprint(visit func(blueprint.Module))
|
2017-10-24 02:59:01 +02:00
|
|
|
VisitDirectDeps(visit func(Module))
|
2017-12-31 02:54:27 +01:00
|
|
|
VisitDirectDepsWithTag(tag blueprint.DependencyTag, visit func(Module))
|
2017-10-24 02:59:01 +02:00
|
|
|
VisitDirectDepsIf(pred func(Module) bool, visit func(Module))
|
2018-06-21 22:03:07 +02:00
|
|
|
// Deprecated: use WalkDeps instead to support multiple dependency tags on the same module
|
2017-10-24 02:59:01 +02:00
|
|
|
VisitDepsDepthFirst(visit func(Module))
|
2018-06-21 22:03:07 +02:00
|
|
|
// Deprecated: use WalkDeps instead to support multiple dependency tags on the same module
|
2017-10-24 02:59:01 +02:00
|
|
|
VisitDepsDepthFirstIf(pred func(Module) bool, visit func(Module))
|
|
|
|
WalkDeps(visit func(Module, Module) bool)
|
2019-02-27 23:19:50 +01:00
|
|
|
WalkDepsBlueprint(visit func(blueprint.Module, blueprint.Module) bool)
|
2017-10-24 02:10:29 +02:00
|
|
|
|
2017-11-29 02:34:01 +01:00
|
|
|
Variable(pctx PackageContext, name, value string)
|
|
|
|
Rule(pctx PackageContext, name string, params blueprint.RuleParams, argNames ...string) blueprint.Rule
|
2017-10-24 02:16:14 +02:00
|
|
|
// Similar to blueprint.ModuleContext.Build, but takes Paths instead of []string,
|
|
|
|
// and performs more verification.
|
2017-11-29 02:34:01 +01:00
|
|
|
Build(pctx PackageContext, params BuildParams)
|
2017-10-24 02:10:29 +02:00
|
|
|
|
2017-11-29 02:34:01 +01:00
|
|
|
PrimaryModule() Module
|
|
|
|
FinalModule() Module
|
|
|
|
VisitAllModuleVariants(visit func(Module))
|
2017-10-24 02:10:29 +02:00
|
|
|
|
|
|
|
GetMissingDependencies() []string
|
2017-11-30 01:47:17 +01:00
|
|
|
Namespace() blueprint.Namespace
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
type Module interface {
|
2015-01-31 02:27:36 +01:00
|
|
|
blueprint.Module
|
|
|
|
|
2017-09-28 02:01:44 +02:00
|
|
|
// GenerateAndroidBuildActions is analogous to Blueprints' GenerateBuildActions,
|
|
|
|
// but GenerateAndroidBuildActions also has access to Android-specific information.
|
|
|
|
// For more information, see Module.GenerateBuildActions within Blueprint's module_ctx.go
|
2016-05-19 00:37:25 +02:00
|
|
|
GenerateAndroidBuildActions(ModuleContext)
|
2017-09-28 02:01:44 +02:00
|
|
|
|
2016-10-12 23:38:15 +02:00
|
|
|
DepsMutator(BottomUpMutatorContext)
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
base() *ModuleBase
|
2015-12-01 01:06:01 +01:00
|
|
|
Enabled() bool
|
2016-06-02 02:09:44 +02:00
|
|
|
Target() Target
|
2015-12-21 23:55:28 +01:00
|
|
|
InstallInData() bool
|
2017-03-30 07:00:18 +02:00
|
|
|
InstallInSanitizerDir() bool
|
2018-01-31 16:54:12 +01:00
|
|
|
InstallInRecovery() bool
|
2016-11-30 00:16:18 +01: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 10:23:01 +01:00
|
|
|
ExportedToMake() bool
|
2019-03-18 04:01:38 +01:00
|
|
|
NoticeFile() OptionalPath
|
2017-06-24 00:06:31 +02:00
|
|
|
|
|
|
|
AddProperties(props ...interface{})
|
|
|
|
GetProperties() []interface{}
|
2017-07-13 23:43:27 +02:00
|
|
|
|
2017-10-24 02:16:14 +02:00
|
|
|
BuildParamsForTests() []BuildParams
|
2019-02-25 23:54:28 +01:00
|
|
|
RuleParamsForTests() map[blueprint.Rule]blueprint.RuleParams
|
2018-12-12 18:01:34 +01:00
|
|
|
VariablesForTests() map[string]string
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2016-05-18 01:34:16 +02:00
|
|
|
type nameProperties struct {
|
|
|
|
// The name of the module. Must be unique across all modules.
|
2017-11-07 19:57:05 +01:00
|
|
|
Name *string
|
2016-05-18 01:34:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
type commonProperties struct {
|
2015-12-01 01:06:01 +01:00
|
|
|
// emit build rules for this module
|
|
|
|
Enabled *bool `android:"arch_variant"`
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2015-05-11 22:39:40 +02:00
|
|
|
// control whether this module compiles for 32-bit, 64-bit, or both. Possible values
|
2015-01-31 02:27:36 +01:00
|
|
|
// are "32" (compile for 32-bit only), "64" (compile for 64-bit only), "both" (compile for both
|
|
|
|
// architectures), or "first" (compile for 64-bit on a 64-bit platform, and 32-bit on a 32-bit
|
|
|
|
// platform
|
2017-11-01 18:38:29 +01:00
|
|
|
Compile_multilib *string `android:"arch_variant"`
|
2016-09-06 19:39:07 +02:00
|
|
|
|
|
|
|
Target struct {
|
|
|
|
Host struct {
|
2017-11-01 18:38:29 +01:00
|
|
|
Compile_multilib *string
|
2016-09-06 19:39:07 +02:00
|
|
|
}
|
|
|
|
Android struct {
|
2017-11-01 18:38:29 +01:00
|
|
|
Compile_multilib *string
|
2016-09-06 19:39:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-03 07:01:37 +02:00
|
|
|
UseTargetVariants bool `blueprint:"mutated"`
|
|
|
|
Default_multilib string `blueprint:"mutated"`
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2015-12-21 23:55:28 +01:00
|
|
|
// whether this is a proprietary vendor module, and should be installed into /vendor
|
2017-11-01 18:38:29 +01:00
|
|
|
Proprietary *bool
|
2015-12-21 23:55:28 +01:00
|
|
|
|
2017-03-20 21:23:34 +01:00
|
|
|
// vendor who owns this module
|
2017-07-19 04:42:09 +02:00
|
|
|
Owner *string
|
2017-03-20 21:23:34 +01:00
|
|
|
|
2017-11-08 08:03:48 +01:00
|
|
|
// whether this module is specific to an SoC (System-On-a-Chip). When set to true,
|
|
|
|
// it is installed into /vendor (or /system/vendor if vendor partition does not exist).
|
|
|
|
// Use `soc_specific` instead for better meaning.
|
2017-11-01 18:38:29 +01:00
|
|
|
Vendor *bool
|
2017-04-06 21:49:58 +02:00
|
|
|
|
2017-11-08 08:03:48 +01:00
|
|
|
// whether this module is specific to an SoC (System-On-a-Chip). When set to true,
|
|
|
|
// it is installed into /vendor (or /system/vendor if vendor partition does not exist).
|
|
|
|
Soc_specific *bool
|
|
|
|
|
|
|
|
// whether this module is specific to a device, not only for SoC, but also for off-chip
|
|
|
|
// peripherals. When set to true, it is installed into /odm (or /vendor/odm if odm partition
|
|
|
|
// does not exist, or /system/vendor/odm if both odm and vendor partitions do not exist).
|
|
|
|
// This implies `soc_specific:true`.
|
|
|
|
Device_specific *bool
|
|
|
|
|
|
|
|
// whether this module is specific to a software configuration of a product (e.g. country,
|
2018-01-10 11:00:15 +01:00
|
|
|
// network operator, etc). When set to true, it is installed into /product (or
|
|
|
|
// /system/product if product partition does not exist).
|
2017-11-08 08:03:48 +01:00
|
|
|
Product_specific *bool
|
|
|
|
|
2018-05-29 14:28:54 +02:00
|
|
|
// whether this module provides services owned by the OS provider to the core platform. When set
|
2018-08-17 01:57:57 +02:00
|
|
|
// to true, it is installed into /product_services (or /system/product_services if
|
|
|
|
// product_services partition does not exist).
|
|
|
|
Product_services_specific *bool
|
2018-05-29 14:28:54 +02:00
|
|
|
|
2018-01-31 16:54:12 +01:00
|
|
|
// Whether this module is installed to recovery partition
|
|
|
|
Recovery *bool
|
|
|
|
|
2016-07-26 05:27:39 +02:00
|
|
|
// init.rc files to be installed if this module is installed
|
2019-03-05 07:35:41 +01:00
|
|
|
Init_rc []string `android:"path"`
|
2016-07-26 05:27:39 +02:00
|
|
|
|
2018-04-05 00:42:19 +02:00
|
|
|
// VINTF manifest fragments to be installed if this module is installed
|
2019-03-05 07:35:41 +01:00
|
|
|
Vintf_fragments []string `android:"path"`
|
2018-04-05 00:42:19 +02:00
|
|
|
|
2016-08-15 20:47:23 +02:00
|
|
|
// names of other modules to install if this module is installed
|
2017-05-05 22:36:36 +02:00
|
|
|
Required []string `android:"arch_variant"`
|
2016-08-15 20:47:23 +02:00
|
|
|
|
2017-09-01 00:07:09 +02:00
|
|
|
// relative path to a file to include in the list of notices for the device
|
2019-03-05 07:35:41 +01:00
|
|
|
Notice *string `android:"path"`
|
2017-09-01 00:07:09 +02:00
|
|
|
|
2018-11-19 18:33:29 +01: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 02:09:44 +02:00
|
|
|
// Set by TargetMutator
|
2018-10-03 07:01:37 +02:00
|
|
|
CompileTarget Target `blueprint:"mutated"`
|
|
|
|
CompileMultiTargets []Target `blueprint:"mutated"`
|
|
|
|
CompilePrimary bool `blueprint:"mutated"`
|
2015-01-31 02:27:36 +01:00
|
|
|
|
|
|
|
// Set by InitAndroidModule
|
|
|
|
HostOrDeviceSupported HostOrDeviceSupported `blueprint:"mutated"`
|
2016-10-05 00:13:37 +02:00
|
|
|
ArchSpecific bool `blueprint:"mutated"`
|
2016-10-07 01:12:58 +02:00
|
|
|
|
|
|
|
SkipInstall bool `blueprint:"mutated"`
|
2017-11-30 01:47:17 +01:00
|
|
|
|
|
|
|
NamespaceExportedToMake bool `blueprint:"mutated"`
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
type hostAndDeviceProperties struct {
|
2018-11-09 19:36:55 +01:00
|
|
|
// If set to true, build a variant of the module for the host. Defaults to false.
|
|
|
|
Host_supported *bool
|
|
|
|
|
|
|
|
// If set to true, build a variant of the module for the device. Defaults to true.
|
2016-07-12 22:11:25 +02:00
|
|
|
Device_supported *bool
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2015-03-17 23:06:21 +01:00
|
|
|
type Multilib string
|
|
|
|
|
|
|
|
const (
|
2017-12-05 22:42:45 +01:00
|
|
|
MultilibBoth Multilib = "both"
|
|
|
|
MultilibFirst Multilib = "first"
|
|
|
|
MultilibCommon Multilib = "common"
|
|
|
|
MultilibCommonFirst Multilib = "common_first"
|
|
|
|
MultilibDefault Multilib = ""
|
2015-03-17 23:06:21 +01:00
|
|
|
)
|
|
|
|
|
2016-06-02 02:09:44 +02:00
|
|
|
type HostOrDeviceSupported int
|
|
|
|
|
|
|
|
const (
|
|
|
|
_ HostOrDeviceSupported = iota
|
2018-08-02 22:46:35 +02:00
|
|
|
|
|
|
|
// Host and HostCross are built by default. Device is not supported.
|
2016-06-02 02:09:44 +02:00
|
|
|
HostSupported
|
2018-08-02 22:46:35 +02:00
|
|
|
|
|
|
|
// Host is built by default. HostCross and Device are not supported.
|
2016-10-20 10:36:11 +02:00
|
|
|
HostSupportedNoCross
|
2018-08-02 22:46:35 +02:00
|
|
|
|
|
|
|
// Device is built by default. Host and HostCross are not supported.
|
2016-06-02 02:09:44 +02:00
|
|
|
DeviceSupported
|
2018-08-02 22:46:35 +02:00
|
|
|
|
|
|
|
// Device is built by default. Host and HostCross are supported.
|
2016-06-02 02:09:44 +02:00
|
|
|
HostAndDeviceSupported
|
2018-08-02 22:46:35 +02:00
|
|
|
|
|
|
|
// Host, HostCross, and Device are built by default.
|
2016-06-02 02:09:44 +02:00
|
|
|
HostAndDeviceDefault
|
2018-08-02 22:46:35 +02:00
|
|
|
|
|
|
|
// Nothing is supported. This is not exposed to the user, but used to mark a
|
|
|
|
// host only module as unsupported when the module type is not supported on
|
|
|
|
// the host OS. E.g. benchmarks are supported on Linux but not Darwin.
|
2016-10-05 00:13:37 +02:00
|
|
|
NeitherHostNorDeviceSupported
|
2016-06-02 02:09:44 +02:00
|
|
|
)
|
|
|
|
|
2017-11-08 08:03:48 +01:00
|
|
|
type moduleKind int
|
|
|
|
|
|
|
|
const (
|
|
|
|
platformModule moduleKind = iota
|
|
|
|
deviceSpecificModule
|
|
|
|
socSpecificModule
|
|
|
|
productSpecificModule
|
2018-05-29 14:28:54 +02:00
|
|
|
productServicesSpecificModule
|
2017-11-08 08:03:48 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func (k moduleKind) String() string {
|
|
|
|
switch k {
|
|
|
|
case platformModule:
|
|
|
|
return "platform"
|
|
|
|
case deviceSpecificModule:
|
|
|
|
return "device-specific"
|
|
|
|
case socSpecificModule:
|
|
|
|
return "soc-specific"
|
|
|
|
case productSpecificModule:
|
|
|
|
return "product-specific"
|
2018-05-29 14:28:54 +02:00
|
|
|
case productServicesSpecificModule:
|
|
|
|
return "productservices-specific"
|
2017-11-08 08:03:48 +01:00
|
|
|
default:
|
|
|
|
panic(fmt.Errorf("unknown module kind %d", k))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-24 00:06:31 +02:00
|
|
|
func InitAndroidModule(m Module) {
|
2015-01-31 02:27:36 +01:00
|
|
|
base := m.base()
|
|
|
|
base.module = m
|
2015-03-18 21:28:46 +01:00
|
|
|
|
2017-06-24 00:06:31 +02:00
|
|
|
m.AddProperties(
|
2016-05-18 01:34:16 +02:00
|
|
|
&base.nameProperties,
|
|
|
|
&base.commonProperties,
|
|
|
|
&base.variableProperties)
|
2019-03-18 20:24:29 +01:00
|
|
|
base.generalProperties = m.GetProperties()
|
2018-04-17 23:58:42 +02:00
|
|
|
base.customizableProperties = m.GetProperties()
|
2015-03-18 21:28:46 +01:00
|
|
|
}
|
|
|
|
|
2017-06-24 00:06:31 +02:00
|
|
|
func InitAndroidArchModule(m Module, hod HostOrDeviceSupported, defaultMultilib Multilib) {
|
|
|
|
InitAndroidModule(m)
|
2015-03-18 21:28:46 +01:00
|
|
|
|
|
|
|
base := m.base()
|
2015-01-31 02:27:36 +01:00
|
|
|
base.commonProperties.HostOrDeviceSupported = hod
|
2016-09-06 19:39:07 +02:00
|
|
|
base.commonProperties.Default_multilib = string(defaultMultilib)
|
2016-10-05 00:13:37 +02:00
|
|
|
base.commonProperties.ArchSpecific = true
|
2018-10-03 07:01:37 +02:00
|
|
|
base.commonProperties.UseTargetVariants = true
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2015-07-09 03:13:11 +02:00
|
|
|
switch hod {
|
2017-07-05 19:35:11 +02:00
|
|
|
case HostAndDeviceSupported, HostAndDeviceDefault:
|
2017-06-24 00:06:31 +02:00
|
|
|
m.AddProperties(&base.hostAndDeviceProperties)
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2017-06-24 00:06:31 +02:00
|
|
|
InitArchModule(m)
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2018-10-03 07:01:37 +02:00
|
|
|
func InitAndroidMultiTargetsArchModule(m Module, hod HostOrDeviceSupported, defaultMultilib Multilib) {
|
|
|
|
InitAndroidArchModule(m, hod, defaultMultilib)
|
|
|
|
m.base().commonProperties.UseTargetVariants = false
|
|
|
|
}
|
|
|
|
|
2017-02-02 19:46:07 +01:00
|
|
|
// A ModuleBase object contains the properties that are common to all Android
|
2015-01-31 02:27:36 +01:00
|
|
|
// modules. It should be included as an anonymous field in every module
|
|
|
|
// struct definition. InitAndroidModule should then be called from the module's
|
|
|
|
// factory function, and the return values from InitAndroidModule should be
|
|
|
|
// returned from the factory function.
|
|
|
|
//
|
2017-02-02 19:46:07 +01:00
|
|
|
// The ModuleBase type is responsible for implementing the GenerateBuildActions
|
|
|
|
// method to support the blueprint.Module interface. This method will then call
|
|
|
|
// the module's GenerateAndroidBuildActions method once for each build variant
|
|
|
|
// that is to be built. GenerateAndroidBuildActions is passed a
|
|
|
|
// AndroidModuleContext rather than the usual blueprint.ModuleContext.
|
2015-01-31 02:27:36 +01:00
|
|
|
// AndroidModuleContext exposes extra functionality specific to the Android build
|
|
|
|
// system including details about the particular build variant that is to be
|
|
|
|
// generated.
|
|
|
|
//
|
|
|
|
// For example:
|
|
|
|
//
|
|
|
|
// import (
|
2017-02-02 19:46:07 +01:00
|
|
|
// "android/soong/android"
|
2015-01-31 02:27:36 +01:00
|
|
|
// )
|
|
|
|
//
|
|
|
|
// type myModule struct {
|
2017-02-02 19:46:07 +01:00
|
|
|
// android.ModuleBase
|
2015-01-31 02:27:36 +01:00
|
|
|
// properties struct {
|
|
|
|
// MyProperty string
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
2017-06-24 00:06:31 +02:00
|
|
|
// func NewMyModule() android.Module) {
|
2015-01-31 02:27:36 +01:00
|
|
|
// m := &myModule{}
|
2017-06-24 00:06:31 +02:00
|
|
|
// m.AddProperties(&m.properties)
|
|
|
|
// android.InitAndroidModule(m)
|
|
|
|
// return m
|
2015-01-31 02:27:36 +01:00
|
|
|
// }
|
|
|
|
//
|
2017-02-02 19:46:07 +01:00
|
|
|
// func (m *myModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
2015-01-31 02:27:36 +01:00
|
|
|
// // Get the CPU architecture for the current build variant.
|
|
|
|
// variantArch := ctx.Arch()
|
|
|
|
//
|
|
|
|
// // ...
|
|
|
|
// }
|
2016-05-19 00:37:25 +02:00
|
|
|
type ModuleBase struct {
|
2015-01-31 02:27:36 +01:00
|
|
|
// Putting the curiously recurring thing pointing to the thing that contains
|
|
|
|
// the thing pattern to good use.
|
2017-06-24 00:06:31 +02:00
|
|
|
// TODO: remove this
|
2016-05-19 00:37:25 +02:00
|
|
|
module Module
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2016-05-18 01:34:16 +02:00
|
|
|
nameProperties nameProperties
|
2015-01-31 02:27:36 +01:00
|
|
|
commonProperties commonProperties
|
2015-07-09 22:57:48 +02:00
|
|
|
variableProperties variableProperties
|
2015-01-31 02:27:36 +01:00
|
|
|
hostAndDeviceProperties hostAndDeviceProperties
|
|
|
|
generalProperties []interface{}
|
2018-10-24 21:42:09 +02:00
|
|
|
archProperties [][]interface{}
|
2016-08-20 01:07:38 +02:00
|
|
|
customizableProperties []interface{}
|
2015-01-31 02:27:36 +01:00
|
|
|
|
|
|
|
noAddressSanitizer bool
|
2015-09-24 00:26:20 +02:00
|
|
|
installFiles Paths
|
|
|
|
checkbuildFiles Paths
|
2019-03-18 04:01:38 +01:00
|
|
|
noticeFile OptionalPath
|
2015-06-17 01:38:17 +02:00
|
|
|
|
|
|
|
// Used by buildTargetSingleton to create checkbuild and per-directory build targets
|
|
|
|
// Only set on the final variant of each module
|
2017-11-29 02:34:01 +01:00
|
|
|
installTarget WritablePath
|
|
|
|
checkbuildTarget WritablePath
|
2015-06-17 01:38:17 +02:00
|
|
|
blueprintDir string
|
2016-08-20 01:07:38 +02:00
|
|
|
|
2016-09-13 22:42:32 +02:00
|
|
|
hooks hooks
|
2017-06-24 00:06:31 +02:00
|
|
|
|
|
|
|
registerProps []interface{}
|
2017-07-13 23:43:27 +02:00
|
|
|
|
|
|
|
// For tests
|
2017-10-24 02:16:14 +02:00
|
|
|
buildParams []BuildParams
|
2019-02-25 23:54:28 +01:00
|
|
|
ruleParams map[blueprint.Rule]blueprint.RuleParams
|
2018-12-12 18:01:34 +01:00
|
|
|
variables map[string]string
|
2018-10-02 22:59:46 +02:00
|
|
|
|
|
|
|
prefer32 func(ctx BaseModuleContext, base *ModuleBase, class OsClass) bool
|
2017-06-24 00:06:31 +02:00
|
|
|
}
|
|
|
|
|
2019-02-02 01:53:07 +01:00
|
|
|
func (a *ModuleBase) DepsMutator(BottomUpMutatorContext) {}
|
|
|
|
|
2017-06-24 00:06:31 +02:00
|
|
|
func (a *ModuleBase) AddProperties(props ...interface{}) {
|
|
|
|
a.registerProps = append(a.registerProps, props...)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *ModuleBase) GetProperties() []interface{} {
|
|
|
|
return a.registerProps
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2017-10-24 02:16:14 +02:00
|
|
|
func (a *ModuleBase) BuildParamsForTests() []BuildParams {
|
2017-07-13 23:43:27 +02:00
|
|
|
return a.buildParams
|
|
|
|
}
|
|
|
|
|
2019-02-25 23:54:28 +01:00
|
|
|
func (a *ModuleBase) RuleParamsForTests() map[blueprint.Rule]blueprint.RuleParams {
|
|
|
|
return a.ruleParams
|
|
|
|
}
|
|
|
|
|
2018-12-12 18:01:34 +01:00
|
|
|
func (a *ModuleBase) VariablesForTests() map[string]string {
|
|
|
|
return a.variables
|
|
|
|
}
|
|
|
|
|
2018-10-02 22:59:46 +02:00
|
|
|
func (a *ModuleBase) Prefer32(prefer32 func(ctx BaseModuleContext, base *ModuleBase, class OsClass) bool) {
|
|
|
|
a.prefer32 = prefer32
|
|
|
|
}
|
|
|
|
|
2016-10-07 01:12:58 +02:00
|
|
|
// Name returns the name of the module. It may be overridden by individual module types, for
|
|
|
|
// example prebuilts will prepend prebuilt_ to the name.
|
2016-05-18 01:34:16 +02:00
|
|
|
func (a *ModuleBase) Name() string {
|
2017-11-07 19:57:05 +01:00
|
|
|
return String(a.nameProperties.Name)
|
2016-05-18 01:34:16 +02:00
|
|
|
}
|
|
|
|
|
2016-10-07 01:12:58 +02:00
|
|
|
// BaseModuleName returns the name of the module as specified in the blueprints file.
|
|
|
|
func (a *ModuleBase) BaseModuleName() string {
|
2017-11-07 19:57:05 +01:00
|
|
|
return String(a.nameProperties.Name)
|
2016-10-07 01:12:58 +02:00
|
|
|
}
|
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
func (a *ModuleBase) base() *ModuleBase {
|
2015-01-31 02:27:36 +01:00
|
|
|
return a
|
|
|
|
}
|
|
|
|
|
2018-10-03 07:01:37 +02:00
|
|
|
func (a *ModuleBase) SetTarget(target Target, multiTargets []Target, primary bool) {
|
2016-06-02 02:09:44 +02:00
|
|
|
a.commonProperties.CompileTarget = target
|
2018-10-03 07:01:37 +02:00
|
|
|
a.commonProperties.CompileMultiTargets = multiTargets
|
2016-09-13 18:59:14 +02:00
|
|
|
a.commonProperties.CompilePrimary = primary
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2016-06-02 02:09:44 +02:00
|
|
|
func (a *ModuleBase) Target() Target {
|
|
|
|
return a.commonProperties.CompileTarget
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2016-09-13 18:59:14 +02:00
|
|
|
func (a *ModuleBase) TargetPrimary() bool {
|
|
|
|
return a.commonProperties.CompilePrimary
|
|
|
|
}
|
|
|
|
|
2018-10-03 07:01:37 +02:00
|
|
|
func (a *ModuleBase) MultiTargets() []Target {
|
|
|
|
return a.commonProperties.CompileMultiTargets
|
|
|
|
}
|
|
|
|
|
2016-06-02 02:09:44 +02:00
|
|
|
func (a *ModuleBase) Os() OsType {
|
|
|
|
return a.Target().Os
|
2015-11-25 02:53:15 +01:00
|
|
|
}
|
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
func (a *ModuleBase) Host() bool {
|
2016-06-02 02:09:44 +02:00
|
|
|
return a.Os().Class == Host || a.Os().Class == HostCross
|
2016-02-10 02:43:51 +01:00
|
|
|
}
|
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
func (a *ModuleBase) Arch() Arch {
|
2016-06-02 02:09:44 +02:00
|
|
|
return a.Target().Arch
|
2016-02-10 02:43:51 +01:00
|
|
|
}
|
|
|
|
|
2016-10-05 00:13:37 +02:00
|
|
|
func (a *ModuleBase) ArchSpecific() bool {
|
|
|
|
return a.commonProperties.ArchSpecific
|
|
|
|
}
|
|
|
|
|
2016-06-02 02:09:44 +02:00
|
|
|
func (a *ModuleBase) OsClassSupported() []OsClass {
|
|
|
|
switch a.commonProperties.HostOrDeviceSupported {
|
|
|
|
case HostSupported:
|
|
|
|
return []OsClass{Host, HostCross}
|
2016-10-20 10:36:11 +02:00
|
|
|
case HostSupportedNoCross:
|
|
|
|
return []OsClass{Host}
|
2016-06-02 02:09:44 +02:00
|
|
|
case DeviceSupported:
|
|
|
|
return []OsClass{Device}
|
2018-08-02 22:46:35 +02:00
|
|
|
case HostAndDeviceSupported, HostAndDeviceDefault:
|
2016-06-02 02:09:44 +02:00
|
|
|
var supported []OsClass
|
2018-08-02 22:46:35 +02:00
|
|
|
if Bool(a.hostAndDeviceProperties.Host_supported) ||
|
|
|
|
(a.commonProperties.HostOrDeviceSupported == HostAndDeviceDefault &&
|
|
|
|
a.hostAndDeviceProperties.Host_supported == nil) {
|
2016-06-02 02:09:44 +02:00
|
|
|
supported = append(supported, Host, HostCross)
|
|
|
|
}
|
2017-07-05 19:35:11 +02:00
|
|
|
if a.hostAndDeviceProperties.Device_supported == nil ||
|
|
|
|
*a.hostAndDeviceProperties.Device_supported {
|
2016-06-02 02:09:44 +02:00
|
|
|
supported = append(supported, Device)
|
|
|
|
}
|
|
|
|
return supported
|
|
|
|
default:
|
|
|
|
return nil
|
|
|
|
}
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
func (a *ModuleBase) DeviceSupported() bool {
|
2015-01-31 02:27:36 +01:00
|
|
|
return a.commonProperties.HostOrDeviceSupported == DeviceSupported ||
|
|
|
|
a.commonProperties.HostOrDeviceSupported == HostAndDeviceSupported &&
|
2017-07-05 19:35:11 +02:00
|
|
|
(a.hostAndDeviceProperties.Device_supported == nil ||
|
|
|
|
*a.hostAndDeviceProperties.Device_supported)
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2018-04-10 06:07:10 +02:00
|
|
|
func (a *ModuleBase) Platform() bool {
|
2018-05-29 14:28:54 +02:00
|
|
|
return !a.DeviceSpecific() && !a.SocSpecific() && !a.ProductSpecific() && !a.ProductServicesSpecific()
|
2018-04-10 06:07:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (a *ModuleBase) DeviceSpecific() bool {
|
|
|
|
return Bool(a.commonProperties.Device_specific)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *ModuleBase) SocSpecific() bool {
|
|
|
|
return Bool(a.commonProperties.Vendor) || Bool(a.commonProperties.Proprietary) || Bool(a.commonProperties.Soc_specific)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *ModuleBase) ProductSpecific() bool {
|
|
|
|
return Bool(a.commonProperties.Product_specific)
|
|
|
|
}
|
|
|
|
|
2018-05-29 14:28:54 +02:00
|
|
|
func (a *ModuleBase) ProductServicesSpecific() bool {
|
2018-08-17 01:57:57 +02:00
|
|
|
return Bool(a.commonProperties.Product_services_specific)
|
2018-05-29 14:28:54 +02:00
|
|
|
}
|
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
func (a *ModuleBase) Enabled() bool {
|
2015-12-01 01:06:01 +01:00
|
|
|
if a.commonProperties.Enabled == nil {
|
2016-11-13 19:16:05 +01:00
|
|
|
return !a.Os().DefaultDisabled
|
2015-11-25 02:53:15 +01:00
|
|
|
}
|
2015-12-01 01:06:01 +01:00
|
|
|
return *a.commonProperties.Enabled
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2016-10-07 01:12:58 +02:00
|
|
|
func (a *ModuleBase) SkipInstall() {
|
|
|
|
a.commonProperties.SkipInstall = true
|
|
|
|
}
|
|
|
|
|
Allow platform modules to link to vendor public libraries
Normally, when building with VNDK, platform modules are not allowed to
link against vendor libraries, because the ABI of the vendor libraries
are not guaranteed to be stable and may differ across multiple vendor
images.
However, the vendor public libraries are the exceptions. Vendor public
libraries are vendor libraries that are exposed to 3rd party apps and
listed in /vendor/etc/public.libraries.txt. Since they are intended to
be exposed to public, their ABI stability is guaranteed (by definition,
though it is up to the vendor to actually guarantee it).
This change provides a way to make a vendor lib as public by defining a
module of type 'vendor_public_library' with a map file that enumerates
public symbols that are publicized:
cc_library {
name: "libvendor",
proprietary: true,
...
}
vendor_public_library {
name: "libvendor",
symbol_file: "libvendor.map.txt",
}
This defines a stub library module named libvendor.vendorpublic from the
map file. `shared_libs: ["libvendor"]` is redirected to the stub library
when it is from the outside of the vendor partition.
Bug: 74275385
Test: m -j
Test: cc_test.go passes
Change-Id: I5bed94d7c4282b777632ab2f0fb63c203ee313ba
2018-03-19 10:23:01 +01:00
|
|
|
func (a *ModuleBase) ExportedToMake() bool {
|
|
|
|
return a.commonProperties.NamespaceExportedToMake
|
|
|
|
}
|
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
func (a *ModuleBase) computeInstallDeps(
|
2015-09-24 00:26:20 +02:00
|
|
|
ctx blueprint.ModuleContext) Paths {
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2015-09-24 00:26:20 +02:00
|
|
|
result := Paths{}
|
2018-06-21 22:03:07 +02:00
|
|
|
// TODO(ccross): we need to use WalkDeps and have some way to know which dependencies require installation
|
2015-01-31 02:27:36 +01:00
|
|
|
ctx.VisitDepsDepthFirstIf(isFileInstaller,
|
|
|
|
func(m blueprint.Module) {
|
|
|
|
fileInstaller := m.(fileInstaller)
|
|
|
|
files := fileInstaller.filesToInstall()
|
|
|
|
result = append(result, files...)
|
|
|
|
})
|
|
|
|
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
func (a *ModuleBase) filesToInstall() Paths {
|
2015-01-31 02:27:36 +01:00
|
|
|
return a.installFiles
|
|
|
|
}
|
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
func (p *ModuleBase) NoAddressSanitizer() bool {
|
2015-01-31 02:27:36 +01:00
|
|
|
return p.noAddressSanitizer
|
|
|
|
}
|
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
func (p *ModuleBase) InstallInData() bool {
|
2015-12-21 23:55:28 +01:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2017-03-30 07:00:18 +02:00
|
|
|
func (p *ModuleBase) InstallInSanitizerDir() bool {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2018-01-31 16:54:12 +01:00
|
|
|
func (p *ModuleBase) InstallInRecovery() bool {
|
|
|
|
return Bool(p.commonProperties.Recovery)
|
|
|
|
}
|
|
|
|
|
2018-08-31 11:01:37 +02:00
|
|
|
func (a *ModuleBase) Owner() string {
|
|
|
|
return String(a.commonProperties.Owner)
|
|
|
|
}
|
|
|
|
|
2019-03-18 04:01:38 +01:00
|
|
|
func (a *ModuleBase) NoticeFile() OptionalPath {
|
|
|
|
return a.noticeFile
|
|
|
|
}
|
|
|
|
|
2017-11-29 02:34:01 +01:00
|
|
|
func (a *ModuleBase) generateModuleTarget(ctx ModuleContext) {
|
2015-09-24 00:26:20 +02:00
|
|
|
allInstalledFiles := Paths{}
|
|
|
|
allCheckbuildFiles := Paths{}
|
2017-11-29 02:34:01 +01:00
|
|
|
ctx.VisitAllModuleVariants(func(module Module) {
|
|
|
|
a := module.base()
|
2015-03-27 00:10:12 +01:00
|
|
|
allInstalledFiles = append(allInstalledFiles, a.installFiles...)
|
|
|
|
allCheckbuildFiles = append(allCheckbuildFiles, a.checkbuildFiles...)
|
2015-01-31 02:27:36 +01:00
|
|
|
})
|
|
|
|
|
2017-11-29 02:34:01 +01:00
|
|
|
var deps Paths
|
2015-03-17 21:24:18 +01:00
|
|
|
|
2017-11-30 01:47:17 +01:00
|
|
|
namespacePrefix := ctx.Namespace().(*Namespace).id
|
|
|
|
if namespacePrefix != "" {
|
|
|
|
namespacePrefix = namespacePrefix + "-"
|
|
|
|
}
|
|
|
|
|
2015-01-31 02:27:36 +01:00
|
|
|
if len(allInstalledFiles) > 0 {
|
2017-11-30 01:47:17 +01:00
|
|
|
name := PathForPhony(ctx, namespacePrefix+ctx.ModuleName()+"-install")
|
2017-11-29 02:34:01 +01:00
|
|
|
ctx.Build(pctx, BuildParams{
|
2015-03-17 21:24:18 +01:00
|
|
|
Rule: blueprint.Phony,
|
2017-11-29 02:34:01 +01:00
|
|
|
Output: name,
|
|
|
|
Implicits: allInstalledFiles,
|
2017-11-29 09:27:14 +01:00
|
|
|
Default: !ctx.Config().EmbeddedInMake(),
|
2015-03-17 21:24:18 +01:00
|
|
|
})
|
|
|
|
deps = append(deps, name)
|
2015-06-17 01:38:17 +02:00
|
|
|
a.installTarget = name
|
2015-03-17 21:24:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if len(allCheckbuildFiles) > 0 {
|
2017-11-30 01:47:17 +01:00
|
|
|
name := PathForPhony(ctx, namespacePrefix+ctx.ModuleName()+"-checkbuild")
|
2017-11-29 02:34:01 +01:00
|
|
|
ctx.Build(pctx, BuildParams{
|
2015-03-17 21:24:18 +01:00
|
|
|
Rule: blueprint.Phony,
|
2017-11-29 02:34:01 +01:00
|
|
|
Output: name,
|
|
|
|
Implicits: allCheckbuildFiles,
|
2015-03-17 21:24:18 +01:00
|
|
|
})
|
|
|
|
deps = append(deps, name)
|
2015-06-17 01:38:17 +02:00
|
|
|
a.checkbuildTarget = name
|
2015-03-17 21:24:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if len(deps) > 0 {
|
2015-12-11 22:51:06 +01:00
|
|
|
suffix := ""
|
2017-11-29 09:27:14 +01:00
|
|
|
if ctx.Config().EmbeddedInMake() {
|
2015-12-11 22:51:06 +01:00
|
|
|
suffix = "-soong"
|
|
|
|
}
|
|
|
|
|
2017-11-30 01:47:17 +01:00
|
|
|
name := PathForPhony(ctx, namespacePrefix+ctx.ModuleName()+suffix)
|
2017-11-29 02:34:01 +01:00
|
|
|
ctx.Build(pctx, BuildParams{
|
2015-03-17 21:24:18 +01:00
|
|
|
Rule: blueprint.Phony,
|
2017-11-30 01:47:17 +01:00
|
|
|
Outputs: []WritablePath{name},
|
2015-03-17 21:24:18 +01:00
|
|
|
Implicits: deps,
|
2015-01-31 02:27:36 +01:00
|
|
|
})
|
2015-06-17 01:38:17 +02:00
|
|
|
|
|
|
|
a.blueprintDir = ctx.ModuleDir()
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-08 08:03:48 +01:00
|
|
|
func determineModuleKind(a *ModuleBase, ctx blueprint.BaseModuleContext) moduleKind {
|
|
|
|
var socSpecific = Bool(a.commonProperties.Vendor) || Bool(a.commonProperties.Proprietary) || Bool(a.commonProperties.Soc_specific)
|
|
|
|
var deviceSpecific = Bool(a.commonProperties.Device_specific)
|
|
|
|
var productSpecific = Bool(a.commonProperties.Product_specific)
|
2018-08-17 01:57:57 +02:00
|
|
|
var productServicesSpecific = Bool(a.commonProperties.Product_services_specific)
|
2017-11-08 08:03:48 +01:00
|
|
|
|
2018-05-29 14:28:54 +02:00
|
|
|
msg := "conflicting value set here"
|
|
|
|
if socSpecific && deviceSpecific {
|
|
|
|
ctx.PropertyErrorf("device_specific", "a module cannot be specific to SoC and device at the same time.")
|
2017-11-08 08:03:48 +01:00
|
|
|
if Bool(a.commonProperties.Vendor) {
|
|
|
|
ctx.PropertyErrorf("vendor", msg)
|
|
|
|
}
|
|
|
|
if Bool(a.commonProperties.Proprietary) {
|
|
|
|
ctx.PropertyErrorf("proprietary", msg)
|
|
|
|
}
|
|
|
|
if Bool(a.commonProperties.Soc_specific) {
|
|
|
|
ctx.PropertyErrorf("soc_specific", msg)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-29 14:28:54 +02:00
|
|
|
if productSpecific && productServicesSpecific {
|
|
|
|
ctx.PropertyErrorf("product_specific", "a module cannot be specific to product and product_services at the same time.")
|
|
|
|
ctx.PropertyErrorf("product_services_specific", msg)
|
|
|
|
}
|
|
|
|
|
|
|
|
if (socSpecific || deviceSpecific) && (productSpecific || productServicesSpecific) {
|
|
|
|
if productSpecific {
|
|
|
|
ctx.PropertyErrorf("product_specific", "a module cannot be specific to SoC or device and product at the same time.")
|
|
|
|
} else {
|
|
|
|
ctx.PropertyErrorf("product_services_specific", "a module cannot be specific to SoC or device and product_services at the same time.")
|
|
|
|
}
|
|
|
|
if deviceSpecific {
|
|
|
|
ctx.PropertyErrorf("device_specific", msg)
|
|
|
|
} else {
|
|
|
|
if Bool(a.commonProperties.Vendor) {
|
|
|
|
ctx.PropertyErrorf("vendor", msg)
|
|
|
|
}
|
|
|
|
if Bool(a.commonProperties.Proprietary) {
|
|
|
|
ctx.PropertyErrorf("proprietary", msg)
|
|
|
|
}
|
|
|
|
if Bool(a.commonProperties.Soc_specific) {
|
|
|
|
ctx.PropertyErrorf("soc_specific", msg)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-08 08:03:48 +01:00
|
|
|
if productSpecific {
|
|
|
|
return productSpecificModule
|
2018-05-29 14:28:54 +02:00
|
|
|
} else if productServicesSpecific {
|
|
|
|
return productServicesSpecificModule
|
2017-11-08 08:03:48 +01:00
|
|
|
} else if deviceSpecific {
|
|
|
|
return deviceSpecificModule
|
|
|
|
} else if socSpecific {
|
|
|
|
return socSpecificModule
|
|
|
|
} else {
|
|
|
|
return platformModule
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
func (a *ModuleBase) androidBaseContextFactory(ctx blueprint.BaseModuleContext) androidBaseContextImpl {
|
2015-10-29 23:25:03 +01:00
|
|
|
return androidBaseContextImpl{
|
2016-09-13 18:59:14 +02:00
|
|
|
target: a.commonProperties.CompileTarget,
|
|
|
|
targetPrimary: a.commonProperties.CompilePrimary,
|
2018-10-03 07:01:37 +02:00
|
|
|
multiTargets: a.commonProperties.CompileMultiTargets,
|
2017-11-08 08:03:48 +01:00
|
|
|
kind: determineModuleKind(a, ctx),
|
2016-09-13 18:59:14 +02:00
|
|
|
config: ctx.Config().(Config),
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-29 02:34:01 +01:00
|
|
|
func (a *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) {
|
|
|
|
ctx := &androidModuleContext{
|
2016-08-03 20:57:50 +02:00
|
|
|
module: a.module,
|
2017-11-29 02:34:01 +01:00
|
|
|
ModuleContext: blueprintCtx,
|
|
|
|
androidBaseContextImpl: a.androidBaseContextFactory(blueprintCtx),
|
|
|
|
installDeps: a.computeInstallDeps(blueprintCtx),
|
2015-10-29 23:25:03 +01:00
|
|
|
installFiles: a.installFiles,
|
2017-11-29 02:34:01 +01:00
|
|
|
missingDeps: blueprintCtx.GetMissingDependencies(),
|
2018-12-12 18:01:34 +01:00
|
|
|
variables: make(map[string]string),
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2019-02-25 23:54:28 +01:00
|
|
|
if ctx.config.captureBuild {
|
|
|
|
ctx.ruleParams = make(map[blueprint.Rule]blueprint.RuleParams)
|
|
|
|
}
|
|
|
|
|
2017-05-09 22:45:28 +02:00
|
|
|
desc := "//" + ctx.ModuleDir() + ":" + ctx.ModuleName() + " "
|
|
|
|
var suffix []string
|
2017-11-29 02:34:01 +01:00
|
|
|
if ctx.Os().Class != Device && ctx.Os().Class != Generic {
|
|
|
|
suffix = append(suffix, ctx.Os().String())
|
2017-05-09 22:45:28 +02:00
|
|
|
}
|
2017-11-29 02:34:01 +01:00
|
|
|
if !ctx.PrimaryArch() {
|
|
|
|
suffix = append(suffix, ctx.Arch().ArchType.String())
|
2017-05-09 22:45:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ctx.Variable(pctx, "moduleDesc", desc)
|
|
|
|
|
|
|
|
s := ""
|
|
|
|
if len(suffix) > 0 {
|
|
|
|
s = " [" + strings.Join(suffix, " ") + "]"
|
|
|
|
}
|
|
|
|
ctx.Variable(pctx, "moduleDescSuffix", s)
|
|
|
|
|
2018-11-19 18:33:29 +01:00
|
|
|
// Some common property checks for properties that will be used later in androidmk.go
|
|
|
|
if a.commonProperties.Dist.Dest != nil {
|
|
|
|
_, err := validateSafePath(*a.commonProperties.Dist.Dest)
|
|
|
|
if err != nil {
|
|
|
|
ctx.PropertyErrorf("dist.dest", "%s", err.Error())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if a.commonProperties.Dist.Dir != nil {
|
|
|
|
_, err := validateSafePath(*a.commonProperties.Dist.Dir)
|
|
|
|
if err != nil {
|
|
|
|
ctx.PropertyErrorf("dist.dir", "%s", err.Error())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if a.commonProperties.Dist.Suffix != nil {
|
|
|
|
if strings.Contains(*a.commonProperties.Dist.Suffix, "/") {
|
|
|
|
ctx.PropertyErrorf("dist.suffix", "Suffix may not contain a '/' character.")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-20 00:18:11 +02:00
|
|
|
if a.Enabled() {
|
2017-11-29 02:34:01 +01:00
|
|
|
a.module.GenerateAndroidBuildActions(ctx)
|
2016-09-20 00:18:11 +02:00
|
|
|
if ctx.Failed() {
|
|
|
|
return
|
|
|
|
}
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2017-11-29 02:34:01 +01:00
|
|
|
a.installFiles = append(a.installFiles, ctx.installFiles...)
|
|
|
|
a.checkbuildFiles = append(a.checkbuildFiles, ctx.checkbuildFiles...)
|
2018-11-16 22:26:43 +01:00
|
|
|
|
2019-03-18 04:01:38 +01:00
|
|
|
notice := proptools.StringDefault(a.commonProperties.Notice, "NOTICE")
|
|
|
|
if m := SrcIsModule(notice); m != "" {
|
|
|
|
a.noticeFile = ctx.ExpandOptionalSource(¬ice, "notice")
|
|
|
|
} else {
|
|
|
|
noticePath := filepath.Join(ctx.ModuleDir(), notice)
|
|
|
|
a.noticeFile = ExistentPathForSource(ctx, noticePath)
|
2018-11-16 22:26:43 +01:00
|
|
|
}
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2016-09-20 00:18:11 +02:00
|
|
|
if a == ctx.FinalModule().(Module).base() {
|
|
|
|
a.generateModuleTarget(ctx)
|
|
|
|
if ctx.Failed() {
|
|
|
|
return
|
|
|
|
}
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
2017-07-13 23:43:27 +02:00
|
|
|
|
2017-11-29 02:34:01 +01:00
|
|
|
a.buildParams = ctx.buildParams
|
2019-02-25 23:54:28 +01:00
|
|
|
a.ruleParams = ctx.ruleParams
|
2018-12-12 18:01:34 +01:00
|
|
|
a.variables = ctx.variables
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2015-03-24 19:13:38 +01:00
|
|
|
type androidBaseContextImpl struct {
|
2016-09-13 18:59:14 +02:00
|
|
|
target Target
|
2018-10-03 07:01:37 +02:00
|
|
|
multiTargets []Target
|
2016-09-13 18:59:14 +02:00
|
|
|
targetPrimary bool
|
|
|
|
debug bool
|
2017-11-08 08:03:48 +01:00
|
|
|
kind moduleKind
|
2016-09-13 18:59:14 +02:00
|
|
|
config Config
|
2015-03-24 19:13:38 +01:00
|
|
|
}
|
|
|
|
|
2015-01-31 02:27:36 +01:00
|
|
|
type androidModuleContext struct {
|
|
|
|
blueprint.ModuleContext
|
2015-03-24 19:13:38 +01:00
|
|
|
androidBaseContextImpl
|
2015-09-24 00:26:20 +02:00
|
|
|
installDeps Paths
|
|
|
|
installFiles Paths
|
|
|
|
checkbuildFiles Paths
|
2015-12-18 01:39:19 +01:00
|
|
|
missingDeps []string
|
2016-08-03 20:57:50 +02:00
|
|
|
module Module
|
2017-07-13 23:43:27 +02:00
|
|
|
|
|
|
|
// For tests
|
2017-10-24 02:16:14 +02:00
|
|
|
buildParams []BuildParams
|
2019-02-25 23:54:28 +01:00
|
|
|
ruleParams map[blueprint.Rule]blueprint.RuleParams
|
2018-12-12 18:01:34 +01:00
|
|
|
variables map[string]string
|
2015-12-18 01:39:19 +01:00
|
|
|
}
|
|
|
|
|
2017-05-09 22:45:28 +02:00
|
|
|
func (a *androidModuleContext) ninjaError(desc string, outputs []string, err error) {
|
2017-11-29 02:34:01 +01:00
|
|
|
a.ModuleContext.Build(pctx.PackageContext, blueprint.BuildParams{
|
2017-05-09 22:45:28 +02:00
|
|
|
Rule: ErrorRule,
|
|
|
|
Description: desc,
|
|
|
|
Outputs: outputs,
|
|
|
|
Optional: true,
|
2015-12-18 01:39:19 +01:00
|
|
|
Args: map[string]string{
|
|
|
|
"error": err.Error(),
|
|
|
|
},
|
|
|
|
})
|
|
|
|
return
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2017-11-29 09:27:14 +01:00
|
|
|
func (a *androidModuleContext) Config() Config {
|
|
|
|
return a.ModuleContext.Config().(Config)
|
|
|
|
}
|
|
|
|
|
2017-11-29 02:34:01 +01:00
|
|
|
func (a *androidModuleContext) ModuleBuild(pctx PackageContext, params ModuleBuildParams) {
|
2017-10-24 02:16:14 +02:00
|
|
|
a.Build(pctx, BuildParams(params))
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2017-11-29 02:34:01 +01:00
|
|
|
func convertBuildParams(params BuildParams) blueprint.BuildParams {
|
2015-09-24 00:26:20 +02:00
|
|
|
bparams := blueprint.BuildParams{
|
2016-11-03 22:28:31 +01:00
|
|
|
Rule: params.Rule,
|
2017-11-29 02:34:01 +01:00
|
|
|
Description: params.Description,
|
2016-11-22 02:23:08 +01:00
|
|
|
Deps: params.Deps,
|
2016-11-03 22:28:31 +01:00
|
|
|
Outputs: params.Outputs.Strings(),
|
|
|
|
ImplicitOutputs: params.ImplicitOutputs.Strings(),
|
|
|
|
Inputs: params.Inputs.Strings(),
|
|
|
|
Implicits: params.Implicits.Strings(),
|
|
|
|
OrderOnly: params.OrderOnly.Strings(),
|
|
|
|
Args: params.Args,
|
|
|
|
Optional: !params.Default,
|
2015-09-24 00:26:20 +02:00
|
|
|
}
|
|
|
|
|
2016-11-22 02:23:08 +01:00
|
|
|
if params.Depfile != nil {
|
|
|
|
bparams.Depfile = params.Depfile.String()
|
|
|
|
}
|
2015-09-24 00:26:20 +02:00
|
|
|
if params.Output != nil {
|
|
|
|
bparams.Outputs = append(bparams.Outputs, params.Output.String())
|
|
|
|
}
|
2016-11-03 22:28:31 +01:00
|
|
|
if params.ImplicitOutput != nil {
|
|
|
|
bparams.ImplicitOutputs = append(bparams.ImplicitOutputs, params.ImplicitOutput.String())
|
|
|
|
}
|
2015-09-24 00:26:20 +02:00
|
|
|
if params.Input != nil {
|
|
|
|
bparams.Inputs = append(bparams.Inputs, params.Input.String())
|
|
|
|
}
|
|
|
|
if params.Implicit != nil {
|
|
|
|
bparams.Implicits = append(bparams.Implicits, params.Implicit.String())
|
|
|
|
}
|
|
|
|
|
2019-02-28 20:00:01 +01: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-12 19:02:13 +02:00
|
|
|
|
2017-11-29 02:34:01 +01:00
|
|
|
return bparams
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *androidModuleContext) Variable(pctx PackageContext, name, value string) {
|
2018-12-12 18:01:34 +01:00
|
|
|
if a.config.captureBuild {
|
|
|
|
a.variables[name] = value
|
|
|
|
}
|
|
|
|
|
2017-11-29 02:34:01 +01:00
|
|
|
a.ModuleContext.Variable(pctx.PackageContext, name, value)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *androidModuleContext) Rule(pctx PackageContext, name string, params blueprint.RuleParams,
|
|
|
|
argNames ...string) blueprint.Rule {
|
|
|
|
|
2019-02-25 23:54:28 +01:00
|
|
|
rule := a.ModuleContext.Rule(pctx.PackageContext, name, params, argNames...)
|
|
|
|
|
|
|
|
if a.config.captureBuild {
|
|
|
|
a.ruleParams[rule] = params
|
|
|
|
}
|
|
|
|
|
|
|
|
return rule
|
2017-11-29 02:34:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (a *androidModuleContext) Build(pctx PackageContext, params BuildParams) {
|
|
|
|
if a.config.captureBuild {
|
|
|
|
a.buildParams = append(a.buildParams, params)
|
|
|
|
}
|
|
|
|
|
|
|
|
bparams := convertBuildParams(params)
|
|
|
|
|
|
|
|
if bparams.Description != "" {
|
|
|
|
bparams.Description = "${moduleDesc}" + params.Description + "${moduleDescSuffix}"
|
|
|
|
}
|
|
|
|
|
2015-12-18 01:39:19 +01:00
|
|
|
if a.missingDeps != nil {
|
2017-05-09 22:45:28 +02:00
|
|
|
a.ninjaError(bparams.Description, bparams.Outputs,
|
|
|
|
fmt.Errorf("module %s missing dependencies: %s\n",
|
|
|
|
a.ModuleName(), strings.Join(a.missingDeps, ", ")))
|
2015-12-18 01:39:19 +01:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-11-29 02:34:01 +01:00
|
|
|
a.ModuleContext.Build(pctx.PackageContext, bparams)
|
2015-09-24 00:26:20 +02:00
|
|
|
}
|
|
|
|
|
2015-12-18 01:39:19 +01:00
|
|
|
func (a *androidModuleContext) GetMissingDependencies() []string {
|
|
|
|
return a.missingDeps
|
|
|
|
}
|
|
|
|
|
2016-03-11 03:14:25 +01:00
|
|
|
func (a *androidModuleContext) AddMissingDependencies(deps []string) {
|
|
|
|
if deps != nil {
|
|
|
|
a.missingDeps = append(a.missingDeps, deps...)
|
2017-10-24 02:59:01 +02:00
|
|
|
a.missingDeps = FirstUniqueStrings(a.missingDeps)
|
2016-03-11 03:14:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-24 02:59:01 +02:00
|
|
|
func (a *androidModuleContext) validateAndroidModule(module blueprint.Module) Module {
|
|
|
|
aModule, _ := module.(Module)
|
|
|
|
if aModule == nil {
|
|
|
|
a.ModuleErrorf("module %q not an android module", a.OtherModuleName(aModule))
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
if !aModule.Enabled() {
|
2017-11-29 09:27:14 +01:00
|
|
|
if a.Config().AllowMissingDependencies() {
|
2017-10-24 02:59:01 +02:00
|
|
|
a.AddMissingDependencies([]string{a.OtherModuleName(aModule)})
|
|
|
|
} else {
|
|
|
|
a.ModuleErrorf("depends on disabled module %q", a.OtherModuleName(aModule))
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return aModule
|
|
|
|
}
|
|
|
|
|
2017-11-16 09:11:20 +01:00
|
|
|
func (a *androidModuleContext) VisitDirectDepsBlueprint(visit func(blueprint.Module)) {
|
|
|
|
a.ModuleContext.VisitDirectDeps(visit)
|
|
|
|
}
|
|
|
|
|
2017-10-24 02:59:01 +02:00
|
|
|
func (a *androidModuleContext) VisitDirectDeps(visit func(Module)) {
|
|
|
|
a.ModuleContext.VisitDirectDeps(func(module blueprint.Module) {
|
|
|
|
if aModule := a.validateAndroidModule(module); aModule != nil {
|
|
|
|
visit(aModule)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2017-12-31 02:54:27 +01:00
|
|
|
func (a *androidModuleContext) VisitDirectDepsWithTag(tag blueprint.DependencyTag, visit func(Module)) {
|
|
|
|
a.ModuleContext.VisitDirectDeps(func(module blueprint.Module) {
|
|
|
|
if aModule := a.validateAndroidModule(module); aModule != nil {
|
|
|
|
if a.ModuleContext.OtherModuleDependencyTag(aModule) == tag {
|
|
|
|
visit(aModule)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2017-10-24 02:59:01 +02:00
|
|
|
func (a *androidModuleContext) VisitDirectDepsIf(pred func(Module) bool, visit func(Module)) {
|
|
|
|
a.ModuleContext.VisitDirectDepsIf(
|
|
|
|
// pred
|
|
|
|
func(module blueprint.Module) bool {
|
|
|
|
if aModule := a.validateAndroidModule(module); aModule != nil {
|
|
|
|
return pred(aModule)
|
|
|
|
} else {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// visit
|
|
|
|
func(module blueprint.Module) {
|
|
|
|
visit(module.(Module))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *androidModuleContext) VisitDepsDepthFirst(visit func(Module)) {
|
|
|
|
a.ModuleContext.VisitDepsDepthFirst(func(module blueprint.Module) {
|
|
|
|
if aModule := a.validateAndroidModule(module); aModule != nil {
|
|
|
|
visit(aModule)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *androidModuleContext) VisitDepsDepthFirstIf(pred func(Module) bool, visit func(Module)) {
|
|
|
|
a.ModuleContext.VisitDepsDepthFirstIf(
|
|
|
|
// pred
|
|
|
|
func(module blueprint.Module) bool {
|
|
|
|
if aModule := a.validateAndroidModule(module); aModule != nil {
|
|
|
|
return pred(aModule)
|
|
|
|
} else {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// visit
|
|
|
|
func(module blueprint.Module) {
|
|
|
|
visit(module.(Module))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-02-27 23:19:50 +01:00
|
|
|
func (a *androidModuleContext) WalkDepsBlueprint(visit func(blueprint.Module, blueprint.Module) bool) {
|
|
|
|
a.ModuleContext.WalkDeps(visit)
|
|
|
|
}
|
|
|
|
|
2017-10-24 02:59:01 +02:00
|
|
|
func (a *androidModuleContext) WalkDeps(visit func(Module, Module) bool) {
|
|
|
|
a.ModuleContext.WalkDeps(func(child, parent blueprint.Module) bool {
|
|
|
|
childAndroidModule := a.validateAndroidModule(child)
|
|
|
|
parentAndroidModule := a.validateAndroidModule(parent)
|
|
|
|
if childAndroidModule != nil && parentAndroidModule != nil {
|
|
|
|
return visit(childAndroidModule, parentAndroidModule)
|
|
|
|
} else {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2017-11-29 02:34:01 +01:00
|
|
|
func (a *androidModuleContext) VisitAllModuleVariants(visit func(Module)) {
|
|
|
|
a.ModuleContext.VisitAllModuleVariants(func(module blueprint.Module) {
|
|
|
|
visit(module.(Module))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *androidModuleContext) PrimaryModule() Module {
|
|
|
|
return a.ModuleContext.PrimaryModule().(Module)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *androidModuleContext) FinalModule() Module {
|
|
|
|
return a.ModuleContext.FinalModule().(Module)
|
|
|
|
}
|
|
|
|
|
2016-06-02 02:09:44 +02:00
|
|
|
func (a *androidBaseContextImpl) Target() Target {
|
|
|
|
return a.target
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2016-09-13 18:59:14 +02:00
|
|
|
func (a *androidBaseContextImpl) TargetPrimary() bool {
|
|
|
|
return a.targetPrimary
|
|
|
|
}
|
|
|
|
|
2018-10-03 07:01:37 +02:00
|
|
|
func (a *androidBaseContextImpl) MultiTargets() []Target {
|
|
|
|
return a.multiTargets
|
|
|
|
}
|
|
|
|
|
2016-06-02 02:09:44 +02:00
|
|
|
func (a *androidBaseContextImpl) Arch() Arch {
|
|
|
|
return a.target.Arch
|
2015-05-07 23:11:29 +02:00
|
|
|
}
|
|
|
|
|
2016-06-02 02:09:44 +02:00
|
|
|
func (a *androidBaseContextImpl) Os() OsType {
|
|
|
|
return a.target.Os
|
2015-11-25 02:53:15 +01:00
|
|
|
}
|
|
|
|
|
2015-03-24 19:13:38 +01:00
|
|
|
func (a *androidBaseContextImpl) Host() bool {
|
2016-06-02 02:09:44 +02:00
|
|
|
return a.target.Os.Class == Host || a.target.Os.Class == HostCross
|
2015-03-24 19:13:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (a *androidBaseContextImpl) Device() bool {
|
2016-06-02 02:09:44 +02:00
|
|
|
return a.target.Os.Class == Device
|
2015-03-24 19:13:38 +01:00
|
|
|
}
|
|
|
|
|
2015-05-01 01:36:18 +02:00
|
|
|
func (a *androidBaseContextImpl) Darwin() bool {
|
2016-06-02 02:09:44 +02:00
|
|
|
return a.target.Os == Darwin
|
2015-05-01 01:36:18 +02:00
|
|
|
}
|
|
|
|
|
2019-01-16 21:06:11 +01:00
|
|
|
func (a *androidBaseContextImpl) Fuchsia() bool {
|
|
|
|
return a.target.Os == Fuchsia
|
|
|
|
}
|
|
|
|
|
2017-04-04 21:59:48 +02:00
|
|
|
func (a *androidBaseContextImpl) Windows() bool {
|
|
|
|
return a.target.Os == Windows
|
|
|
|
}
|
|
|
|
|
2015-03-24 19:13:38 +01:00
|
|
|
func (a *androidBaseContextImpl) Debug() bool {
|
|
|
|
return a.debug
|
|
|
|
}
|
|
|
|
|
2016-08-25 00:25:47 +02:00
|
|
|
func (a *androidBaseContextImpl) PrimaryArch() bool {
|
2018-10-11 02:02:29 +02:00
|
|
|
if len(a.config.Targets[a.target.Os]) <= 1 {
|
2017-05-09 22:45:28 +02:00
|
|
|
return true
|
|
|
|
}
|
2018-10-11 02:02:29 +02:00
|
|
|
return a.target.Arch.ArchType == a.config.Targets[a.target.Os][0].Arch.ArchType
|
2016-08-25 00:25:47 +02:00
|
|
|
}
|
|
|
|
|
2015-04-08 02:11:30 +02:00
|
|
|
func (a *androidBaseContextImpl) AConfig() Config {
|
|
|
|
return a.config
|
|
|
|
}
|
|
|
|
|
2016-08-18 00:24:12 +02:00
|
|
|
func (a *androidBaseContextImpl) DeviceConfig() DeviceConfig {
|
|
|
|
return DeviceConfig{a.config.deviceConfig}
|
|
|
|
}
|
|
|
|
|
2017-11-08 08:03:48 +01:00
|
|
|
func (a *androidBaseContextImpl) Platform() bool {
|
|
|
|
return a.kind == platformModule
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *androidBaseContextImpl) DeviceSpecific() bool {
|
|
|
|
return a.kind == deviceSpecificModule
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *androidBaseContextImpl) SocSpecific() bool {
|
|
|
|
return a.kind == socSpecificModule
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *androidBaseContextImpl) ProductSpecific() bool {
|
|
|
|
return a.kind == productSpecificModule
|
2015-12-21 23:55:28 +01:00
|
|
|
}
|
|
|
|
|
2018-05-29 14:28:54 +02:00
|
|
|
func (a *androidBaseContextImpl) ProductServicesSpecific() bool {
|
|
|
|
return a.kind == productServicesSpecificModule
|
|
|
|
}
|
|
|
|
|
2018-08-28 02:55:37 +02:00
|
|
|
// Makes this module a platform module, i.e. not specific to soc, device,
|
|
|
|
// product, or product_services.
|
|
|
|
func (a *ModuleBase) MakeAsPlatform() {
|
|
|
|
a.commonProperties.Vendor = boolPtr(false)
|
|
|
|
a.commonProperties.Proprietary = boolPtr(false)
|
|
|
|
a.commonProperties.Soc_specific = boolPtr(false)
|
|
|
|
a.commonProperties.Product_specific = boolPtr(false)
|
|
|
|
a.commonProperties.Product_services_specific = boolPtr(false)
|
|
|
|
}
|
|
|
|
|
2016-08-03 20:57:50 +02:00
|
|
|
func (a *androidModuleContext) InstallInData() bool {
|
|
|
|
return a.module.InstallInData()
|
2015-12-21 23:55:28 +01:00
|
|
|
}
|
|
|
|
|
2017-03-30 07:00:18 +02:00
|
|
|
func (a *androidModuleContext) InstallInSanitizerDir() bool {
|
|
|
|
return a.module.InstallInSanitizerDir()
|
|
|
|
}
|
|
|
|
|
2018-01-31 16:54:12 +01:00
|
|
|
func (a *androidModuleContext) InstallInRecovery() bool {
|
|
|
|
return a.module.InstallInRecovery()
|
|
|
|
}
|
|
|
|
|
2017-04-27 02:34:03 +02:00
|
|
|
func (a *androidModuleContext) skipInstall(fullInstallPath OutputPath) bool {
|
|
|
|
if a.module.base().commonProperties.SkipInstall {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2018-05-08 00:28:05 +02:00
|
|
|
// We'll need a solution for choosing which of modules with the same name in different
|
|
|
|
// namespaces to install. For now, reuse the list of namespaces exported to Make as the
|
|
|
|
// list of namespaces to install in a Soong-only build.
|
|
|
|
if !a.module.base().commonProperties.NamespaceExportedToMake {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2017-04-27 02:34:03 +02:00
|
|
|
if a.Device() {
|
2017-11-29 09:27:14 +01:00
|
|
|
if a.Config().SkipDeviceInstall() {
|
2017-04-27 02:34:03 +02:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2017-11-29 09:27:14 +01:00
|
|
|
if a.Config().SkipMegaDeviceInstall(fullInstallPath.String()) {
|
2017-04-27 02:34:03 +02:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2017-08-31 21:29:17 +02:00
|
|
|
func (a *androidModuleContext) InstallFile(installPath OutputPath, name string, srcPath Path,
|
2016-03-24 21:14:12 +01:00
|
|
|
deps ...Path) OutputPath {
|
2017-08-31 21:29:17 +02:00
|
|
|
return a.installFile(installPath, name, srcPath, Cp, deps)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *androidModuleContext) InstallExecutable(installPath OutputPath, name string, srcPath Path,
|
|
|
|
deps ...Path) OutputPath {
|
|
|
|
return a.installFile(installPath, name, srcPath, CpExecutable, deps)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *androidModuleContext) installFile(installPath OutputPath, name string, srcPath Path,
|
|
|
|
rule blueprint.Rule, deps []Path) OutputPath {
|
2015-04-02 23:37:16 +02:00
|
|
|
|
2015-12-21 23:55:28 +01:00
|
|
|
fullInstallPath := installPath.Join(a, name)
|
2016-09-13 22:42:32 +02:00
|
|
|
a.module.base().hooks.runInstallHooks(a, fullInstallPath, false)
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2017-04-27 02:34:03 +02:00
|
|
|
if !a.skipInstall(fullInstallPath) {
|
2016-10-07 01:12:58 +02:00
|
|
|
|
2016-01-13 08:07:05 +01:00
|
|
|
deps = append(deps, a.installDeps...)
|
|
|
|
|
2016-10-04 02:47:19 +02:00
|
|
|
var implicitDeps, orderOnlyDeps Paths
|
|
|
|
|
|
|
|
if a.Host() {
|
|
|
|
// 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
|
|
|
|
}
|
|
|
|
|
2017-10-24 02:16:14 +02:00
|
|
|
a.Build(pctx, BuildParams{
|
2017-08-31 21:29:17 +02:00
|
|
|
Rule: rule,
|
2017-05-09 22:45:28 +02:00
|
|
|
Description: "install " + fullInstallPath.Base(),
|
|
|
|
Output: fullInstallPath,
|
|
|
|
Input: srcPath,
|
|
|
|
Implicits: implicitDeps,
|
|
|
|
OrderOnly: orderOnlyDeps,
|
2017-11-29 09:27:14 +01:00
|
|
|
Default: !a.Config().EmbeddedInMake(),
|
2016-01-13 08:07:05 +01:00
|
|
|
})
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2016-01-13 08:07:05 +01:00
|
|
|
a.installFiles = append(a.installFiles, fullInstallPath)
|
|
|
|
}
|
2015-06-17 01:38:17 +02:00
|
|
|
a.checkbuildFiles = append(a.checkbuildFiles, srcPath)
|
2015-04-02 23:37:16 +02:00
|
|
|
return fullInstallPath
|
|
|
|
}
|
|
|
|
|
2016-01-11 21:49:11 +01:00
|
|
|
func (a *androidModuleContext) InstallSymlink(installPath OutputPath, name string, srcPath OutputPath) OutputPath {
|
|
|
|
fullInstallPath := installPath.Join(a, name)
|
2016-09-13 22:42:32 +02:00
|
|
|
a.module.base().hooks.runInstallHooks(a, fullInstallPath, true)
|
2016-01-11 21:49:11 +01:00
|
|
|
|
2017-04-27 02:34:03 +02:00
|
|
|
if !a.skipInstall(fullInstallPath) {
|
2016-10-07 01:12:58 +02:00
|
|
|
|
2019-01-17 22:57:45 +01:00
|
|
|
relPath, err := filepath.Rel(path.Dir(fullInstallPath.String()), srcPath.String())
|
|
|
|
if err != nil {
|
|
|
|
panic(fmt.Sprintf("Unable to generate symlink between %q and %q: %s", fullInstallPath.Base(), srcPath.Base(), err))
|
|
|
|
}
|
2017-10-24 02:16:14 +02:00
|
|
|
a.Build(pctx, BuildParams{
|
2017-05-09 22:45:28 +02:00
|
|
|
Rule: Symlink,
|
|
|
|
Description: "install symlink " + fullInstallPath.Base(),
|
|
|
|
Output: fullInstallPath,
|
|
|
|
OrderOnly: Paths{srcPath},
|
2017-11-29 09:27:14 +01:00
|
|
|
Default: !a.Config().EmbeddedInMake(),
|
2016-01-11 21:49:11 +01:00
|
|
|
Args: map[string]string{
|
2019-01-17 22:57:45 +01:00
|
|
|
"fromPath": relPath,
|
2016-01-11 21:49:11 +01:00
|
|
|
},
|
|
|
|
})
|
2016-01-11 21:49:11 +01:00
|
|
|
|
2016-01-11 21:49:11 +01:00
|
|
|
a.installFiles = append(a.installFiles, fullInstallPath)
|
|
|
|
a.checkbuildFiles = append(a.checkbuildFiles, srcPath)
|
|
|
|
}
|
2016-01-11 21:49:11 +01:00
|
|
|
return fullInstallPath
|
|
|
|
}
|
|
|
|
|
2019-02-25 03:05:47 +01:00
|
|
|
// installPath/name -> absPath where absPath might be a path that is available only at runtime
|
|
|
|
// (e.g. /apex/...)
|
|
|
|
func (a *androidModuleContext) InstallAbsoluteSymlink(installPath OutputPath, name string, absPath string) OutputPath {
|
|
|
|
fullInstallPath := installPath.Join(a, name)
|
|
|
|
a.module.base().hooks.runInstallHooks(a, fullInstallPath, true)
|
|
|
|
|
|
|
|
if !a.skipInstall(fullInstallPath) {
|
|
|
|
a.Build(pctx, BuildParams{
|
|
|
|
Rule: Symlink,
|
|
|
|
Description: "install symlink " + fullInstallPath.Base() + " -> " + absPath,
|
|
|
|
Output: fullInstallPath,
|
|
|
|
Default: !a.Config().EmbeddedInMake(),
|
|
|
|
Args: map[string]string{
|
|
|
|
"fromPath": absPath,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
a.installFiles = append(a.installFiles, fullInstallPath)
|
|
|
|
}
|
|
|
|
return fullInstallPath
|
|
|
|
}
|
|
|
|
|
2015-09-24 00:26:20 +02:00
|
|
|
func (a *androidModuleContext) CheckbuildFile(srcPath Path) {
|
2015-01-31 02:27:36 +01:00
|
|
|
a.checkbuildFiles = append(a.checkbuildFiles, srcPath)
|
|
|
|
}
|
|
|
|
|
|
|
|
type fileInstaller interface {
|
2015-09-24 00:26:20 +02:00
|
|
|
filesToInstall() Paths
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func isFileInstaller(m blueprint.Module) bool {
|
|
|
|
_, ok := m.(fileInstaller)
|
|
|
|
return ok
|
|
|
|
}
|
|
|
|
|
|
|
|
func isAndroidModule(m blueprint.Module) bool {
|
2016-05-19 00:37:25 +02:00
|
|
|
_, ok := m.(Module)
|
2015-01-31 02:27:36 +01:00
|
|
|
return ok
|
|
|
|
}
|
2015-04-08 20:21:40 +02:00
|
|
|
|
2015-07-01 03:15:24 +02:00
|
|
|
func findStringInSlice(str string, slice []string) int {
|
|
|
|
for i, s := range slice {
|
|
|
|
if s == str {
|
|
|
|
return i
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1
|
|
|
|
}
|
|
|
|
|
2016-12-14 00:23:47 +01:00
|
|
|
func SrcIsModule(s string) string {
|
|
|
|
if len(s) > 1 && s[0] == ':' {
|
|
|
|
return s[1:]
|
|
|
|
}
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
|
|
|
type sourceDependencyTag struct {
|
|
|
|
blueprint.BaseDependencyTag
|
|
|
|
}
|
|
|
|
|
|
|
|
var SourceDepTag sourceDependencyTag
|
|
|
|
|
2017-12-12 01:29:02 +01:00
|
|
|
// Adds necessary dependencies to satisfy filegroup or generated sources modules listed in srcFiles
|
|
|
|
// using ":module" syntax, if any.
|
2019-03-05 07:35:41 +01:00
|
|
|
//
|
|
|
|
// Deprecated: tag the property with `android:"path"` instead.
|
2016-12-14 00:23:47 +01:00
|
|
|
func ExtractSourcesDeps(ctx BottomUpMutatorContext, srcFiles []string) {
|
|
|
|
var deps []string
|
2017-04-10 20:27:50 +02:00
|
|
|
set := make(map[string]bool)
|
|
|
|
|
2016-12-14 00:23:47 +01:00
|
|
|
for _, s := range srcFiles {
|
|
|
|
if m := SrcIsModule(s); m != "" {
|
2017-04-10 20:27:50 +02:00
|
|
|
if _, found := set[m]; found {
|
|
|
|
ctx.ModuleErrorf("found source dependency duplicate: %q!", m)
|
|
|
|
} else {
|
|
|
|
set[m] = true
|
|
|
|
deps = append(deps, m)
|
|
|
|
}
|
2016-12-14 00:23:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ctx.AddDependency(ctx.Module(), SourceDepTag, deps...)
|
|
|
|
}
|
|
|
|
|
2017-12-12 01:29:02 +01:00
|
|
|
// Adds necessary dependencies to satisfy filegroup or generated sources modules specified in s
|
|
|
|
// using ":module" syntax, if any.
|
2019-03-05 07:35:41 +01:00
|
|
|
//
|
|
|
|
// Deprecated: tag the property with `android:"path"` instead.
|
2017-12-12 01:29:02 +01:00
|
|
|
func ExtractSourceDeps(ctx BottomUpMutatorContext, s *string) {
|
|
|
|
if s != nil {
|
|
|
|
if m := SrcIsModule(*s); m != "" {
|
|
|
|
ctx.AddDependency(ctx.Module(), SourceDepTag, m)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-14 00:23:47 +01:00
|
|
|
type SourceFileProducer interface {
|
|
|
|
Srcs() Paths
|
|
|
|
}
|
|
|
|
|
2019-03-29 03:30:56 +01:00
|
|
|
type HostToolProvider interface {
|
|
|
|
HostToolPath() OptionalPath
|
|
|
|
}
|
|
|
|
|
2019-03-05 07:35:41 +01:00
|
|
|
// Returns a list of paths expanded from globs and modules referenced using ":module" syntax. The property must
|
|
|
|
// be tagged with `android:"path" to support automatic source module dependency resolution.
|
2019-03-06 07:25:09 +01:00
|
|
|
//
|
|
|
|
// Deprecated: use PathsForModuleSrc or PathsForModuleSrcExcludes instead.
|
2015-09-24 00:26:20 +02:00
|
|
|
func (ctx *androidModuleContext) ExpandSources(srcFiles, excludes []string) Paths {
|
2019-03-06 07:25:09 +01:00
|
|
|
return PathsForModuleSrcExcludes(ctx, srcFiles, excludes)
|
2015-06-18 00:09:06 +02:00
|
|
|
}
|
|
|
|
|
2019-03-05 21:39:51 +01:00
|
|
|
// Returns a single path expanded from globs and modules referenced using ":module" syntax. The property must
|
|
|
|
// be tagged with `android:"path" to support automatic source module dependency resolution.
|
2019-03-06 07:25:09 +01:00
|
|
|
//
|
|
|
|
// Deprecated: use PathForModuleSrc instead.
|
2019-03-05 21:39:51 +01:00
|
|
|
func (ctx *androidModuleContext) ExpandSource(srcFile, prop string) Path {
|
2019-03-06 07:25:09 +01:00
|
|
|
return PathForModuleSrc(ctx, srcFile)
|
2019-03-05 21:39:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Returns an optional single path expanded from globs and modules referenced using ":module" syntax if
|
|
|
|
// the srcFile is non-nil. The property must be tagged with `android:"path" to support automatic source module
|
|
|
|
// dependency resolution.
|
|
|
|
func (ctx *androidModuleContext) ExpandOptionalSource(srcFile *string, prop string) OptionalPath {
|
|
|
|
if srcFile != nil {
|
2019-03-06 07:25:09 +01:00
|
|
|
return OptionalPathForPath(PathForModuleSrc(ctx, *srcFile))
|
2019-03-05 21:39:51 +01:00
|
|
|
}
|
|
|
|
return OptionalPath{}
|
|
|
|
}
|
|
|
|
|
2017-02-05 02:47:46 +01:00
|
|
|
func (ctx *androidModuleContext) RequiredModuleNames() []string {
|
|
|
|
return ctx.module.base().commonProperties.Required
|
|
|
|
}
|
|
|
|
|
2016-11-01 19:10:25 +01:00
|
|
|
func (ctx *androidModuleContext) Glob(globPattern string, excludes []string) Paths {
|
|
|
|
ret, err := ctx.GlobWithDeps(globPattern, excludes)
|
2015-06-18 00:09:06 +02:00
|
|
|
if err != nil {
|
|
|
|
ctx.ModuleErrorf("glob: %s", err.Error())
|
|
|
|
}
|
2018-02-27 06:50:08 +01:00
|
|
|
return pathsForModuleSrcFromFullPath(ctx, ret, true)
|
2015-04-08 20:21:40 +02:00
|
|
|
}
|
2015-06-17 01:38:17 +02:00
|
|
|
|
2018-01-11 01:06:12 +01:00
|
|
|
func (ctx *androidModuleContext) GlobFiles(globPattern string, excludes []string) Paths {
|
2018-02-27 06:50:08 +01:00
|
|
|
ret, err := ctx.GlobWithDeps(globPattern, excludes)
|
2018-01-11 01:06:12 +01:00
|
|
|
if err != nil {
|
|
|
|
ctx.ModuleErrorf("glob: %s", err.Error())
|
|
|
|
}
|
2018-02-27 06:50:08 +01:00
|
|
|
return pathsForModuleSrcFromFullPath(ctx, ret, false)
|
2018-01-11 01:06:12 +01:00
|
|
|
}
|
|
|
|
|
2015-06-17 23:20:06 +02:00
|
|
|
func init() {
|
2016-10-12 23:28:16 +02:00
|
|
|
RegisterSingletonType("buildtarget", BuildTargetSingleton)
|
2015-06-17 23:20:06 +02:00
|
|
|
}
|
|
|
|
|
2017-11-29 02:34:01 +01:00
|
|
|
func BuildTargetSingleton() Singleton {
|
2015-06-17 01:38:17 +02:00
|
|
|
return &buildTargetSingleton{}
|
|
|
|
}
|
|
|
|
|
2017-04-25 19:01:55 +02:00
|
|
|
func parentDir(dir string) string {
|
|
|
|
dir, _ = filepath.Split(dir)
|
|
|
|
return filepath.Clean(dir)
|
|
|
|
}
|
|
|
|
|
2015-06-17 01:38:17 +02:00
|
|
|
type buildTargetSingleton struct{}
|
|
|
|
|
2017-11-29 02:34:01 +01:00
|
|
|
func (c *buildTargetSingleton) GenerateBuildActions(ctx SingletonContext) {
|
|
|
|
var checkbuildDeps Paths
|
2015-06-17 01:38:17 +02:00
|
|
|
|
2017-11-29 02:34:01 +01:00
|
|
|
mmTarget := func(dir string) WritablePath {
|
|
|
|
return PathForPhony(ctx,
|
|
|
|
"MODULES-IN-"+strings.Replace(filepath.Clean(dir), "/", "-", -1))
|
2017-04-25 19:01:55 +02:00
|
|
|
}
|
|
|
|
|
2017-11-29 02:34:01 +01:00
|
|
|
modulesInDir := make(map[string]Paths)
|
2015-06-17 01:38:17 +02:00
|
|
|
|
2017-11-29 02:34:01 +01:00
|
|
|
ctx.VisitAllModules(func(module Module) {
|
|
|
|
blueprintDir := module.base().blueprintDir
|
|
|
|
installTarget := module.base().installTarget
|
|
|
|
checkbuildTarget := module.base().checkbuildTarget
|
2015-06-17 01:38:17 +02:00
|
|
|
|
2017-11-29 02:34:01 +01:00
|
|
|
if checkbuildTarget != nil {
|
|
|
|
checkbuildDeps = append(checkbuildDeps, checkbuildTarget)
|
|
|
|
modulesInDir[blueprintDir] = append(modulesInDir[blueprintDir], checkbuildTarget)
|
|
|
|
}
|
2015-06-17 01:38:17 +02:00
|
|
|
|
2017-11-29 02:34:01 +01:00
|
|
|
if installTarget != nil {
|
|
|
|
modulesInDir[blueprintDir] = append(modulesInDir[blueprintDir], installTarget)
|
2015-06-17 01:38:17 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2015-12-11 22:51:06 +01:00
|
|
|
suffix := ""
|
2017-11-29 09:27:14 +01:00
|
|
|
if ctx.Config().EmbeddedInMake() {
|
2015-12-11 22:51:06 +01:00
|
|
|
suffix = "-soong"
|
|
|
|
}
|
|
|
|
|
2015-06-17 01:38:17 +02:00
|
|
|
// Create a top-level checkbuild target that depends on all modules
|
2017-11-29 02:34:01 +01:00
|
|
|
ctx.Build(pctx, BuildParams{
|
2015-06-17 01:38:17 +02:00
|
|
|
Rule: blueprint.Phony,
|
2017-11-29 02:34:01 +01:00
|
|
|
Output: PathForPhony(ctx, "checkbuild"+suffix),
|
2015-06-17 01:38:17 +02:00
|
|
|
Implicits: checkbuildDeps,
|
|
|
|
})
|
|
|
|
|
2017-09-20 23:30:50 +02:00
|
|
|
// Make will generate the MODULES-IN-* targets
|
2017-11-29 09:27:14 +01:00
|
|
|
if ctx.Config().EmbeddedInMake() {
|
2017-09-20 23:30:50 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-11-29 02:34:01 +01:00
|
|
|
sortedKeys := func(m map[string]Paths) []string {
|
|
|
|
s := make([]string, 0, len(m))
|
|
|
|
for k := range m {
|
|
|
|
s = append(s, k)
|
|
|
|
}
|
|
|
|
sort.Strings(s)
|
|
|
|
return s
|
|
|
|
}
|
|
|
|
|
2017-04-25 19:01:55 +02:00
|
|
|
// Ensure ancestor directories are in modulesInDir
|
|
|
|
dirs := sortedKeys(modulesInDir)
|
|
|
|
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
|
|
|
|
dirs = sortedKeys(modulesInDir)
|
|
|
|
for _, dir := range dirs {
|
|
|
|
p := parentDir(dir)
|
|
|
|
if p != "." && p != "/" {
|
|
|
|
modulesInDir[p] = append(modulesInDir[p], mmTarget(dir))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-20 23:30:50 +02:00
|
|
|
// Create a MODULES-IN-<directory> target that depends on all modules in a directory, and
|
|
|
|
// depends on the MODULES-IN-* targets of all of its subdirectories that contain Android.bp
|
|
|
|
// files.
|
2015-06-17 01:38:17 +02:00
|
|
|
for _, dir := range dirs {
|
2017-11-29 02:34:01 +01:00
|
|
|
ctx.Build(pctx, BuildParams{
|
2015-06-17 01:38:17 +02:00
|
|
|
Rule: blueprint.Phony,
|
2017-11-29 02:34:01 +01:00
|
|
|
Output: mmTarget(dir),
|
2017-04-25 19:01:55 +02:00
|
|
|
Implicits: modulesInDir[dir],
|
2015-12-11 22:51:06 +01:00
|
|
|
// HACK: checkbuild should be an optional build, but force it
|
|
|
|
// enabled for now in standalone builds
|
2017-11-29 09:27:14 +01:00
|
|
|
Default: !ctx.Config().EmbeddedInMake(),
|
2015-06-17 01:38:17 +02:00
|
|
|
})
|
|
|
|
}
|
2017-09-21 02:29:08 +02:00
|
|
|
|
|
|
|
// Create (host|host-cross|target)-<OS> phony rules to build a reduced checkbuild.
|
|
|
|
osDeps := map[OsType]Paths{}
|
2017-11-29 02:34:01 +01:00
|
|
|
ctx.VisitAllModules(func(module Module) {
|
|
|
|
if module.Enabled() {
|
|
|
|
os := module.Target().Os
|
|
|
|
osDeps[os] = append(osDeps[os], module.base().checkbuildFiles...)
|
2017-09-21 02:29:08 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2017-11-29 02:34:01 +01:00
|
|
|
osClass := make(map[string]Paths)
|
2017-09-21 02:29:08 +02: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 02:34:01 +01:00
|
|
|
name := PathForPhony(ctx, className+"-"+os.Name)
|
2017-09-21 02:29:08 +02:00
|
|
|
osClass[className] = append(osClass[className], name)
|
|
|
|
|
2017-11-29 02:34:01 +01:00
|
|
|
ctx.Build(pctx, BuildParams{
|
2017-09-21 02:29:08 +02:00
|
|
|
Rule: blueprint.Phony,
|
2017-11-29 02:34:01 +01:00
|
|
|
Output: name,
|
|
|
|
Implicits: deps,
|
2017-09-21 02:29:08 +02:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// Wrap those into host|host-cross|target phony rules
|
|
|
|
osClasses := sortedKeys(osClass)
|
|
|
|
for _, class := range osClasses {
|
2017-11-29 02:34:01 +01:00
|
|
|
ctx.Build(pctx, BuildParams{
|
2017-09-21 02:29:08 +02:00
|
|
|
Rule: blueprint.Phony,
|
2017-11-29 02:34:01 +01:00
|
|
|
Output: PathForPhony(ctx, class),
|
2017-09-21 02:29:08 +02:00
|
|
|
Implicits: osClass[class],
|
|
|
|
})
|
|
|
|
}
|
2015-06-17 01:38:17 +02:00
|
|
|
}
|
2015-12-18 03:00:23 +01:00
|
|
|
|
2018-08-16 00:35:38 +02:00
|
|
|
// Collect information for opening IDE project files in java/jdeps.go.
|
|
|
|
type IDEInfo interface {
|
|
|
|
IDEInfo(ideInfo *IdeInfo)
|
|
|
|
BaseModuleName() string
|
|
|
|
}
|
|
|
|
|
|
|
|
// Extract the base module name from the Import name.
|
|
|
|
// Often the Import name has a prefix "prebuilt_".
|
|
|
|
// Remove the prefix explicitly if needed
|
|
|
|
// until we find a better solution to get the Import name.
|
|
|
|
type IDECustomizedModuleName interface {
|
|
|
|
IDECustomizedModuleName() string
|
|
|
|
}
|
|
|
|
|
|
|
|
type IdeInfo struct {
|
|
|
|
Deps []string `json:"dependencies,omitempty"`
|
|
|
|
Srcs []string `json:"srcs,omitempty"`
|
|
|
|
Aidl_include_dirs []string `json:"aidl_include_dirs,omitempty"`
|
|
|
|
Jarjar_rules []string `json:"jarjar_rules,omitempty"`
|
|
|
|
Jars []string `json:"jars,omitempty"`
|
|
|
|
Classes []string `json:"class,omitempty"`
|
|
|
|
Installed_paths []string `json:"installed,omitempty"`
|
|
|
|
}
|