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"
|
2015-01-31 02:27:36 +01:00
|
|
|
"path/filepath"
|
2015-12-18 01:39:19 +01:00
|
|
|
"strings"
|
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"
|
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"
|
|
|
|
)
|
|
|
|
|
2015-09-24 00:26:20 +02:00
|
|
|
type ModuleBuildParams struct {
|
2016-11-03 22:28:31 +01:00
|
|
|
Rule blueprint.Rule
|
|
|
|
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
|
|
|
}
|
|
|
|
|
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
|
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
|
2015-03-24 19:13:38 +01:00
|
|
|
Debug() bool
|
2016-08-25 00:25:47 +02:00
|
|
|
PrimaryArch() 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 {
|
2015-03-24 19:13:38 +01:00
|
|
|
blueprint.BaseModuleContext
|
|
|
|
androidBaseContext
|
|
|
|
}
|
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
type ModuleContext interface {
|
2015-01-31 02:27:36 +01:00
|
|
|
blueprint.ModuleContext
|
2015-03-24 19:13:38 +01:00
|
|
|
androidBaseContext
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2015-09-24 00:26:20 +02:00
|
|
|
// Similar to Build, but takes Paths instead of []string,
|
|
|
|
// and performs more verification.
|
|
|
|
ModuleBuild(pctx blueprint.PackageContext, params ModuleBuildParams)
|
|
|
|
|
|
|
|
ExpandSources(srcFiles, excludes []string) Paths
|
2016-11-01 19:10:25 +01:00
|
|
|
Glob(globPattern string, excludes []string) Paths
|
2015-06-18 00:09:06 +02:00
|
|
|
|
2016-03-24 21:14:12 +01:00
|
|
|
InstallFile(installPath OutputPath, srcPath Path, deps ...Path) OutputPath
|
|
|
|
InstallFileName(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
|
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
|
|
|
|
|
|
|
Proprietary() bool
|
|
|
|
InstallInData() bool
|
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
|
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
GenerateAndroidBuildActions(ModuleContext)
|
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
|
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.
|
2015-04-02 22:54:39 +02:00
|
|
|
Name string
|
2016-05-18 01:34:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
type commonProperties struct {
|
2015-04-02 22:54:39 +02:00
|
|
|
Tags []string
|
2015-01-31 02:27:36 +01:00
|
|
|
|
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
|
2016-09-06 19:39:07 +02:00
|
|
|
Compile_multilib string `android:"arch_variant"`
|
|
|
|
|
|
|
|
Target struct {
|
|
|
|
Host struct {
|
|
|
|
Compile_multilib string
|
|
|
|
}
|
|
|
|
Android struct {
|
|
|
|
Compile_multilib string
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
Proprietary bool
|
|
|
|
|
2016-06-02 00:25:32 +02:00
|
|
|
// *.logtags files, to combine together in order to generate the /system/etc/event-log-tags
|
|
|
|
// file
|
|
|
|
Logtags []string
|
|
|
|
|
2016-07-26 05:27:39 +02:00
|
|
|
// init.rc files to be installed if this module is installed
|
|
|
|
Init_rc []string
|
|
|
|
|
2016-08-15 20:47:23 +02:00
|
|
|
// names of other modules to install if this module is installed
|
|
|
|
Required []string
|
|
|
|
|
2016-06-02 02:09:44 +02:00
|
|
|
// Set by TargetMutator
|
2016-09-13 18:59:14 +02:00
|
|
|
CompileTarget 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"`
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
type hostAndDeviceProperties struct {
|
2016-07-12 22:11:25 +02:00
|
|
|
Host_supported *bool
|
|
|
|
Device_supported *bool
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2015-03-17 23:06:21 +01:00
|
|
|
type Multilib string
|
|
|
|
|
|
|
|
const (
|
2015-07-09 03:13:11 +02:00
|
|
|
MultilibBoth Multilib = "both"
|
|
|
|
MultilibFirst Multilib = "first"
|
|
|
|
MultilibCommon Multilib = "common"
|
|
|
|
MultilibDefault Multilib = ""
|
2015-03-17 23:06:21 +01:00
|
|
|
)
|
|
|
|
|
2016-06-02 02:09:44 +02:00
|
|
|
type HostOrDeviceSupported int
|
|
|
|
|
|
|
|
const (
|
|
|
|
_ HostOrDeviceSupported = iota
|
|
|
|
HostSupported
|
2016-10-20 10:36:11 +02:00
|
|
|
HostSupportedNoCross
|
2016-06-02 02:09:44 +02:00
|
|
|
DeviceSupported
|
|
|
|
HostAndDeviceSupported
|
|
|
|
HostAndDeviceDefault
|
2016-10-05 00:13:37 +02:00
|
|
|
NeitherHostNorDeviceSupported
|
2016-06-02 02:09:44 +02:00
|
|
|
)
|
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
func InitAndroidModule(m Module,
|
2015-01-31 02:27:36 +01:00
|
|
|
propertyStructs ...interface{}) (blueprint.Module, []interface{}) {
|
|
|
|
|
|
|
|
base := m.base()
|
|
|
|
base.module = m
|
2015-03-18 21:28:46 +01:00
|
|
|
|
2016-05-18 01:34:16 +02:00
|
|
|
propertyStructs = append(propertyStructs,
|
|
|
|
&base.nameProperties,
|
|
|
|
&base.commonProperties,
|
|
|
|
&base.variableProperties)
|
2015-03-18 21:28:46 +01:00
|
|
|
|
|
|
|
return m, propertyStructs
|
|
|
|
}
|
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
func InitAndroidArchModule(m Module, hod HostOrDeviceSupported, defaultMultilib Multilib,
|
2015-03-18 21:28:46 +01:00
|
|
|
propertyStructs ...interface{}) (blueprint.Module, []interface{}) {
|
|
|
|
|
|
|
|
_, propertyStructs = InitAndroidModule(m, propertyStructs...)
|
|
|
|
|
|
|
|
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
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2015-07-09 03:13:11 +02:00
|
|
|
switch hod {
|
|
|
|
case HostAndDeviceSupported:
|
2015-01-31 02:27:36 +01:00
|
|
|
// Default to module to device supported, host not supported, can override in module
|
|
|
|
// properties
|
2016-07-12 22:11:25 +02:00
|
|
|
base.hostAndDeviceProperties.Device_supported = boolPtr(true)
|
2015-07-09 03:13:11 +02:00
|
|
|
fallthrough
|
|
|
|
case HostAndDeviceDefault:
|
2015-01-31 02:27:36 +01:00
|
|
|
propertyStructs = append(propertyStructs, &base.hostAndDeviceProperties)
|
|
|
|
}
|
|
|
|
|
2015-11-03 01:43:11 +01:00
|
|
|
return InitArchModule(m, propertyStructs...)
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// A AndroidModuleBase object contains the properties that are common to all Android
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
// The AndroidModuleBase 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.
|
|
|
|
// 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 (
|
|
|
|
// "android/soong/common"
|
2015-03-23 20:57:34 +01:00
|
|
|
// "github.com/google/blueprint"
|
2015-01-31 02:27:36 +01:00
|
|
|
// )
|
|
|
|
//
|
|
|
|
// type myModule struct {
|
|
|
|
// common.AndroidModuleBase
|
|
|
|
// properties struct {
|
|
|
|
// MyProperty string
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// func NewMyModule() (blueprint.Module, []interface{}) {
|
|
|
|
// m := &myModule{}
|
|
|
|
// return common.InitAndroidModule(m, &m.properties)
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// func (m *myModule) GenerateAndroidBuildActions(ctx common.AndroidModuleContext) {
|
|
|
|
// // 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.
|
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{}
|
2016-06-24 08:44:54 +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
|
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
|
|
|
|
installTarget string
|
|
|
|
checkbuildTarget string
|
|
|
|
blueprintDir string
|
2016-08-20 01:07:38 +02:00
|
|
|
|
2016-09-13 22:42:32 +02:00
|
|
|
hooks hooks
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2016-10-07 01:12:58 +02:00
|
|
|
// Name returns the name of the module. It may be overridden by individual module types, for
|
|
|
|
// example prebuilts will prepend prebuilt_ to the name.
|
2016-05-18 01:34:16 +02:00
|
|
|
func (a *ModuleBase) Name() string {
|
|
|
|
return a.nameProperties.Name
|
|
|
|
}
|
|
|
|
|
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 {
|
|
|
|
return a.nameProperties.Name
|
|
|
|
}
|
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
func (a *ModuleBase) base() *ModuleBase {
|
2015-01-31 02:27:36 +01:00
|
|
|
return a
|
|
|
|
}
|
|
|
|
|
2016-09-13 18:59:14 +02:00
|
|
|
func (a *ModuleBase) SetTarget(target Target, primary bool) {
|
2016-06-02 02:09:44 +02:00
|
|
|
a.commonProperties.CompileTarget = target
|
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
|
|
|
|
}
|
|
|
|
|
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}
|
|
|
|
case HostAndDeviceSupported:
|
|
|
|
var supported []OsClass
|
2016-07-12 22:11:25 +02:00
|
|
|
if Bool(a.hostAndDeviceProperties.Host_supported) {
|
2016-06-02 02:09:44 +02:00
|
|
|
supported = append(supported, Host, HostCross)
|
|
|
|
}
|
2016-07-12 22:11:25 +02:00
|
|
|
if Bool(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 &&
|
2016-07-12 22:11:25 +02:00
|
|
|
Bool(a.hostAndDeviceProperties.Device_supported)
|
2015-01-31 02:27:36 +01: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-06-02 02:09:44 +02:00
|
|
|
return a.Os().Class != HostCross
|
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
|
|
|
|
}
|
|
|
|
|
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{}
|
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
|
|
|
|
}
|
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
func (a *ModuleBase) generateModuleTarget(ctx blueprint.ModuleContext) {
|
2015-09-24 00:26:20 +02:00
|
|
|
allInstalledFiles := Paths{}
|
|
|
|
allCheckbuildFiles := Paths{}
|
2015-01-31 02:27:36 +01:00
|
|
|
ctx.VisitAllModuleVariants(func(module blueprint.Module) {
|
2016-05-19 00:37:25 +02:00
|
|
|
a := module.(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
|
|
|
})
|
|
|
|
|
2015-03-17 21:24:18 +01:00
|
|
|
deps := []string{}
|
|
|
|
|
2015-01-31 02:27:36 +01:00
|
|
|
if len(allInstalledFiles) > 0 {
|
2015-03-17 21:24:18 +01:00
|
|
|
name := ctx.ModuleName() + "-install"
|
|
|
|
ctx.Build(pctx, blueprint.BuildParams{
|
|
|
|
Rule: blueprint.Phony,
|
|
|
|
Outputs: []string{name},
|
2015-09-24 00:26:20 +02:00
|
|
|
Implicits: allInstalledFiles.Strings(),
|
2015-12-18 02:19:51 +01:00
|
|
|
Optional: ctx.Config().(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 {
|
|
|
|
name := ctx.ModuleName() + "-checkbuild"
|
2015-01-31 02:27:36 +01:00
|
|
|
ctx.Build(pctx, blueprint.BuildParams{
|
2015-03-17 21:24:18 +01:00
|
|
|
Rule: blueprint.Phony,
|
|
|
|
Outputs: []string{name},
|
2015-09-24 00:26:20 +02:00
|
|
|
Implicits: allCheckbuildFiles.Strings(),
|
2015-03-17 21:24:18 +01:00
|
|
|
Optional: true,
|
|
|
|
})
|
|
|
|
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 := ""
|
|
|
|
if ctx.Config().(Config).EmbeddedInMake() {
|
|
|
|
suffix = "-soong"
|
|
|
|
}
|
|
|
|
|
2015-03-17 21:24:18 +01:00
|
|
|
ctx.Build(pctx, blueprint.BuildParams{
|
|
|
|
Rule: blueprint.Phony,
|
2015-12-11 22:51:06 +01:00
|
|
|
Outputs: []string{ctx.ModuleName() + suffix},
|
2015-03-17 21:24:18 +01:00
|
|
|
Implicits: deps,
|
|
|
|
Optional: true,
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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,
|
|
|
|
config: ctx.Config().(Config),
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
func (a *ModuleBase) GenerateBuildActions(ctx blueprint.ModuleContext) {
|
2015-01-31 02:27:36 +01:00
|
|
|
androidCtx := &androidModuleContext{
|
2016-08-03 20:57:50 +02:00
|
|
|
module: a.module,
|
2015-10-29 23:25:03 +01:00
|
|
|
ModuleContext: ctx,
|
|
|
|
androidBaseContextImpl: a.androidBaseContextFactory(ctx),
|
|
|
|
installDeps: a.computeInstallDeps(ctx),
|
|
|
|
installFiles: a.installFiles,
|
2015-12-18 01:39:19 +01:00
|
|
|
missingDeps: ctx.GetMissingDependencies(),
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2016-09-20 00:18:11 +02:00
|
|
|
if a.Enabled() {
|
|
|
|
a.module.GenerateAndroidBuildActions(androidCtx)
|
|
|
|
if ctx.Failed() {
|
|
|
|
return
|
|
|
|
}
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2016-09-20 00:18:11 +02:00
|
|
|
a.installFiles = append(a.installFiles, androidCtx.installFiles...)
|
|
|
|
a.checkbuildFiles = append(a.checkbuildFiles, androidCtx.checkbuildFiles...)
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-24 19:13:38 +01:00
|
|
|
type androidBaseContextImpl struct {
|
2016-09-13 18:59:14 +02:00
|
|
|
target Target
|
|
|
|
targetPrimary bool
|
|
|
|
debug bool
|
|
|
|
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
|
2015-12-18 01:39:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (a *androidModuleContext) ninjaError(outputs []string, err error) {
|
|
|
|
a.ModuleContext.Build(pctx, blueprint.BuildParams{
|
|
|
|
Rule: ErrorRule,
|
|
|
|
Outputs: outputs,
|
|
|
|
Optional: true,
|
|
|
|
Args: map[string]string{
|
|
|
|
"error": err.Error(),
|
|
|
|
},
|
|
|
|
})
|
|
|
|
return
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2015-11-30 22:59:34 +01:00
|
|
|
func (a *androidModuleContext) Build(pctx blueprint.PackageContext, params blueprint.BuildParams) {
|
2016-11-01 19:10:25 +01:00
|
|
|
if a.missingDeps != nil {
|
2015-12-18 01:39:19 +01:00
|
|
|
a.ninjaError(params.Outputs, fmt.Errorf("module %s missing dependencies: %s\n",
|
|
|
|
a.ModuleName(), strings.Join(a.missingDeps, ", ")))
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2015-01-31 02:27:36 +01:00
|
|
|
params.Optional = true
|
|
|
|
a.ModuleContext.Build(pctx, params)
|
|
|
|
}
|
|
|
|
|
2015-09-24 00:26:20 +02:00
|
|
|
func (a *androidModuleContext) ModuleBuild(pctx blueprint.PackageContext, params ModuleBuildParams) {
|
|
|
|
bparams := blueprint.BuildParams{
|
2016-11-03 22:28:31 +01:00
|
|
|
Rule: params.Rule,
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
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())
|
|
|
|
}
|
|
|
|
|
2015-12-18 01:39:19 +01:00
|
|
|
if a.missingDeps != nil {
|
|
|
|
a.ninjaError(bparams.Outputs, fmt.Errorf("module %s missing dependencies: %s\n",
|
|
|
|
a.ModuleName(), strings.Join(a.missingDeps, ", ")))
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2015-09-24 00:26:20 +02:00
|
|
|
a.ModuleContext.Build(pctx, bparams)
|
|
|
|
}
|
|
|
|
|
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...)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
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 {
|
|
|
|
return a.target.Arch.ArchType == a.config.Targets[a.target.Os.Class][0].Arch.ArchType
|
|
|
|
}
|
|
|
|
|
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}
|
|
|
|
}
|
|
|
|
|
2016-08-03 20:57:50 +02:00
|
|
|
func (a *androidModuleContext) Proprietary() bool {
|
|
|
|
return a.module.base().commonProperties.Proprietary
|
2015-12-21 23:55:28 +01:00
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
func (a *androidModuleContext) InstallFileName(installPath OutputPath, name string, srcPath Path,
|
2016-03-24 21:14:12 +01:00
|
|
|
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
|
|
|
|
2016-10-07 01:12:58 +02:00
|
|
|
if !a.module.base().commonProperties.SkipInstall &&
|
|
|
|
(a.Host() || !a.AConfig().SkipDeviceInstall()) {
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2016-01-13 08:07:05 +01:00
|
|
|
a.ModuleBuild(pctx, ModuleBuildParams{
|
|
|
|
Rule: Cp,
|
|
|
|
Output: fullInstallPath,
|
|
|
|
Input: srcPath,
|
2016-10-04 02:47:19 +02:00
|
|
|
Implicits: implicitDeps,
|
|
|
|
OrderOnly: orderOnlyDeps,
|
2016-01-14 20:22:23 +01:00
|
|
|
Default: !a.AConfig().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-03-24 21:14:12 +01:00
|
|
|
func (a *androidModuleContext) InstallFile(installPath OutputPath, srcPath Path, deps ...Path) OutputPath {
|
2015-09-24 00:26:20 +02:00
|
|
|
return a.InstallFileName(installPath, filepath.Base(srcPath.String()), srcPath, deps...)
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2016-10-07 01:12:58 +02:00
|
|
|
if !a.module.base().commonProperties.SkipInstall &&
|
|
|
|
(a.Host() || !a.AConfig().SkipDeviceInstall()) {
|
|
|
|
|
2016-01-11 21:49:11 +01:00
|
|
|
a.ModuleBuild(pctx, ModuleBuildParams{
|
|
|
|
Rule: Symlink,
|
|
|
|
Output: fullInstallPath,
|
|
|
|
OrderOnly: Paths{srcPath},
|
|
|
|
Default: !a.AConfig().EmbeddedInMake(),
|
|
|
|
Args: map[string]string{
|
|
|
|
"fromPath": srcPath.String(),
|
|
|
|
},
|
|
|
|
})
|
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
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2015-09-24 00:26:20 +02:00
|
|
|
func (ctx *androidModuleContext) ExpandSources(srcFiles, excludes []string) Paths {
|
|
|
|
prefix := PathForModuleSrc(ctx).String()
|
2015-07-01 03:15:24 +02:00
|
|
|
for i, e := range excludes {
|
|
|
|
j := findStringInSlice(e, srcFiles)
|
|
|
|
if j != -1 {
|
|
|
|
srcFiles = append(srcFiles[:j], srcFiles[j+1:]...)
|
2015-04-08 20:21:40 +02:00
|
|
|
}
|
2015-07-01 03:15:24 +02:00
|
|
|
|
|
|
|
excludes[i] = filepath.Join(prefix, e)
|
2015-04-08 20:21:40 +02:00
|
|
|
}
|
|
|
|
|
2015-09-24 00:26:20 +02:00
|
|
|
globbedSrcFiles := make(Paths, 0, len(srcFiles))
|
2015-06-18 00:09:06 +02:00
|
|
|
for _, s := range srcFiles {
|
2016-11-01 19:10:25 +01:00
|
|
|
if pathtools.IsGlob(s) {
|
|
|
|
globbedSrcFiles = append(globbedSrcFiles, ctx.Glob(filepath.Join(prefix, s), excludes)...)
|
2015-06-18 00:09:06 +02:00
|
|
|
} else {
|
2015-09-24 00:26:20 +02:00
|
|
|
globbedSrcFiles = append(globbedSrcFiles, PathForModuleSrc(ctx, s))
|
2015-06-18 00:09:06 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return globbedSrcFiles
|
|
|
|
}
|
|
|
|
|
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())
|
|
|
|
}
|
2015-09-24 00:26:20 +02:00
|
|
|
return pathsForModuleSrcFromFullPath(ctx, ret)
|
2015-04-08 20:21:40 +02:00
|
|
|
}
|
2015-06-17 01:38:17 +02: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
|
|
|
}
|
|
|
|
|
2015-06-17 01:38:17 +02:00
|
|
|
func BuildTargetSingleton() blueprint.Singleton {
|
|
|
|
return &buildTargetSingleton{}
|
|
|
|
}
|
|
|
|
|
|
|
|
type buildTargetSingleton struct{}
|
|
|
|
|
|
|
|
func (c *buildTargetSingleton) GenerateBuildActions(ctx blueprint.SingletonContext) {
|
|
|
|
checkbuildDeps := []string{}
|
|
|
|
|
|
|
|
dirModules := make(map[string][]string)
|
|
|
|
|
|
|
|
ctx.VisitAllModules(func(module blueprint.Module) {
|
2016-05-19 00:37:25 +02:00
|
|
|
if a, ok := module.(Module); ok {
|
2015-06-17 01:38:17 +02:00
|
|
|
blueprintDir := a.base().blueprintDir
|
|
|
|
installTarget := a.base().installTarget
|
|
|
|
checkbuildTarget := a.base().checkbuildTarget
|
|
|
|
|
|
|
|
if checkbuildTarget != "" {
|
|
|
|
checkbuildDeps = append(checkbuildDeps, checkbuildTarget)
|
|
|
|
dirModules[blueprintDir] = append(dirModules[blueprintDir], checkbuildTarget)
|
|
|
|
}
|
|
|
|
|
|
|
|
if installTarget != "" {
|
|
|
|
dirModules[blueprintDir] = append(dirModules[blueprintDir], installTarget)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2015-12-11 22:51:06 +01:00
|
|
|
suffix := ""
|
|
|
|
if ctx.Config().(Config).EmbeddedInMake() {
|
|
|
|
suffix = "-soong"
|
|
|
|
}
|
|
|
|
|
2015-06-17 01:38:17 +02:00
|
|
|
// Create a top-level checkbuild target that depends on all modules
|
|
|
|
ctx.Build(pctx, blueprint.BuildParams{
|
|
|
|
Rule: blueprint.Phony,
|
2015-12-11 22:51:06 +01:00
|
|
|
Outputs: []string{"checkbuild" + suffix},
|
2015-06-17 01:38:17 +02:00
|
|
|
Implicits: checkbuildDeps,
|
2015-07-09 03:13:11 +02:00
|
|
|
Optional: true,
|
2015-06-17 01:38:17 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
// Create a mm/<directory> target that depends on all modules in a directory
|
|
|
|
dirs := sortedKeys(dirModules)
|
|
|
|
for _, dir := range dirs {
|
|
|
|
ctx.Build(pctx, blueprint.BuildParams{
|
|
|
|
Rule: blueprint.Phony,
|
|
|
|
Outputs: []string{filepath.Join("mm", dir)},
|
|
|
|
Implicits: dirModules[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
|
2015-12-18 01:33:43 +01:00
|
|
|
Optional: ctx.Config().(Config).EmbeddedInMake(),
|
2015-06-17 01:38:17 +02:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2015-12-18 03:00:23 +01:00
|
|
|
|
|
|
|
type AndroidModulesByName struct {
|
2016-05-19 00:37:25 +02:00
|
|
|
slice []Module
|
2015-12-18 03:00:23 +01: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] }
|