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"
|
2015-01-31 09:27:36 +08:00
|
|
|
"path/filepath"
|
2015-12-18 08:39:19 +08:00
|
|
|
"strings"
|
2015-03-25 02:13:38 +08:00
|
|
|
|
|
|
|
"github.com/google/blueprint"
|
2016-11-02 02:10:25 +08:00
|
|
|
"github.com/google/blueprint/pathtools"
|
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
|
|
|
|
|
2015-03-25 02:13:38 +08:00
|
|
|
type androidBaseContext interface {
|
2016-06-02 08:09:44 +08:00
|
|
|
Target() Target
|
2016-09-14 00:59:14 +08:00
|
|
|
TargetPrimary() bool
|
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
|
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
|
2017-09-28 08:01:44 +08:00
|
|
|
InstallOnVendorPartition() bool
|
2015-04-08 08:11:30 +08:00
|
|
|
AConfig() Config
|
2016-08-18 06:24:12 +08:00
|
|
|
DeviceConfig() DeviceConfig
|
2015-03-25 02:13:38 +08:00
|
|
|
}
|
|
|
|
|
2016-05-19 06:37:25 +08:00
|
|
|
type BaseContext interface {
|
2015-03-25 02:13:38 +08:00
|
|
|
blueprint.BaseModuleContext
|
|
|
|
androidBaseContext
|
|
|
|
}
|
|
|
|
|
2016-05-19 06:37:25 +08:00
|
|
|
type ModuleContext interface {
|
2015-03-25 02:13:38 +08:00
|
|
|
androidBaseContext
|
2017-10-24 08:10:29 +08:00
|
|
|
blueprint.BaseModuleContext
|
2015-01-31 09:27:36 +08:00
|
|
|
|
2017-10-24 08:16:14 +08:00
|
|
|
// Deprecated: use ModuleContext.Build instead.
|
2015-09-24 06:26:20 +08:00
|
|
|
ModuleBuild(pctx blueprint.PackageContext, params ModuleBuildParams)
|
|
|
|
|
|
|
|
ExpandSources(srcFiles, excludes []string) Paths
|
2017-02-02 06:12:44 +08:00
|
|
|
ExpandSourcesSubDir(srcFiles, excludes []string, subDir string) Paths
|
2016-11-02 02:10:25 +08:00
|
|
|
Glob(globPattern string, excludes []string) Paths
|
2015-06-18 06:09:06 +08:00
|
|
|
|
2017-09-01 03:29:17 +08:00
|
|
|
InstallExecutable(installPath OutputPath, name string, srcPath Path, deps ...Path) OutputPath
|
|
|
|
InstallFile(installPath OutputPath, name string, srcPath Path, deps ...Path) OutputPath
|
2016-01-12 04:49:11 +08:00
|
|
|
InstallSymlink(installPath OutputPath, name string, srcPath OutputPath) OutputPath
|
2015-09-24 06:26:20 +08:00
|
|
|
CheckbuildFile(srcPath Path)
|
2016-03-11 10:14:25 +08:00
|
|
|
|
|
|
|
AddMissingDependencies(deps []string)
|
2016-08-04 02:57:50 +08:00
|
|
|
|
|
|
|
InstallInData() bool
|
2017-03-30 13:00:18 +08:00
|
|
|
InstallInSanitizerDir() bool
|
2017-02-05 09:47:46 +08:00
|
|
|
|
|
|
|
RequiredModuleNames() []string
|
2017-10-24 08:10:29 +08: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-10-24 08:59:01 +08:00
|
|
|
VisitDirectDeps(visit func(Module))
|
|
|
|
VisitDirectDepsIf(pred func(Module) bool, visit func(Module))
|
|
|
|
VisitDepsDepthFirst(visit func(Module))
|
|
|
|
VisitDepsDepthFirstIf(pred func(Module) bool, visit func(Module))
|
|
|
|
WalkDeps(visit func(Module, Module) bool)
|
2017-10-24 08:10:29 +08:00
|
|
|
|
|
|
|
Variable(pctx blueprint.PackageContext, name, value string)
|
|
|
|
Rule(pctx blueprint.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.
|
|
|
|
Build(pctx blueprint.PackageContext, params BuildParams)
|
2017-10-24 08:10:29 +08:00
|
|
|
|
|
|
|
PrimaryModule() blueprint.Module
|
|
|
|
FinalModule() blueprint.Module
|
|
|
|
VisitAllModuleVariants(visit func(blueprint.Module))
|
|
|
|
|
|
|
|
GetMissingDependencies() []string
|
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
|
2017-03-30 13:00:18 +08:00
|
|
|
InstallInSanitizerDir() bool
|
2016-11-30 07:16:18 +08:00
|
|
|
SkipInstall()
|
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
|
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.
|
2015-04-03 04:54:39 +08:00
|
|
|
Name string
|
2016-05-18 07:34:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
type commonProperties struct {
|
2015-04-03 04:54:39 +08:00
|
|
|
Tags []string
|
2015-01-31 09:27:36 +08:00
|
|
|
|
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
|
|
|
|
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-01 17:32:53 +08:00
|
|
|
Compile_multilib string `android:"arch_variant"`
|
2016-09-07 01:39:07 +08:00
|
|
|
|
|
|
|
Target struct {
|
|
|
|
Host struct {
|
2017-11-01 17:32:53 +08:00
|
|
|
Compile_multilib string
|
2016-09-07 01:39:07 +08:00
|
|
|
}
|
|
|
|
Android struct {
|
2017-11-01 17:32:53 +08:00
|
|
|
Compile_multilib string
|
2016-09-07 01:39:07 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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-01 17:32:53 +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-04-07 03:49:58 +08:00
|
|
|
// whether this module is device specific and should be installed into /vendor
|
2017-11-01 17:32:53 +08:00
|
|
|
Vendor bool
|
2017-04-07 03:49:58 +08:00
|
|
|
|
2016-06-02 06:25:32 +08:00
|
|
|
// *.logtags files, to combine together in order to generate the /system/etc/event-log-tags
|
|
|
|
// file
|
|
|
|
Logtags []string
|
|
|
|
|
2016-07-26 11:27:39 +08:00
|
|
|
// init.rc files to be installed if this module is installed
|
|
|
|
Init_rc []string
|
|
|
|
|
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
|
|
|
|
2017-09-01 06:07:09 +08:00
|
|
|
// relative path to a file to include in the list of notices for the device
|
|
|
|
Notice *string
|
|
|
|
|
2016-06-02 08:09:44 +08:00
|
|
|
// Set by TargetMutator
|
2016-09-14 00:59:14 +08:00
|
|
|
CompileTarget 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"`
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
type hostAndDeviceProperties struct {
|
2016-07-13 04:11:25 +08:00
|
|
|
Host_supported *bool
|
|
|
|
Device_supported *bool
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
2015-03-18 06:06:21 +08:00
|
|
|
type Multilib string
|
|
|
|
|
|
|
|
const (
|
2015-07-09 09:13:11 +08:00
|
|
|
MultilibBoth Multilib = "both"
|
|
|
|
MultilibFirst Multilib = "first"
|
|
|
|
MultilibCommon Multilib = "common"
|
|
|
|
MultilibDefault Multilib = ""
|
2015-03-18 06:06:21 +08:00
|
|
|
)
|
|
|
|
|
2016-06-02 08:09:44 +08:00
|
|
|
type HostOrDeviceSupported int
|
|
|
|
|
|
|
|
const (
|
|
|
|
_ HostOrDeviceSupported = iota
|
|
|
|
HostSupported
|
2016-10-20 16:36:11 +08:00
|
|
|
HostSupportedNoCross
|
2016-06-02 08:09:44 +08:00
|
|
|
DeviceSupported
|
|
|
|
HostAndDeviceSupported
|
|
|
|
HostAndDeviceDefault
|
2016-10-05 06:13:37 +08:00
|
|
|
NeitherHostNorDeviceSupported
|
2016-06-02 08:09:44 +08:00
|
|
|
)
|
|
|
|
|
2017-06-24 06:06:31 +08:00
|
|
|
func InitAndroidModule(m Module) {
|
2015-01-31 09:27:36 +08:00
|
|
|
base := m.base()
|
|
|
|
base.module = m
|
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,
|
|
|
|
&base.commonProperties,
|
|
|
|
&base.variableProperties)
|
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
|
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
|
|
|
}
|
|
|
|
|
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
|
|
|
|
// that is to be built. GenerateAndroidBuildActions is passed a
|
|
|
|
// AndroidModuleContext rather than the usual blueprint.ModuleContext.
|
2015-01-31 09:27:36 +08: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-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
|
2015-07-10 04:57:48 +08:00
|
|
|
variableProperties variableProperties
|
2015-01-31 09:27:36 +08:00
|
|
|
hostAndDeviceProperties hostAndDeviceProperties
|
|
|
|
generalProperties []interface{}
|
2016-06-24 14:44:54 +08:00
|
|
|
archProperties []interface{}
|
2016-08-20 07:07:38 +08:00
|
|
|
customizableProperties []interface{}
|
2015-01-31 09:27:36 +08:00
|
|
|
|
|
|
|
noAddressSanitizer bool
|
2015-09-24 06:26:20 +08:00
|
|
|
installFiles Paths
|
|
|
|
checkbuildFiles Paths
|
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
|
|
|
|
installTarget string
|
|
|
|
checkbuildTarget string
|
|
|
|
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
|
2017-06-24 06:06:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (a *ModuleBase) AddProperties(props ...interface{}) {
|
|
|
|
a.registerProps = append(a.registerProps, props...)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *ModuleBase) GetProperties() []interface{} {
|
|
|
|
return a.registerProps
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
2017-10-24 08:16:14 +08:00
|
|
|
func (a *ModuleBase) BuildParamsForTests() []BuildParams {
|
2017-07-14 05:43:27 +08:00
|
|
|
return a.buildParams
|
|
|
|
}
|
|
|
|
|
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.
|
2016-05-18 07:34:16 +08:00
|
|
|
func (a *ModuleBase) Name() string {
|
|
|
|
return a.nameProperties.Name
|
|
|
|
}
|
|
|
|
|
2016-10-07 07:12:58 +08:00
|
|
|
// BaseModuleName returns the name of the module as specified in the blueprints file.
|
|
|
|
func (a *ModuleBase) BaseModuleName() string {
|
|
|
|
return a.nameProperties.Name
|
|
|
|
}
|
|
|
|
|
2016-05-19 06:37:25 +08:00
|
|
|
func (a *ModuleBase) base() *ModuleBase {
|
2015-01-31 09:27:36 +08:00
|
|
|
return a
|
|
|
|
}
|
|
|
|
|
2016-09-14 00:59:14 +08:00
|
|
|
func (a *ModuleBase) SetTarget(target Target, primary bool) {
|
2016-06-02 08:09:44 +08:00
|
|
|
a.commonProperties.CompileTarget = target
|
2016-09-14 00:59:14 +08:00
|
|
|
a.commonProperties.CompilePrimary = primary
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
2016-06-02 08:09:44 +08:00
|
|
|
func (a *ModuleBase) Target() Target {
|
|
|
|
return a.commonProperties.CompileTarget
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
2016-09-14 00:59:14 +08:00
|
|
|
func (a *ModuleBase) TargetPrimary() bool {
|
|
|
|
return a.commonProperties.CompilePrimary
|
|
|
|
}
|
|
|
|
|
2016-06-02 08:09:44 +08:00
|
|
|
func (a *ModuleBase) Os() OsType {
|
|
|
|
return a.Target().Os
|
2015-11-25 09:53:15 +08:00
|
|
|
}
|
|
|
|
|
2016-05-19 06:37:25 +08:00
|
|
|
func (a *ModuleBase) Host() bool {
|
2016-06-02 08:09:44 +08:00
|
|
|
return a.Os().Class == Host || a.Os().Class == HostCross
|
2016-02-10 09:43:51 +08:00
|
|
|
}
|
|
|
|
|
2016-05-19 06:37:25 +08:00
|
|
|
func (a *ModuleBase) Arch() Arch {
|
2016-06-02 08:09:44 +08:00
|
|
|
return a.Target().Arch
|
2016-02-10 09:43:51 +08:00
|
|
|
}
|
|
|
|
|
2016-10-05 06:13:37 +08:00
|
|
|
func (a *ModuleBase) ArchSpecific() bool {
|
|
|
|
return a.commonProperties.ArchSpecific
|
|
|
|
}
|
|
|
|
|
2016-06-02 08:09:44 +08:00
|
|
|
func (a *ModuleBase) OsClassSupported() []OsClass {
|
|
|
|
switch a.commonProperties.HostOrDeviceSupported {
|
|
|
|
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}
|
|
|
|
case HostAndDeviceSupported:
|
|
|
|
var supported []OsClass
|
2016-07-13 04:11:25 +08:00
|
|
|
if Bool(a.hostAndDeviceProperties.Host_supported) {
|
2016-06-02 08:09:44 +08:00
|
|
|
supported = append(supported, Host, HostCross)
|
|
|
|
}
|
2017-07-06 01:35:11 +08:00
|
|
|
if a.hostAndDeviceProperties.Device_supported == nil ||
|
|
|
|
*a.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
|
|
|
}
|
|
|
|
|
2016-05-19 06:37:25 +08:00
|
|
|
func (a *ModuleBase) DeviceSupported() bool {
|
2015-01-31 09:27:36 +08:00
|
|
|
return a.commonProperties.HostOrDeviceSupported == DeviceSupported ||
|
|
|
|
a.commonProperties.HostOrDeviceSupported == HostAndDeviceSupported &&
|
2017-07-06 01:35:11 +08:00
|
|
|
(a.hostAndDeviceProperties.Device_supported == nil ||
|
|
|
|
*a.hostAndDeviceProperties.Device_supported)
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
2016-05-19 06:37:25 +08:00
|
|
|
func (a *ModuleBase) Enabled() bool {
|
2015-12-01 08:06:01 +08:00
|
|
|
if a.commonProperties.Enabled == nil {
|
2016-11-14 02:16:05 +08:00
|
|
|
return !a.Os().DefaultDisabled
|
2015-11-25 09:53:15 +08:00
|
|
|
}
|
2015-12-01 08:06:01 +08:00
|
|
|
return *a.commonProperties.Enabled
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
2016-10-07 07:12:58 +08:00
|
|
|
func (a *ModuleBase) SkipInstall() {
|
|
|
|
a.commonProperties.SkipInstall = true
|
|
|
|
}
|
|
|
|
|
2016-05-19 06:37:25 +08:00
|
|
|
func (a *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{}
|
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
|
|
|
|
}
|
|
|
|
|
2016-05-19 06:37:25 +08:00
|
|
|
func (a *ModuleBase) filesToInstall() Paths {
|
2015-01-31 09:27:36 +08:00
|
|
|
return a.installFiles
|
|
|
|
}
|
|
|
|
|
2016-05-19 06:37:25 +08:00
|
|
|
func (p *ModuleBase) NoAddressSanitizer() bool {
|
2015-01-31 09:27:36 +08:00
|
|
|
return p.noAddressSanitizer
|
|
|
|
}
|
|
|
|
|
2016-05-19 06:37:25 +08:00
|
|
|
func (p *ModuleBase) InstallInData() bool {
|
2015-12-22 06:55:28 +08:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2017-03-30 13:00:18 +08:00
|
|
|
func (p *ModuleBase) InstallInSanitizerDir() bool {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2016-05-19 06:37:25 +08:00
|
|
|
func (a *ModuleBase) generateModuleTarget(ctx blueprint.ModuleContext) {
|
2015-09-24 06:26:20 +08:00
|
|
|
allInstalledFiles := Paths{}
|
|
|
|
allCheckbuildFiles := Paths{}
|
2015-01-31 09:27:36 +08:00
|
|
|
ctx.VisitAllModuleVariants(func(module blueprint.Module) {
|
2016-05-19 06:37:25 +08:00
|
|
|
a := module.(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
|
|
|
})
|
|
|
|
|
2015-03-18 04:24:18 +08:00
|
|
|
deps := []string{}
|
|
|
|
|
2015-01-31 09:27:36 +08:00
|
|
|
if len(allInstalledFiles) > 0 {
|
2015-03-18 04:24:18 +08:00
|
|
|
name := ctx.ModuleName() + "-install"
|
|
|
|
ctx.Build(pctx, blueprint.BuildParams{
|
|
|
|
Rule: blueprint.Phony,
|
|
|
|
Outputs: []string{name},
|
2015-09-24 06:26:20 +08:00
|
|
|
Implicits: allInstalledFiles.Strings(),
|
2015-12-18 09:19:51 +08:00
|
|
|
Optional: ctx.Config().(Config).EmbeddedInMake(),
|
2015-03-18 04:24:18 +08:00
|
|
|
})
|
|
|
|
deps = append(deps, name)
|
2015-06-17 07:38:17 +08:00
|
|
|
a.installTarget = name
|
2015-03-18 04:24:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if len(allCheckbuildFiles) > 0 {
|
|
|
|
name := ctx.ModuleName() + "-checkbuild"
|
2015-01-31 09:27:36 +08:00
|
|
|
ctx.Build(pctx, blueprint.BuildParams{
|
2015-03-18 04:24:18 +08:00
|
|
|
Rule: blueprint.Phony,
|
|
|
|
Outputs: []string{name},
|
2015-09-24 06:26:20 +08:00
|
|
|
Implicits: allCheckbuildFiles.Strings(),
|
2015-03-18 04:24:18 +08:00
|
|
|
Optional: true,
|
|
|
|
})
|
|
|
|
deps = append(deps, name)
|
2015-06-17 07:38:17 +08:00
|
|
|
a.checkbuildTarget = name
|
2015-03-18 04:24:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if len(deps) > 0 {
|
2015-12-12 05:51:06 +08:00
|
|
|
suffix := ""
|
|
|
|
if ctx.Config().(Config).EmbeddedInMake() {
|
|
|
|
suffix = "-soong"
|
|
|
|
}
|
|
|
|
|
2015-03-18 04:24:18 +08:00
|
|
|
ctx.Build(pctx, blueprint.BuildParams{
|
|
|
|
Rule: blueprint.Phony,
|
2015-12-12 05:51:06 +08:00
|
|
|
Outputs: []string{ctx.ModuleName() + suffix},
|
2015-03-18 04:24:18 +08:00
|
|
|
Implicits: deps,
|
|
|
|
Optional: true,
|
2015-01-31 09:27:36 +08:00
|
|
|
})
|
2015-06-17 07:38:17 +08:00
|
|
|
|
|
|
|
a.blueprintDir = ctx.ModuleDir()
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-19 06:37:25 +08:00
|
|
|
func (a *ModuleBase) androidBaseContextFactory(ctx blueprint.BaseModuleContext) androidBaseContextImpl {
|
2015-10-30 06:25:03 +08:00
|
|
|
return androidBaseContextImpl{
|
2016-09-14 00:59:14 +08:00
|
|
|
target: a.commonProperties.CompileTarget,
|
|
|
|
targetPrimary: a.commonProperties.CompilePrimary,
|
2017-11-01 17:32:53 +08:00
|
|
|
vendor: a.commonProperties.Proprietary || a.commonProperties.Vendor,
|
2016-09-14 00:59:14 +08:00
|
|
|
config: ctx.Config().(Config),
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-19 06:37:25 +08:00
|
|
|
func (a *ModuleBase) GenerateBuildActions(ctx blueprint.ModuleContext) {
|
2015-01-31 09:27:36 +08:00
|
|
|
androidCtx := &androidModuleContext{
|
2016-08-04 02:57:50 +08:00
|
|
|
module: a.module,
|
2015-10-30 06:25:03 +08:00
|
|
|
ModuleContext: ctx,
|
|
|
|
androidBaseContextImpl: a.androidBaseContextFactory(ctx),
|
|
|
|
installDeps: a.computeInstallDeps(ctx),
|
|
|
|
installFiles: a.installFiles,
|
2015-12-18 08:39:19 +08:00
|
|
|
missingDeps: ctx.GetMissingDependencies(),
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
2017-05-10 04:45:28 +08:00
|
|
|
desc := "//" + ctx.ModuleDir() + ":" + ctx.ModuleName() + " "
|
|
|
|
var suffix []string
|
|
|
|
if androidCtx.Os().Class != Device && androidCtx.Os().Class != Generic {
|
|
|
|
suffix = append(suffix, androidCtx.Os().String())
|
|
|
|
}
|
|
|
|
if !androidCtx.PrimaryArch() {
|
|
|
|
suffix = append(suffix, androidCtx.Arch().ArchType.String())
|
|
|
|
}
|
|
|
|
|
|
|
|
ctx.Variable(pctx, "moduleDesc", desc)
|
|
|
|
|
|
|
|
s := ""
|
|
|
|
if len(suffix) > 0 {
|
|
|
|
s = " [" + strings.Join(suffix, " ") + "]"
|
|
|
|
}
|
|
|
|
ctx.Variable(pctx, "moduleDescSuffix", s)
|
|
|
|
|
2016-09-20 06:18:11 +08:00
|
|
|
if a.Enabled() {
|
|
|
|
a.module.GenerateAndroidBuildActions(androidCtx)
|
|
|
|
if ctx.Failed() {
|
|
|
|
return
|
|
|
|
}
|
2015-01-31 09:27:36 +08:00
|
|
|
|
2016-09-20 06:18:11 +08:00
|
|
|
a.installFiles = append(a.installFiles, androidCtx.installFiles...)
|
|
|
|
a.checkbuildFiles = append(a.checkbuildFiles, androidCtx.checkbuildFiles...)
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
2016-09-20 06:18:11 +08:00
|
|
|
if a == ctx.FinalModule().(Module).base() {
|
|
|
|
a.generateModuleTarget(ctx)
|
|
|
|
if ctx.Failed() {
|
|
|
|
return
|
|
|
|
}
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
2017-07-14 05:43:27 +08:00
|
|
|
|
|
|
|
a.buildParams = androidCtx.buildParams
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
2015-03-25 02:13:38 +08:00
|
|
|
type androidBaseContextImpl struct {
|
2016-09-14 00:59:14 +08:00
|
|
|
target Target
|
|
|
|
targetPrimary bool
|
|
|
|
debug bool
|
2017-04-07 03:49:58 +08:00
|
|
|
vendor bool
|
2016-09-14 00:59:14 +08:00
|
|
|
config Config
|
2015-03-25 02:13:38 +08:00
|
|
|
}
|
|
|
|
|
2015-01-31 09:27:36 +08:00
|
|
|
type androidModuleContext struct {
|
|
|
|
blueprint.ModuleContext
|
2015-03-25 02:13:38 +08:00
|
|
|
androidBaseContextImpl
|
2015-09-24 06:26:20 +08:00
|
|
|
installDeps Paths
|
|
|
|
installFiles Paths
|
|
|
|
checkbuildFiles Paths
|
2015-12-18 08:39:19 +08:00
|
|
|
missingDeps []string
|
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
|
2015-12-18 08:39:19 +08:00
|
|
|
}
|
|
|
|
|
2017-05-10 04:45:28 +08:00
|
|
|
func (a *androidModuleContext) ninjaError(desc string, outputs []string, err error) {
|
2015-12-18 08:39:19 +08:00
|
|
|
a.ModuleContext.Build(pctx, blueprint.BuildParams{
|
2017-05-10 04:45:28 +08:00
|
|
|
Rule: ErrorRule,
|
|
|
|
Description: desc,
|
|
|
|
Outputs: outputs,
|
|
|
|
Optional: true,
|
2015-12-18 08:39:19 +08:00
|
|
|
Args: map[string]string{
|
|
|
|
"error": err.Error(),
|
|
|
|
},
|
|
|
|
})
|
|
|
|
return
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
2017-10-24 08:16:14 +08:00
|
|
|
func (a *androidModuleContext) ModuleBuild(pctx blueprint.PackageContext, params ModuleBuildParams) {
|
|
|
|
a.Build(pctx, BuildParams(params))
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
2017-10-24 08:16:14 +08:00
|
|
|
func (a *androidModuleContext) Build(pctx blueprint.PackageContext, params BuildParams) {
|
2017-07-14 05:43:27 +08:00
|
|
|
if a.config.captureBuild {
|
|
|
|
a.buildParams = append(a.buildParams, params)
|
|
|
|
}
|
|
|
|
|
2015-09-24 06:26:20 +08:00
|
|
|
bparams := blueprint.BuildParams{
|
2016-11-04 05:28:31 +08:00
|
|
|
Rule: params.Rule,
|
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
|
|
|
}
|
|
|
|
|
2017-05-10 04:45:28 +08:00
|
|
|
if params.Description != "" {
|
|
|
|
bparams.Description = "${moduleDesc}" + params.Description + "${moduleDescSuffix}"
|
|
|
|
}
|
|
|
|
|
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())
|
|
|
|
}
|
|
|
|
|
2015-12-18 08:39:19 +08:00
|
|
|
if a.missingDeps != nil {
|
2017-05-10 04:45:28 +08:00
|
|
|
a.ninjaError(bparams.Description, bparams.Outputs,
|
|
|
|
fmt.Errorf("module %s missing dependencies: %s\n",
|
|
|
|
a.ModuleName(), strings.Join(a.missingDeps, ", ")))
|
2015-12-18 08:39:19 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2015-09-24 06:26:20 +08:00
|
|
|
a.ModuleContext.Build(pctx, bparams)
|
|
|
|
}
|
|
|
|
|
2015-12-18 08:39:19 +08:00
|
|
|
func (a *androidModuleContext) GetMissingDependencies() []string {
|
|
|
|
return a.missingDeps
|
|
|
|
}
|
|
|
|
|
2016-03-11 10:14:25 +08:00
|
|
|
func (a *androidModuleContext) AddMissingDependencies(deps []string) {
|
|
|
|
if deps != nil {
|
|
|
|
a.missingDeps = append(a.missingDeps, deps...)
|
2017-10-24 08:59:01 +08:00
|
|
|
a.missingDeps = FirstUniqueStrings(a.missingDeps)
|
2016-03-11 10:14:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-24 08:59:01 +08: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() {
|
|
|
|
if a.AConfig().AllowMissingDependencies() {
|
|
|
|
a.AddMissingDependencies([]string{a.OtherModuleName(aModule)})
|
|
|
|
} else {
|
|
|
|
a.ModuleErrorf("depends on disabled module %q", a.OtherModuleName(aModule))
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return aModule
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *androidModuleContext) VisitDirectDeps(visit func(Module)) {
|
|
|
|
a.ModuleContext.VisitDirectDeps(func(module blueprint.Module) {
|
|
|
|
if aModule := a.validateAndroidModule(module); aModule != nil {
|
|
|
|
visit(aModule)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
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))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2016-06-02 08:09:44 +08:00
|
|
|
func (a *androidBaseContextImpl) Target() Target {
|
|
|
|
return a.target
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
2016-09-14 00:59:14 +08:00
|
|
|
func (a *androidBaseContextImpl) TargetPrimary() bool {
|
|
|
|
return a.targetPrimary
|
|
|
|
}
|
|
|
|
|
2016-06-02 08:09:44 +08:00
|
|
|
func (a *androidBaseContextImpl) Arch() Arch {
|
|
|
|
return a.target.Arch
|
2015-05-08 05:11:29 +08:00
|
|
|
}
|
|
|
|
|
2016-06-02 08:09:44 +08:00
|
|
|
func (a *androidBaseContextImpl) Os() OsType {
|
|
|
|
return a.target.Os
|
2015-11-25 09:53:15 +08:00
|
|
|
}
|
|
|
|
|
2015-03-25 02:13:38 +08:00
|
|
|
func (a *androidBaseContextImpl) Host() bool {
|
2016-06-02 08:09:44 +08:00
|
|
|
return a.target.Os.Class == Host || a.target.Os.Class == HostCross
|
2015-03-25 02:13:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (a *androidBaseContextImpl) Device() bool {
|
2016-06-02 08:09:44 +08:00
|
|
|
return a.target.Os.Class == Device
|
2015-03-25 02:13:38 +08:00
|
|
|
}
|
|
|
|
|
2015-05-01 07:36:18 +08:00
|
|
|
func (a *androidBaseContextImpl) Darwin() bool {
|
2016-06-02 08:09:44 +08:00
|
|
|
return a.target.Os == Darwin
|
2015-05-01 07:36:18 +08:00
|
|
|
}
|
|
|
|
|
2017-04-05 03:59:48 +08:00
|
|
|
func (a *androidBaseContextImpl) Windows() bool {
|
|
|
|
return a.target.Os == Windows
|
|
|
|
}
|
|
|
|
|
2015-03-25 02:13:38 +08:00
|
|
|
func (a *androidBaseContextImpl) Debug() bool {
|
|
|
|
return a.debug
|
|
|
|
}
|
|
|
|
|
2016-08-25 06:25:47 +08:00
|
|
|
func (a *androidBaseContextImpl) PrimaryArch() bool {
|
2017-05-10 04:45:28 +08:00
|
|
|
if len(a.config.Targets[a.target.Os.Class]) <= 1 {
|
|
|
|
return true
|
|
|
|
}
|
2016-08-25 06:25:47 +08:00
|
|
|
return a.target.Arch.ArchType == a.config.Targets[a.target.Os.Class][0].Arch.ArchType
|
|
|
|
}
|
|
|
|
|
2015-04-08 08:11:30 +08:00
|
|
|
func (a *androidBaseContextImpl) AConfig() Config {
|
|
|
|
return a.config
|
|
|
|
}
|
|
|
|
|
2016-08-18 06:24:12 +08:00
|
|
|
func (a *androidBaseContextImpl) DeviceConfig() DeviceConfig {
|
|
|
|
return DeviceConfig{a.config.deviceConfig}
|
|
|
|
}
|
|
|
|
|
2017-09-28 08:01:44 +08:00
|
|
|
func (a *androidBaseContextImpl) InstallOnVendorPartition() bool {
|
2017-04-07 03:49:58 +08:00
|
|
|
return a.vendor
|
2015-12-22 06:55:28 +08:00
|
|
|
}
|
|
|
|
|
2016-08-04 02:57:50 +08:00
|
|
|
func (a *androidModuleContext) InstallInData() bool {
|
|
|
|
return a.module.InstallInData()
|
2015-12-22 06:55:28 +08:00
|
|
|
}
|
|
|
|
|
2017-03-30 13:00:18 +08:00
|
|
|
func (a *androidModuleContext) InstallInSanitizerDir() bool {
|
|
|
|
return a.module.InstallInSanitizerDir()
|
|
|
|
}
|
|
|
|
|
2017-04-27 08:34:03 +08:00
|
|
|
func (a *androidModuleContext) skipInstall(fullInstallPath OutputPath) bool {
|
|
|
|
if a.module.base().commonProperties.SkipInstall {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
if a.Device() {
|
|
|
|
if a.AConfig().SkipDeviceInstall() {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
if a.AConfig().SkipMegaDeviceInstall(fullInstallPath.String()) {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2017-09-01 03:29:17 +08:00
|
|
|
func (a *androidModuleContext) InstallFile(installPath OutputPath, name string, srcPath Path,
|
2016-03-25 04:14:12 +08:00
|
|
|
deps ...Path) OutputPath {
|
2017-09-01 03:29:17 +08: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-03 05:37:16 +08:00
|
|
|
|
2015-12-22 06:55:28 +08:00
|
|
|
fullInstallPath := installPath.Join(a, name)
|
2016-09-14 04:42:32 +08:00
|
|
|
a.module.base().hooks.runInstallHooks(a, fullInstallPath, false)
|
2015-01-31 09:27:36 +08:00
|
|
|
|
2017-04-27 08:34:03 +08:00
|
|
|
if !a.skipInstall(fullInstallPath) {
|
2016-10-07 07:12:58 +08:00
|
|
|
|
2016-01-13 15:07:05 +08:00
|
|
|
deps = append(deps, a.installDeps...)
|
|
|
|
|
2016-10-04 08:47:19 +08: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 08:16:14 +08:00
|
|
|
a.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,
|
|
|
|
Default: !a.AConfig().EmbeddedInMake(),
|
2016-01-13 15:07:05 +08:00
|
|
|
})
|
2015-01-31 09:27:36 +08:00
|
|
|
|
2016-01-13 15:07:05 +08:00
|
|
|
a.installFiles = append(a.installFiles, fullInstallPath)
|
|
|
|
}
|
2015-06-17 07:38:17 +08:00
|
|
|
a.checkbuildFiles = append(a.checkbuildFiles, srcPath)
|
2015-04-03 05:37:16 +08:00
|
|
|
return fullInstallPath
|
|
|
|
}
|
|
|
|
|
2016-01-12 04:49:11 +08:00
|
|
|
func (a *androidModuleContext) InstallSymlink(installPath OutputPath, name string, srcPath OutputPath) OutputPath {
|
|
|
|
fullInstallPath := installPath.Join(a, name)
|
2016-09-14 04:42:32 +08:00
|
|
|
a.module.base().hooks.runInstallHooks(a, fullInstallPath, true)
|
2016-01-12 04:49:11 +08:00
|
|
|
|
2017-04-27 08:34:03 +08:00
|
|
|
if !a.skipInstall(fullInstallPath) {
|
2016-10-07 07:12:58 +08:00
|
|
|
|
2017-10-24 08:16:14 +08:00
|
|
|
a.Build(pctx, BuildParams{
|
2017-05-10 04:45:28 +08:00
|
|
|
Rule: Symlink,
|
|
|
|
Description: "install symlink " + fullInstallPath.Base(),
|
|
|
|
Output: fullInstallPath,
|
|
|
|
OrderOnly: Paths{srcPath},
|
|
|
|
Default: !a.AConfig().EmbeddedInMake(),
|
2016-01-12 04:49:11 +08:00
|
|
|
Args: map[string]string{
|
|
|
|
"fromPath": srcPath.String(),
|
|
|
|
},
|
|
|
|
})
|
2016-01-12 04:49:11 +08:00
|
|
|
|
2016-01-12 04:49:11 +08:00
|
|
|
a.installFiles = append(a.installFiles, fullInstallPath)
|
|
|
|
a.checkbuildFiles = append(a.checkbuildFiles, srcPath)
|
|
|
|
}
|
2016-01-12 04:49:11 +08:00
|
|
|
return fullInstallPath
|
|
|
|
}
|
|
|
|
|
2015-09-24 06:26:20 +08:00
|
|
|
func (a *androidModuleContext) CheckbuildFile(srcPath Path) {
|
2015-01-31 09:27:36 +08:00
|
|
|
a.checkbuildFiles = append(a.checkbuildFiles, srcPath)
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2016-12-14 07:23:47 +08:00
|
|
|
func SrcIsModule(s string) string {
|
|
|
|
if len(s) > 1 && s[0] == ':' {
|
|
|
|
return s[1:]
|
|
|
|
}
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
|
|
|
type sourceDependencyTag struct {
|
|
|
|
blueprint.BaseDependencyTag
|
|
|
|
}
|
|
|
|
|
|
|
|
var SourceDepTag sourceDependencyTag
|
|
|
|
|
|
|
|
// Returns a list of modules that must be depended on to satisfy filegroup or generated sources
|
|
|
|
// modules listed in srcFiles using ":module" syntax
|
|
|
|
func ExtractSourcesDeps(ctx BottomUpMutatorContext, srcFiles []string) {
|
|
|
|
var deps []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 {
|
|
|
|
if m := SrcIsModule(s); m != "" {
|
2017-04-11 02:27:50 +08: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 07:23:47 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ctx.AddDependency(ctx.Module(), SourceDepTag, deps...)
|
|
|
|
}
|
|
|
|
|
|
|
|
type SourceFileProducer interface {
|
|
|
|
Srcs() Paths
|
|
|
|
}
|
|
|
|
|
|
|
|
// Returns a list of paths expanded from globs and modules referenced using ":module" syntax.
|
2017-02-02 06:12:44 +08:00
|
|
|
// ExtractSourcesDeps must have already been called during the dependency resolution phase.
|
2015-09-24 06:26:20 +08:00
|
|
|
func (ctx *androidModuleContext) ExpandSources(srcFiles, excludes []string) Paths {
|
2017-02-02 06:12:44 +08:00
|
|
|
return ctx.ExpandSourcesSubDir(srcFiles, excludes, "")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ctx *androidModuleContext) ExpandSourcesSubDir(srcFiles, excludes []string, subDir string) Paths {
|
2015-09-24 06:26:20 +08:00
|
|
|
prefix := PathForModuleSrc(ctx).String()
|
2017-02-02 06:12:44 +08:00
|
|
|
|
2015-07-01 09:15:24 +08:00
|
|
|
for i, e := range excludes {
|
|
|
|
j := findStringInSlice(e, srcFiles)
|
|
|
|
if j != -1 {
|
|
|
|
srcFiles = append(srcFiles[:j], srcFiles[j+1:]...)
|
2015-04-09 02:21:40 +08:00
|
|
|
}
|
2015-07-01 09:15:24 +08:00
|
|
|
|
|
|
|
excludes[i] = filepath.Join(prefix, e)
|
2015-04-09 02:21:40 +08:00
|
|
|
}
|
|
|
|
|
2017-02-02 06:12:44 +08:00
|
|
|
expandedSrcFiles := make(Paths, 0, len(srcFiles))
|
2015-06-18 06:09:06 +08:00
|
|
|
for _, s := range srcFiles {
|
2016-12-14 07:23:47 +08:00
|
|
|
if m := SrcIsModule(s); m != "" {
|
|
|
|
module := ctx.GetDirectDepWithTag(m, SourceDepTag)
|
2017-10-25 04:01:18 +08:00
|
|
|
if module == nil {
|
|
|
|
// Error will have been handled by ExtractSourcesDeps
|
|
|
|
continue
|
|
|
|
}
|
2016-12-14 07:23:47 +08:00
|
|
|
if srcProducer, ok := module.(SourceFileProducer); ok {
|
2017-02-02 06:12:44 +08:00
|
|
|
expandedSrcFiles = append(expandedSrcFiles, srcProducer.Srcs()...)
|
2016-12-14 07:23:47 +08:00
|
|
|
} else {
|
|
|
|
ctx.ModuleErrorf("srcs dependency %q is not a source file producing module", m)
|
|
|
|
}
|
|
|
|
} else if pathtools.IsGlob(s) {
|
2017-02-02 06:12:44 +08:00
|
|
|
globbedSrcFiles := ctx.Glob(filepath.Join(prefix, s), excludes)
|
2017-10-10 04:35:19 +08:00
|
|
|
for i, s := range globbedSrcFiles {
|
|
|
|
globbedSrcFiles[i] = s.(ModuleSrcPath).WithSubDir(ctx, subDir)
|
2017-02-02 06:12:44 +08:00
|
|
|
}
|
2017-10-10 04:35:19 +08:00
|
|
|
expandedSrcFiles = append(expandedSrcFiles, globbedSrcFiles...)
|
2015-06-18 06:09:06 +08:00
|
|
|
} else {
|
2017-02-02 06:12:44 +08:00
|
|
|
s := PathForModuleSrc(ctx, s).WithSubDir(ctx, subDir)
|
|
|
|
expandedSrcFiles = append(expandedSrcFiles, s)
|
2015-06-18 06:09:06 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-02 06:12:44 +08:00
|
|
|
return expandedSrcFiles
|
2015-06-18 06:09:06 +08:00
|
|
|
}
|
|
|
|
|
2017-02-05 09:47:46 +08:00
|
|
|
func (ctx *androidModuleContext) RequiredModuleNames() []string {
|
|
|
|
return ctx.module.base().commonProperties.Required
|
|
|
|
}
|
|
|
|
|
2016-11-02 02:10:25 +08:00
|
|
|
func (ctx *androidModuleContext) Glob(globPattern string, excludes []string) Paths {
|
|
|
|
ret, err := ctx.GlobWithDeps(globPattern, excludes)
|
2015-06-18 06:09:06 +08:00
|
|
|
if err != nil {
|
|
|
|
ctx.ModuleErrorf("glob: %s", err.Error())
|
|
|
|
}
|
2015-09-24 06:26:20 +08:00
|
|
|
return pathsForModuleSrcFromFullPath(ctx, ret)
|
2015-04-09 02:21:40 +08:00
|
|
|
}
|
2015-06-17 07:38:17 +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
|
|
|
}
|
|
|
|
|
2015-06-17 07:38:17 +08:00
|
|
|
func BuildTargetSingleton() blueprint.Singleton {
|
|
|
|
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{}
|
|
|
|
|
|
|
|
func (c *buildTargetSingleton) GenerateBuildActions(ctx blueprint.SingletonContext) {
|
|
|
|
checkbuildDeps := []string{}
|
|
|
|
|
2017-04-26 01:01:55 +08:00
|
|
|
mmTarget := func(dir string) string {
|
2017-09-21 05:30:50 +08:00
|
|
|
return "MODULES-IN-" + strings.Replace(filepath.Clean(dir), "/", "-", -1)
|
2017-04-26 01:01:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
modulesInDir := make(map[string][]string)
|
2015-06-17 07:38:17 +08:00
|
|
|
|
|
|
|
ctx.VisitAllModules(func(module blueprint.Module) {
|
2016-05-19 06:37:25 +08:00
|
|
|
if a, ok := module.(Module); ok {
|
2015-06-17 07:38:17 +08:00
|
|
|
blueprintDir := a.base().blueprintDir
|
|
|
|
installTarget := a.base().installTarget
|
|
|
|
checkbuildTarget := a.base().checkbuildTarget
|
|
|
|
|
|
|
|
if checkbuildTarget != "" {
|
|
|
|
checkbuildDeps = append(checkbuildDeps, checkbuildTarget)
|
2017-04-26 01:01:55 +08:00
|
|
|
modulesInDir[blueprintDir] = append(modulesInDir[blueprintDir], checkbuildTarget)
|
2015-06-17 07:38:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if installTarget != "" {
|
2017-04-26 01:01:55 +08:00
|
|
|
modulesInDir[blueprintDir] = append(modulesInDir[blueprintDir], installTarget)
|
2015-06-17 07:38:17 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2015-12-12 05:51:06 +08:00
|
|
|
suffix := ""
|
|
|
|
if ctx.Config().(Config).EmbeddedInMake() {
|
|
|
|
suffix = "-soong"
|
|
|
|
}
|
|
|
|
|
2015-06-17 07:38:17 +08:00
|
|
|
// Create a top-level checkbuild target that depends on all modules
|
|
|
|
ctx.Build(pctx, blueprint.BuildParams{
|
|
|
|
Rule: blueprint.Phony,
|
2015-12-12 05:51:06 +08:00
|
|
|
Outputs: []string{"checkbuild" + suffix},
|
2015-06-17 07:38:17 +08:00
|
|
|
Implicits: checkbuildDeps,
|
2015-07-09 09:13:11 +08:00
|
|
|
Optional: true,
|
2015-06-17 07:38:17 +08:00
|
|
|
})
|
|
|
|
|
2017-09-21 05:30:50 +08:00
|
|
|
// Make will generate the MODULES-IN-* targets
|
|
|
|
if ctx.Config().(Config).EmbeddedInMake() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-04-26 01:01:55 +08: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-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 {
|
|
|
|
ctx.Build(pctx, blueprint.BuildParams{
|
|
|
|
Rule: blueprint.Phony,
|
2017-04-26 01:01:55 +08:00
|
|
|
Outputs: []string{mmTarget(dir)},
|
|
|
|
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
|
2015-12-18 08:33:43 +08:00
|
|
|
Optional: ctx.Config().(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{}
|
|
|
|
ctx.VisitAllModules(func(module blueprint.Module) {
|
|
|
|
if a, ok := module.(Module); ok {
|
|
|
|
if a.Enabled() {
|
|
|
|
os := a.Target().Os
|
|
|
|
osDeps[os] = append(osDeps[os], a.base().checkbuildFiles...)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
osClass := make(map[string][]string)
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
name := className + "-" + os.Name
|
|
|
|
osClass[className] = append(osClass[className], name)
|
|
|
|
|
|
|
|
ctx.Build(pctx, blueprint.BuildParams{
|
|
|
|
Rule: blueprint.Phony,
|
|
|
|
Outputs: []string{name},
|
|
|
|
Implicits: deps.Strings(),
|
|
|
|
Optional: true,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// Wrap those into host|host-cross|target phony rules
|
|
|
|
osClasses := sortedKeys(osClass)
|
|
|
|
for _, class := range osClasses {
|
|
|
|
ctx.Build(pctx, blueprint.BuildParams{
|
|
|
|
Rule: blueprint.Phony,
|
|
|
|
Outputs: []string{class},
|
|
|
|
Implicits: osClass[class],
|
|
|
|
Optional: true,
|
|
|
|
})
|
|
|
|
}
|
2015-06-17 07:38:17 +08:00
|
|
|
}
|
2015-12-18 10:00:23 +08:00
|
|
|
|
|
|
|
type AndroidModulesByName struct {
|
2016-05-19 06:37:25 +08:00
|
|
|
slice []Module
|
2015-12-18 10:00:23 +08:00
|
|
|
ctx interface {
|
|
|
|
ModuleName(blueprint.Module) string
|
|
|
|
ModuleSubDir(blueprint.Module) string
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s AndroidModulesByName) Len() int { return len(s.slice) }
|
|
|
|
func (s AndroidModulesByName) Less(i, j int) bool {
|
|
|
|
mi, mj := s.slice[i], s.slice[j]
|
|
|
|
ni, nj := s.ctx.ModuleName(mi), s.ctx.ModuleName(mj)
|
|
|
|
|
|
|
|
if ni != nj {
|
|
|
|
return ni < nj
|
|
|
|
} else {
|
|
|
|
return s.ctx.ModuleSubDir(mi) < s.ctx.ModuleSubDir(mj)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func (s AndroidModulesByName) Swap(i, j int) { s.slice[i], s.slice[j] = s.slice[j], s.slice[i] }
|