Rename common to android

Rename the "common" package to "android", because common is too
generic.  Also removes all android.Android naming stutter.

Ran:
gomvpkg -from 'android/soong/common' -to 'android/soong/android'
gorename -from '"android/soong/android".AndroidModuleContext' -to 'ModuleContext'
gorename -from '"android/soong/android".AndroidBaseContext' -to 'BaseContext'
gorename -from '"android/soong/android".AndroidModuleBase' -to 'ModuleBase'
gorename -from '"android/soong/android".AndroidBottomUpMutatorContext' -to 'BottomUpMutatorContext'
gorename -from '"android/soong/android".AndroidTopDownMutatorContext' -to 'TopDownMutatorContext'
gorename -from '"android/soong/android".AndroidModule' -to 'Module'

Change-Id: I3b23590b8ce7c8a1ea1139411d84a53163288da7
This commit is contained in:
Colin Cross
2016-05-18 15:37:25 -07:00
parent c7fd91a266
commit 635c3b0157
43 changed files with 637 additions and 637 deletions

View File

@@ -16,7 +16,7 @@ bootstrap_go_binary {
"blueprint", "blueprint",
"blueprint-bootstrap", "blueprint-bootstrap",
"soong", "soong",
"soong-common", "soong-android",
"soong-env", "soong-env",
], ],
srcs: [ srcs: [
@@ -79,8 +79,8 @@ bootstrap_go_package {
} }
bootstrap_go_package { bootstrap_go_package {
name: "soong-common", name: "soong-android",
pkgPath: "android/soong/common", pkgPath: "android/soong/android",
deps: [ deps: [
"blueprint", "blueprint",
"blueprint-bootstrap", "blueprint-bootstrap",
@@ -89,25 +89,25 @@ bootstrap_go_package {
"soong-glob", "soong-glob",
], ],
srcs: [ srcs: [
"common/androidmk.go", "android/androidmk.go",
"common/arch.go", "android/arch.go",
"common/config.go", "android/config.go",
"common/defaults.go", "android/defaults.go",
"common/defs.go", "android/defs.go",
"common/glob.go", "android/glob.go",
"common/makevars.go", "android/makevars.go",
"common/module.go", "android/module.go",
"common/mutator.go", "android/mutator.go",
"common/package_ctx.go", "android/package_ctx.go",
"common/paths.go", "android/paths.go",
"common/util.go", "android/util.go",
"common/variable.go", "android/variable.go",
// Lock down environment access last // Lock down environment access last
"common/env.go", "android/env.go",
], ],
testSrcs: [ testSrcs: [
"common/paths_test.go", "android/paths_test.go",
], ],
} }
@@ -118,7 +118,7 @@ bootstrap_go_package {
"blueprint", "blueprint",
"blueprint-pathtools", "blueprint-pathtools",
"soong", "soong",
"soong-common", "soong-android",
"soong-genrule", "soong-genrule",
], ],
srcs: [ srcs: [
@@ -157,7 +157,7 @@ bootstrap_go_package {
"blueprint", "blueprint",
"blueprint-pathtools", "blueprint-pathtools",
"soong", "soong",
"soong-common", "soong-android",
], ],
srcs: [ srcs: [
"genrule/genrule.go", "genrule/genrule.go",
@@ -179,7 +179,7 @@ bootstrap_go_package {
"blueprint", "blueprint",
"blueprint-pathtools", "blueprint-pathtools",
"soong", "soong",
"soong-common", "soong-android",
"soong-genrule", "soong-genrule",
], ],
srcs: [ srcs: [

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package common package android
import ( import (
"bytes" "bytes"
@@ -63,10 +63,10 @@ func (c *androidMkSingleton) GenerateBuildActions(ctx blueprint.SingletonContext
ctx.SetNinjaBuildDir(pctx, filepath.Join(config.buildDir, "..")) ctx.SetNinjaBuildDir(pctx, filepath.Join(config.buildDir, ".."))
var androidMkModulesList []AndroidModule var androidMkModulesList []Module
ctx.VisitAllModules(func(module blueprint.Module) { ctx.VisitAllModules(func(module blueprint.Module) {
if amod, ok := module.(AndroidModule); ok { if amod, ok := module.(Module); ok {
androidMkModulesList = append(androidMkModulesList, amod) androidMkModulesList = append(androidMkModulesList, amod)
} }
}) })
@@ -90,7 +90,7 @@ func (c *androidMkSingleton) GenerateBuildActions(ctx blueprint.SingletonContext
}) })
} }
func translateAndroidMk(ctx blueprint.SingletonContext, mkFile string, mods []AndroidModule) error { func translateAndroidMk(ctx blueprint.SingletonContext, mkFile string, mods []Module) error {
buf := &bytes.Buffer{} buf := &bytes.Buffer{}
fmt.Fprintln(buf, "LOCAL_MODULE_MAKEFILE := $(lastword $(MAKEFILE_LIST))") fmt.Fprintln(buf, "LOCAL_MODULE_MAKEFILE := $(lastword $(MAKEFILE_LIST))")
@@ -134,7 +134,7 @@ func translateAndroidMkModule(ctx blueprint.SingletonContext, w io.Writer, mod b
return nil return nil
} }
amod := mod.(AndroidModule).base() amod := mod.(Module).base()
data, err := provider.AndroidMk() data, err := provider.AndroidMk()
if err != nil { if err != nil {
return err return err

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package common package android
import ( import (
"fmt" "fmt"
@@ -187,7 +187,7 @@ type archProperties struct {
Sandybridge interface{} `blueprint:"filter(android:\"arch_variant\")"` Sandybridge interface{} `blueprint:"filter(android:\"arch_variant\")"`
Silvermont interface{} `blueprint:"filter(android:\"arch_variant\")"` Silvermont interface{} `blueprint:"filter(android:\"arch_variant\")"`
// Generic variant for X86 on X86_64 // Generic variant for X86 on X86_64
X86_64 interface{} `blueprint:"filter(android:\"arch_variant\")"` X86_64 interface{} `blueprint:"filter(android:\"arch_variant\")"`
// X86 arch features // X86 arch features
Ssse3 interface{} `blueprint:"filter(android:\"arch_variant\")"` Ssse3 interface{} `blueprint:"filter(android:\"arch_variant\")"`
@@ -443,10 +443,10 @@ var (
} }
) )
func HostOrDeviceMutator(mctx AndroidBottomUpMutatorContext) { func HostOrDeviceMutator(mctx BottomUpMutatorContext) {
var module AndroidModule var module Module
var ok bool var ok bool
if module, ok = mctx.Module().(AndroidModule); !ok { if module, ok = mctx.Module().(Module); !ok {
return return
} }
@@ -471,14 +471,14 @@ func HostOrDeviceMutator(mctx AndroidBottomUpMutatorContext) {
modules := mctx.CreateVariations(hodNames...) modules := mctx.CreateVariations(hodNames...)
for i, m := range modules { for i, m := range modules {
m.(AndroidModule).base().SetHostOrDevice(hods[i]) m.(Module).base().SetHostOrDevice(hods[i])
} }
} }
func HostTypeMutator(mctx AndroidBottomUpMutatorContext) { func HostTypeMutator(mctx BottomUpMutatorContext) {
var module AndroidModule var module Module
var ok bool var ok bool
if module, ok = mctx.Module().(AndroidModule); !ok { if module, ok = mctx.Module().(Module); !ok {
return return
} }
@@ -499,14 +499,14 @@ func HostTypeMutator(mctx AndroidBottomUpMutatorContext) {
modules := mctx.CreateVariations(typeNames...) modules := mctx.CreateVariations(typeNames...)
for i, m := range modules { for i, m := range modules {
m.(AndroidModule).base().SetHostType(buildTypes[i]) m.(Module).base().SetHostType(buildTypes[i])
} }
} }
func ArchMutator(mctx AndroidBottomUpMutatorContext) { func ArchMutator(mctx BottomUpMutatorContext) {
var module AndroidModule var module Module
var ok bool var ok bool
if module, ok = mctx.Module().(AndroidModule); !ok { if module, ok = mctx.Module().(Module); !ok {
return return
} }
@@ -543,12 +543,12 @@ func ArchMutator(mctx AndroidBottomUpMutatorContext) {
modules := mctx.CreateVariations(archNames...) modules := mctx.CreateVariations(archNames...)
for i, m := range modules { for i, m := range modules {
m.(AndroidModule).base().SetArch(moduleArches[i]) m.(Module).base().SetArch(moduleArches[i])
m.(AndroidModule).base().setArchProperties(mctx) m.(Module).base().setArchProperties(mctx)
} }
} }
func InitArchModule(m AndroidModule, func InitArchModule(m Module,
propertyStructs ...interface{}) (blueprint.Module, []interface{}) { propertyStructs ...interface{}) (blueprint.Module, []interface{}) {
base := m.base() base := m.base()
@@ -589,7 +589,7 @@ func InitArchModule(m AndroidModule,
var variantReplacer = strings.NewReplacer("-", "_", ".", "_") var variantReplacer = strings.NewReplacer("-", "_", ".", "_")
func (a *AndroidModuleBase) appendProperties(ctx AndroidBottomUpMutatorContext, func (a *ModuleBase) appendProperties(ctx BottomUpMutatorContext,
dst, src interface{}, field, srcPrefix string) interface{} { dst, src interface{}, field, srcPrefix string) interface{} {
srcField := reflect.ValueOf(src).FieldByName(field) srcField := reflect.ValueOf(src).FieldByName(field)
@@ -646,7 +646,7 @@ func (a *AndroidModuleBase) appendProperties(ctx AndroidBottomUpMutatorContext,
} }
// Rewrite the module's properties structs to contain arch-specific values. // Rewrite the module's properties structs to contain arch-specific values.
func (a *AndroidModuleBase) setArchProperties(ctx AndroidBottomUpMutatorContext) { func (a *ModuleBase) setArchProperties(ctx BottomUpMutatorContext) {
arch := a.commonProperties.CompileArch arch := a.commonProperties.CompileArch
hod := a.commonProperties.CompileHostOrDevice hod := a.commonProperties.CompileHostOrDevice
ht := a.commonProperties.CompileHostType ht := a.commonProperties.CompileHostType

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package common package android
import ( import (
"encoding/json" "encoding/json"

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package common package android
import ( import (
"github.com/google/blueprint" "github.com/google/blueprint"
@@ -45,12 +45,12 @@ func (d *DefaultableModule) setProperties(props []interface{}) {
type Defaultable interface { type Defaultable interface {
defaults() *defaultsProperties defaults() *defaultsProperties
setProperties([]interface{}) setProperties([]interface{})
applyDefaults(AndroidTopDownMutatorContext, Defaults) applyDefaults(TopDownMutatorContext, Defaults)
} }
var _ Defaultable = (*DefaultableModule)(nil) var _ Defaultable = (*DefaultableModule)(nil)
func InitDefaultableModule(module AndroidModule, d Defaultable, func InitDefaultableModule(module Module, d Defaultable,
props ...interface{}) (blueprint.Module, []interface{}) { props ...interface{}) (blueprint.Module, []interface{}) {
d.setProperties(props) d.setProperties(props)
@@ -82,7 +82,7 @@ func (d *DefaultsModule) setProperties(props []interface{}) {
d.defaultProperties = props d.defaultProperties = props
} }
func InitDefaultsModule(module AndroidModule, d Defaults, props ...interface{}) (blueprint.Module, []interface{}) { func InitDefaultsModule(module Module, d Defaults, props ...interface{}) (blueprint.Module, []interface{}) {
d.setProperties(props) d.setProperties(props)
return module, props return module, props
@@ -90,7 +90,7 @@ func InitDefaultsModule(module AndroidModule, d Defaults, props ...interface{})
var _ Defaults = (*DefaultsModule)(nil) var _ Defaults = (*DefaultsModule)(nil)
func (defaultable *DefaultableModule) applyDefaults(ctx AndroidTopDownMutatorContext, func (defaultable *DefaultableModule) applyDefaults(ctx TopDownMutatorContext,
defaults Defaults) { defaults Defaults) {
for _, prop := range defaultable.defaultableProperties { for _, prop := range defaultable.defaultableProperties {
@@ -109,13 +109,13 @@ func (defaultable *DefaultableModule) applyDefaults(ctx AndroidTopDownMutatorCon
} }
} }
func defaultsDepsMutator(ctx AndroidBottomUpMutatorContext) { func defaultsDepsMutator(ctx BottomUpMutatorContext) {
if defaultable, ok := ctx.Module().(Defaultable); ok { if defaultable, ok := ctx.Module().(Defaultable); ok {
ctx.AddDependency(ctx.Module(), DefaultsDepTag, defaultable.defaults().Defaults...) ctx.AddDependency(ctx.Module(), DefaultsDepTag, defaultable.defaults().Defaults...)
} }
} }
func defaultsMutator(ctx AndroidTopDownMutatorContext) { func defaultsMutator(ctx TopDownMutatorContext) {
if defaultable, ok := ctx.Module().(Defaultable); ok { if defaultable, ok := ctx.Module().(Defaultable); ok {
for _, defaultsDep := range defaultable.defaults().Defaults { for _, defaultsDep := range defaultable.defaults().Defaults {
ctx.VisitDirectDeps(func(m blueprint.Module) { ctx.VisitDirectDeps(func(m blueprint.Module) {

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package common package android
import ( import (
"github.com/google/blueprint" "github.com/google/blueprint"

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package common package android
import ( import (
"android/soong" "android/soong"

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package common package android
import ( import (
"fmt" "fmt"

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package common package android
import ( import (
"bytes" "bytes"

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package common package android
import ( import (
"fmt" "fmt"
@@ -60,12 +60,12 @@ type androidBaseContext interface {
InstallInData() bool InstallInData() bool
} }
type AndroidBaseContext interface { type BaseContext interface {
blueprint.BaseModuleContext blueprint.BaseModuleContext
androidBaseContext androidBaseContext
} }
type AndroidModuleContext interface { type ModuleContext interface {
blueprint.ModuleContext blueprint.ModuleContext
androidBaseContext androidBaseContext
@@ -83,12 +83,12 @@ type AndroidModuleContext interface {
AddMissingDependencies(deps []string) AddMissingDependencies(deps []string)
} }
type AndroidModule interface { type Module interface {
blueprint.Module blueprint.Module
GenerateAndroidBuildActions(AndroidModuleContext) GenerateAndroidBuildActions(ModuleContext)
base() *AndroidModuleBase base() *ModuleBase
Enabled() bool Enabled() bool
HostOrDevice() HostOrDevice HostOrDevice() HostOrDevice
InstallInData() bool InstallInData() bool
@@ -138,7 +138,7 @@ const (
MultilibDefault Multilib = "" MultilibDefault Multilib = ""
) )
func InitAndroidModule(m AndroidModule, func InitAndroidModule(m Module,
propertyStructs ...interface{}) (blueprint.Module, []interface{}) { propertyStructs ...interface{}) (blueprint.Module, []interface{}) {
base := m.base() base := m.base()
@@ -149,7 +149,7 @@ func InitAndroidModule(m AndroidModule,
return m, propertyStructs return m, propertyStructs
} }
func InitAndroidArchModule(m AndroidModule, hod HostOrDeviceSupported, defaultMultilib Multilib, func InitAndroidArchModule(m Module, hod HostOrDeviceSupported, defaultMultilib Multilib,
propertyStructs ...interface{}) (blueprint.Module, []interface{}) { propertyStructs ...interface{}) (blueprint.Module, []interface{}) {
_, propertyStructs = InitAndroidModule(m, propertyStructs...) _, propertyStructs = InitAndroidModule(m, propertyStructs...)
@@ -211,10 +211,10 @@ func InitAndroidArchModule(m AndroidModule, hod HostOrDeviceSupported, defaultMu
// //
// // ... // // ...
// } // }
type AndroidModuleBase struct { type ModuleBase struct {
// Putting the curiously recurring thing pointing to the thing that contains // Putting the curiously recurring thing pointing to the thing that contains
// the thing pattern to good use. // the thing pattern to good use.
module AndroidModule module Module
commonProperties commonProperties commonProperties commonProperties
variableProperties variableProperties variableProperties variableProperties
@@ -233,51 +233,51 @@ type AndroidModuleBase struct {
blueprintDir string blueprintDir string
} }
func (a *AndroidModuleBase) base() *AndroidModuleBase { func (a *ModuleBase) base() *ModuleBase {
return a return a
} }
func (a *AndroidModuleBase) SetHostOrDevice(hod HostOrDevice) { func (a *ModuleBase) SetHostOrDevice(hod HostOrDevice) {
a.commonProperties.CompileHostOrDevice = hod a.commonProperties.CompileHostOrDevice = hod
} }
func (a *AndroidModuleBase) SetHostType(ht HostType) { func (a *ModuleBase) SetHostType(ht HostType) {
a.commonProperties.CompileHostType = ht a.commonProperties.CompileHostType = ht
} }
func (a *AndroidModuleBase) SetArch(arch Arch) { func (a *ModuleBase) SetArch(arch Arch) {
a.commonProperties.CompileArch = arch a.commonProperties.CompileArch = arch
} }
func (a *AndroidModuleBase) HostOrDevice() HostOrDevice { func (a *ModuleBase) HostOrDevice() HostOrDevice {
return a.commonProperties.CompileHostOrDevice return a.commonProperties.CompileHostOrDevice
} }
func (a *AndroidModuleBase) HostType() HostType { func (a *ModuleBase) HostType() HostType {
return a.commonProperties.CompileHostType return a.commonProperties.CompileHostType
} }
func (a *AndroidModuleBase) Host() bool { func (a *ModuleBase) Host() bool {
return a.HostOrDevice().Host() return a.HostOrDevice().Host()
} }
func (a *AndroidModuleBase) Arch() Arch { func (a *ModuleBase) Arch() Arch {
return a.commonProperties.CompileArch return a.commonProperties.CompileArch
} }
func (a *AndroidModuleBase) HostSupported() bool { func (a *ModuleBase) HostSupported() bool {
return a.commonProperties.HostOrDeviceSupported == HostSupported || return a.commonProperties.HostOrDeviceSupported == HostSupported ||
a.commonProperties.HostOrDeviceSupported == HostAndDeviceSupported && a.commonProperties.HostOrDeviceSupported == HostAndDeviceSupported &&
a.hostAndDeviceProperties.Host_supported a.hostAndDeviceProperties.Host_supported
} }
func (a *AndroidModuleBase) DeviceSupported() bool { func (a *ModuleBase) DeviceSupported() bool {
return a.commonProperties.HostOrDeviceSupported == DeviceSupported || return a.commonProperties.HostOrDeviceSupported == DeviceSupported ||
a.commonProperties.HostOrDeviceSupported == HostAndDeviceSupported && a.commonProperties.HostOrDeviceSupported == HostAndDeviceSupported &&
a.hostAndDeviceProperties.Device_supported a.hostAndDeviceProperties.Device_supported
} }
func (a *AndroidModuleBase) Enabled() bool { func (a *ModuleBase) Enabled() bool {
if a.commonProperties.Enabled == nil { if a.commonProperties.Enabled == nil {
if a.HostSupported() && a.HostOrDevice().Host() && a.HostType() == Windows { if a.HostSupported() && a.HostOrDevice().Host() && a.HostType() == Windows {
return false return false
@@ -288,7 +288,7 @@ func (a *AndroidModuleBase) Enabled() bool {
return *a.commonProperties.Enabled return *a.commonProperties.Enabled
} }
func (a *AndroidModuleBase) computeInstallDeps( func (a *ModuleBase) computeInstallDeps(
ctx blueprint.ModuleContext) Paths { ctx blueprint.ModuleContext) Paths {
result := Paths{} result := Paths{}
@@ -302,27 +302,27 @@ func (a *AndroidModuleBase) computeInstallDeps(
return result return result
} }
func (a *AndroidModuleBase) filesToInstall() Paths { func (a *ModuleBase) filesToInstall() Paths {
return a.installFiles return a.installFiles
} }
func (p *AndroidModuleBase) NoAddressSanitizer() bool { func (p *ModuleBase) NoAddressSanitizer() bool {
return p.noAddressSanitizer return p.noAddressSanitizer
} }
func (p *AndroidModuleBase) InstallInData() bool { func (p *ModuleBase) InstallInData() bool {
return false return false
} }
func (a *AndroidModuleBase) generateModuleTarget(ctx blueprint.ModuleContext) { func (a *ModuleBase) generateModuleTarget(ctx blueprint.ModuleContext) {
if a != ctx.FinalModule().(AndroidModule).base() { if a != ctx.FinalModule().(Module).base() {
return return
} }
allInstalledFiles := Paths{} allInstalledFiles := Paths{}
allCheckbuildFiles := Paths{} allCheckbuildFiles := Paths{}
ctx.VisitAllModuleVariants(func(module blueprint.Module) { ctx.VisitAllModuleVariants(func(module blueprint.Module) {
a := module.(AndroidModule).base() a := module.(Module).base()
allInstalledFiles = append(allInstalledFiles, a.installFiles...) allInstalledFiles = append(allInstalledFiles, a.installFiles...)
allCheckbuildFiles = append(allCheckbuildFiles, a.checkbuildFiles...) allCheckbuildFiles = append(allCheckbuildFiles, a.checkbuildFiles...)
}) })
@@ -370,7 +370,7 @@ func (a *AndroidModuleBase) generateModuleTarget(ctx blueprint.ModuleContext) {
} }
} }
func (a *AndroidModuleBase) androidBaseContextFactory(ctx blueprint.BaseModuleContext) androidBaseContextImpl { func (a *ModuleBase) androidBaseContextFactory(ctx blueprint.BaseModuleContext) androidBaseContextImpl {
return androidBaseContextImpl{ return androidBaseContextImpl{
arch: a.commonProperties.CompileArch, arch: a.commonProperties.CompileArch,
hod: a.commonProperties.CompileHostOrDevice, hod: a.commonProperties.CompileHostOrDevice,
@@ -381,7 +381,7 @@ func (a *AndroidModuleBase) androidBaseContextFactory(ctx blueprint.BaseModuleCo
} }
} }
func (a *AndroidModuleBase) GenerateBuildActions(ctx blueprint.ModuleContext) { func (a *ModuleBase) GenerateBuildActions(ctx blueprint.ModuleContext) {
androidCtx := &androidModuleContext{ androidCtx := &androidModuleContext{
ModuleContext: ctx, ModuleContext: ctx,
androidBaseContextImpl: a.androidBaseContextFactory(ctx), androidBaseContextImpl: a.androidBaseContextFactory(ctx),
@@ -570,7 +570,7 @@ func isFileInstaller(m blueprint.Module) bool {
} }
func isAndroidModule(m blueprint.Module) bool { func isAndroidModule(m blueprint.Module) bool {
_, ok := m.(AndroidModule) _, ok := m.(Module)
return ok return ok
} }
@@ -630,7 +630,7 @@ func (c *buildTargetSingleton) GenerateBuildActions(ctx blueprint.SingletonConte
dirModules := make(map[string][]string) dirModules := make(map[string][]string)
ctx.VisitAllModules(func(module blueprint.Module) { ctx.VisitAllModules(func(module blueprint.Module) {
if a, ok := module.(AndroidModule); ok { if a, ok := module.(Module); ok {
blueprintDir := a.base().blueprintDir blueprintDir := a.base().blueprintDir
installTarget := a.base().installTarget installTarget := a.base().installTarget
checkbuildTarget := a.base().checkbuildTarget checkbuildTarget := a.base().checkbuildTarget
@@ -674,7 +674,7 @@ func (c *buildTargetSingleton) GenerateBuildActions(ctx blueprint.SingletonConte
} }
type AndroidModulesByName struct { type AndroidModulesByName struct {
slice []AndroidModule slice []Module
ctx interface { ctx interface {
ModuleName(blueprint.Module) string ModuleName(blueprint.Module) string
ModuleSubDir(blueprint.Module) string ModuleSubDir(blueprint.Module) string

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package common package android
import ( import (
"android/soong" "android/soong"
@@ -20,9 +20,9 @@ import (
"github.com/google/blueprint" "github.com/google/blueprint"
) )
type AndroidTopDownMutator func(AndroidTopDownMutatorContext) type AndroidTopDownMutator func(TopDownMutatorContext)
type AndroidTopDownMutatorContext interface { type TopDownMutatorContext interface {
blueprint.TopDownMutatorContext blueprint.TopDownMutatorContext
androidBaseContext androidBaseContext
} }
@@ -32,9 +32,9 @@ type androidTopDownMutatorContext struct {
androidBaseContextImpl androidBaseContextImpl
} }
type AndroidBottomUpMutator func(AndroidBottomUpMutatorContext) type AndroidBottomUpMutator func(BottomUpMutatorContext)
type AndroidBottomUpMutatorContext interface { type BottomUpMutatorContext interface {
blueprint.BottomUpMutatorContext blueprint.BottomUpMutatorContext
androidBaseContext androidBaseContext
} }
@@ -46,7 +46,7 @@ type androidBottomUpMutatorContext struct {
func RegisterBottomUpMutator(name string, mutator AndroidBottomUpMutator) { func RegisterBottomUpMutator(name string, mutator AndroidBottomUpMutator) {
soong.RegisterBottomUpMutator(name, func(ctx blueprint.BottomUpMutatorContext) { soong.RegisterBottomUpMutator(name, func(ctx blueprint.BottomUpMutatorContext) {
if a, ok := ctx.Module().(AndroidModule); ok { if a, ok := ctx.Module().(Module); ok {
actx := &androidBottomUpMutatorContext{ actx := &androidBottomUpMutatorContext{
BottomUpMutatorContext: ctx, BottomUpMutatorContext: ctx,
androidBaseContextImpl: a.base().androidBaseContextFactory(ctx), androidBaseContextImpl: a.base().androidBaseContextFactory(ctx),
@@ -58,7 +58,7 @@ func RegisterBottomUpMutator(name string, mutator AndroidBottomUpMutator) {
func RegisterTopDownMutator(name string, mutator AndroidTopDownMutator) { func RegisterTopDownMutator(name string, mutator AndroidTopDownMutator) {
soong.RegisterTopDownMutator(name, func(ctx blueprint.TopDownMutatorContext) { soong.RegisterTopDownMutator(name, func(ctx blueprint.TopDownMutatorContext) {
if a, ok := ctx.Module().(AndroidModule); ok { if a, ok := ctx.Module().(Module); ok {
actx := &androidTopDownMutatorContext{ actx := &androidTopDownMutatorContext{
TopDownMutatorContext: ctx, TopDownMutatorContext: ctx,
androidBaseContextImpl: a.base().androidBaseContextFactory(ctx), androidBaseContextImpl: a.base().androidBaseContextFactory(ctx),

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package common package android
import ( import (
"fmt" "fmt"

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package common package android
import ( import (
"fmt" "fmt"
@@ -91,18 +91,18 @@ type WritablePath interface {
} }
type genPathProvider interface { type genPathProvider interface {
genPathWithExt(ctx AndroidModuleContext, ext string) ModuleGenPath genPathWithExt(ctx ModuleContext, ext string) ModuleGenPath
} }
type objPathProvider interface { type objPathProvider interface {
objPathWithExt(ctx AndroidModuleContext, subdir, ext string) ModuleObjPath objPathWithExt(ctx ModuleContext, subdir, ext string) ModuleObjPath
} }
type resPathProvider interface { type resPathProvider interface {
resPathWithName(ctx AndroidModuleContext, name string) ModuleResPath resPathWithName(ctx ModuleContext, name string) ModuleResPath
} }
// GenPathWithExt derives a new file path in ctx's generated sources directory // GenPathWithExt derives a new file path in ctx's generated sources directory
// from the current path, but with the new extension. // from the current path, but with the new extension.
func GenPathWithExt(ctx AndroidModuleContext, p Path, ext string) ModuleGenPath { func GenPathWithExt(ctx ModuleContext, p Path, ext string) ModuleGenPath {
if path, ok := p.(genPathProvider); ok { if path, ok := p.(genPathProvider); ok {
return path.genPathWithExt(ctx, ext) return path.genPathWithExt(ctx, ext)
} }
@@ -112,7 +112,7 @@ func GenPathWithExt(ctx AndroidModuleContext, p Path, ext string) ModuleGenPath
// ObjPathWithExt derives a new file path in ctx's object directory from the // ObjPathWithExt derives a new file path in ctx's object directory from the
// current path, but with the new extension. // current path, but with the new extension.
func ObjPathWithExt(ctx AndroidModuleContext, p Path, subdir, ext string) ModuleObjPath { func ObjPathWithExt(ctx ModuleContext, p Path, subdir, ext string) ModuleObjPath {
if path, ok := p.(objPathProvider); ok { if path, ok := p.(objPathProvider); ok {
return path.objPathWithExt(ctx, subdir, ext) return path.objPathWithExt(ctx, subdir, ext)
} }
@@ -123,7 +123,7 @@ func ObjPathWithExt(ctx AndroidModuleContext, p Path, subdir, ext string) Module
// ResPathWithName derives a new path in ctx's output resource directory, using // ResPathWithName derives a new path in ctx's output resource directory, using
// the current path to create the directory name, and the `name` argument for // the current path to create the directory name, and the `name` argument for
// the filename. // the filename.
func ResPathWithName(ctx AndroidModuleContext, p Path, name string) ModuleResPath { func ResPathWithName(ctx ModuleContext, p Path, name string) ModuleResPath {
if path, ok := p.(resPathProvider); ok { if path, ok := p.(resPathProvider); ok {
return path.resPathWithName(ctx, name) return path.resPathWithName(ctx, name)
} }
@@ -174,7 +174,7 @@ type Paths []Path
// PathsForSource returns Paths rooted from SrcDir // PathsForSource returns Paths rooted from SrcDir
func PathsForSource(ctx PathContext, paths []string) Paths { func PathsForSource(ctx PathContext, paths []string) Paths {
if pathConfig(ctx).AllowMissingDependencies() { if pathConfig(ctx).AllowMissingDependencies() {
if modCtx, ok := ctx.(AndroidModuleContext); ok { if modCtx, ok := ctx.(ModuleContext); ok {
ret := make(Paths, 0, len(paths)) ret := make(Paths, 0, len(paths))
intermediates := filepath.Join(modCtx.ModuleDir(), modCtx.ModuleName(), modCtx.ModuleSubDir(), "missing") intermediates := filepath.Join(modCtx.ModuleDir(), modCtx.ModuleName(), modCtx.ModuleSubDir(), "missing")
for _, path := range paths { for _, path := range paths {
@@ -211,7 +211,7 @@ func PathsForOptionalSource(ctx PathContext, intermediates string, paths []strin
// PathsForModuleSrc returns Paths rooted from the module's local source // PathsForModuleSrc returns Paths rooted from the module's local source
// directory // directory
func PathsForModuleSrc(ctx AndroidModuleContext, paths []string) Paths { func PathsForModuleSrc(ctx ModuleContext, paths []string) Paths {
ret := make(Paths, len(paths)) ret := make(Paths, len(paths))
for i, path := range paths { for i, path := range paths {
ret[i] = PathForModuleSrc(ctx, path) ret[i] = PathForModuleSrc(ctx, path)
@@ -222,7 +222,7 @@ func PathsForModuleSrc(ctx AndroidModuleContext, paths []string) Paths {
// pathsForModuleSrcFromFullPath returns Paths rooted from the module's local // pathsForModuleSrcFromFullPath returns Paths rooted from the module's local
// source directory, but strip the local source directory from the beginning of // source directory, but strip the local source directory from the beginning of
// each string. // each string.
func pathsForModuleSrcFromFullPath(ctx AndroidModuleContext, paths []string) Paths { func pathsForModuleSrcFromFullPath(ctx ModuleContext, paths []string) Paths {
prefix := filepath.Join(ctx.AConfig().srcDir, ctx.ModuleDir()) + "/" prefix := filepath.Join(ctx.AConfig().srcDir, ctx.ModuleDir()) + "/"
ret := make(Paths, 0, len(paths)) ret := make(Paths, 0, len(paths))
for _, p := range paths { for _, p := range paths {
@@ -238,7 +238,7 @@ func pathsForModuleSrcFromFullPath(ctx AndroidModuleContext, paths []string) Pat
// PathsWithOptionalDefaultForModuleSrc returns Paths rooted from the module's // PathsWithOptionalDefaultForModuleSrc returns Paths rooted from the module's
// local source directory. If none are provided, use the default if it exists. // local source directory. If none are provided, use the default if it exists.
func PathsWithOptionalDefaultForModuleSrc(ctx AndroidModuleContext, input []string, def string) Paths { func PathsWithOptionalDefaultForModuleSrc(ctx ModuleContext, input []string, def string) Paths {
if len(input) > 0 { if len(input) > 0 {
return PathsForModuleSrc(ctx, input) return PathsForModuleSrc(ctx, input)
} }
@@ -425,7 +425,7 @@ func (p SourcePath) Join(ctx PathContext, paths ...string) SourcePath {
// OverlayPath returns the overlay for `path' if it exists. This assumes that the // OverlayPath returns the overlay for `path' if it exists. This assumes that the
// SourcePath is the path to a resource overlay directory. // SourcePath is the path to a resource overlay directory.
func (p SourcePath) OverlayPath(ctx AndroidModuleContext, path Path) OptionalPath { func (p SourcePath) OverlayPath(ctx ModuleContext, path Path) OptionalPath {
var relDir string var relDir string
if moduleSrcPath, ok := path.(ModuleSrcPath); ok { if moduleSrcPath, ok := path.(ModuleSrcPath); ok {
relDir = moduleSrcPath.sourcePath.path relDir = moduleSrcPath.sourcePath.path
@@ -510,14 +510,14 @@ var _ resPathProvider = ModuleSrcPath{}
// PathForModuleSrc returns a ModuleSrcPath representing the paths... under the // PathForModuleSrc returns a ModuleSrcPath representing the paths... under the
// module's local source directory. // module's local source directory.
func PathForModuleSrc(ctx AndroidModuleContext, paths ...string) ModuleSrcPath { func PathForModuleSrc(ctx ModuleContext, paths ...string) ModuleSrcPath {
path := validatePath(ctx, paths...) path := validatePath(ctx, paths...)
return ModuleSrcPath{basePath{path, ctx.AConfig()}, PathForSource(ctx, ctx.ModuleDir(), path), ctx.ModuleDir()} return ModuleSrcPath{basePath{path, ctx.AConfig()}, PathForSource(ctx, ctx.ModuleDir(), path), ctx.ModuleDir()}
} }
// OptionalPathForModuleSrc returns an OptionalPath. The OptionalPath contains a // OptionalPathForModuleSrc returns an OptionalPath. The OptionalPath contains a
// valid path if p is non-nil. // valid path if p is non-nil.
func OptionalPathForModuleSrc(ctx AndroidModuleContext, p *string) OptionalPath { func OptionalPathForModuleSrc(ctx ModuleContext, p *string) OptionalPath {
if p == nil { if p == nil {
return OptionalPath{} return OptionalPath{}
} }
@@ -528,15 +528,15 @@ func (p ModuleSrcPath) String() string {
return p.sourcePath.String() return p.sourcePath.String()
} }
func (p ModuleSrcPath) genPathWithExt(ctx AndroidModuleContext, ext string) ModuleGenPath { func (p ModuleSrcPath) genPathWithExt(ctx ModuleContext, ext string) ModuleGenPath {
return PathForModuleGen(ctx, p.moduleDir, pathtools.ReplaceExtension(p.path, ext)) return PathForModuleGen(ctx, p.moduleDir, pathtools.ReplaceExtension(p.path, ext))
} }
func (p ModuleSrcPath) objPathWithExt(ctx AndroidModuleContext, subdir, ext string) ModuleObjPath { func (p ModuleSrcPath) objPathWithExt(ctx ModuleContext, subdir, ext string) ModuleObjPath {
return PathForModuleObj(ctx, subdir, p.moduleDir, pathtools.ReplaceExtension(p.path, ext)) return PathForModuleObj(ctx, subdir, p.moduleDir, pathtools.ReplaceExtension(p.path, ext))
} }
func (p ModuleSrcPath) resPathWithName(ctx AndroidModuleContext, name string) ModuleResPath { func (p ModuleSrcPath) resPathWithName(ctx ModuleContext, name string) ModuleResPath {
// TODO: Use full directory if the new ctx is not the current ctx? // TODO: Use full directory if the new ctx is not the current ctx?
return PathForModuleRes(ctx, p.path, name) return PathForModuleRes(ctx, p.path, name)
} }
@@ -550,7 +550,7 @@ var _ Path = ModuleOutPath{}
// PathForModuleOut returns a Path representing the paths... under the module's // PathForModuleOut returns a Path representing the paths... under the module's
// output directory. // output directory.
func PathForModuleOut(ctx AndroidModuleContext, paths ...string) ModuleOutPath { func PathForModuleOut(ctx ModuleContext, paths ...string) ModuleOutPath {
p := validatePath(ctx, paths...) p := validatePath(ctx, paths...)
return ModuleOutPath{PathForOutput(ctx, ".intermediates", ctx.ModuleDir(), ctx.ModuleName(), ctx.ModuleSubDir(), p)} return ModuleOutPath{PathForOutput(ctx, ".intermediates", ctx.ModuleDir(), ctx.ModuleName(), ctx.ModuleSubDir(), p)}
} }
@@ -568,7 +568,7 @@ var _ objPathProvider = ModuleGenPath{}
// PathForModuleGen returns a Path representing the paths... under the module's // PathForModuleGen returns a Path representing the paths... under the module's
// `gen' directory. // `gen' directory.
func PathForModuleGen(ctx AndroidModuleContext, paths ...string) ModuleGenPath { func PathForModuleGen(ctx ModuleContext, paths ...string) ModuleGenPath {
p := validatePath(ctx, paths...) p := validatePath(ctx, paths...)
return ModuleGenPath{ return ModuleGenPath{
PathForModuleOut(ctx, "gen", p), PathForModuleOut(ctx, "gen", p),
@@ -576,12 +576,12 @@ func PathForModuleGen(ctx AndroidModuleContext, paths ...string) ModuleGenPath {
} }
} }
func (p ModuleGenPath) genPathWithExt(ctx AndroidModuleContext, ext string) ModuleGenPath { func (p ModuleGenPath) genPathWithExt(ctx ModuleContext, ext string) ModuleGenPath {
// TODO: make a different path for local vs remote generated files? // TODO: make a different path for local vs remote generated files?
return PathForModuleGen(ctx, pathtools.ReplaceExtension(p.path, ext)) return PathForModuleGen(ctx, pathtools.ReplaceExtension(p.path, ext))
} }
func (p ModuleGenPath) objPathWithExt(ctx AndroidModuleContext, subdir, ext string) ModuleObjPath { func (p ModuleGenPath) objPathWithExt(ctx ModuleContext, subdir, ext string) ModuleObjPath {
return PathForModuleObj(ctx, subdir, pathtools.ReplaceExtension(p.path, ext)) return PathForModuleObj(ctx, subdir, pathtools.ReplaceExtension(p.path, ext))
} }
@@ -595,7 +595,7 @@ var _ Path = ModuleObjPath{}
// PathForModuleObj returns a Path representing the paths... under the module's // PathForModuleObj returns a Path representing the paths... under the module's
// 'obj' directory. // 'obj' directory.
func PathForModuleObj(ctx AndroidModuleContext, paths ...string) ModuleObjPath { func PathForModuleObj(ctx ModuleContext, paths ...string) ModuleObjPath {
p := validatePath(ctx, paths...) p := validatePath(ctx, paths...)
return ModuleObjPath{PathForModuleOut(ctx, "obj", p)} return ModuleObjPath{PathForModuleOut(ctx, "obj", p)}
} }
@@ -610,14 +610,14 @@ var _ Path = ModuleResPath{}
// PathForModuleRes returns a Path representing the paths... under the module's // PathForModuleRes returns a Path representing the paths... under the module's
// 'res' directory. // 'res' directory.
func PathForModuleRes(ctx AndroidModuleContext, paths ...string) ModuleResPath { func PathForModuleRes(ctx ModuleContext, paths ...string) ModuleResPath {
p := validatePath(ctx, paths...) p := validatePath(ctx, paths...)
return ModuleResPath{PathForModuleOut(ctx, "res", p)} return ModuleResPath{PathForModuleOut(ctx, "res", p)}
} }
// PathForModuleInstall returns a Path representing the install path for the // PathForModuleInstall returns a Path representing the install path for the
// module appended with paths... // module appended with paths...
func PathForModuleInstall(ctx AndroidModuleContext, paths ...string) OutputPath { func PathForModuleInstall(ctx ModuleContext, paths ...string) OutputPath {
var outPaths []string var outPaths []string
if ctx.Device() { if ctx.Device() {
partition := "system" partition := "system"

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package common package android
import ( import (
"errors" "errors"

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package common package android
import "sort" import "sort"

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package common package android
import ( import (
"fmt" "fmt"
@@ -129,10 +129,10 @@ func (v *productVariables) SetDefaultConfig() {
} }
} }
func variableMutator(mctx AndroidBottomUpMutatorContext) { func variableMutator(mctx BottomUpMutatorContext) {
var module AndroidModule var module Module
var ok bool var ok bool
if module, ok = mctx.Module().(AndroidModule); !ok { if module, ok = mctx.Module().(Module); !ok {
return return
} }
@@ -169,7 +169,7 @@ func variableMutator(mctx AndroidBottomUpMutatorContext) {
} }
} }
func (a *AndroidModuleBase) setVariableProperties(ctx AndroidBottomUpMutatorContext, func (a *ModuleBase) setVariableProperties(ctx BottomUpMutatorContext,
prefix string, productVariablePropertyValue reflect.Value, variableValue interface{}) { prefix string, productVariablePropertyValue reflect.Value, variableValue interface{}) {
printfIntoProperties(productVariablePropertyValue, variableValue) printfIntoProperties(productVariablePropertyValue, variableValue)

View File

@@ -20,12 +20,12 @@ import (
"path/filepath" "path/filepath"
"strings" "strings"
"android/soong/common" "android/soong/android"
) )
func (c *Module) AndroidMk() (ret common.AndroidMkData, err error) { func (c *Module) AndroidMk() (ret android.AndroidMkData, err error) {
ret.OutputFile = c.outputFile ret.OutputFile = c.outputFile
ret.Extra = append(ret.Extra, func(w io.Writer, outputFile common.Path) (err error) { ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) (err error) {
fmt.Fprintln(w, "LOCAL_SANITIZE := never") fmt.Fprintln(w, "LOCAL_SANITIZE := never")
if len(c.Properties.AndroidMkSharedLibs) > 0 { if len(c.Properties.AndroidMkSharedLibs) > 0 {
fmt.Fprintln(w, "LOCAL_SHARED_LIBRARIES := "+strings.Join(c.Properties.AndroidMkSharedLibs, " ")) fmt.Fprintln(w, "LOCAL_SHARED_LIBRARIES := "+strings.Join(c.Properties.AndroidMkSharedLibs, " "))
@@ -36,7 +36,7 @@ func (c *Module) AndroidMk() (ret common.AndroidMkData, err error) {
callSubAndroidMk := func(obj interface{}) { callSubAndroidMk := func(obj interface{}) {
if obj != nil { if obj != nil {
if androidmk, ok := obj.(interface { if androidmk, ok := obj.(interface {
AndroidMk(*common.AndroidMkData) AndroidMk(*android.AndroidMkData)
}); ok { }); ok {
androidmk.AndroidMk(&ret) androidmk.AndroidMk(&ret)
} }
@@ -56,7 +56,7 @@ func (c *Module) AndroidMk() (ret common.AndroidMkData, err error) {
return ret, nil return ret, nil
} }
func (library *baseLinker) AndroidMk(ret *common.AndroidMkData) { func (library *baseLinker) AndroidMk(ret *android.AndroidMkData) {
if library.static() { if library.static() {
ret.Class = "STATIC_LIBRARIES" ret.Class = "STATIC_LIBRARIES"
} else { } else {
@@ -64,10 +64,10 @@ func (library *baseLinker) AndroidMk(ret *common.AndroidMkData) {
} }
} }
func (library *libraryLinker) AndroidMk(ret *common.AndroidMkData) { func (library *libraryLinker) AndroidMk(ret *android.AndroidMkData) {
library.baseLinker.AndroidMk(ret) library.baseLinker.AndroidMk(ret)
ret.Extra = append(ret.Extra, func(w io.Writer, outputFile common.Path) error { ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) error {
var exportedIncludes []string var exportedIncludes []string
for _, flag := range library.exportedFlags() { for _, flag := range library.exportedFlags() {
if strings.HasPrefix(flag, "-I") { if strings.HasPrefix(flag, "-I") {
@@ -88,7 +88,7 @@ func (library *libraryLinker) AndroidMk(ret *common.AndroidMkData) {
}) })
} }
func (object *objectLinker) AndroidMk(ret *common.AndroidMkData) { func (object *objectLinker) AndroidMk(ret *android.AndroidMkData) {
ret.Custom = func(w io.Writer, name, prefix string) error { ret.Custom = func(w io.Writer, name, prefix string) error {
out := ret.OutputFile.Path() out := ret.OutputFile.Path()
@@ -99,26 +99,26 @@ func (object *objectLinker) AndroidMk(ret *common.AndroidMkData) {
} }
} }
func (binary *binaryLinker) AndroidMk(ret *common.AndroidMkData) { func (binary *binaryLinker) AndroidMk(ret *android.AndroidMkData) {
ret.Class = "EXECUTABLES" ret.Class = "EXECUTABLES"
ret.Extra = append(ret.Extra, func(w io.Writer, outputFile common.Path) error { ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) error {
fmt.Fprintln(w, "LOCAL_CXX_STL := none") fmt.Fprintln(w, "LOCAL_CXX_STL := none")
fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=") fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=")
return nil return nil
}) })
} }
func (test *testLinker) AndroidMk(ret *common.AndroidMkData) { func (test *testLinker) AndroidMk(ret *android.AndroidMkData) {
test.binaryLinker.AndroidMk(ret) test.binaryLinker.AndroidMk(ret)
if Bool(test.Properties.Test_per_src) { if Bool(test.Properties.Test_per_src) {
ret.SubName = test.binaryLinker.Properties.Stem ret.SubName = test.binaryLinker.Properties.Stem
} }
} }
func (library *toolchainLibraryLinker) AndroidMk(ret *common.AndroidMkData) { func (library *toolchainLibraryLinker) AndroidMk(ret *android.AndroidMkData) {
library.baseLinker.AndroidMk(ret) library.baseLinker.AndroidMk(ret)
ret.Extra = append(ret.Extra, func(w io.Writer, outputFile common.Path) error { ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) error {
fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+outputFile.Ext()) fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+outputFile.Ext())
fmt.Fprintln(w, "LOCAL_CXX_STL := none") fmt.Fprintln(w, "LOCAL_CXX_STL := none")
fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=") fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=")
@@ -127,8 +127,8 @@ func (library *toolchainLibraryLinker) AndroidMk(ret *common.AndroidMkData) {
}) })
} }
func (installer *baseInstaller) AndroidMk(ret *common.AndroidMkData) { func (installer *baseInstaller) AndroidMk(ret *android.AndroidMkData) {
ret.Extra = append(ret.Extra, func(w io.Writer, outputFile common.Path) error { ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) error {
path := installer.path.RelPathString() path := installer.path.RelPathString()
dir, file := filepath.Split(path) dir, file := filepath.Split(path)
stem := strings.TrimSuffix(file, filepath.Ext(file)) stem := strings.TrimSuffix(file, filepath.Ext(file))

View File

@@ -18,7 +18,7 @@ import (
"fmt" "fmt"
"strings" "strings"
"android/soong/common" "android/soong/android"
) )
var ( var (
@@ -195,7 +195,7 @@ func (toolchainArm64) AddressSanitizerRuntimeLibrary() string {
return "libclang_rt.asan-aarch64-android.so" return "libclang_rt.asan-aarch64-android.so"
} }
func arm64ToolchainFactory(arch common.Arch) Toolchain { func arm64ToolchainFactory(arch android.Arch) Toolchain {
if arch.ArchVariant != "armv8-a" { if arch.ArchVariant != "armv8-a" {
panic(fmt.Sprintf("Unknown ARM architecture version: %q", arch.ArchVariant)) panic(fmt.Sprintf("Unknown ARM architecture version: %q", arch.ArchVariant))
} }
@@ -207,5 +207,5 @@ func arm64ToolchainFactory(arch common.Arch) Toolchain {
} }
func init() { func init() {
registerDeviceToolchainFactory(common.Arm64, arm64ToolchainFactory) registerDeviceToolchainFactory(android.Arm64, arm64ToolchainFactory)
} }

View File

@@ -18,7 +18,7 @@ import (
"fmt" "fmt"
"strings" "strings"
"android/soong/common" "android/soong/android"
) )
var ( var (
@@ -348,7 +348,7 @@ func (toolchainArm) AddressSanitizerRuntimeLibrary() string {
return "libclang_rt.asan-arm-android.so" return "libclang_rt.asan-arm-android.so"
} }
func armToolchainFactory(arch common.Arch) Toolchain { func armToolchainFactory(arch android.Arch) Toolchain {
var fixCortexA8 string var fixCortexA8 string
toolchainCflags := make([]string, 2, 3) toolchainCflags := make([]string, 2, 3)
toolchainClangCflags := make([]string, 2, 3) toolchainClangCflags := make([]string, 2, 3)
@@ -391,5 +391,5 @@ func armToolchainFactory(arch common.Arch) Toolchain {
} }
func init() { func init() {
registerDeviceToolchainFactory(common.Arm, armToolchainFactory) registerDeviceToolchainFactory(android.Arm, armToolchainFactory)
} }

View File

@@ -19,7 +19,7 @@ package cc
// functions. // functions.
import ( import (
"android/soong/common" "android/soong/android"
"fmt" "fmt"
"runtime" "runtime"
"strconv" "strconv"
@@ -36,7 +36,7 @@ const (
) )
var ( var (
pctx = common.NewPackageContext("android/soong/cc") pctx = android.NewPackageContext("android/soong/cc")
cc = pctx.StaticRule("cc", cc = pctx.StaticRule("cc",
blueprint.RuleParams{ blueprint.RuleParams{
@@ -170,10 +170,10 @@ type builderFlags struct {
} }
// Generate rules for compiling multiple .c, .cpp, or .S files to individual .o files // Generate rules for compiling multiple .c, .cpp, or .S files to individual .o files
func TransformSourceToObj(ctx common.AndroidModuleContext, subdir string, srcFiles common.Paths, func TransformSourceToObj(ctx android.ModuleContext, subdir string, srcFiles android.Paths,
flags builderFlags, deps common.Paths) (objFiles common.Paths) { flags builderFlags, deps android.Paths) (objFiles android.Paths) {
objFiles = make(common.Paths, len(srcFiles)) objFiles = make(android.Paths, len(srcFiles))
cflags := flags.globalFlags + " " + flags.cFlags + " " + flags.conlyFlags cflags := flags.globalFlags + " " + flags.cFlags + " " + flags.conlyFlags
cppflags := flags.globalFlags + " " + flags.cFlags + " " + flags.cppFlags cppflags := flags.globalFlags + " " + flags.cFlags + " " + flags.cppFlags
@@ -188,7 +188,7 @@ func TransformSourceToObj(ctx common.AndroidModuleContext, subdir string, srcFil
} }
for i, srcFile := range srcFiles { for i, srcFile := range srcFiles {
objFile := common.ObjPathWithExt(ctx, srcFile, subdir, "o") objFile := android.ObjPathWithExt(ctx, srcFile, subdir, "o")
objFiles[i] = objFile objFiles[i] = objFile
@@ -225,7 +225,7 @@ func TransformSourceToObj(ctx common.AndroidModuleContext, subdir string, srcFil
ccCmd = gccCmd(flags.toolchain, ccCmd) ccCmd = gccCmd(flags.toolchain, ccCmd)
} }
ctx.ModuleBuild(pctx, common.ModuleBuildParams{ ctx.ModuleBuild(pctx, android.ModuleBuildParams{
Rule: cc, Rule: cc,
Output: objFile, Output: objFile,
Input: srcFile, Input: srcFile,
@@ -241,13 +241,13 @@ func TransformSourceToObj(ctx common.AndroidModuleContext, subdir string, srcFil
} }
// Generate a rule for compiling multiple .o files to a static library (.a) // Generate a rule for compiling multiple .o files to a static library (.a)
func TransformObjToStaticLib(ctx common.AndroidModuleContext, objFiles common.Paths, func TransformObjToStaticLib(ctx android.ModuleContext, objFiles android.Paths,
flags builderFlags, outputFile common.ModuleOutPath) { flags builderFlags, outputFile android.ModuleOutPath) {
arCmd := gccCmd(flags.toolchain, "ar") arCmd := gccCmd(flags.toolchain, "ar")
arFlags := "crsPD" arFlags := "crsPD"
ctx.ModuleBuild(pctx, common.ModuleBuildParams{ ctx.ModuleBuild(pctx, android.ModuleBuildParams{
Rule: ar, Rule: ar,
Output: outputFile, Output: outputFile,
Inputs: objFiles, Inputs: objFiles,
@@ -262,21 +262,21 @@ func TransformObjToStaticLib(ctx common.AndroidModuleContext, objFiles common.Pa
// darwin. The darwin ar tool doesn't support @file for list files, and has a // darwin. The darwin ar tool doesn't support @file for list files, and has a
// very small command line length limit, so we have to split the ar into multiple // very small command line length limit, so we have to split the ar into multiple
// steps, each appending to the previous one. // steps, each appending to the previous one.
func TransformDarwinObjToStaticLib(ctx common.AndroidModuleContext, objFiles common.Paths, func TransformDarwinObjToStaticLib(ctx android.ModuleContext, objFiles android.Paths,
flags builderFlags, outputPath common.ModuleOutPath) { flags builderFlags, outputPath android.ModuleOutPath) {
arFlags := "cqs" arFlags := "cqs"
if len(objFiles) == 0 { if len(objFiles) == 0 {
dummy := common.PathForModuleOut(ctx, "dummy" + objectExtension) dummy := android.PathForModuleOut(ctx, "dummy"+objectExtension)
dummyAr := common.PathForModuleOut(ctx, "dummy" + staticLibraryExtension) dummyAr := android.PathForModuleOut(ctx, "dummy"+staticLibraryExtension)
ctx.ModuleBuild(pctx, common.ModuleBuildParams{ ctx.ModuleBuild(pctx, android.ModuleBuildParams{
Rule: emptyFile, Rule: emptyFile,
Output: dummy, Output: dummy,
}) })
ctx.ModuleBuild(pctx, common.ModuleBuildParams{ ctx.ModuleBuild(pctx, android.ModuleBuildParams{
Rule: darwinAr, Rule: darwinAr,
Output: dummyAr, Output: dummyAr,
Input: dummy, Input: dummy,
@@ -285,7 +285,7 @@ func TransformDarwinObjToStaticLib(ctx common.AndroidModuleContext, objFiles com
}, },
}) })
ctx.ModuleBuild(pctx, common.ModuleBuildParams{ ctx.ModuleBuild(pctx, android.ModuleBuildParams{
Rule: darwinAppendAr, Rule: darwinAppendAr,
Output: outputPath, Output: outputPath,
Input: dummy, Input: dummy,
@@ -325,9 +325,9 @@ func TransformDarwinObjToStaticLib(ctx common.AndroidModuleContext, objFiles com
}) })
} else { } else {
ctx.Build(pctx, blueprint.BuildParams{ ctx.Build(pctx, blueprint.BuildParams{
Rule: darwinAppendAr, Rule: darwinAppendAr,
Outputs: []string{out}, Outputs: []string{out},
Inputs: l, Inputs: l,
Args: map[string]string{ Args: map[string]string{
"arFlags": arFlags, "arFlags": arFlags,
"inAr": in, "inAr": in,
@@ -339,9 +339,9 @@ func TransformDarwinObjToStaticLib(ctx common.AndroidModuleContext, objFiles com
// Generate a rule for compiling multiple .o files, plus static libraries, whole static libraries, // Generate a rule for compiling multiple .o files, plus static libraries, whole static libraries,
// and shared libraires, to a shared library (.so) or dynamic executable // and shared libraires, to a shared library (.so) or dynamic executable
func TransformObjToDynamicBinary(ctx common.AndroidModuleContext, func TransformObjToDynamicBinary(ctx android.ModuleContext,
objFiles, sharedLibs, staticLibs, lateStaticLibs, wholeStaticLibs, deps common.Paths, objFiles, sharedLibs, staticLibs, lateStaticLibs, wholeStaticLibs, deps android.Paths,
crtBegin, crtEnd common.OptionalPath, groupLate bool, flags builderFlags, outputFile common.WritablePath) { crtBegin, crtEnd android.OptionalPath, groupLate bool, flags builderFlags, outputFile android.WritablePath) {
var ldCmd string var ldCmd string
if flags.clang { if flags.clang {
@@ -359,7 +359,7 @@ func TransformObjToDynamicBinary(ctx common.AndroidModuleContext,
if len(wholeStaticLibs) > 0 { if len(wholeStaticLibs) > 0 {
if ctx.Host() && ctx.Darwin() { if ctx.Host() && ctx.Darwin() {
libFlagsList = append(libFlagsList, common.JoinWithPrefix(wholeStaticLibs.Strings(), "-force_load ")) libFlagsList = append(libFlagsList, android.JoinWithPrefix(wholeStaticLibs.Strings(), "-force_load "))
} else { } else {
libFlagsList = append(libFlagsList, "-Wl,--whole-archive ") libFlagsList = append(libFlagsList, "-Wl,--whole-archive ")
libFlagsList = append(libFlagsList, wholeStaticLibs.Strings()...) libFlagsList = append(libFlagsList, wholeStaticLibs.Strings()...)
@@ -398,7 +398,7 @@ func TransformObjToDynamicBinary(ctx common.AndroidModuleContext,
deps = append(deps, crtBegin.Path(), crtEnd.Path()) deps = append(deps, crtBegin.Path(), crtEnd.Path())
} }
ctx.ModuleBuild(pctx, common.ModuleBuildParams{ ctx.ModuleBuild(pctx, android.ModuleBuildParams{
Rule: ld, Rule: ld,
Output: outputFile, Output: outputFile,
Inputs: objFiles, Inputs: objFiles,
@@ -415,8 +415,8 @@ func TransformObjToDynamicBinary(ctx common.AndroidModuleContext,
} }
// Generate a rule for compiling multiple .o files to a .o using ld partial linking // Generate a rule for compiling multiple .o files to a .o using ld partial linking
func TransformObjsToObj(ctx common.AndroidModuleContext, objFiles common.Paths, func TransformObjsToObj(ctx android.ModuleContext, objFiles android.Paths,
flags builderFlags, outputFile common.WritablePath) { flags builderFlags, outputFile android.WritablePath) {
var ldCmd string var ldCmd string
if flags.clang { if flags.clang {
@@ -425,7 +425,7 @@ func TransformObjsToObj(ctx common.AndroidModuleContext, objFiles common.Paths,
ldCmd = gccCmd(flags.toolchain, "g++") ldCmd = gccCmd(flags.toolchain, "g++")
} }
ctx.ModuleBuild(pctx, common.ModuleBuildParams{ ctx.ModuleBuild(pctx, android.ModuleBuildParams{
Rule: partialLd, Rule: partialLd,
Output: outputFile, Output: outputFile,
Inputs: objFiles, Inputs: objFiles,
@@ -437,12 +437,12 @@ func TransformObjsToObj(ctx common.AndroidModuleContext, objFiles common.Paths,
} }
// Generate a rule for runing objcopy --prefix-symbols on a binary // Generate a rule for runing objcopy --prefix-symbols on a binary
func TransformBinaryPrefixSymbols(ctx common.AndroidModuleContext, prefix string, inputFile common.Path, func TransformBinaryPrefixSymbols(ctx android.ModuleContext, prefix string, inputFile android.Path,
flags builderFlags, outputFile common.WritablePath) { flags builderFlags, outputFile android.WritablePath) {
objcopyCmd := gccCmd(flags.toolchain, "objcopy") objcopyCmd := gccCmd(flags.toolchain, "objcopy")
ctx.ModuleBuild(pctx, common.ModuleBuildParams{ ctx.ModuleBuild(pctx, android.ModuleBuildParams{
Rule: prefixSymbols, Rule: prefixSymbols,
Output: outputFile, Output: outputFile,
Input: inputFile, Input: inputFile,
@@ -453,8 +453,8 @@ func TransformBinaryPrefixSymbols(ctx common.AndroidModuleContext, prefix string
}) })
} }
func TransformStrip(ctx common.AndroidModuleContext, inputFile common.Path, func TransformStrip(ctx android.ModuleContext, inputFile android.Path,
outputFile common.WritablePath, flags builderFlags) { outputFile android.WritablePath, flags builderFlags) {
crossCompile := gccCmd(flags.toolchain, "") crossCompile := gccCmd(flags.toolchain, "")
args := "" args := ""
@@ -468,7 +468,7 @@ func TransformStrip(ctx common.AndroidModuleContext, inputFile common.Path,
args += " --keep-symbols" args += " --keep-symbols"
} }
ctx.ModuleBuild(pctx, common.ModuleBuildParams{ ctx.ModuleBuild(pctx, android.ModuleBuildParams{
Rule: strip, Rule: strip,
Output: outputFile, Output: outputFile,
Input: inputFile, Input: inputFile,
@@ -479,20 +479,20 @@ func TransformStrip(ctx common.AndroidModuleContext, inputFile common.Path,
}) })
} }
func TransformDarwinStrip(ctx common.AndroidModuleContext, inputFile common.Path, func TransformDarwinStrip(ctx android.ModuleContext, inputFile android.Path,
outputFile common.WritablePath) { outputFile android.WritablePath) {
ctx.ModuleBuild(pctx, common.ModuleBuildParams{ ctx.ModuleBuild(pctx, android.ModuleBuildParams{
Rule: darwinStrip, Rule: darwinStrip,
Output: outputFile, Output: outputFile,
Input: inputFile, Input: inputFile,
}) })
} }
func CopyGccLib(ctx common.AndroidModuleContext, libName string, func CopyGccLib(ctx android.ModuleContext, libName string,
flags builderFlags, outputFile common.WritablePath) { flags builderFlags, outputFile android.WritablePath) {
ctx.ModuleBuild(pctx, common.ModuleBuildParams{ ctx.ModuleBuild(pctx, android.ModuleBuildParams{
Rule: copyGccLib, Rule: copyGccLib,
Output: outputFile, Output: outputFile,
Args: map[string]string{ Args: map[string]string{

300
cc/cc.go
View File

@@ -27,7 +27,7 @@ import (
"github.com/google/blueprint/proptools" "github.com/google/blueprint/proptools"
"android/soong" "android/soong"
"android/soong/common" "android/soong/android"
"android/soong/genrule" "android/soong/genrule"
) )
@@ -56,19 +56,19 @@ func init() {
// LinkageMutator must be registered after common.ArchMutator, but that is guaranteed by // LinkageMutator must be registered after common.ArchMutator, but that is guaranteed by
// the Go initialization order because this package depends on common, so common's init // the Go initialization order because this package depends on common, so common's init
// functions will run first. // functions will run first.
common.RegisterBottomUpMutator("link", linkageMutator) android.RegisterBottomUpMutator("link", linkageMutator)
common.RegisterBottomUpMutator("test_per_src", testPerSrcMutator) android.RegisterBottomUpMutator("test_per_src", testPerSrcMutator)
common.RegisterBottomUpMutator("deps", depsMutator) android.RegisterBottomUpMutator("deps", depsMutator)
common.RegisterTopDownMutator("asan_deps", sanitizerDepsMutator(asan)) android.RegisterTopDownMutator("asan_deps", sanitizerDepsMutator(asan))
common.RegisterBottomUpMutator("asan", sanitizerMutator(asan)) android.RegisterBottomUpMutator("asan", sanitizerMutator(asan))
common.RegisterTopDownMutator("tsan_deps", sanitizerDepsMutator(tsan)) android.RegisterTopDownMutator("tsan_deps", sanitizerDepsMutator(tsan))
common.RegisterBottomUpMutator("tsan", sanitizerMutator(tsan)) android.RegisterBottomUpMutator("tsan", sanitizerMutator(tsan))
} }
var ( var (
HostPrebuiltTag = pctx.VariableConfigMethod("HostPrebuiltTag", common.Config.PrebuiltOS) HostPrebuiltTag = pctx.VariableConfigMethod("HostPrebuiltTag", android.Config.PrebuiltOS)
LibcRoot = pctx.SourcePathVariable("LibcRoot", "bionic/libc") LibcRoot = pctx.SourcePathVariable("LibcRoot", "bionic/libc")
) )
@@ -118,7 +118,7 @@ var (
) )
func init() { func init() {
if common.CurrentHostType() == common.Linux { if android.CurrentHostType() == android.Linux {
commonGlobalCflags = append(commonGlobalCflags, "-fdebug-prefix-map=/proc/self/cwd=") commonGlobalCflags = append(commonGlobalCflags, "-fdebug-prefix-map=/proc/self/cwd=")
} }
@@ -163,13 +163,13 @@ func init() {
pctx.SourcePathVariable("clangDefaultBase", "prebuilts/clang/host") pctx.SourcePathVariable("clangDefaultBase", "prebuilts/clang/host")
pctx.VariableFunc("clangBase", func(config interface{}) (string, error) { pctx.VariableFunc("clangBase", func(config interface{}) (string, error) {
if override := config.(common.Config).Getenv("LLVM_PREBUILTS_BASE"); override != "" { if override := config.(android.Config).Getenv("LLVM_PREBUILTS_BASE"); override != "" {
return override, nil return override, nil
} }
return "${clangDefaultBase}", nil return "${clangDefaultBase}", nil
}) })
pctx.VariableFunc("clangVersion", func(config interface{}) (string, error) { pctx.VariableFunc("clangVersion", func(config interface{}) (string, error) {
if override := config.(common.Config).Getenv("LLVM_PREBUILTS_VERSION"); override != "" { if override := config.(android.Config).Getenv("LLVM_PREBUILTS_VERSION"); override != "" {
return override, nil return override, nil
} }
return "clang-2812033", nil return "clang-2812033", nil
@@ -193,18 +193,18 @@ type Deps struct {
} }
type PathDeps struct { type PathDeps struct {
SharedLibs, LateSharedLibs common.Paths SharedLibs, LateSharedLibs android.Paths
StaticLibs, LateStaticLibs, WholeStaticLibs common.Paths StaticLibs, LateStaticLibs, WholeStaticLibs android.Paths
ObjFiles common.Paths ObjFiles android.Paths
WholeStaticLibObjFiles common.Paths WholeStaticLibObjFiles android.Paths
GeneratedSources common.Paths GeneratedSources android.Paths
GeneratedHeaders common.Paths GeneratedHeaders android.Paths
Cflags, ReexportedCflags []string Cflags, ReexportedCflags []string
CrtBegin, CrtEnd common.OptionalPath CrtBegin, CrtEnd android.OptionalPath
} }
type Flags struct { type Flags struct {
@@ -224,7 +224,7 @@ type Flags struct {
RequiredInstructionSet string RequiredInstructionSet string
DynamicLinker string DynamicLinker string
CFlagsDeps common.Paths // Files depended on by compiler flags CFlagsDeps android.Paths // Files depended on by compiler flags
} }
type BaseCompilerProperties struct { type BaseCompilerProperties struct {
@@ -460,12 +460,12 @@ type ModuleContextIntf interface {
} }
type ModuleContext interface { type ModuleContext interface {
common.AndroidModuleContext android.ModuleContext
ModuleContextIntf ModuleContextIntf
} }
type BaseModuleContext interface { type BaseModuleContext interface {
common.AndroidBaseContext android.BaseContext
ModuleContextIntf ModuleContextIntf
} }
@@ -483,18 +483,18 @@ type feature interface {
type compiler interface { type compiler interface {
feature feature
compile(ctx ModuleContext, flags Flags, deps PathDeps) common.Paths compile(ctx ModuleContext, flags Flags, deps PathDeps) android.Paths
} }
type linker interface { type linker interface {
feature feature
link(ctx ModuleContext, flags Flags, deps PathDeps, objFiles common.Paths) common.Path link(ctx ModuleContext, flags Flags, deps PathDeps, objFiles android.Paths) android.Path
installable() bool installable() bool
} }
type installer interface { type installer interface {
props() []interface{} props() []interface{}
install(ctx ModuleContext, path common.Path) install(ctx ModuleContext, path android.Path)
inData() bool inData() bool
} }
@@ -522,15 +522,15 @@ var (
// the blueprint.Module interface. It delegates to compiler, linker, and installer interfaces // the blueprint.Module interface. It delegates to compiler, linker, and installer interfaces
// to construct the output file. Behavior can be customized with a Customizer interface // to construct the output file. Behavior can be customized with a Customizer interface
type Module struct { type Module struct {
common.AndroidModuleBase android.ModuleBase
common.DefaultableModule android.DefaultableModule
Properties BaseProperties Properties BaseProperties
unused UnusedProperties unused UnusedProperties
// initialize before calling Init // initialize before calling Init
hod common.HostOrDeviceSupported hod android.HostOrDeviceSupported
multilib common.Multilib multilib android.Multilib
// delegates, initialize before calling Init // delegates, initialize before calling Init
customizer Customizer customizer Customizer
@@ -543,7 +543,7 @@ type Module struct {
androidMkSharedLibDeps []string androidMkSharedLibDeps []string
outputFile common.OptionalPath outputFile android.OptionalPath
cachedToolchain Toolchain cachedToolchain Toolchain
} }
@@ -572,18 +572,18 @@ func (c *Module) Init() (blueprint.Module, []interface{}) {
props = append(props, feature.props()...) props = append(props, feature.props()...)
} }
_, props = common.InitAndroidArchModule(c, c.hod, c.multilib, props...) _, props = android.InitAndroidArchModule(c, c.hod, c.multilib, props...)
return common.InitDefaultableModule(c, c, props...) return android.InitDefaultableModule(c, c, props...)
} }
type baseModuleContext struct { type baseModuleContext struct {
common.AndroidBaseContext android.BaseContext
moduleContextImpl moduleContextImpl
} }
type moduleContext struct { type moduleContext struct {
common.AndroidModuleContext android.ModuleContext
moduleContextImpl moduleContextImpl
} }
@@ -645,23 +645,23 @@ func (ctx *moduleContextImpl) selectedStl() string {
return "" return ""
} }
func newBaseModule(hod common.HostOrDeviceSupported, multilib common.Multilib) *Module { func newBaseModule(hod android.HostOrDeviceSupported, multilib android.Multilib) *Module {
return &Module{ return &Module{
hod: hod, hod: hod,
multilib: multilib, multilib: multilib,
} }
} }
func newModule(hod common.HostOrDeviceSupported, multilib common.Multilib) *Module { func newModule(hod android.HostOrDeviceSupported, multilib android.Multilib) *Module {
module := newBaseModule(hod, multilib) module := newBaseModule(hod, multilib)
module.stl = &stl{} module.stl = &stl{}
module.sanitize = &sanitize{} module.sanitize = &sanitize{}
return module return module
} }
func (c *Module) GenerateAndroidBuildActions(actx common.AndroidModuleContext) { func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
ctx := &moduleContext{ ctx := &moduleContext{
AndroidModuleContext: actx, ModuleContext: actx,
moduleContextImpl: moduleContextImpl{ moduleContextImpl: moduleContextImpl{
mod: c, mod: c,
}, },
@@ -711,7 +711,7 @@ func (c *Module) GenerateAndroidBuildActions(actx common.AndroidModuleContext) {
flags.CFlags = append(flags.CFlags, deps.Cflags...) flags.CFlags = append(flags.CFlags, deps.Cflags...)
var objFiles common.Paths var objFiles android.Paths
if c.compiler != nil { if c.compiler != nil {
objFiles = c.compiler.compile(ctx, flags, deps) objFiles = c.compiler.compile(ctx, flags, deps)
if ctx.Failed() { if ctx.Failed() {
@@ -724,7 +724,7 @@ func (c *Module) GenerateAndroidBuildActions(actx common.AndroidModuleContext) {
if ctx.Failed() { if ctx.Failed() {
return return
} }
c.outputFile = common.OptionalPathForPath(outputFile) c.outputFile = android.OptionalPathForPath(outputFile)
if c.installer != nil && c.linker.installable() { if c.installer != nil && c.linker.installable() {
c.installer.install(ctx, outputFile) c.installer.install(ctx, outputFile)
@@ -796,9 +796,9 @@ func (c *Module) deps(ctx BaseModuleContext) Deps {
return deps return deps
} }
func (c *Module) depsMutator(actx common.AndroidBottomUpMutatorContext) { func (c *Module) depsMutator(actx android.BottomUpMutatorContext) {
ctx := &baseModuleContext{ ctx := &baseModuleContext{
AndroidBaseContext: actx, BaseContext: actx,
moduleContextImpl: moduleContextImpl{ moduleContextImpl: moduleContextImpl{
mod: c, mod: c,
}, },
@@ -843,7 +843,7 @@ func (c *Module) depsMutator(actx common.AndroidBottomUpMutatorContext) {
} }
} }
func depsMutator(ctx common.AndroidBottomUpMutatorContext) { func depsMutator(ctx android.BottomUpMutatorContext) {
if c, ok := ctx.Module().(*Module); ok { if c, ok := ctx.Module().(*Module); ok {
c.depsMutator(ctx) c.depsMutator(ctx)
} }
@@ -870,14 +870,14 @@ func (c *Module) clang(ctx BaseModuleContext) bool {
} }
// Convert dependencies to paths. Returns a PathDeps containing paths // Convert dependencies to paths. Returns a PathDeps containing paths
func (c *Module) depsToPaths(ctx common.AndroidModuleContext) PathDeps { func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
var depPaths PathDeps var depPaths PathDeps
ctx.VisitDirectDeps(func(m blueprint.Module) { ctx.VisitDirectDeps(func(m blueprint.Module) {
name := ctx.OtherModuleName(m) name := ctx.OtherModuleName(m)
tag := ctx.OtherModuleDependencyTag(m) tag := ctx.OtherModuleDependencyTag(m)
a, _ := m.(common.AndroidModule) a, _ := m.(android.Module)
if a == nil { if a == nil {
ctx.ModuleErrorf("module %q not an android module", name) ctx.ModuleErrorf("module %q not an android module", name)
return return
@@ -886,7 +886,7 @@ func (c *Module) depsToPaths(ctx common.AndroidModuleContext) PathDeps {
c, _ := m.(*Module) c, _ := m.(*Module)
if c == nil { if c == nil {
switch tag { switch tag {
case common.DefaultsDepTag: case android.DefaultsDepTag:
case genSourceDepTag: case genSourceDepTag:
if genRule, ok := m.(genrule.SourceFileGenerator); ok { if genRule, ok := m.(genrule.SourceFileGenerator); ok {
depPaths.GeneratedSources = append(depPaths.GeneratedSources, depPaths.GeneratedSources = append(depPaths.GeneratedSources,
@@ -899,7 +899,7 @@ func (c *Module) depsToPaths(ctx common.AndroidModuleContext) PathDeps {
depPaths.GeneratedHeaders = append(depPaths.GeneratedHeaders, depPaths.GeneratedHeaders = append(depPaths.GeneratedHeaders,
genRule.GeneratedSourceFiles()...) genRule.GeneratedSourceFiles()...)
depPaths.Cflags = append(depPaths.Cflags, depPaths.Cflags = append(depPaths.Cflags,
includeDirsToFlags(common.Paths{genRule.GeneratedHeaderDir()})) includeDirsToFlags(android.Paths{genRule.GeneratedHeaderDir()}))
} else { } else {
ctx.ModuleErrorf("module %q is not a genrule", name) ctx.ModuleErrorf("module %q is not a genrule", name)
} }
@@ -938,7 +938,7 @@ func (c *Module) depsToPaths(ctx common.AndroidModuleContext) PathDeps {
} }
} }
var depPtr *common.Paths var depPtr *android.Paths
switch tag { switch tag {
case sharedDepTag: case sharedDepTag:
@@ -1039,14 +1039,14 @@ func (compiler *baseCompiler) flags(ctx ModuleContext, flags Flags) Flags {
flags.YaccFlags = append(flags.YaccFlags, compiler.Properties.Yaccflags...) flags.YaccFlags = append(flags.YaccFlags, compiler.Properties.Yaccflags...)
// Include dir cflags // Include dir cflags
rootIncludeDirs := common.PathsForSource(ctx, compiler.Properties.Include_dirs) rootIncludeDirs := android.PathsForSource(ctx, compiler.Properties.Include_dirs)
localIncludeDirs := common.PathsForModuleSrc(ctx, compiler.Properties.Local_include_dirs) localIncludeDirs := android.PathsForModuleSrc(ctx, compiler.Properties.Local_include_dirs)
flags.GlobalFlags = append(flags.GlobalFlags, flags.GlobalFlags = append(flags.GlobalFlags,
includeDirsToFlags(localIncludeDirs), includeDirsToFlags(localIncludeDirs),
includeDirsToFlags(rootIncludeDirs)) includeDirsToFlags(rootIncludeDirs))
rootIncludeFiles := common.PathsForSource(ctx, compiler.Properties.Include_files) rootIncludeFiles := android.PathsForSource(ctx, compiler.Properties.Include_files)
localIncludeFiles := common.PathsForModuleSrc(ctx, compiler.Properties.Local_include_files) localIncludeFiles := android.PathsForModuleSrc(ctx, compiler.Properties.Local_include_files)
flags.GlobalFlags = append(flags.GlobalFlags, flags.GlobalFlags = append(flags.GlobalFlags,
includeFilesToFlags(rootIncludeFiles), includeFilesToFlags(rootIncludeFiles),
@@ -1061,9 +1061,9 @@ func (compiler *baseCompiler) flags(ctx ModuleContext, flags Flags) Flags {
} }
flags.GlobalFlags = append(flags.GlobalFlags, []string{ flags.GlobalFlags = append(flags.GlobalFlags, []string{
"-I" + common.PathForModuleSrc(ctx).String(), "-I" + android.PathForModuleSrc(ctx).String(),
"-I" + common.PathForModuleOut(ctx).String(), "-I" + android.PathForModuleOut(ctx).String(),
"-I" + common.PathForModuleGen(ctx).String(), "-I" + android.PathForModuleGen(ctx).String(),
}...) }...)
} }
@@ -1164,7 +1164,7 @@ func (compiler *baseCompiler) flags(ctx ModuleContext, flags Flags) Flags {
// vendor/device specific things), we could extend this to be a ternary // vendor/device specific things), we could extend this to be a ternary
// value. // value.
strict := true strict := true
if strings.HasPrefix(common.PathForModuleSrc(ctx).String(), "external/") { if strings.HasPrefix(android.PathForModuleSrc(ctx).String(), "external/") {
strict = false strict = false
} }
@@ -1177,7 +1177,7 @@ func (compiler *baseCompiler) flags(ctx ModuleContext, flags Flags) Flags {
return flags return flags
} }
func (compiler *baseCompiler) compile(ctx ModuleContext, flags Flags, deps PathDeps) common.Paths { func (compiler *baseCompiler) compile(ctx ModuleContext, flags Flags, deps PathDeps) android.Paths {
// Compile files listed in c.Properties.Srcs into objects // Compile files listed in c.Properties.Srcs into objects
objFiles := compiler.compileObjs(ctx, flags, "", objFiles := compiler.compileObjs(ctx, flags, "",
compiler.Properties.Srcs, compiler.Properties.Exclude_srcs, compiler.Properties.Srcs, compiler.Properties.Exclude_srcs,
@@ -1191,8 +1191,8 @@ func (compiler *baseCompiler) compile(ctx ModuleContext, flags Flags, deps PathD
} }
// Compile a list of source files into objects a specified subdirectory // Compile a list of source files into objects a specified subdirectory
func (compiler *baseCompiler) compileObjs(ctx common.AndroidModuleContext, flags Flags, func (compiler *baseCompiler) compileObjs(ctx android.ModuleContext, flags Flags,
subdir string, srcFiles, excludes []string, extraSrcs, deps common.Paths) common.Paths { subdir string, srcFiles, excludes []string, extraSrcs, deps android.Paths) android.Paths {
buildFlags := flagsToBuilderFlags(flags) buildFlags := flagsToBuilderFlags(flags)
@@ -1349,7 +1349,7 @@ type baseInstaller struct {
dir64 string dir64 string
data bool data bool
path common.OutputPath path android.OutputPath
} }
var _ installer = (*baseInstaller)(nil) var _ installer = (*baseInstaller)(nil)
@@ -1358,12 +1358,12 @@ func (installer *baseInstaller) props() []interface{} {
return []interface{}{&installer.Properties} return []interface{}{&installer.Properties}
} }
func (installer *baseInstaller) install(ctx ModuleContext, file common.Path) { func (installer *baseInstaller) install(ctx ModuleContext, file android.Path) {
subDir := installer.dir subDir := installer.dir
if ctx.toolchain().Is64Bit() && installer.dir64 != "" { if ctx.toolchain().Is64Bit() && installer.dir64 != "" {
subDir = installer.dir64 subDir = installer.dir64
} }
dir := common.PathForModuleInstall(ctx, subDir, installer.Properties.Relative_install_path) dir := android.PathForModuleInstall(ctx, subDir, installer.Properties.Relative_install_path)
installer.path = ctx.InstallFile(dir, file) installer.path = ctx.InstallFile(dir, file)
} }
@@ -1382,8 +1382,8 @@ type flagExporter struct {
} }
func (f *flagExporter) exportIncludes(ctx ModuleContext, inc string) { func (f *flagExporter) exportIncludes(ctx ModuleContext, inc string) {
includeDirs := common.PathsForModuleSrc(ctx, f.Properties.Export_include_dirs) includeDirs := android.PathsForModuleSrc(ctx, f.Properties.Export_include_dirs)
f.flags = append(f.flags, common.JoinWithPrefix(includeDirs.Strings(), inc)) f.flags = append(f.flags, android.JoinWithPrefix(includeDirs.Strings(), inc))
} }
func (f *flagExporter) reexportFlags(flags []string) { func (f *flagExporter) reexportFlags(flags []string) {
@@ -1407,7 +1407,7 @@ type libraryCompiler struct {
Properties LibraryCompilerProperties Properties LibraryCompilerProperties
// For reusing static library objects for shared library // For reusing static library objects for shared library
reuseObjFiles common.Paths reuseObjFiles android.Paths
} }
var _ compiler = (*libraryCompiler)(nil) var _ compiler = (*libraryCompiler)(nil)
@@ -1423,7 +1423,7 @@ func (library *libraryCompiler) flags(ctx ModuleContext, flags Flags) Flags {
// MinGW spits out warnings about -fPIC even for -fpie?!) being ignored because // MinGW spits out warnings about -fPIC even for -fpie?!) being ignored because
// all code is position independent, and then those warnings get promoted to // all code is position independent, and then those warnings get promoted to
// errors. // errors.
if ctx.HostType() != common.Windows { if ctx.HostType() != android.Windows {
flags.CFlags = append(flags.CFlags, "-fPIC") flags.CFlags = append(flags.CFlags, "-fPIC")
} }
@@ -1436,18 +1436,18 @@ func (library *libraryCompiler) flags(ctx ModuleContext, flags Flags) Flags {
return flags return flags
} }
func (library *libraryCompiler) compile(ctx ModuleContext, flags Flags, deps PathDeps) common.Paths { func (library *libraryCompiler) compile(ctx ModuleContext, flags Flags, deps PathDeps) android.Paths {
var objFiles common.Paths var objFiles android.Paths
objFiles = library.baseCompiler.compile(ctx, flags, deps) objFiles = library.baseCompiler.compile(ctx, flags, deps)
library.reuseObjFiles = objFiles library.reuseObjFiles = objFiles
if library.linker.static() { if library.linker.static() {
objFiles = append(objFiles, library.compileObjs(ctx, flags, common.DeviceStaticLibrary, objFiles = append(objFiles, library.compileObjs(ctx, flags, android.DeviceStaticLibrary,
library.Properties.Static.Srcs, library.Properties.Static.Exclude_srcs, library.Properties.Static.Srcs, library.Properties.Static.Exclude_srcs,
nil, deps.GeneratedHeaders)...) nil, deps.GeneratedHeaders)...)
} else { } else {
objFiles = append(objFiles, library.compileObjs(ctx, flags, common.DeviceSharedLibrary, objFiles = append(objFiles, library.compileObjs(ctx, flags, android.DeviceSharedLibrary,
library.Properties.Shared.Srcs, library.Properties.Shared.Exclude_srcs, library.Properties.Shared.Srcs, library.Properties.Shared.Exclude_srcs,
nil, deps.GeneratedHeaders)...) nil, deps.GeneratedHeaders)...)
} }
@@ -1472,7 +1472,7 @@ type libraryLinker struct {
wholeStaticMissingDeps []string wholeStaticMissingDeps []string
// For whole_static_libs // For whole_static_libs
objFiles common.Paths objFiles android.Paths
} }
var _ linker = (*libraryLinker)(nil) var _ linker = (*libraryLinker)(nil)
@@ -1549,12 +1549,12 @@ func (library *libraryLinker) deps(ctx BaseModuleContext, deps Deps) Deps {
} }
func (library *libraryLinker) linkStatic(ctx ModuleContext, func (library *libraryLinker) linkStatic(ctx ModuleContext,
flags Flags, deps PathDeps, objFiles common.Paths) common.Path { flags Flags, deps PathDeps, objFiles android.Paths) android.Path {
library.objFiles = append(common.Paths{}, deps.WholeStaticLibObjFiles...) library.objFiles = append(android.Paths{}, deps.WholeStaticLibObjFiles...)
library.objFiles = append(library.objFiles, objFiles...) library.objFiles = append(library.objFiles, objFiles...)
outputFile := common.PathForModuleOut(ctx, outputFile := android.PathForModuleOut(ctx,
ctx.ModuleName()+library.Properties.VariantName+staticLibraryExtension) ctx.ModuleName()+library.Properties.VariantName+staticLibraryExtension)
if ctx.Darwin() { if ctx.Darwin() {
@@ -1571,14 +1571,14 @@ func (library *libraryLinker) linkStatic(ctx ModuleContext,
} }
func (library *libraryLinker) linkShared(ctx ModuleContext, func (library *libraryLinker) linkShared(ctx ModuleContext,
flags Flags, deps PathDeps, objFiles common.Paths) common.Path { flags Flags, deps PathDeps, objFiles android.Paths) android.Path {
var linkerDeps common.Paths var linkerDeps android.Paths
versionScript := common.OptionalPathForModuleSrc(ctx, library.Properties.Version_script) versionScript := android.OptionalPathForModuleSrc(ctx, library.Properties.Version_script)
unexportedSymbols := common.OptionalPathForModuleSrc(ctx, library.Properties.Unexported_symbols_list) unexportedSymbols := android.OptionalPathForModuleSrc(ctx, library.Properties.Unexported_symbols_list)
forceNotWeakSymbols := common.OptionalPathForModuleSrc(ctx, library.Properties.Force_symbols_not_weak_list) forceNotWeakSymbols := android.OptionalPathForModuleSrc(ctx, library.Properties.Force_symbols_not_weak_list)
forceWeakSymbols := common.OptionalPathForModuleSrc(ctx, library.Properties.Force_symbols_weak_list) forceWeakSymbols := android.OptionalPathForModuleSrc(ctx, library.Properties.Force_symbols_weak_list)
if !ctx.Darwin() { if !ctx.Darwin() {
if versionScript.Valid() { if versionScript.Valid() {
flags.LdFlags = append(flags.LdFlags, "-Wl,--version-script,"+versionScript.String()) flags.LdFlags = append(flags.LdFlags, "-Wl,--version-script,"+versionScript.String())
@@ -1612,14 +1612,14 @@ func (library *libraryLinker) linkShared(ctx ModuleContext,
} }
fileName := ctx.ModuleName() + library.Properties.VariantName + flags.Toolchain.ShlibSuffix() fileName := ctx.ModuleName() + library.Properties.VariantName + flags.Toolchain.ShlibSuffix()
outputFile := common.PathForModuleOut(ctx, fileName) outputFile := android.PathForModuleOut(ctx, fileName)
ret := outputFile ret := outputFile
builderFlags := flagsToBuilderFlags(flags) builderFlags := flagsToBuilderFlags(flags)
if library.stripper.needsStrip(ctx) { if library.stripper.needsStrip(ctx) {
strippedOutputFile := outputFile strippedOutputFile := outputFile
outputFile = common.PathForModuleOut(ctx, "unstripped", fileName) outputFile = android.PathForModuleOut(ctx, "unstripped", fileName)
library.stripper.strip(ctx, outputFile, strippedOutputFile, builderFlags) library.stripper.strip(ctx, outputFile, strippedOutputFile, builderFlags)
} }
@@ -1634,11 +1634,11 @@ func (library *libraryLinker) linkShared(ctx ModuleContext,
} }
func (library *libraryLinker) link(ctx ModuleContext, func (library *libraryLinker) link(ctx ModuleContext,
flags Flags, deps PathDeps, objFiles common.Paths) common.Path { flags Flags, deps PathDeps, objFiles android.Paths) android.Path {
objFiles = append(objFiles, deps.ObjFiles...) objFiles = append(objFiles, deps.ObjFiles...)
var out common.Path var out android.Path
if library.static() { if library.static() {
out = library.linkStatic(ctx, flags, deps, objFiles) out = library.linkStatic(ctx, flags, deps, objFiles)
} else { } else {
@@ -1678,7 +1678,7 @@ type libraryInstaller struct {
sanitize *sanitize sanitize *sanitize
} }
func (library *libraryInstaller) install(ctx ModuleContext, file common.Path) { func (library *libraryInstaller) install(ctx ModuleContext, file android.Path) {
if !library.linker.static() { if !library.linker.static() {
library.baseInstaller.install(ctx, file) library.baseInstaller.install(ctx, file)
} }
@@ -1688,8 +1688,8 @@ func (library *libraryInstaller) inData() bool {
return library.baseInstaller.inData() || library.sanitize.inData() return library.baseInstaller.inData() || library.sanitize.inData()
} }
func NewLibrary(hod common.HostOrDeviceSupported, shared, static bool) *Module { func NewLibrary(hod android.HostOrDeviceSupported, shared, static bool) *Module {
module := newModule(hod, common.MultilibBoth) module := newModule(hod, android.MultilibBoth)
linker := &libraryLinker{} linker := &libraryLinker{}
linker.dynamicProperties.BuildShared = shared linker.dynamicProperties.BuildShared = shared
@@ -1712,7 +1712,7 @@ func NewLibrary(hod common.HostOrDeviceSupported, shared, static bool) *Module {
} }
func libraryFactory() (blueprint.Module, []interface{}) { func libraryFactory() (blueprint.Module, []interface{}) {
module := NewLibrary(common.HostAndDeviceSupported, true, true) module := NewLibrary(android.HostAndDeviceSupported, true, true)
return module.Init() return module.Init()
} }
@@ -1725,7 +1725,7 @@ type objectLinker struct {
} }
func objectFactory() (blueprint.Module, []interface{}) { func objectFactory() (blueprint.Module, []interface{}) {
module := newBaseModule(common.DeviceSupported, common.MultilibBoth) module := newBaseModule(android.DeviceSupported, android.MultilibBoth)
module.compiler = &baseCompiler{} module.compiler = &baseCompiler{}
module.linker = &objectLinker{} module.linker = &objectLinker{}
return module.Init() return module.Init()
@@ -1753,15 +1753,15 @@ func (*objectLinker) flags(ctx ModuleContext, flags Flags) Flags {
} }
func (object *objectLinker) link(ctx ModuleContext, func (object *objectLinker) link(ctx ModuleContext,
flags Flags, deps PathDeps, objFiles common.Paths) common.Path { flags Flags, deps PathDeps, objFiles android.Paths) android.Path {
objFiles = append(objFiles, deps.ObjFiles...) objFiles = append(objFiles, deps.ObjFiles...)
var outputFile common.Path var outputFile android.Path
if len(objFiles) == 1 { if len(objFiles) == 1 {
outputFile = objFiles[0] outputFile = objFiles[0]
} else { } else {
output := common.PathForModuleOut(ctx, ctx.ModuleName()+objectExtension) output := android.PathForModuleOut(ctx, ctx.ModuleName()+objectExtension)
TransformObjsToObj(ctx, objFiles, flagsToBuilderFlags(flags), output) TransformObjsToObj(ctx, objFiles, flagsToBuilderFlags(flags), output)
outputFile = output outputFile = output
} }
@@ -1784,7 +1784,7 @@ type binaryLinker struct {
Properties BinaryLinkerProperties Properties BinaryLinkerProperties
hostToolPath common.OptionalPath hostToolPath android.OptionalPath
} }
var _ linker = (*binaryLinker)(nil) var _ linker = (*binaryLinker)(nil)
@@ -1861,8 +1861,8 @@ func (binary *binaryLinker) isDependencyRoot() bool {
return true return true
} }
func NewBinary(hod common.HostOrDeviceSupported) *Module { func NewBinary(hod android.HostOrDeviceSupported) *Module {
module := newModule(hod, common.MultilibFirst) module := newModule(hod, android.MultilibFirst)
module.compiler = &baseCompiler{} module.compiler = &baseCompiler{}
module.linker = &binaryLinker{} module.linker = &binaryLinker{}
module.installer = &baseInstaller{ module.installer = &baseInstaller{
@@ -1872,7 +1872,7 @@ func NewBinary(hod common.HostOrDeviceSupported) *Module {
} }
func binaryFactory() (blueprint.Module, []interface{}) { func binaryFactory() (blueprint.Module, []interface{}) {
module := NewBinary(common.HostAndDeviceSupported) module := NewBinary(android.HostAndDeviceSupported)
return module.Init() return module.Init()
} }
@@ -1881,7 +1881,7 @@ func (binary *binaryLinker) begin(ctx BaseModuleContext) {
static := Bool(binary.Properties.Static_executable) static := Bool(binary.Properties.Static_executable)
if ctx.Host() { if ctx.Host() {
if ctx.HostType() == common.Linux { if ctx.HostType() == android.Linux {
if binary.Properties.Static_executable == nil && Bool(ctx.AConfig().ProductVariables.HostStaticBinaries) { if binary.Properties.Static_executable == nil && Bool(ctx.AConfig().ProductVariables.HostStaticBinaries) {
static = true static = true
} }
@@ -1901,7 +1901,7 @@ func (binary *binaryLinker) flags(ctx ModuleContext, flags Flags) Flags {
if ctx.Host() && !binary.staticBinary() { if ctx.Host() && !binary.staticBinary() {
flags.LdFlags = append(flags.LdFlags, "-pie") flags.LdFlags = append(flags.LdFlags, "-pie")
if ctx.HostType() == common.Windows { if ctx.HostType() == android.Windows {
flags.LdFlags = append(flags.LdFlags, "-Wl,-e_mainCRTStartup") flags.LdFlags = append(flags.LdFlags, "-Wl,-e_mainCRTStartup")
} }
} }
@@ -1909,7 +1909,7 @@ func (binary *binaryLinker) flags(ctx ModuleContext, flags Flags) Flags {
// MinGW spits out warnings about -fPIC even for -fpie?!) being ignored because // MinGW spits out warnings about -fPIC even for -fpie?!) being ignored because
// all code is position independent, and then those warnings get promoted to // all code is position independent, and then those warnings get promoted to
// errors. // errors.
if ctx.HostType() != common.Windows { if ctx.HostType() != android.Windows {
flags.CFlags = append(flags.CFlags, "-fpie") flags.CFlags = append(flags.CFlags, "-fpie")
} }
@@ -1958,16 +1958,16 @@ func (binary *binaryLinker) flags(ctx ModuleContext, flags Flags) Flags {
} }
func (binary *binaryLinker) link(ctx ModuleContext, func (binary *binaryLinker) link(ctx ModuleContext,
flags Flags, deps PathDeps, objFiles common.Paths) common.Path { flags Flags, deps PathDeps, objFiles android.Paths) android.Path {
fileName := binary.getStem(ctx) + flags.Toolchain.ExecutableSuffix() fileName := binary.getStem(ctx) + flags.Toolchain.ExecutableSuffix()
outputFile := common.PathForModuleOut(ctx, fileName) outputFile := android.PathForModuleOut(ctx, fileName)
ret := outputFile ret := outputFile
if ctx.HostOrDevice().Host() { if ctx.HostOrDevice().Host() {
binary.hostToolPath = common.OptionalPathForPath(outputFile) binary.hostToolPath = android.OptionalPathForPath(outputFile)
} }
var linkerDeps common.Paths var linkerDeps android.Paths
sharedLibs := deps.SharedLibs sharedLibs := deps.SharedLibs
sharedLibs = append(sharedLibs, deps.LateSharedLibs...) sharedLibs = append(sharedLibs, deps.LateSharedLibs...)
@@ -1980,13 +1980,13 @@ func (binary *binaryLinker) link(ctx ModuleContext,
if binary.stripper.needsStrip(ctx) { if binary.stripper.needsStrip(ctx) {
strippedOutputFile := outputFile strippedOutputFile := outputFile
outputFile = common.PathForModuleOut(ctx, "unstripped", fileName) outputFile = android.PathForModuleOut(ctx, "unstripped", fileName)
binary.stripper.strip(ctx, outputFile, strippedOutputFile, builderFlags) binary.stripper.strip(ctx, outputFile, strippedOutputFile, builderFlags)
} }
if binary.Properties.Prefix_symbols != "" { if binary.Properties.Prefix_symbols != "" {
afterPrefixSymbols := outputFile afterPrefixSymbols := outputFile
outputFile = common.PathForModuleOut(ctx, "unprefixed", fileName) outputFile = android.PathForModuleOut(ctx, "unprefixed", fileName)
TransformBinaryPrefixSymbols(ctx, binary.Properties.Prefix_symbols, outputFile, TransformBinaryPrefixSymbols(ctx, binary.Properties.Prefix_symbols, outputFile,
flagsToBuilderFlags(flags), afterPrefixSymbols) flagsToBuilderFlags(flags), afterPrefixSymbols)
} }
@@ -1998,7 +1998,7 @@ func (binary *binaryLinker) link(ctx ModuleContext,
return ret return ret
} }
func (binary *binaryLinker) HostToolPath() common.OptionalPath { func (binary *binaryLinker) HostToolPath() android.OptionalPath {
return binary.hostToolPath return binary.hostToolPath
} }
@@ -2010,7 +2010,7 @@ func (stripper *stripper) needsStrip(ctx ModuleContext) bool {
return !ctx.AConfig().EmbeddedInMake() && !stripper.StripProperties.Strip.None return !ctx.AConfig().EmbeddedInMake() && !stripper.StripProperties.Strip.None
} }
func (stripper *stripper) strip(ctx ModuleContext, in, out common.ModuleOutPath, func (stripper *stripper) strip(ctx ModuleContext, in, out android.ModuleOutPath,
flags builderFlags) { flags builderFlags) {
if ctx.Darwin() { if ctx.Darwin() {
TransformDarwinStrip(ctx, in, out) TransformDarwinStrip(ctx, in, out)
@@ -2022,7 +2022,7 @@ func (stripper *stripper) strip(ctx ModuleContext, in, out common.ModuleOutPath,
} }
} }
func testPerSrcMutator(mctx common.AndroidBottomUpMutatorContext) { func testPerSrcMutator(mctx android.BottomUpMutatorContext) {
if m, ok := mctx.Module().(*Module); ok { if m, ok := mctx.Module().(*Module); ok {
if test, ok := m.linker.(*testLinker); ok { if test, ok := m.linker.(*testLinker); ok {
if Bool(test.Properties.Test_per_src) { if Bool(test.Properties.Test_per_src) {
@@ -2071,12 +2071,12 @@ func (test *testLinker) flags(ctx ModuleContext, flags Flags) Flags {
flags.CFlags = append(flags.CFlags, "-O0", "-g") flags.CFlags = append(flags.CFlags, "-O0", "-g")
switch ctx.HostType() { switch ctx.HostType() {
case common.Windows: case android.Windows:
flags.CFlags = append(flags.CFlags, "-DGTEST_OS_WINDOWS") flags.CFlags = append(flags.CFlags, "-DGTEST_OS_WINDOWS")
case common.Linux: case android.Linux:
flags.CFlags = append(flags.CFlags, "-DGTEST_OS_LINUX") flags.CFlags = append(flags.CFlags, "-DGTEST_OS_LINUX")
flags.LdFlags = append(flags.LdFlags, "-lpthread") flags.LdFlags = append(flags.LdFlags, "-lpthread")
case common.Darwin: case android.Darwin:
flags.CFlags = append(flags.CFlags, "-DGTEST_OS_MAC") flags.CFlags = append(flags.CFlags, "-DGTEST_OS_MAC")
flags.LdFlags = append(flags.LdFlags, "-lpthread") flags.LdFlags = append(flags.LdFlags, "-lpthread")
} }
@@ -2110,14 +2110,14 @@ type testInstaller struct {
baseInstaller baseInstaller
} }
func (installer *testInstaller) install(ctx ModuleContext, file common.Path) { func (installer *testInstaller) install(ctx ModuleContext, file android.Path) {
installer.dir = filepath.Join(installer.dir, ctx.ModuleName()) installer.dir = filepath.Join(installer.dir, ctx.ModuleName())
installer.dir64 = filepath.Join(installer.dir64, ctx.ModuleName()) installer.dir64 = filepath.Join(installer.dir64, ctx.ModuleName())
installer.baseInstaller.install(ctx, file) installer.baseInstaller.install(ctx, file)
} }
func NewTest(hod common.HostOrDeviceSupported) *Module { func NewTest(hod android.HostOrDeviceSupported) *Module {
module := newModule(hod, common.MultilibBoth) module := newModule(hod, android.MultilibBoth)
module.compiler = &baseCompiler{} module.compiler = &baseCompiler{}
linker := &testLinker{} linker := &testLinker{}
linker.Properties.Gtest = true linker.Properties.Gtest = true
@@ -2133,7 +2133,7 @@ func NewTest(hod common.HostOrDeviceSupported) *Module {
} }
func testFactory() (blueprint.Module, []interface{}) { func testFactory() (blueprint.Module, []interface{}) {
module := NewTest(common.HostAndDeviceSupported) module := NewTest(android.HostAndDeviceSupported)
return module.Init() return module.Init()
} }
@@ -2147,8 +2147,8 @@ func (benchmark *benchmarkLinker) deps(ctx BaseModuleContext, deps Deps) Deps {
return deps return deps
} }
func NewBenchmark(hod common.HostOrDeviceSupported) *Module { func NewBenchmark(hod android.HostOrDeviceSupported) *Module {
module := newModule(hod, common.MultilibFirst) module := newModule(hod, android.MultilibFirst)
module.compiler = &baseCompiler{} module.compiler = &baseCompiler{}
module.linker = &benchmarkLinker{} module.linker = &benchmarkLinker{}
module.installer = &baseInstaller{ module.installer = &baseInstaller{
@@ -2160,7 +2160,7 @@ func NewBenchmark(hod common.HostOrDeviceSupported) *Module {
} }
func benchmarkFactory() (blueprint.Module, []interface{}) { func benchmarkFactory() (blueprint.Module, []interface{}) {
module := NewBenchmark(common.HostAndDeviceSupported) module := NewBenchmark(android.HostAndDeviceSupported)
return module.Init() return module.Init()
} }
@@ -2169,7 +2169,7 @@ func benchmarkFactory() (blueprint.Module, []interface{}) {
// //
func libraryStaticFactory() (blueprint.Module, []interface{}) { func libraryStaticFactory() (blueprint.Module, []interface{}) {
module := NewLibrary(common.HostAndDeviceSupported, false, true) module := NewLibrary(android.HostAndDeviceSupported, false, true)
return module.Init() return module.Init()
} }
@@ -2178,7 +2178,7 @@ func libraryStaticFactory() (blueprint.Module, []interface{}) {
// //
func librarySharedFactory() (blueprint.Module, []interface{}) { func librarySharedFactory() (blueprint.Module, []interface{}) {
module := NewLibrary(common.HostAndDeviceSupported, true, false) module := NewLibrary(android.HostAndDeviceSupported, true, false)
return module.Init() return module.Init()
} }
@@ -2187,7 +2187,7 @@ func librarySharedFactory() (blueprint.Module, []interface{}) {
// //
func libraryHostStaticFactory() (blueprint.Module, []interface{}) { func libraryHostStaticFactory() (blueprint.Module, []interface{}) {
module := NewLibrary(common.HostSupported, false, true) module := NewLibrary(android.HostSupported, false, true)
return module.Init() return module.Init()
} }
@@ -2196,7 +2196,7 @@ func libraryHostStaticFactory() (blueprint.Module, []interface{}) {
// //
func libraryHostSharedFactory() (blueprint.Module, []interface{}) { func libraryHostSharedFactory() (blueprint.Module, []interface{}) {
module := NewLibrary(common.HostSupported, true, false) module := NewLibrary(android.HostSupported, true, false)
return module.Init() return module.Init()
} }
@@ -2205,7 +2205,7 @@ func libraryHostSharedFactory() (blueprint.Module, []interface{}) {
// //
func binaryHostFactory() (blueprint.Module, []interface{}) { func binaryHostFactory() (blueprint.Module, []interface{}) {
module := NewBinary(common.HostSupported) module := NewBinary(android.HostSupported)
return module.Init() return module.Init()
} }
@@ -2214,7 +2214,7 @@ func binaryHostFactory() (blueprint.Module, []interface{}) {
// //
func testHostFactory() (blueprint.Module, []interface{}) { func testHostFactory() (blueprint.Module, []interface{}) {
module := NewTest(common.HostSupported) module := NewTest(android.HostSupported)
return module.Init() return module.Init()
} }
@@ -2223,7 +2223,7 @@ func testHostFactory() (blueprint.Module, []interface{}) {
// //
func benchmarkHostFactory() (blueprint.Module, []interface{}) { func benchmarkHostFactory() (blueprint.Module, []interface{}) {
module := NewBenchmark(common.HostSupported) module := NewBenchmark(android.HostSupported)
return module.Init() return module.Init()
} }
@@ -2231,11 +2231,11 @@ func benchmarkHostFactory() (blueprint.Module, []interface{}) {
// Defaults // Defaults
// //
type Defaults struct { type Defaults struct {
common.AndroidModuleBase android.ModuleBase
common.DefaultsModule android.DefaultsModule
} }
func (*Defaults) GenerateAndroidBuildActions(ctx common.AndroidModuleContext) { func (*Defaults) GenerateAndroidBuildActions(ctx android.ModuleContext) {
} }
func defaultsFactory() (blueprint.Module, []interface{}) { func defaultsFactory() (blueprint.Module, []interface{}) {
@@ -2256,10 +2256,10 @@ func defaultsFactory() (blueprint.Module, []interface{}) {
&StripProperties{}, &StripProperties{},
} }
_, propertyStructs = common.InitAndroidArchModule(module, common.HostAndDeviceDefault, _, propertyStructs = android.InitAndroidArchModule(module, android.HostAndDeviceDefault,
common.MultilibDefault, propertyStructs...) android.MultilibDefault, propertyStructs...)
return common.InitDefaultsModule(module, module, propertyStructs...) return android.InitDefaultsModule(module, module, propertyStructs...)
} }
// //
@@ -2286,7 +2286,7 @@ func (*toolchainLibraryLinker) buildShared() bool {
} }
func toolchainLibraryFactory() (blueprint.Module, []interface{}) { func toolchainLibraryFactory() (blueprint.Module, []interface{}) {
module := newBaseModule(common.DeviceSupported, common.MultilibBoth) module := newBaseModule(android.DeviceSupported, android.MultilibBoth)
module.compiler = &baseCompiler{} module.compiler = &baseCompiler{}
module.linker = &toolchainLibraryLinker{} module.linker = &toolchainLibraryLinker{}
module.Properties.Clang = proptools.BoolPtr(false) module.Properties.Clang = proptools.BoolPtr(false)
@@ -2294,10 +2294,10 @@ func toolchainLibraryFactory() (blueprint.Module, []interface{}) {
} }
func (library *toolchainLibraryLinker) link(ctx ModuleContext, func (library *toolchainLibraryLinker) link(ctx ModuleContext,
flags Flags, deps PathDeps, objFiles common.Paths) common.Path { flags Flags, deps PathDeps, objFiles android.Paths) android.Path {
libName := ctx.ModuleName() + staticLibraryExtension libName := ctx.ModuleName() + staticLibraryExtension
outputFile := common.PathForModuleOut(ctx, libName) outputFile := android.PathForModuleOut(ctx, libName)
if flags.Clang { if flags.Clang {
ctx.ModuleErrorf("toolchain_library must use GCC, not Clang") ctx.ModuleErrorf("toolchain_library must use GCC, not Clang")
@@ -2320,19 +2320,19 @@ func (*toolchainLibraryLinker) installable() bool {
// either (with the exception of the shared STLs, which are installed to the app's directory rather // either (with the exception of the shared STLs, which are installed to the app's directory rather
// than to the system image). // than to the system image).
func getNdkLibDir(ctx common.AndroidModuleContext, toolchain Toolchain, version string) common.SourcePath { func getNdkLibDir(ctx android.ModuleContext, toolchain Toolchain, version string) android.SourcePath {
suffix := "" suffix := ""
// Most 64-bit NDK prebuilts store libraries in "lib64", except for arm64 which is not a // Most 64-bit NDK prebuilts store libraries in "lib64", except for arm64 which is not a
// multilib toolchain and stores the libraries in "lib". // multilib toolchain and stores the libraries in "lib".
if toolchain.Is64Bit() && ctx.Arch().ArchType != common.Arm64 { if toolchain.Is64Bit() && ctx.Arch().ArchType != android.Arm64 {
suffix = "64" suffix = "64"
} }
return common.PathForSource(ctx, fmt.Sprintf("prebuilts/ndk/current/platforms/android-%s/arch-%s/usr/lib%s", return android.PathForSource(ctx, fmt.Sprintf("prebuilts/ndk/current/platforms/android-%s/arch-%s/usr/lib%s",
version, toolchain.Name(), suffix)) version, toolchain.Name(), suffix))
} }
func ndkPrebuiltModuleToPath(ctx common.AndroidModuleContext, toolchain Toolchain, func ndkPrebuiltModuleToPath(ctx android.ModuleContext, toolchain Toolchain,
ext string, version string) common.Path { ext string, version string) android.Path {
// NDK prebuilts are named like: ndk_NAME.EXT.SDK_VERSION. // NDK prebuilts are named like: ndk_NAME.EXT.SDK_VERSION.
// We want to translate to just NAME.EXT // We want to translate to just NAME.EXT
@@ -2351,13 +2351,13 @@ func (*ndkPrebuiltObjectLinker) deps(ctx BaseModuleContext, deps Deps) Deps {
} }
func ndkPrebuiltObjectFactory() (blueprint.Module, []interface{}) { func ndkPrebuiltObjectFactory() (blueprint.Module, []interface{}) {
module := newBaseModule(common.DeviceSupported, common.MultilibBoth) module := newBaseModule(android.DeviceSupported, android.MultilibBoth)
module.linker = &ndkPrebuiltObjectLinker{} module.linker = &ndkPrebuiltObjectLinker{}
return module.Init() return module.Init()
} }
func (c *ndkPrebuiltObjectLinker) link(ctx ModuleContext, flags Flags, func (c *ndkPrebuiltObjectLinker) link(ctx ModuleContext, flags Flags,
deps PathDeps, objFiles common.Paths) common.Path { deps PathDeps, objFiles android.Paths) android.Path {
// A null build step, but it sets up the output path. // A null build step, but it sets up the output path.
if !strings.HasPrefix(ctx.ModuleName(), "ndk_crt") { if !strings.HasPrefix(ctx.ModuleName(), "ndk_crt") {
ctx.ModuleErrorf("NDK prebuilts must have an ndk_crt prefixed name") ctx.ModuleErrorf("NDK prebuilts must have an ndk_crt prefixed name")
@@ -2383,7 +2383,7 @@ func (*ndkPrebuiltLibraryLinker) deps(ctx BaseModuleContext, deps Deps) Deps {
} }
func ndkPrebuiltLibraryFactory() (blueprint.Module, []interface{}) { func ndkPrebuiltLibraryFactory() (blueprint.Module, []interface{}) {
module := newBaseModule(common.DeviceSupported, common.MultilibBoth) module := newBaseModule(android.DeviceSupported, android.MultilibBoth)
linker := &ndkPrebuiltLibraryLinker{} linker := &ndkPrebuiltLibraryLinker{}
linker.dynamicProperties.BuildShared = true linker.dynamicProperties.BuildShared = true
module.linker = linker module.linker = linker
@@ -2391,7 +2391,7 @@ func ndkPrebuiltLibraryFactory() (blueprint.Module, []interface{}) {
} }
func (ndk *ndkPrebuiltLibraryLinker) link(ctx ModuleContext, flags Flags, func (ndk *ndkPrebuiltLibraryLinker) link(ctx ModuleContext, flags Flags,
deps PathDeps, objFiles common.Paths) common.Path { deps PathDeps, objFiles android.Paths) android.Path {
// A null build step, but it sets up the output path. // A null build step, but it sets up the output path.
if !strings.HasPrefix(ctx.ModuleName(), "ndk_lib") { if !strings.HasPrefix(ctx.ModuleName(), "ndk_lib") {
ctx.ModuleErrorf("NDK prebuilts must have an ndk_lib prefixed name") ctx.ModuleErrorf("NDK prebuilts must have an ndk_lib prefixed name")
@@ -2412,7 +2412,7 @@ type ndkPrebuiltStlLinker struct {
} }
func ndkPrebuiltSharedStlFactory() (blueprint.Module, []interface{}) { func ndkPrebuiltSharedStlFactory() (blueprint.Module, []interface{}) {
module := newBaseModule(common.DeviceSupported, common.MultilibBoth) module := newBaseModule(android.DeviceSupported, android.MultilibBoth)
linker := &ndkPrebuiltStlLinker{} linker := &ndkPrebuiltStlLinker{}
linker.dynamicProperties.BuildShared = true linker.dynamicProperties.BuildShared = true
module.linker = linker module.linker = linker
@@ -2420,14 +2420,14 @@ func ndkPrebuiltSharedStlFactory() (blueprint.Module, []interface{}) {
} }
func ndkPrebuiltStaticStlFactory() (blueprint.Module, []interface{}) { func ndkPrebuiltStaticStlFactory() (blueprint.Module, []interface{}) {
module := newBaseModule(common.DeviceSupported, common.MultilibBoth) module := newBaseModule(android.DeviceSupported, android.MultilibBoth)
linker := &ndkPrebuiltStlLinker{} linker := &ndkPrebuiltStlLinker{}
linker.dynamicProperties.BuildStatic = true linker.dynamicProperties.BuildStatic = true
module.linker = linker module.linker = linker
return module.Init() return module.Init()
} }
func getNdkStlLibDir(ctx common.AndroidModuleContext, toolchain Toolchain, stl string) common.SourcePath { func getNdkStlLibDir(ctx android.ModuleContext, toolchain Toolchain, stl string) android.SourcePath {
gccVersion := toolchain.GccVersion() gccVersion := toolchain.GccVersion()
var libDir string var libDir string
switch stl { switch stl {
@@ -2441,15 +2441,15 @@ func getNdkStlLibDir(ctx common.AndroidModuleContext, toolchain Toolchain, stl s
if libDir != "" { if libDir != "" {
ndkSrcRoot := "prebuilts/ndk/current/sources" ndkSrcRoot := "prebuilts/ndk/current/sources"
return common.PathForSource(ctx, ndkSrcRoot).Join(ctx, libDir, ctx.Arch().Abi[0]) return android.PathForSource(ctx, ndkSrcRoot).Join(ctx, libDir, ctx.Arch().Abi[0])
} }
ctx.ModuleErrorf("Unknown NDK STL: %s", stl) ctx.ModuleErrorf("Unknown NDK STL: %s", stl)
return common.PathForSource(ctx, "") return android.PathForSource(ctx, "")
} }
func (ndk *ndkPrebuiltStlLinker) link(ctx ModuleContext, flags Flags, func (ndk *ndkPrebuiltStlLinker) link(ctx ModuleContext, flags Flags,
deps PathDeps, objFiles common.Paths) common.Path { deps PathDeps, objFiles android.Paths) android.Path {
// A null build step, but it sets up the output path. // A null build step, but it sets up the output path.
if !strings.HasPrefix(ctx.ModuleName(), "ndk_lib") { if !strings.HasPrefix(ctx.ModuleName(), "ndk_lib") {
ctx.ModuleErrorf("NDK prebuilts must have an ndk_lib prefixed name") ctx.ModuleErrorf("NDK prebuilts must have an ndk_lib prefixed name")
@@ -2469,7 +2469,7 @@ func (ndk *ndkPrebuiltStlLinker) link(ctx ModuleContext, flags Flags,
return libDir.Join(ctx, libName+libExt) return libDir.Join(ctx, libName+libExt)
} }
func linkageMutator(mctx common.AndroidBottomUpMutatorContext) { func linkageMutator(mctx android.BottomUpMutatorContext) {
if m, ok := mctx.Module().(*Module); ok { if m, ok := mctx.Module().(*Module); ok {
if m.linker != nil { if m.linker != nil {
if linker, ok := m.linker.(baseLinkerInterface); ok { if linker, ok := m.linker.(baseLinkerInterface); ok {

View File

@@ -21,7 +21,7 @@ package cc
import ( import (
"github.com/google/blueprint" "github.com/google/blueprint"
"android/soong/common" "android/soong/android"
) )
func init() { func init() {
@@ -47,12 +47,12 @@ var (
}) })
) )
func genYacc(ctx common.AndroidModuleContext, yaccFile common.Path, outFile common.ModuleGenPath, yaccFlags string) (headerFile common.ModuleGenPath) { func genYacc(ctx android.ModuleContext, yaccFile android.Path, outFile android.ModuleGenPath, yaccFlags string) (headerFile android.ModuleGenPath) {
headerFile = common.GenPathWithExt(ctx, yaccFile, "h") headerFile = android.GenPathWithExt(ctx, yaccFile, "h")
ctx.ModuleBuild(pctx, common.ModuleBuildParams{ ctx.ModuleBuild(pctx, android.ModuleBuildParams{
Rule: yacc, Rule: yacc,
Outputs: common.WritablePaths{outFile, headerFile}, Outputs: android.WritablePaths{outFile, headerFile},
Input: yaccFile, Input: yaccFile,
Args: map[string]string{ Args: map[string]string{
"yaccFlags": yaccFlags, "yaccFlags": yaccFlags,
@@ -64,35 +64,35 @@ func genYacc(ctx common.AndroidModuleContext, yaccFile common.Path, outFile comm
return headerFile return headerFile
} }
func genLex(ctx common.AndroidModuleContext, lexFile common.Path, outFile common.ModuleGenPath) { func genLex(ctx android.ModuleContext, lexFile android.Path, outFile android.ModuleGenPath) {
ctx.ModuleBuild(pctx, common.ModuleBuildParams{ ctx.ModuleBuild(pctx, android.ModuleBuildParams{
Rule: lex, Rule: lex,
Output: outFile, Output: outFile,
Input: lexFile, Input: lexFile,
}) })
} }
func genSources(ctx common.AndroidModuleContext, srcFiles common.Paths, func genSources(ctx android.ModuleContext, srcFiles android.Paths,
buildFlags builderFlags) (common.Paths, common.Paths) { buildFlags builderFlags) (android.Paths, android.Paths) {
var deps common.Paths var deps android.Paths
for i, srcFile := range srcFiles { for i, srcFile := range srcFiles {
switch srcFile.Ext() { switch srcFile.Ext() {
case ".y": case ".y":
cFile := common.GenPathWithExt(ctx, srcFile, "c") cFile := android.GenPathWithExt(ctx, srcFile, "c")
srcFiles[i] = cFile srcFiles[i] = cFile
deps = append(deps, genYacc(ctx, srcFile, cFile, buildFlags.yaccFlags)) deps = append(deps, genYacc(ctx, srcFile, cFile, buildFlags.yaccFlags))
case ".yy": case ".yy":
cppFile := common.GenPathWithExt(ctx, srcFile, "cpp") cppFile := android.GenPathWithExt(ctx, srcFile, "cpp")
srcFiles[i] = cppFile srcFiles[i] = cppFile
deps = append(deps, genYacc(ctx, srcFile, cppFile, buildFlags.yaccFlags)) deps = append(deps, genYacc(ctx, srcFile, cppFile, buildFlags.yaccFlags))
case ".l": case ".l":
cFile := common.GenPathWithExt(ctx, srcFile, "c") cFile := android.GenPathWithExt(ctx, srcFile, "c")
srcFiles[i] = cFile srcFiles[i] = cFile
genLex(ctx, srcFile, cFile) genLex(ctx, srcFile, cFile)
case ".ll": case ".ll":
cppFile := common.GenPathWithExt(ctx, srcFile, "cpp") cppFile := android.GenPathWithExt(ctx, srcFile, "cpp")
srcFiles[i] = cppFile srcFiles[i] = cppFile
genLex(ctx, srcFile, cppFile) genLex(ctx, srcFile, cppFile)
} }

View File

@@ -19,14 +19,14 @@ import (
"path/filepath" "path/filepath"
"strings" "strings"
"android/soong/common" "android/soong/android"
) )
func init() { func init() {
common.RegisterMakeVarsProvider(pctx, makeVarsProvider) android.RegisterMakeVarsProvider(pctx, makeVarsProvider)
} }
func makeVarsProvider(ctx common.MakeVarsContext) { func makeVarsProvider(ctx android.MakeVarsContext) {
ctx.Strict("LLVM_PREBUILTS_VERSION", "${clangVersion}") ctx.Strict("LLVM_PREBUILTS_VERSION", "${clangVersion}")
ctx.Strict("LLVM_PREBUILTS_BASE", "${clangBase}") ctx.Strict("LLVM_PREBUILTS_BASE", "${clangBase}")
ctx.Strict("LLVM_PREBUILTS_PATH", "${clangBin}") ctx.Strict("LLVM_PREBUILTS_PATH", "${clangBin}")
@@ -35,32 +35,32 @@ func makeVarsProvider(ctx common.MakeVarsContext) {
ctx.Strict("LLVM_AS", "${clangBin}/llvm-as") ctx.Strict("LLVM_AS", "${clangBin}/llvm-as")
ctx.Strict("LLVM_LINK", "${clangBin}/llvm-link") ctx.Strict("LLVM_LINK", "${clangBin}/llvm-link")
hostType := common.CurrentHostType() hostType := android.CurrentHostType()
arches := ctx.Config().HostArches[hostType] arches := ctx.Config().HostArches[hostType]
makeVarsToolchain(ctx, "", common.Host, hostType, arches[0]) makeVarsToolchain(ctx, "", android.Host, hostType, arches[0])
if len(arches) > 1 { if len(arches) > 1 {
makeVarsToolchain(ctx, "2ND_", common.Host, hostType, arches[1]) makeVarsToolchain(ctx, "2ND_", android.Host, hostType, arches[1])
} }
if winArches, ok := ctx.Config().HostArches[common.Windows]; ok { if winArches, ok := ctx.Config().HostArches[android.Windows]; ok {
makeVarsToolchain(ctx, "", common.Host, common.Windows, winArches[0]) makeVarsToolchain(ctx, "", android.Host, android.Windows, winArches[0])
if len(winArches) > 1 { if len(winArches) > 1 {
makeVarsToolchain(ctx, "2ND_", common.Host, common.Windows, winArches[1]) makeVarsToolchain(ctx, "2ND_", android.Host, android.Windows, winArches[1])
} }
} }
arches = ctx.Config().DeviceArches arches = ctx.Config().DeviceArches
makeVarsToolchain(ctx, "", common.Device, common.NoHostType, arches[0]) makeVarsToolchain(ctx, "", android.Device, android.NoHostType, arches[0])
if len(arches) > 1 { if len(arches) > 1 {
makeVarsToolchain(ctx, "2ND_", common.Device, common.NoHostType, arches[1]) makeVarsToolchain(ctx, "2ND_", android.Device, android.NoHostType, arches[1])
} }
} }
func makeVarsToolchain(ctx common.MakeVarsContext, secondPrefix string, func makeVarsToolchain(ctx android.MakeVarsContext, secondPrefix string,
hod common.HostOrDevice, ht common.HostType, arch common.Arch) { hod android.HostOrDevice, ht android.HostType, arch android.Arch) {
var typePrefix string var typePrefix string
if hod.Host() { if hod.Host() {
if ht == common.Windows { if ht == android.Windows {
typePrefix = "HOST_CROSS_" typePrefix = "HOST_CROSS_"
} else { } else {
typePrefix = "HOST_" typePrefix = "HOST_"
@@ -102,7 +102,7 @@ func makeVarsToolchain(ctx common.MakeVarsContext, secondPrefix string,
if toolchain.ClangSupported() { if toolchain.ClangSupported() {
clangPrefix := secondPrefix + "CLANG_" + typePrefix clangPrefix := secondPrefix + "CLANG_" + typePrefix
clangExtras := "-target " + toolchain.ClangTriple() clangExtras := "-target " + toolchain.ClangTriple()
if ht != common.Darwin { if ht != android.Darwin {
clangExtras += " -B" + filepath.Join(toolchain.GccRoot(), toolchain.GccTriple(), "bin") clangExtras += " -B" + filepath.Join(toolchain.GccRoot(), toolchain.GccTriple(), "bin")
} }
@@ -131,7 +131,7 @@ func makeVarsToolchain(ctx common.MakeVarsContext, secondPrefix string,
ctx.Strict(makePrefix+"CC", gccCmd(toolchain, "gcc")) ctx.Strict(makePrefix+"CC", gccCmd(toolchain, "gcc"))
ctx.Strict(makePrefix+"CXX", gccCmd(toolchain, "g++")) ctx.Strict(makePrefix+"CXX", gccCmd(toolchain, "g++"))
if ht == common.Darwin { if ht == android.Darwin {
ctx.Strict(makePrefix+"AR", "${macArPath}") ctx.Strict(makePrefix+"AR", "${macArPath}")
} else { } else {
ctx.Strict(makePrefix+"AR", gccCmd(toolchain, "ar")) ctx.Strict(makePrefix+"AR", gccCmd(toolchain, "ar"))
@@ -139,7 +139,7 @@ func makeVarsToolchain(ctx common.MakeVarsContext, secondPrefix string,
ctx.Strict(makePrefix+"NM", gccCmd(toolchain, "nm")) ctx.Strict(makePrefix+"NM", gccCmd(toolchain, "nm"))
} }
if ht == common.Windows { if ht == android.Windows {
ctx.Strict(makePrefix+"OBJDUMP", gccCmd(toolchain, "objdump")) ctx.Strict(makePrefix+"OBJDUMP", gccCmd(toolchain, "objdump"))
} }

View File

@@ -17,7 +17,7 @@ package cc
import ( import (
"strings" "strings"
"android/soong/common" "android/soong/android"
) )
var ( var (
@@ -87,7 +87,7 @@ const (
) )
func init() { func init() {
common.RegisterArchFeatures(common.Mips64, "mips64r6", android.RegisterArchFeatures(android.Mips64, "mips64r6",
"rev6") "rev6")
pctx.StaticVariable("mips64GccVersion", mips64GccVersion) pctx.StaticVariable("mips64GccVersion", mips64GccVersion)
@@ -185,7 +185,7 @@ func (t *toolchainMips64) ClangLdflags() string {
return "${mips64ClangLdflags}" return "${mips64ClangLdflags}"
} }
func mips64ToolchainFactory(arch common.Arch) Toolchain { func mips64ToolchainFactory(arch android.Arch) Toolchain {
return &toolchainMips64{ return &toolchainMips64{
cflags: "${mips64Cflags}", cflags: "${mips64Cflags}",
clangCflags: "${mips64ClangCflags}", clangCflags: "${mips64ClangCflags}",
@@ -195,5 +195,5 @@ func mips64ToolchainFactory(arch common.Arch) Toolchain {
} }
func init() { func init() {
registerDeviceToolchainFactory(common.Mips64, mips64ToolchainFactory) registerDeviceToolchainFactory(android.Mips64, mips64ToolchainFactory)
} }

View File

@@ -17,7 +17,7 @@ package cc
import ( import (
"strings" "strings"
"android/soong/common" "android/soong/android"
) )
var ( var (
@@ -122,7 +122,7 @@ const (
) )
func init() { func init() {
common.RegisterArchFeatures(common.Mips, "mips32r6", android.RegisterArchFeatures(android.Mips, "mips32r6",
"rev6") "rev6")
pctx.StaticVariable("mipsGccVersion", mipsGccVersion) pctx.StaticVariable("mipsGccVersion", mipsGccVersion)
@@ -233,7 +233,7 @@ func (t *toolchainMips) ClangLdflags() string {
return "${mipsClangLdflags}" return "${mipsClangLdflags}"
} }
func mipsToolchainFactory(arch common.Arch) Toolchain { func mipsToolchainFactory(arch android.Arch) Toolchain {
return &toolchainMips{ return &toolchainMips{
cflags: "${mipsCflags}", cflags: "${mipsCflags}",
clangCflags: "${mipsClangCflags}", clangCflags: "${mipsClangCflags}",
@@ -243,5 +243,5 @@ func mipsToolchainFactory(arch common.Arch) Toolchain {
} }
func init() { func init() {
registerDeviceToolchainFactory(common.Mips, mipsToolchainFactory) registerDeviceToolchainFactory(android.Mips, mipsToolchainFactory)
} }

View File

@@ -20,7 +20,7 @@ import (
"github.com/google/blueprint" "github.com/google/blueprint"
"android/soong/common" "android/soong/android"
) )
type sanitizerType int type sanitizerType int
@@ -213,7 +213,7 @@ func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags) Flags {
} }
if sanitize.Properties.Sanitize.Address { if sanitize.Properties.Sanitize.Address {
if ctx.Arch().ArchType == common.Arm { if ctx.Arch().ArchType == android.Arm {
// Frame pointer based unwinder in ASan requires ARM frame setup. // Frame pointer based unwinder in ASan requires ARM frame setup.
// TODO: put in flags? // TODO: put in flags?
flags.RequiredInstructionSet = "arm" flags.RequiredInstructionSet = "arm"
@@ -268,7 +268,7 @@ func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags) Flags {
} }
} }
blacklist := common.OptionalPathForModuleSrc(ctx, sanitize.Properties.Sanitize.Blacklist) blacklist := android.OptionalPathForModuleSrc(ctx, sanitize.Properties.Sanitize.Blacklist)
if blacklist.Valid() { if blacklist.Valid() {
flags.CFlags = append(flags.CFlags, "-fsanitize-blacklist="+blacklist.String()) flags.CFlags = append(flags.CFlags, "-fsanitize-blacklist="+blacklist.String())
flags.CFlagsDeps = append(flags.CFlagsDeps, blacklist.Path()) flags.CFlagsDeps = append(flags.CFlagsDeps, blacklist.Path())
@@ -311,8 +311,8 @@ func (sanitize *sanitize) SetSanitizer(t sanitizerType, b bool) {
} }
// Propagate asan requirements down from binaries // Propagate asan requirements down from binaries
func sanitizerDepsMutator(t sanitizerType) func(common.AndroidTopDownMutatorContext) { func sanitizerDepsMutator(t sanitizerType) func(android.TopDownMutatorContext) {
return func(mctx common.AndroidTopDownMutatorContext) { return func(mctx android.TopDownMutatorContext) {
if c, ok := mctx.Module().(*Module); ok && c.sanitize.Sanitizer(t) { if c, ok := mctx.Module().(*Module); ok && c.sanitize.Sanitizer(t) {
mctx.VisitDepsDepthFirst(func(module blueprint.Module) { mctx.VisitDepsDepthFirst(func(module blueprint.Module) {
if d, ok := mctx.Module().(*Module); ok && c.sanitize != nil && if d, ok := mctx.Module().(*Module); ok && c.sanitize != nil &&
@@ -325,8 +325,8 @@ func sanitizerDepsMutator(t sanitizerType) func(common.AndroidTopDownMutatorCont
} }
// Create asan variants for modules that need them // Create asan variants for modules that need them
func sanitizerMutator(t sanitizerType) func(common.AndroidBottomUpMutatorContext) { func sanitizerMutator(t sanitizerType) func(android.BottomUpMutatorContext) {
return func(mctx common.AndroidBottomUpMutatorContext) { return func(mctx android.BottomUpMutatorContext) {
if c, ok := mctx.Module().(*Module); ok && c.sanitize != nil { if c, ok := mctx.Module().(*Module); ok && c.sanitize != nil {
if d, ok := c.linker.(baseLinkerInterface); ok && d.isDependencyRoot() && c.sanitize.Sanitizer(t) { if d, ok := c.linker.(baseLinkerInterface); ok && d.isDependencyRoot() && c.sanitize.Sanitizer(t) {
modules := mctx.CreateVariations(t.String()) modules := mctx.CreateVariations(t.String())

View File

@@ -15,7 +15,7 @@
package cc package cc
import ( import (
"android/soong/common" "android/soong/android"
"fmt" "fmt"
) )
@@ -52,7 +52,7 @@ func (stl *stl) begin(ctx BaseModuleContext) {
ctx.ModuleErrorf("stl: %q is not a supported STL with sdk_version set", stl.Properties.Stl) ctx.ModuleErrorf("stl: %q is not a supported STL with sdk_version set", stl.Properties.Stl)
return "" return ""
} }
} else if ctx.HostType() == common.Windows { } else if ctx.HostType() == android.Windows {
switch stl.Properties.Stl { switch stl.Properties.Stl {
case "libc++", "libc++_static", "libstdc++", "": case "libc++", "libc++_static", "libstdc++", "":
// libc++ is not supported on mingw // libc++ is not supported on mingw
@@ -97,7 +97,7 @@ func (stl *stl) deps(ctx BaseModuleContext, deps Deps) Deps {
deps.StaticLibs = append(deps.StaticLibs, stl.Properties.SelectedStl) deps.StaticLibs = append(deps.StaticLibs, stl.Properties.SelectedStl)
} }
if ctx.Device() { if ctx.Device() {
if ctx.Arch().ArchType == common.Arm { if ctx.Arch().ArchType == android.Arm {
deps.StaticLibs = append(deps.StaticLibs, "libunwind_llvm") deps.StaticLibs = append(deps.StaticLibs, "libunwind_llvm")
} }
if ctx.staticBinary() { if ctx.staticBinary() {
@@ -138,7 +138,7 @@ func (stl *stl) flags(ctx ModuleContext, flags Flags) Flags {
flags.LdFlags = append(flags.LdFlags, hostDynamicGccLibs[ctx.HostType()]...) flags.LdFlags = append(flags.LdFlags, hostDynamicGccLibs[ctx.HostType()]...)
} }
} else { } else {
if ctx.Arch().ArchType == common.Arm { if ctx.Arch().ArchType == android.Arm {
flags.LdFlags = append(flags.LdFlags, "-Wl,--exclude-libs,libunwind_llvm.a") flags.LdFlags = append(flags.LdFlags, "-Wl,--exclude-libs,libunwind_llvm.a")
} }
} }
@@ -147,14 +147,14 @@ func (stl *stl) flags(ctx ModuleContext, flags Flags) Flags {
// tree is in good enough shape to not need it. // tree is in good enough shape to not need it.
// Host builds will use GNU libstdc++. // Host builds will use GNU libstdc++.
if ctx.Device() { if ctx.Device() {
flags.CFlags = append(flags.CFlags, "-I"+common.PathForSource(ctx, "bionic/libstdc++/include").String()) flags.CFlags = append(flags.CFlags, "-I"+android.PathForSource(ctx, "bionic/libstdc++/include").String())
} else { } else {
// Host builds will use the system C++. libc++ on Darwin, GNU libstdc++ everywhere else // Host builds will use the system C++. libc++ on Darwin, GNU libstdc++ everywhere else
flags.CppFlags = append(flags.CppFlags, flags.Toolchain.SystemCppCppflags()) flags.CppFlags = append(flags.CppFlags, flags.Toolchain.SystemCppCppflags())
flags.LdFlags = append(flags.LdFlags, flags.Toolchain.SystemCppLdflags()) flags.LdFlags = append(flags.LdFlags, flags.Toolchain.SystemCppLdflags())
} }
case "ndk_system": case "ndk_system":
ndkSrcRoot := common.PathForSource(ctx, "prebuilts/ndk/current/sources/cxx-stl/system/include") ndkSrcRoot := android.PathForSource(ctx, "prebuilts/ndk/current/sources/cxx-stl/system/include")
flags.CFlags = append(flags.CFlags, "-isystem "+ndkSrcRoot.String()) flags.CFlags = append(flags.CFlags, "-isystem "+ndkSrcRoot.String())
case "ndk_libc++_shared", "ndk_libc++_static": case "ndk_libc++_shared", "ndk_libc++_static":
// TODO(danalbert): This really shouldn't be here... // TODO(danalbert): This really shouldn't be here...
@@ -179,20 +179,20 @@ func (stl *stl) flags(ctx ModuleContext, flags Flags) Flags {
return flags return flags
} }
var hostDynamicGccLibs, hostStaticGccLibs map[common.HostType][]string var hostDynamicGccLibs, hostStaticGccLibs map[android.HostType][]string
func init() { func init() {
hostDynamicGccLibs = map[common.HostType][]string{ hostDynamicGccLibs = map[android.HostType][]string{
common.Linux: []string{"-lgcc_s", "-lgcc", "-lc", "-lgcc_s", "-lgcc"}, android.Linux: []string{"-lgcc_s", "-lgcc", "-lc", "-lgcc_s", "-lgcc"},
common.Darwin: []string{"-lc", "-lSystem"}, android.Darwin: []string{"-lc", "-lSystem"},
common.Windows: []string{"-lmsvcr110", "-lmingw32", "-lgcc", "-lmoldname", android.Windows: []string{"-lmsvcr110", "-lmingw32", "-lgcc", "-lmoldname",
"-lmingwex", "-lmsvcrt", "-ladvapi32", "-lshell32", "-luser32", "-lmingwex", "-lmsvcrt", "-ladvapi32", "-lshell32", "-luser32",
"-lkernel32", "-lmingw32", "-lgcc", "-lmoldname", "-lmingwex", "-lkernel32", "-lmingw32", "-lgcc", "-lmoldname", "-lmingwex",
"-lmsvcrt"}, "-lmsvcrt"},
} }
hostStaticGccLibs = map[common.HostType][]string{ hostStaticGccLibs = map[android.HostType][]string{
common.Linux: []string{"-Wl,--start-group", "-lgcc", "-lgcc_eh", "-lc", "-Wl,--end-group"}, android.Linux: []string{"-Wl,--start-group", "-lgcc", "-lgcc_eh", "-lc", "-Wl,--end-group"},
common.Darwin: []string{"NO_STATIC_HOST_BINARIES_ON_DARWIN"}, android.Darwin: []string{"NO_STATIC_HOST_BINARIES_ON_DARWIN"},
common.Windows: []string{"NO_STATIC_HOST_BINARIES_ON_WINDOWS"}, android.Windows: []string{"NO_STATIC_HOST_BINARIES_ON_WINDOWS"},
} }
} }

View File

@@ -17,28 +17,28 @@ package cc
import ( import (
"fmt" "fmt"
"android/soong/common" "android/soong/android"
) )
type toolchainFactory func(arch common.Arch) Toolchain type toolchainFactory func(arch android.Arch) Toolchain
var toolchainFactories = map[common.HostOrDevice]map[common.HostType]map[common.ArchType]toolchainFactory{ var toolchainFactories = map[android.HostOrDevice]map[android.HostType]map[android.ArchType]toolchainFactory{
common.Host: map[common.HostType]map[common.ArchType]toolchainFactory{ android.Host: map[android.HostType]map[android.ArchType]toolchainFactory{
common.Linux: make(map[common.ArchType]toolchainFactory), android.Linux: make(map[android.ArchType]toolchainFactory),
common.Darwin: make(map[common.ArchType]toolchainFactory), android.Darwin: make(map[android.ArchType]toolchainFactory),
common.Windows: make(map[common.ArchType]toolchainFactory), android.Windows: make(map[android.ArchType]toolchainFactory),
}, },
common.Device: map[common.HostType]map[common.ArchType]toolchainFactory{ android.Device: map[android.HostType]map[android.ArchType]toolchainFactory{
common.NoHostType: make(map[common.ArchType]toolchainFactory), android.NoHostType: make(map[android.ArchType]toolchainFactory),
}, },
} }
func registerDeviceToolchainFactory(arch common.ArchType, factory toolchainFactory) { func registerDeviceToolchainFactory(arch android.ArchType, factory toolchainFactory) {
toolchainFactories[common.Device][common.NoHostType][arch] = factory toolchainFactories[android.Device][android.NoHostType][arch] = factory
} }
func registerHostToolchainFactory(ht common.HostType, arch common.ArchType, factory toolchainFactory) { func registerHostToolchainFactory(ht android.HostType, arch android.ArchType, factory toolchainFactory) {
toolchainFactories[common.Host][ht][arch] = factory toolchainFactories[android.Host][ht][arch] = factory
} }
type Toolchain interface { type Toolchain interface {

View File

@@ -19,25 +19,25 @@ import (
"regexp" "regexp"
"strings" "strings"
"android/soong/common" "android/soong/android"
) )
// Efficiently converts a list of include directories to a single string // Efficiently converts a list of include directories to a single string
// of cflags with -I prepended to each directory. // of cflags with -I prepended to each directory.
func includeDirsToFlags(dirs common.Paths) string { func includeDirsToFlags(dirs android.Paths) string {
return common.JoinWithPrefix(dirs.Strings(), "-I") return android.JoinWithPrefix(dirs.Strings(), "-I")
} }
func includeFilesToFlags(files common.Paths) string { func includeFilesToFlags(files android.Paths) string {
return common.JoinWithPrefix(files.Strings(), "-include ") return android.JoinWithPrefix(files.Strings(), "-include ")
} }
func ldDirsToFlags(dirs []string) string { func ldDirsToFlags(dirs []string) string {
return common.JoinWithPrefix(dirs, "-L") return android.JoinWithPrefix(dirs, "-L")
} }
func libNamesToFlags(names []string) string { func libNamesToFlags(names []string) string {
return common.JoinWithPrefix(names, "-l") return android.JoinWithPrefix(names, "-l")
} }
func indexList(s string, list []string) int { func indexList(s string, list []string) int {

View File

@@ -17,7 +17,7 @@ package cc
import ( import (
"strings" "strings"
"android/soong/common" "android/soong/android"
) )
var ( var (
@@ -99,13 +99,13 @@ const (
) )
func init() { func init() {
common.RegisterArchFeatures(common.X86_64, "", android.RegisterArchFeatures(android.X86_64, "",
"ssse3", "ssse3",
"sse4", "sse4",
"sse4_1", "sse4_1",
"sse4_2", "sse4_2",
"popcnt") "popcnt")
common.RegisterArchFeatures(common.X86_64, "haswell", android.RegisterArchFeatures(android.X86_64, "haswell",
"ssse3", "ssse3",
"sse4", "sse4",
"sse4_1", "sse4_1",
@@ -113,7 +113,7 @@ func init() {
"aes_ni", "aes_ni",
"avx", "avx",
"popcnt") "popcnt")
common.RegisterArchFeatures(common.X86_64, "ivybridge", android.RegisterArchFeatures(android.X86_64, "ivybridge",
"ssse3", "ssse3",
"sse4", "sse4",
"sse4_1", "sse4_1",
@@ -121,13 +121,13 @@ func init() {
"aes_ni", "aes_ni",
"avx", "avx",
"popcnt") "popcnt")
common.RegisterArchFeatures(common.X86_64, "sandybridge", android.RegisterArchFeatures(android.X86_64, "sandybridge",
"ssse3", "ssse3",
"sse4", "sse4",
"sse4_1", "sse4_1",
"sse4_2", "sse4_2",
"popcnt") "popcnt")
common.RegisterArchFeatures(common.X86_64, "silvermont", android.RegisterArchFeatures(android.X86_64, "silvermont",
"ssse3", "ssse3",
"sse4", "sse4",
"sse4_1", "sse4_1",
@@ -239,7 +239,7 @@ func (t *toolchainX86_64) ClangLdflags() string {
return "${x86_64Ldflags}" return "${x86_64Ldflags}"
} }
func x86_64ToolchainFactory(arch common.Arch) Toolchain { func x86_64ToolchainFactory(arch android.Arch) Toolchain {
toolchainCflags := []string{ toolchainCflags := []string{
"${x86_64ToolchainCflags}", "${x86_64ToolchainCflags}",
"${x86_64" + arch.ArchVariant + "VariantCflags}", "${x86_64" + arch.ArchVariant + "VariantCflags}",
@@ -262,5 +262,5 @@ func x86_64ToolchainFactory(arch common.Arch) Toolchain {
} }
func init() { func init() {
registerDeviceToolchainFactory(common.X86_64, x86_64ToolchainFactory) registerDeviceToolchainFactory(android.X86_64, x86_64ToolchainFactory)
} }

View File

@@ -5,7 +5,7 @@ import (
"os/exec" "os/exec"
"strings" "strings"
"android/soong/common" "android/soong/android"
) )
var ( var (
@@ -97,7 +97,7 @@ func init() {
}) })
pctx.StaticVariable("macToolchainRoot", "${macSdkPath}/Toolchains/XcodeDefault.xctoolchain") pctx.StaticVariable("macToolchainRoot", "${macSdkPath}/Toolchains/XcodeDefault.xctoolchain")
pctx.VariableFunc("macSdkRoot", func(config interface{}) (string, error) { pctx.VariableFunc("macSdkRoot", func(config interface{}) (string, error) {
return xcrunSdk(config.(common.Config), "--show-sdk-path") return xcrunSdk(config.(android.Config), "--show-sdk-path")
}) })
pctx.StaticVariable("macSdkVersion", darwinSupportedSdkVersions[0]) pctx.StaticVariable("macSdkVersion", darwinSupportedSdkVersions[0])
pctx.VariableFunc("macArPath", func(config interface{}) (string, error) { pctx.VariableFunc("macArPath", func(config interface{}) (string, error) {
@@ -138,7 +138,7 @@ func init() {
pctx.StaticVariable("darwinX8664ClangLdflags", strings.Join(darwinX8664ClangLdflags, " ")) pctx.StaticVariable("darwinX8664ClangLdflags", strings.Join(darwinX8664ClangLdflags, " "))
} }
func xcrunSdk(config common.Config, arg string) (string, error) { func xcrunSdk(config android.Config, arg string) (string, error) {
if selected := config.Getenv("MAC_SDK_VERSION"); selected != "" { if selected := config.Getenv("MAC_SDK_VERSION"); selected != "" {
if !inList(selected, darwinSupportedSdkVersions) { if !inList(selected, darwinSupportedSdkVersions) {
return "", fmt.Errorf("MAC_SDK_VERSION %s isn't supported: %q", selected, darwinSupportedSdkVersions) return "", fmt.Errorf("MAC_SDK_VERSION %s isn't supported: %q", selected, darwinSupportedSdkVersions)
@@ -261,15 +261,15 @@ func (t *toolchainDarwin) SystemCppLdflags() string {
var toolchainDarwinX86Singleton Toolchain = &toolchainDarwinX86{} var toolchainDarwinX86Singleton Toolchain = &toolchainDarwinX86{}
var toolchainDarwinX8664Singleton Toolchain = &toolchainDarwinX8664{} var toolchainDarwinX8664Singleton Toolchain = &toolchainDarwinX8664{}
func darwinX86ToolchainFactory(arch common.Arch) Toolchain { func darwinX86ToolchainFactory(arch android.Arch) Toolchain {
return toolchainDarwinX86Singleton return toolchainDarwinX86Singleton
} }
func darwinX8664ToolchainFactory(arch common.Arch) Toolchain { func darwinX8664ToolchainFactory(arch android.Arch) Toolchain {
return toolchainDarwinX8664Singleton return toolchainDarwinX8664Singleton
} }
func init() { func init() {
registerHostToolchainFactory(common.Darwin, common.X86, darwinX86ToolchainFactory) registerHostToolchainFactory(android.Darwin, android.X86, darwinX86ToolchainFactory)
registerHostToolchainFactory(common.Darwin, common.X86_64, darwinX8664ToolchainFactory) registerHostToolchainFactory(android.Darwin, android.X86_64, darwinX8664ToolchainFactory)
} }

View File

@@ -17,7 +17,7 @@ package cc
import ( import (
"strings" "strings"
"android/soong/common" "android/soong/android"
) )
var ( var (
@@ -113,16 +113,16 @@ const (
) )
func init() { func init() {
common.RegisterArchFeatures(common.X86, "x86_64", android.RegisterArchFeatures(android.X86, "x86_64",
"ssse3", "ssse3",
"sse4", "sse4",
"sse4_1", "sse4_1",
"sse4_2", "sse4_2",
"popcnt") "popcnt")
common.RegisterArchFeatures(common.X86, "atom", android.RegisterArchFeatures(android.X86, "atom",
"ssse3", "ssse3",
"movbe") "movbe")
common.RegisterArchFeatures(common.X86, "haswell", android.RegisterArchFeatures(android.X86, "haswell",
"ssse3", "ssse3",
"sse4", "sse4",
"sse4_1", "sse4_1",
@@ -131,7 +131,7 @@ func init() {
"avx", "avx",
"popcnt", "popcnt",
"movbe") "movbe")
common.RegisterArchFeatures(common.X86, "ivybridge", android.RegisterArchFeatures(android.X86, "ivybridge",
"ssse3", "ssse3",
"sse4", "sse4",
"sse4_1", "sse4_1",
@@ -139,13 +139,13 @@ func init() {
"aes_ni", "aes_ni",
"avx", "avx",
"popcnt") "popcnt")
common.RegisterArchFeatures(common.X86, "sandybridge", android.RegisterArchFeatures(android.X86, "sandybridge",
"ssse3", "ssse3",
"sse4", "sse4",
"sse4_1", "sse4_1",
"sse4_2", "sse4_2",
"popcnt") "popcnt")
common.RegisterArchFeatures(common.X86, "silvermont", android.RegisterArchFeatures(android.X86, "silvermont",
"ssse3", "ssse3",
"sse4", "sse4",
"sse4_1", "sse4_1",
@@ -262,7 +262,7 @@ func (toolchainX86) AddressSanitizerRuntimeLibrary() string {
return "libclang_rt.asan-i686-android.so" return "libclang_rt.asan-i686-android.so"
} }
func x86ToolchainFactory(arch common.Arch) Toolchain { func x86ToolchainFactory(arch android.Arch) Toolchain {
toolchainCflags := []string{ toolchainCflags := []string{
"${x86ToolchainCflags}", "${x86ToolchainCflags}",
"${x86" + arch.ArchVariant + "VariantCflags}", "${x86" + arch.ArchVariant + "VariantCflags}",
@@ -285,5 +285,5 @@ func x86ToolchainFactory(arch common.Arch) Toolchain {
} }
func init() { func init() {
registerDeviceToolchainFactory(common.X86, x86ToolchainFactory) registerDeviceToolchainFactory(android.X86, x86ToolchainFactory)
} }

View File

@@ -3,7 +3,7 @@ package cc
import ( import (
"strings" "strings"
"android/soong/common" "android/soong/android"
) )
var ( var (
@@ -227,15 +227,15 @@ func (t *toolchainLinuxX8664) ClangLdflags() string {
var toolchainLinuxX86Singleton Toolchain = &toolchainLinuxX86{} var toolchainLinuxX86Singleton Toolchain = &toolchainLinuxX86{}
var toolchainLinuxX8664Singleton Toolchain = &toolchainLinuxX8664{} var toolchainLinuxX8664Singleton Toolchain = &toolchainLinuxX8664{}
func linuxX86ToolchainFactory(arch common.Arch) Toolchain { func linuxX86ToolchainFactory(arch android.Arch) Toolchain {
return toolchainLinuxX86Singleton return toolchainLinuxX86Singleton
} }
func linuxX8664ToolchainFactory(arch common.Arch) Toolchain { func linuxX8664ToolchainFactory(arch android.Arch) Toolchain {
return toolchainLinuxX8664Singleton return toolchainLinuxX8664Singleton
} }
func init() { func init() {
registerHostToolchainFactory(common.Linux, common.X86, linuxX86ToolchainFactory) registerHostToolchainFactory(android.Linux, android.X86, linuxX86ToolchainFactory)
registerHostToolchainFactory(common.Linux, common.X86_64, linuxX8664ToolchainFactory) registerHostToolchainFactory(android.Linux, android.X86_64, linuxX8664ToolchainFactory)
} }

View File

@@ -17,7 +17,7 @@ package cc
import ( import (
"strings" "strings"
"android/soong/common" "android/soong/android"
) )
var ( var (
@@ -186,15 +186,15 @@ func (t *toolchainWindows) ExecutableSuffix() string {
var toolchainWindowsX86Singleton Toolchain = &toolchainWindowsX86{} var toolchainWindowsX86Singleton Toolchain = &toolchainWindowsX86{}
var toolchainWindowsX8664Singleton Toolchain = &toolchainWindowsX8664{} var toolchainWindowsX8664Singleton Toolchain = &toolchainWindowsX8664{}
func windowsX86ToolchainFactory(arch common.Arch) Toolchain { func windowsX86ToolchainFactory(arch android.Arch) Toolchain {
return toolchainWindowsX86Singleton return toolchainWindowsX86Singleton
} }
func windowsX8664ToolchainFactory(arch common.Arch) Toolchain { func windowsX8664ToolchainFactory(arch android.Arch) Toolchain {
return toolchainWindowsX8664Singleton return toolchainWindowsX8664Singleton
} }
func init() { func init() {
registerHostToolchainFactory(common.Windows, common.X86, windowsX86ToolchainFactory) registerHostToolchainFactory(android.Windows, android.X86, windowsX86ToolchainFactory)
registerHostToolchainFactory(common.Windows, common.X86_64, windowsX8664ToolchainFactory) registerHostToolchainFactory(android.Windows, android.X86_64, windowsX8664ToolchainFactory)
} }

View File

@@ -24,7 +24,7 @@ import (
"android/soong" "android/soong"
"android/soong/common" "android/soong/android"
) )
func main() { func main() {
@@ -35,7 +35,7 @@ func main() {
ctx := soong.NewContext() ctx := soong.NewContext()
configuration, err := common.NewConfig(srcDir, bootstrap.BuildDir) configuration, err := android.NewConfig(srcDir, bootstrap.BuildDir)
if err != nil { if err != nil {
fmt.Fprintf(os.Stderr, "%s", err) fmt.Fprintf(os.Stderr, "%s", err)
os.Exit(1) os.Exit(1)

View File

@@ -18,18 +18,18 @@ import (
"github.com/google/blueprint" "github.com/google/blueprint"
"android/soong" "android/soong"
"android/soong/common" "android/soong/android"
) )
func init() { func init() {
soong.RegisterModuleType("gensrcs", GenSrcsFactory) soong.RegisterModuleType("gensrcs", GenSrcsFactory)
soong.RegisterModuleType("genrule", GenRuleFactory) soong.RegisterModuleType("genrule", GenRuleFactory)
common.RegisterBottomUpMutator("genrule_deps", genruleDepsMutator) android.RegisterBottomUpMutator("genrule_deps", genruleDepsMutator)
} }
var ( var (
pctx = common.NewPackageContext("android/soong/genrule") pctx = android.NewPackageContext("android/soong/genrule")
) )
func init() { func init() {
@@ -38,12 +38,12 @@ func init() {
} }
type SourceFileGenerator interface { type SourceFileGenerator interface {
GeneratedSourceFiles() common.Paths GeneratedSourceFiles() android.Paths
GeneratedHeaderDir() common.Path GeneratedHeaderDir() android.Path
} }
type HostToolProvider interface { type HostToolProvider interface {
HostToolPath() common.OptionalPath HostToolPath() android.OptionalPath
} }
type generatorProperties struct { type generatorProperties struct {
@@ -64,47 +64,47 @@ type generatorProperties struct {
} }
type generator struct { type generator struct {
common.AndroidModuleBase android.ModuleBase
properties generatorProperties properties generatorProperties
tasks taskFunc tasks taskFunc
deps common.Paths deps android.Paths
rule blueprint.Rule rule blueprint.Rule
genPath common.Path genPath android.Path
outputFiles common.Paths outputFiles android.Paths
} }
type taskFunc func(ctx common.AndroidModuleContext) []generateTask type taskFunc func(ctx android.ModuleContext) []generateTask
type generateTask struct { type generateTask struct {
in common.Paths in android.Paths
out common.ModuleGenPath out android.ModuleGenPath
} }
func (g *generator) GeneratedSourceFiles() common.Paths { func (g *generator) GeneratedSourceFiles() android.Paths {
return g.outputFiles return g.outputFiles
} }
func (g *generator) GeneratedHeaderDir() common.Path { func (g *generator) GeneratedHeaderDir() android.Path {
return g.genPath return g.genPath
} }
func genruleDepsMutator(ctx common.AndroidBottomUpMutatorContext) { func genruleDepsMutator(ctx android.BottomUpMutatorContext) {
if g, ok := ctx.Module().(*generator); ok { if g, ok := ctx.Module().(*generator); ok {
if g.properties.Tool != "" { if g.properties.Tool != "" {
ctx.AddFarVariationDependencies([]blueprint.Variation{ ctx.AddFarVariationDependencies([]blueprint.Variation{
{"host_or_device", common.Host.String()}, {"host_or_device", android.Host.String()},
{"host_type", common.CurrentHostType().String()}, {"host_type", android.CurrentHostType().String()},
}, nil, g.properties.Tool) }, nil, g.properties.Tool)
} }
} }
} }
func (g *generator) GenerateAndroidBuildActions(ctx common.AndroidModuleContext) { func (g *generator) GenerateAndroidBuildActions(ctx android.ModuleContext) {
if g.properties.Tool != "" && g.properties.Tool_file != "" { if g.properties.Tool != "" && g.properties.Tool_file != "" {
ctx.ModuleErrorf("`tool` and `tool_file` may not be specified at the same time") ctx.ModuleErrorf("`tool` and `tool_file` may not be specified at the same time")
return return
@@ -116,7 +116,7 @@ func (g *generator) GenerateAndroidBuildActions(ctx common.AndroidModuleContext)
var tool string var tool string
if g.properties.Tool_file != "" { if g.properties.Tool_file != "" {
toolpath := common.PathForModuleSrc(ctx, g.properties.Tool_file) toolpath := android.PathForModuleSrc(ctx, g.properties.Tool_file)
g.deps = append(g.deps, toolpath) g.deps = append(g.deps, toolpath)
tool = toolpath.String() tool = toolpath.String()
} else if g.properties.Tool != "" { } else if g.properties.Tool != "" {
@@ -135,15 +135,15 @@ func (g *generator) GenerateAndroidBuildActions(ctx common.AndroidModuleContext)
}) })
} }
g.genPath = common.PathForModuleGen(ctx, "") g.genPath = android.PathForModuleGen(ctx, "")
for _, task := range g.tasks(ctx) { for _, task := range g.tasks(ctx) {
g.generateSourceFile(ctx, task, tool) g.generateSourceFile(ctx, task, tool)
} }
} }
func (g *generator) generateSourceFile(ctx common.AndroidModuleContext, task generateTask, tool string) { func (g *generator) generateSourceFile(ctx android.ModuleContext, task generateTask, tool string) {
ctx.ModuleBuild(pctx, common.ModuleBuildParams{ ctx.ModuleBuild(pctx, android.ModuleBuildParams{
Rule: g.rule, Rule: g.rule,
Output: task.out, Output: task.out,
Inputs: task.in, Inputs: task.in,
@@ -163,19 +163,19 @@ func generatorFactory(tasks taskFunc, props ...interface{}) (blueprint.Module, [
props = append(props, &module.properties) props = append(props, &module.properties)
return common.InitAndroidModule(module, props...) return android.InitAndroidModule(module, props...)
} }
func GenSrcsFactory() (blueprint.Module, []interface{}) { func GenSrcsFactory() (blueprint.Module, []interface{}) {
properties := &genSrcsProperties{} properties := &genSrcsProperties{}
tasks := func(ctx common.AndroidModuleContext) []generateTask { tasks := func(ctx android.ModuleContext) []generateTask {
srcFiles := ctx.ExpandSources(properties.Srcs, nil) srcFiles := ctx.ExpandSources(properties.Srcs, nil)
tasks := make([]generateTask, 0, len(srcFiles)) tasks := make([]generateTask, 0, len(srcFiles))
for _, in := range srcFiles { for _, in := range srcFiles {
tasks = append(tasks, generateTask{ tasks = append(tasks, generateTask{
in: common.Paths{in}, in: android.Paths{in},
out: common.GenPathWithExt(ctx, in, properties.Output_extension), out: android.GenPathWithExt(ctx, in, properties.Output_extension),
}) })
} }
return tasks return tasks
@@ -195,11 +195,11 @@ type genSrcsProperties struct {
func GenRuleFactory() (blueprint.Module, []interface{}) { func GenRuleFactory() (blueprint.Module, []interface{}) {
properties := &genRuleProperties{} properties := &genRuleProperties{}
tasks := func(ctx common.AndroidModuleContext) []generateTask { tasks := func(ctx android.ModuleContext) []generateTask {
return []generateTask{ return []generateTask{
{ {
in: ctx.ExpandSources(properties.Srcs, nil), in: ctx.ExpandSources(properties.Srcs, nil),
out: common.PathForModuleGen(ctx, properties.Out), out: android.PathForModuleGen(ctx, properties.Out),
}, },
} }
} }

View File

@@ -17,17 +17,17 @@ package java
import ( import (
"fmt" "fmt"
"android/soong/common" "android/soong/android"
) )
func (*JavaLibrary) AndroidMk() (ret common.AndroidMkData, err error) { func (*JavaLibrary) AndroidMk() (ret android.AndroidMkData, err error) {
ret.Class = "JAVA_LIBRARIES" ret.Class = "JAVA_LIBRARIES"
// TODO // TODO
err = fmt.Errorf("Not yet implemented") err = fmt.Errorf("Not yet implemented")
return return
} }
func (*JavaPrebuilt) AndroidMk() (ret common.AndroidMkData, err error) { func (*JavaPrebuilt) AndroidMk() (ret android.AndroidMkData, err error) {
ret.Class = "JAVA_LIBRARIES" ret.Class = "JAVA_LIBRARIES"
// TODO // TODO
err = fmt.Errorf("Not yet implemented") err = fmt.Errorf("Not yet implemented")

View File

@@ -22,7 +22,7 @@ import (
"github.com/google/blueprint" "github.com/google/blueprint"
"android/soong/common" "android/soong/android"
) )
// AAR prebuilts // AAR prebuilts
@@ -61,8 +61,8 @@ type AndroidApp struct {
appProperties androidAppProperties appProperties androidAppProperties
aaptJavaFileList common.Path aaptJavaFileList android.Path
exportPackage common.Path exportPackage android.Path
} }
func (a *AndroidApp) JavaDependencies(ctx AndroidJavaModuleContext) []string { func (a *AndroidApp) JavaDependencies(ctx AndroidJavaModuleContext) []string {
@@ -80,7 +80,7 @@ func (a *AndroidApp) JavaDependencies(ctx AndroidJavaModuleContext) []string {
return deps return deps
} }
func (a *AndroidApp) GenerateJavaBuildActions(ctx common.AndroidModuleContext) { func (a *AndroidApp) GenerateJavaBuildActions(ctx android.ModuleContext) {
aaptFlags, aaptDeps, hasResources := a.aaptFlags(ctx) aaptFlags, aaptDeps, hasResources := a.aaptFlags(ctx)
if hasResources { if hasResources {
@@ -143,16 +143,16 @@ func (a *AndroidApp) GenerateJavaBuildActions(ctx common.AndroidModuleContext) {
} else if dir, _ := filepath.Split(certificate); dir == "" { } else if dir, _ := filepath.Split(certificate); dir == "" {
certificate = filepath.Join(ctx.AConfig().DefaultAppCertificateDir(ctx).String(), certificate) certificate = filepath.Join(ctx.AConfig().DefaultAppCertificateDir(ctx).String(), certificate)
} else { } else {
certificate = filepath.Join(common.PathForSource(ctx).String(), certificate) certificate = filepath.Join(android.PathForSource(ctx).String(), certificate)
} }
certificates := []string{certificate} certificates := []string{certificate}
for _, c := range a.appProperties.Additional_certificates { for _, c := range a.appProperties.Additional_certificates {
certificates = append(certificates, filepath.Join(common.PathForSource(ctx).String(), c)) certificates = append(certificates, filepath.Join(android.PathForSource(ctx).String(), c))
} }
a.outputFile = CreateAppPackage(ctx, aaptPackageFlags, a.outputFile, certificates) a.outputFile = CreateAppPackage(ctx, aaptPackageFlags, a.outputFile, certificates)
ctx.InstallFileName(common.PathForModuleInstall(ctx, "app"), ctx.ModuleName()+".apk", a.outputFile) ctx.InstallFileName(android.PathForModuleInstall(ctx, "app"), ctx.ModuleName()+".apk", a.outputFile)
} }
var aaptIgnoreFilenames = []string{ var aaptIgnoreFilenames = []string{
@@ -167,7 +167,7 @@ var aaptIgnoreFilenames = []string{
"*~", "*~",
} }
func (a *AndroidApp) aaptFlags(ctx common.AndroidModuleContext) ([]string, common.Paths, bool) { func (a *AndroidApp) aaptFlags(ctx android.ModuleContext) ([]string, android.Paths, bool) {
aaptFlags := a.appProperties.Aaptflags aaptFlags := a.appProperties.Aaptflags
hasVersionCode := false hasVersionCode := false
hasVersionName := false hasVersionName := false
@@ -183,10 +183,10 @@ func (a *AndroidApp) aaptFlags(ctx common.AndroidModuleContext) ([]string, commo
aaptFlags = append(aaptFlags, "-z") aaptFlags = append(aaptFlags, "-z")
} }
assetDirs := common.PathsWithOptionalDefaultForModuleSrc(ctx, a.appProperties.Asset_dirs, "assets") assetDirs := android.PathsWithOptionalDefaultForModuleSrc(ctx, a.appProperties.Asset_dirs, "assets")
resourceDirs := common.PathsWithOptionalDefaultForModuleSrc(ctx, a.appProperties.Android_resource_dirs, "res") resourceDirs := android.PathsWithOptionalDefaultForModuleSrc(ctx, a.appProperties.Android_resource_dirs, "res")
var overlayResourceDirs common.Paths var overlayResourceDirs android.Paths
// For every resource directory, check if there is an overlay directory with the same path. // For every resource directory, check if there is an overlay directory with the same path.
// If found, it will be prepended to the list of resource directories. // If found, it will be prepended to the list of resource directories.
for _, overlayDir := range ctx.AConfig().ResourceOverlays() { for _, overlayDir := range ctx.AConfig().ResourceOverlays() {
@@ -204,7 +204,7 @@ func (a *AndroidApp) aaptFlags(ctx common.AndroidModuleContext) ([]string, commo
// aapt needs to rerun if any files are added or modified in the assets or resource directories, // aapt needs to rerun if any files are added or modified in the assets or resource directories,
// use glob to create a filelist. // use glob to create a filelist.
var aaptDeps common.Paths var aaptDeps android.Paths
var hasResources bool var hasResources bool
for _, d := range resourceDirs { for _, d := range resourceDirs {
newDeps := ctx.Glob("app_resources", filepath.Join(d.String(), "**/*"), aaptIgnoreFilenames) newDeps := ctx.Glob("app_resources", filepath.Join(d.String(), "**/*"), aaptIgnoreFilenames)
@@ -225,20 +225,20 @@ func (a *AndroidApp) aaptFlags(ctx common.AndroidModuleContext) ([]string, commo
manifestFile = *a.properties.Manifest manifestFile = *a.properties.Manifest
} }
manifestPath := common.PathForModuleSrc(ctx, manifestFile) manifestPath := android.PathForModuleSrc(ctx, manifestFile)
aaptDeps = append(aaptDeps, manifestPath) aaptDeps = append(aaptDeps, manifestPath)
aaptFlags = append(aaptFlags, "-M "+manifestPath.String()) aaptFlags = append(aaptFlags, "-M "+manifestPath.String())
aaptFlags = append(aaptFlags, common.JoinWithPrefix(assetDirs.Strings(), "-A ")) aaptFlags = append(aaptFlags, android.JoinWithPrefix(assetDirs.Strings(), "-A "))
aaptFlags = append(aaptFlags, common.JoinWithPrefix(resourceDirs.Strings(), "-S ")) aaptFlags = append(aaptFlags, android.JoinWithPrefix(resourceDirs.Strings(), "-S "))
ctx.VisitDirectDeps(func(module blueprint.Module) { ctx.VisitDirectDeps(func(module blueprint.Module) {
var depFile common.OptionalPath var depFile android.OptionalPath
if sdkDep, ok := module.(sdkDependency); ok { if sdkDep, ok := module.(sdkDependency); ok {
depFile = common.OptionalPathForPath(sdkDep.ClasspathFile()) depFile = android.OptionalPathForPath(sdkDep.ClasspathFile())
} else if javaDep, ok := module.(JavaDependency); ok { } else if javaDep, ok := module.(JavaDependency); ok {
if ctx.OtherModuleName(module) == "framework-res" { if ctx.OtherModuleName(module) == "framework-res" {
depFile = common.OptionalPathForPath(javaDep.(*javaBase).module.(*AndroidApp).exportPackage) depFile = android.OptionalPathForPath(javaDep.(*javaBase).module.(*AndroidApp).exportPackage)
} }
} }
if depFile.Valid() { if depFile.Valid() {
@@ -278,5 +278,5 @@ func AndroidAppFactory() (blueprint.Module, []interface{}) {
module.properties.Dex = true module.properties.Dex = true
return NewJavaBase(&module.javaBase, module, common.DeviceSupported, &module.appProperties) return NewJavaBase(&module.javaBase, module, android.DeviceSupported, &module.appProperties)
} }

View File

@@ -23,7 +23,7 @@ import (
"github.com/google/blueprint" "github.com/google/blueprint"
"android/soong/common" "android/soong/android"
) )
var ( var (
@@ -79,16 +79,16 @@ func init() {
pctx.HostJavaToolVariable("signapkCmd", "signapk.jar") pctx.HostJavaToolVariable("signapkCmd", "signapk.jar")
} }
func CreateResourceJavaFiles(ctx common.AndroidModuleContext, flags []string, func CreateResourceJavaFiles(ctx android.ModuleContext, flags []string,
deps common.Paths) (common.Path, common.Path, common.Path) { deps android.Paths) (android.Path, android.Path, android.Path) {
javaDir := common.PathForModuleGen(ctx, "R") javaDir := android.PathForModuleGen(ctx, "R")
javaFileList := common.PathForModuleOut(ctx, "R.filelist") javaFileList := android.PathForModuleOut(ctx, "R.filelist")
publicResourcesFile := common.PathForModuleOut(ctx, "public_resources.xml") publicResourcesFile := android.PathForModuleOut(ctx, "public_resources.xml")
proguardOptionsFile := common.PathForModuleOut(ctx, "proguard.options") proguardOptionsFile := android.PathForModuleOut(ctx, "proguard.options")
ctx.ModuleBuild(pctx, common.ModuleBuildParams{ ctx.ModuleBuild(pctx, android.ModuleBuildParams{
Rule: aaptCreateResourceJavaFile, Rule: aaptCreateResourceJavaFile,
Outputs: common.WritablePaths{publicResourcesFile, proguardOptionsFile, javaFileList}, Outputs: android.WritablePaths{publicResourcesFile, proguardOptionsFile, javaFileList},
Implicits: deps, Implicits: deps,
Args: map[string]string{ Args: map[string]string{
"aaptFlags": strings.Join(flags, " "), "aaptFlags": strings.Join(flags, " "),
@@ -102,10 +102,10 @@ func CreateResourceJavaFiles(ctx common.AndroidModuleContext, flags []string,
return publicResourcesFile, proguardOptionsFile, javaFileList return publicResourcesFile, proguardOptionsFile, javaFileList
} }
func CreateExportPackage(ctx common.AndroidModuleContext, flags []string, deps common.Paths) common.ModuleOutPath { func CreateExportPackage(ctx android.ModuleContext, flags []string, deps android.Paths) android.ModuleOutPath {
outputFile := common.PathForModuleOut(ctx, "package-export.apk") outputFile := android.PathForModuleOut(ctx, "package-export.apk")
ctx.ModuleBuild(pctx, common.ModuleBuildParams{ ctx.ModuleBuild(pctx, android.ModuleBuildParams{
Rule: aaptCreateAssetsPackage, Rule: aaptCreateAssetsPackage,
Output: outputFile, Output: outputFile,
Implicits: deps, Implicits: deps,
@@ -117,12 +117,12 @@ func CreateExportPackage(ctx common.AndroidModuleContext, flags []string, deps c
return outputFile return outputFile
} }
func CreateAppPackage(ctx common.AndroidModuleContext, flags []string, jarFile common.Path, func CreateAppPackage(ctx android.ModuleContext, flags []string, jarFile android.Path,
certificates []string) common.Path { certificates []string) android.Path {
resourceApk := common.PathForModuleOut(ctx, "resources.apk") resourceApk := android.PathForModuleOut(ctx, "resources.apk")
ctx.ModuleBuild(pctx, common.ModuleBuildParams{ ctx.ModuleBuild(pctx, android.ModuleBuildParams{
Rule: aaptAddResources, Rule: aaptAddResources,
Output: resourceApk, Output: resourceApk,
Input: jarFile, Input: jarFile,
@@ -131,14 +131,14 @@ func CreateAppPackage(ctx common.AndroidModuleContext, flags []string, jarFile c
}, },
}) })
outputFile := common.PathForModuleOut(ctx, "package.apk") outputFile := android.PathForModuleOut(ctx, "package.apk")
var certificateArgs []string var certificateArgs []string
for _, c := range certificates { for _, c := range certificates {
certificateArgs = append(certificateArgs, c+".x509.pem", c+".pk8") certificateArgs = append(certificateArgs, c+".x509.pem", c+".pk8")
} }
ctx.ModuleBuild(pctx, common.ModuleBuildParams{ ctx.ModuleBuild(pctx, android.ModuleBuildParams{
Rule: signapk, Rule: signapk,
Output: outputFile, Output: outputFile,
Input: resourceApk, Input: resourceApk,

View File

@@ -22,14 +22,14 @@ import (
"path/filepath" "path/filepath"
"strings" "strings"
"android/soong/common" "android/soong/android"
"github.com/google/blueprint" "github.com/google/blueprint"
_ "github.com/google/blueprint/bootstrap" _ "github.com/google/blueprint/bootstrap"
) )
var ( var (
pctx = common.NewPackageContext("android/soong/java") pctx = android.NewPackageContext("android/soong/java")
// Compiling java is not conducive to proper dependency tracking. The path-matches-class-name // Compiling java is not conducive to proper dependency tracking. The path-matches-class-name
// requirement leads to unpredictable generated source file names, and a single .java file // requirement leads to unpredictable generated source file names, and a single .java file
@@ -104,24 +104,24 @@ type javaBuilderFlags struct {
} }
type jarSpec struct { type jarSpec struct {
fileList, dir common.Path fileList, dir android.Path
} }
func (j jarSpec) soongJarArgs() string { func (j jarSpec) soongJarArgs() string {
return "-C " + j.dir.String() + " -l " + j.fileList.String() return "-C " + j.dir.String() + " -l " + j.fileList.String()
} }
func TransformJavaToClasses(ctx common.AndroidModuleContext, srcFiles common.Paths, srcFileLists common.Paths, func TransformJavaToClasses(ctx android.ModuleContext, srcFiles android.Paths, srcFileLists android.Paths,
flags javaBuilderFlags, deps common.Paths) jarSpec { flags javaBuilderFlags, deps android.Paths) jarSpec {
classDir := common.PathForModuleOut(ctx, "classes") classDir := android.PathForModuleOut(ctx, "classes")
classFileList := common.PathForModuleOut(ctx, "classes.list") classFileList := android.PathForModuleOut(ctx, "classes.list")
javacFlags := flags.javacFlags + common.JoinWithPrefix(srcFileLists.Strings(), "@") javacFlags := flags.javacFlags + android.JoinWithPrefix(srcFileLists.Strings(), "@")
deps = append(deps, srcFileLists...) deps = append(deps, srcFileLists...)
ctx.ModuleBuild(pctx, common.ModuleBuildParams{ ctx.ModuleBuild(pctx, android.ModuleBuildParams{
Rule: javac, Rule: javac,
Output: classFileList, Output: classFileList,
Inputs: srcFiles, Inputs: srcFiles,
@@ -137,12 +137,12 @@ func TransformJavaToClasses(ctx common.AndroidModuleContext, srcFiles common.Pat
return jarSpec{classFileList, classDir} return jarSpec{classFileList, classDir}
} }
func TransformClassesToJar(ctx common.AndroidModuleContext, classes []jarSpec, func TransformClassesToJar(ctx android.ModuleContext, classes []jarSpec,
manifest common.OptionalPath) common.Path { manifest android.OptionalPath) android.Path {
outputFile := common.PathForModuleOut(ctx, "classes-full-debug.jar") outputFile := android.PathForModuleOut(ctx, "classes-full-debug.jar")
deps := common.Paths{} deps := android.Paths{}
jarArgs := []string{} jarArgs := []string{}
for _, j := range classes { for _, j := range classes {
@@ -155,7 +155,7 @@ func TransformClassesToJar(ctx common.AndroidModuleContext, classes []jarSpec,
jarArgs = append(jarArgs, "-m "+manifest.String()) jarArgs = append(jarArgs, "-m "+manifest.String())
} }
ctx.ModuleBuild(pctx, common.ModuleBuildParams{ ctx.ModuleBuild(pctx, android.ModuleBuildParams{
Rule: jar, Rule: jar,
Output: outputFile, Output: outputFile,
Implicits: deps, Implicits: deps,
@@ -167,13 +167,13 @@ func TransformClassesToJar(ctx common.AndroidModuleContext, classes []jarSpec,
return outputFile return outputFile
} }
func TransformClassesJarToDex(ctx common.AndroidModuleContext, classesJar common.Path, func TransformClassesJarToDex(ctx android.ModuleContext, classesJar android.Path,
flags javaBuilderFlags) jarSpec { flags javaBuilderFlags) jarSpec {
outDir := common.PathForModuleOut(ctx, "dex") outDir := android.PathForModuleOut(ctx, "dex")
outputFile := common.PathForModuleOut(ctx, "dex.filelist") outputFile := android.PathForModuleOut(ctx, "dex.filelist")
ctx.ModuleBuild(pctx, common.ModuleBuildParams{ ctx.ModuleBuild(pctx, android.ModuleBuildParams{
Rule: dx, Rule: dx,
Output: outputFile, Output: outputFile,
Input: classesJar, Input: classesJar,
@@ -186,11 +186,11 @@ func TransformClassesJarToDex(ctx common.AndroidModuleContext, classesJar common
return jarSpec{outputFile, outDir} return jarSpec{outputFile, outDir}
} }
func TransformDexToJavaLib(ctx common.AndroidModuleContext, resources []jarSpec, func TransformDexToJavaLib(ctx android.ModuleContext, resources []jarSpec,
dexJarSpec jarSpec) common.Path { dexJarSpec jarSpec) android.Path {
outputFile := common.PathForModuleOut(ctx, "javalib.jar") outputFile := android.PathForModuleOut(ctx, "javalib.jar")
var deps common.Paths var deps android.Paths
var jarArgs []string var jarArgs []string
for _, j := range resources { for _, j := range resources {
@@ -201,7 +201,7 @@ func TransformDexToJavaLib(ctx common.AndroidModuleContext, resources []jarSpec,
deps = append(deps, dexJarSpec.fileList) deps = append(deps, dexJarSpec.fileList)
jarArgs = append(jarArgs, dexJarSpec.soongJarArgs()) jarArgs = append(jarArgs, dexJarSpec.soongJarArgs())
ctx.ModuleBuild(pctx, common.ModuleBuildParams{ ctx.ModuleBuild(pctx, android.ModuleBuildParams{
Rule: jar, Rule: jar,
Output: outputFile, Output: outputFile,
Implicits: deps, Implicits: deps,
@@ -213,9 +213,9 @@ func TransformDexToJavaLib(ctx common.AndroidModuleContext, resources []jarSpec,
return outputFile return outputFile
} }
func TransformJarJar(ctx common.AndroidModuleContext, classesJar common.Path, rulesFile common.Path) common.Path { func TransformJarJar(ctx android.ModuleContext, classesJar android.Path, rulesFile android.Path) android.Path {
outputFile := common.PathForModuleOut(ctx, "classes-jarjar.jar") outputFile := android.PathForModuleOut(ctx, "classes-jarjar.jar")
ctx.ModuleBuild(pctx, common.ModuleBuildParams{ ctx.ModuleBuild(pctx, android.ModuleBuildParams{
Rule: jarjar, Rule: jarjar,
Output: outputFile, Output: outputFile,
Input: classesJar, Input: classesJar,
@@ -228,16 +228,16 @@ func TransformJarJar(ctx common.AndroidModuleContext, classesJar common.Path, ru
return outputFile return outputFile
} }
func TransformPrebuiltJarToClasses(ctx common.AndroidModuleContext, func TransformPrebuiltJarToClasses(ctx android.ModuleContext,
prebuilt common.Path) (classJarSpec, resourceJarSpec jarSpec) { prebuilt android.Path) (classJarSpec, resourceJarSpec jarSpec) {
classDir := common.PathForModuleOut(ctx, "extracted/classes") classDir := android.PathForModuleOut(ctx, "extracted/classes")
classFileList := common.PathForModuleOut(ctx, "extracted/classes.list") classFileList := android.PathForModuleOut(ctx, "extracted/classes.list")
resourceFileList := common.PathForModuleOut(ctx, "extracted/resources.list") resourceFileList := android.PathForModuleOut(ctx, "extracted/resources.list")
ctx.ModuleBuild(pctx, common.ModuleBuildParams{ ctx.ModuleBuild(pctx, android.ModuleBuildParams{
Rule: extractPrebuilt, Rule: extractPrebuilt,
Outputs: common.WritablePaths{classFileList, resourceFileList}, Outputs: android.WritablePaths{classFileList, resourceFileList},
Input: prebuilt, Input: prebuilt,
Args: map[string]string{ Args: map[string]string{
"outDir": classDir.String(), "outDir": classDir.String(),

View File

@@ -21,7 +21,7 @@ package java
import ( import (
"github.com/google/blueprint" "github.com/google/blueprint"
"android/soong/common" "android/soong/android"
) )
func init() { func init() {
@@ -56,11 +56,11 @@ var (
}) })
) )
func genAidl(ctx common.AndroidModuleContext, aidlFile common.Path, aidlFlags string) common.Path { func genAidl(ctx android.ModuleContext, aidlFile android.Path, aidlFlags string) android.Path {
javaFile := common.GenPathWithExt(ctx, aidlFile, "java") javaFile := android.GenPathWithExt(ctx, aidlFile, "java")
depFile := javaFile.String() + ".d" depFile := javaFile.String() + ".d"
ctx.ModuleBuild(pctx, common.ModuleBuildParams{ ctx.ModuleBuild(pctx, android.ModuleBuildParams{
Rule: aidl, Rule: aidl,
Output: javaFile, Output: javaFile,
Input: aidlFile, Input: aidlFile,
@@ -73,10 +73,10 @@ func genAidl(ctx common.AndroidModuleContext, aidlFile common.Path, aidlFlags st
return javaFile return javaFile
} }
func genLogtags(ctx common.AndroidModuleContext, logtagsFile common.Path) common.Path { func genLogtags(ctx android.ModuleContext, logtagsFile android.Path) android.Path {
javaFile := common.GenPathWithExt(ctx, logtagsFile, "java") javaFile := android.GenPathWithExt(ctx, logtagsFile, "java")
ctx.ModuleBuild(pctx, common.ModuleBuildParams{ ctx.ModuleBuild(pctx, android.ModuleBuildParams{
Rule: logtags, Rule: logtags,
Output: javaFile, Output: javaFile,
Input: logtagsFile, Input: logtagsFile,
@@ -85,8 +85,8 @@ func genLogtags(ctx common.AndroidModuleContext, logtagsFile common.Path) common
return javaFile return javaFile
} }
func (j *javaBase) genSources(ctx common.AndroidModuleContext, srcFiles common.Paths, func (j *javaBase) genSources(ctx android.ModuleContext, srcFiles android.Paths,
flags javaBuilderFlags) common.Paths { flags javaBuilderFlags) android.Paths {
for i, srcFile := range srcFiles { for i, srcFile := range srcFiles {
switch srcFile.Ext() { switch srcFile.Ext() {
@@ -108,13 +108,13 @@ func LogtagsSingleton() blueprint.Singleton {
} }
type logtagsProducer interface { type logtagsProducer interface {
logtags() common.Paths logtags() android.Paths
} }
type logtagsSingleton struct{} type logtagsSingleton struct{}
func (l *logtagsSingleton) GenerateBuildActions(ctx blueprint.SingletonContext) { func (l *logtagsSingleton) GenerateBuildActions(ctx blueprint.SingletonContext) {
var allLogtags common.Paths var allLogtags android.Paths
ctx.VisitAllModules(func(module blueprint.Module) { ctx.VisitAllModules(func(module blueprint.Module) {
if logtags, ok := module.(logtagsProducer); ok { if logtags, ok := module.(logtagsProducer); ok {
allLogtags = append(allLogtags, logtags.logtags()...) allLogtags = append(allLogtags, logtags.logtags()...)

View File

@@ -25,7 +25,7 @@ import (
"github.com/google/blueprint" "github.com/google/blueprint"
"android/soong" "android/soong"
"android/soong/common" "android/soong/android"
"android/soong/genrule" "android/soong/genrule"
) )
@@ -114,16 +114,16 @@ type javaBaseProperties struct {
// javaBase contains the properties and members used by all java module types, and implements // javaBase contains the properties and members used by all java module types, and implements
// the blueprint.Module interface. // the blueprint.Module interface.
type javaBase struct { type javaBase struct {
common.AndroidModuleBase android.ModuleBase
module JavaModuleType module JavaModuleType
properties javaBaseProperties properties javaBaseProperties
// output file suitable for inserting into the classpath of another compile // output file suitable for inserting into the classpath of another compile
classpathFile common.Path classpathFile android.Path
// output file suitable for installing or running // output file suitable for installing or running
outputFile common.Path outputFile android.Path
// jarSpecs suitable for inserting classes from a static library into another jar // jarSpecs suitable for inserting classes from a static library into another jar
classJarSpecs []jarSpec classJarSpecs []jarSpec
@@ -131,43 +131,43 @@ type javaBase struct {
// jarSpecs suitable for inserting resources from a static library into another jar // jarSpecs suitable for inserting resources from a static library into another jar
resourceJarSpecs []jarSpec resourceJarSpecs []jarSpec
exportAidlIncludeDirs common.Paths exportAidlIncludeDirs android.Paths
logtagsSrcs common.Paths logtagsSrcs android.Paths
// filelists of extra source files that should be included in the javac command line, // filelists of extra source files that should be included in the javac command line,
// for example R.java generated by aapt for android apps // for example R.java generated by aapt for android apps
ExtraSrcLists common.Paths ExtraSrcLists android.Paths
// installed file for binary dependency // installed file for binary dependency
installFile common.Path installFile android.Path
} }
type AndroidJavaModuleContext common.AndroidBaseContext type AndroidJavaModuleContext android.BaseContext
type JavaModuleType interface { type JavaModuleType interface {
GenerateJavaBuildActions(ctx common.AndroidModuleContext) GenerateJavaBuildActions(ctx android.ModuleContext)
JavaDependencies(ctx AndroidJavaModuleContext) []string JavaDependencies(ctx AndroidJavaModuleContext) []string
} }
type JavaDependency interface { type JavaDependency interface {
ClasspathFile() common.Path ClasspathFile() android.Path
ClassJarSpecs() []jarSpec ClassJarSpecs() []jarSpec
ResourceJarSpecs() []jarSpec ResourceJarSpecs() []jarSpec
AidlIncludeDirs() common.Paths AidlIncludeDirs() android.Paths
} }
func NewJavaBase(base *javaBase, module JavaModuleType, hod common.HostOrDeviceSupported, func NewJavaBase(base *javaBase, module JavaModuleType, hod android.HostOrDeviceSupported,
props ...interface{}) (blueprint.Module, []interface{}) { props ...interface{}) (blueprint.Module, []interface{}) {
base.module = module base.module = module
props = append(props, &base.properties) props = append(props, &base.properties)
return common.InitAndroidArchModule(base, hod, common.MultilibCommon, props...) return android.InitAndroidArchModule(base, hod, android.MultilibCommon, props...)
} }
func (j *javaBase) BootClasspath(ctx common.AndroidBaseContext) string { func (j *javaBase) BootClasspath(ctx android.BaseContext) string {
if ctx.Device() { if ctx.Device() {
if j.properties.Sdk_version == "" { if j.properties.Sdk_version == "" {
return "core-libart" return "core-libart"
@@ -191,7 +191,7 @@ func (j *javaBase) BootClasspath(ctx common.AndroidBaseContext) string {
var defaultJavaLibraries = []string{"core-libart", "core-junit", "ext", "framework"} var defaultJavaLibraries = []string{"core-libart", "core-junit", "ext", "framework"}
func javaDepsMutator(ctx common.AndroidBottomUpMutatorContext) { func javaDepsMutator(ctx android.BottomUpMutatorContext) {
if j, ok := ctx.Module().(JavaModuleType); ok { if j, ok := ctx.Module().(JavaModuleType); ok {
ctx.AddDependency(ctx.Module(), nil, j.JavaDependencies(ctx)...) ctx.AddDependency(ctx.Module(), nil, j.JavaDependencies(ctx)...)
} }
@@ -215,35 +215,35 @@ func (j *javaBase) JavaDependencies(ctx AndroidJavaModuleContext) []string {
return deps return deps
} }
func (j *javaBase) aidlFlags(ctx common.AndroidModuleContext, aidlPreprocess common.OptionalPath, func (j *javaBase) aidlFlags(ctx android.ModuleContext, aidlPreprocess android.OptionalPath,
aidlIncludeDirs common.Paths) []string { aidlIncludeDirs android.Paths) []string {
localAidlIncludes := common.PathsForModuleSrc(ctx, j.properties.Aidl_includes) localAidlIncludes := android.PathsForModuleSrc(ctx, j.properties.Aidl_includes)
var flags []string var flags []string
if aidlPreprocess.Valid() { if aidlPreprocess.Valid() {
flags = append(flags, "-p"+aidlPreprocess.String()) flags = append(flags, "-p"+aidlPreprocess.String())
} else { } else {
flags = append(flags, common.JoinWithPrefix(aidlIncludeDirs.Strings(), "-I")) flags = append(flags, android.JoinWithPrefix(aidlIncludeDirs.Strings(), "-I"))
} }
flags = append(flags, common.JoinWithPrefix(j.exportAidlIncludeDirs.Strings(), "-I")) flags = append(flags, android.JoinWithPrefix(j.exportAidlIncludeDirs.Strings(), "-I"))
flags = append(flags, common.JoinWithPrefix(localAidlIncludes.Strings(), "-I")) flags = append(flags, android.JoinWithPrefix(localAidlIncludes.Strings(), "-I"))
flags = append(flags, "-I"+common.PathForModuleSrc(ctx).String()) flags = append(flags, "-I"+android.PathForModuleSrc(ctx).String())
flags = append(flags, "-I"+common.PathForModuleSrc(ctx, "src").String()) flags = append(flags, "-I"+android.PathForModuleSrc(ctx, "src").String())
return flags return flags
} }
func (j *javaBase) collectDeps(ctx common.AndroidModuleContext) (classpath common.Paths, func (j *javaBase) collectDeps(ctx android.ModuleContext) (classpath android.Paths,
bootClasspath common.OptionalPath, classJarSpecs, resourceJarSpecs []jarSpec, aidlPreprocess common.OptionalPath, bootClasspath android.OptionalPath, classJarSpecs, resourceJarSpecs []jarSpec, aidlPreprocess android.OptionalPath,
aidlIncludeDirs common.Paths, srcFileLists common.Paths) { aidlIncludeDirs android.Paths, srcFileLists android.Paths) {
ctx.VisitDirectDeps(func(module blueprint.Module) { ctx.VisitDirectDeps(func(module blueprint.Module) {
otherName := ctx.OtherModuleName(module) otherName := ctx.OtherModuleName(module)
if javaDep, ok := module.(JavaDependency); ok { if javaDep, ok := module.(JavaDependency); ok {
if otherName == j.BootClasspath(ctx) { if otherName == j.BootClasspath(ctx) {
bootClasspath = common.OptionalPathForPath(javaDep.ClasspathFile()) bootClasspath = android.OptionalPathForPath(javaDep.ClasspathFile())
} else if inList(otherName, defaultJavaLibraries) { } else if inList(otherName, defaultJavaLibraries) {
classpath = append(classpath, javaDep.ClasspathFile()) classpath = append(classpath, javaDep.ClasspathFile())
} else if inList(otherName, j.properties.Java_libs) { } else if inList(otherName, j.properties.Java_libs) {
@@ -279,13 +279,13 @@ func (j *javaBase) collectDeps(ctx common.AndroidModuleContext) (classpath commo
aidlIncludeDirs, srcFileLists aidlIncludeDirs, srcFileLists
} }
func (j *javaBase) GenerateAndroidBuildActions(ctx common.AndroidModuleContext) { func (j *javaBase) GenerateAndroidBuildActions(ctx android.ModuleContext) {
j.module.GenerateJavaBuildActions(ctx) j.module.GenerateJavaBuildActions(ctx)
} }
func (j *javaBase) GenerateJavaBuildActions(ctx common.AndroidModuleContext) { func (j *javaBase) GenerateJavaBuildActions(ctx android.ModuleContext) {
j.exportAidlIncludeDirs = common.PathsForModuleSrc(ctx, j.properties.Export_aidl_include_dirs) j.exportAidlIncludeDirs = android.PathsForModuleSrc(ctx, j.properties.Export_aidl_include_dirs)
classpath, bootClasspath, classJarSpecs, resourceJarSpecs, aidlPreprocess, classpath, bootClasspath, classJarSpecs, resourceJarSpecs, aidlPreprocess,
aidlIncludeDirs, srcFileLists := j.collectDeps(ctx) aidlIncludeDirs, srcFileLists := j.collectDeps(ctx)
@@ -304,7 +304,7 @@ func (j *javaBase) GenerateJavaBuildActions(ctx common.AndroidModuleContext) {
flags.aidlFlags = "$aidlFlags" flags.aidlFlags = "$aidlFlags"
} }
var javacDeps common.Paths var javacDeps android.Paths
if bootClasspath.Valid() { if bootClasspath.Valid() {
flags.bootClasspath = "-bootclasspath " + bootClasspath.String() flags.bootClasspath = "-bootclasspath " + bootClasspath.String()
@@ -341,7 +341,7 @@ func (j *javaBase) GenerateJavaBuildActions(ctx common.AndroidModuleContext) {
resourceJarSpecs = append(ResourceDirsToJarSpecs(ctx, j.properties.Java_resource_dirs, j.properties.Exclude_java_resource_dirs), resourceJarSpecs = append(ResourceDirsToJarSpecs(ctx, j.properties.Java_resource_dirs, j.properties.Exclude_java_resource_dirs),
resourceJarSpecs...) resourceJarSpecs...)
manifest := common.OptionalPathForModuleSrc(ctx, j.properties.Manifest) manifest := android.OptionalPathForModuleSrc(ctx, j.properties.Manifest)
allJarSpecs := append([]jarSpec(nil), classJarSpecs...) allJarSpecs := append([]jarSpec(nil), classJarSpecs...)
allJarSpecs = append(allJarSpecs, resourceJarSpecs...) allJarSpecs = append(allJarSpecs, resourceJarSpecs...)
@@ -353,7 +353,7 @@ func (j *javaBase) GenerateJavaBuildActions(ctx common.AndroidModuleContext) {
} }
if j.properties.Jarjar_rules != nil { if j.properties.Jarjar_rules != nil {
jarjar_rules := common.PathForModuleSrc(ctx, *j.properties.Jarjar_rules) jarjar_rules := android.PathForModuleSrc(ctx, *j.properties.Jarjar_rules)
// Transform classes-full-debug.jar into classes-jarjar.jar // Transform classes-full-debug.jar into classes-jarjar.jar
outputFile = TransformJarJar(ctx, outputFile, jarjar_rules) outputFile = TransformJarJar(ctx, outputFile, jarjar_rules)
if ctx.Failed() { if ctx.Failed() {
@@ -388,7 +388,7 @@ func (j *javaBase) GenerateJavaBuildActions(ctx common.AndroidModuleContext) {
dxFlags = append(dxFlags, dxFlags = append(dxFlags,
"--debug", "--debug",
"--verbose", "--verbose",
"--dump-to="+common.PathForModuleOut(ctx, "classes.lst").String(), "--dump-to="+android.PathForModuleOut(ctx, "classes.lst").String(),
"--dump-width=1000") "--dump-width=1000")
} }
@@ -409,7 +409,7 @@ func (j *javaBase) GenerateJavaBuildActions(ctx common.AndroidModuleContext) {
var _ JavaDependency = (*JavaLibrary)(nil) var _ JavaDependency = (*JavaLibrary)(nil)
func (j *javaBase) ClasspathFile() common.Path { func (j *javaBase) ClasspathFile() android.Path {
return j.classpathFile return j.classpathFile
} }
@@ -421,13 +421,13 @@ func (j *javaBase) ResourceJarSpecs() []jarSpec {
return j.resourceJarSpecs return j.resourceJarSpecs
} }
func (j *javaBase) AidlIncludeDirs() common.Paths { func (j *javaBase) AidlIncludeDirs() android.Paths {
return j.exportAidlIncludeDirs return j.exportAidlIncludeDirs
} }
var _ logtagsProducer = (*javaBase)(nil) var _ logtagsProducer = (*javaBase)(nil)
func (j *javaBase) logtags() common.Paths { func (j *javaBase) logtags() android.Paths {
return j.logtagsSrcs return j.logtagsSrcs
} }
@@ -439,10 +439,10 @@ type JavaLibrary struct {
javaBase javaBase
} }
func (j *JavaLibrary) GenerateJavaBuildActions(ctx common.AndroidModuleContext) { func (j *JavaLibrary) GenerateJavaBuildActions(ctx android.ModuleContext) {
j.javaBase.GenerateJavaBuildActions(ctx) j.javaBase.GenerateJavaBuildActions(ctx)
j.installFile = ctx.InstallFileName(common.PathForModuleInstall(ctx, "framework"), ctx.ModuleName()+".jar", j.outputFile) j.installFile = ctx.InstallFileName(android.PathForModuleInstall(ctx, "framework"), ctx.ModuleName()+".jar", j.outputFile)
} }
func JavaLibraryFactory() (blueprint.Module, []interface{}) { func JavaLibraryFactory() (blueprint.Module, []interface{}) {
@@ -450,13 +450,13 @@ func JavaLibraryFactory() (blueprint.Module, []interface{}) {
module.properties.Dex = true module.properties.Dex = true
return NewJavaBase(&module.javaBase, module, common.HostAndDeviceSupported) return NewJavaBase(&module.javaBase, module, android.HostAndDeviceSupported)
} }
func JavaLibraryHostFactory() (blueprint.Module, []interface{}) { func JavaLibraryHostFactory() (blueprint.Module, []interface{}) {
module := &JavaLibrary{} module := &JavaLibrary{}
return NewJavaBase(&module.javaBase, module, common.HostSupported) return NewJavaBase(&module.javaBase, module, android.HostSupported)
} }
// //
@@ -474,12 +474,12 @@ type JavaBinary struct {
binaryProperties javaBinaryProperties binaryProperties javaBinaryProperties
} }
func (j *JavaBinary) GenerateJavaBuildActions(ctx common.AndroidModuleContext) { func (j *JavaBinary) GenerateJavaBuildActions(ctx android.ModuleContext) {
j.JavaLibrary.GenerateJavaBuildActions(ctx) j.JavaLibrary.GenerateJavaBuildActions(ctx)
// Depend on the installed jar (j.installFile) so that the wrapper doesn't get executed by // Depend on the installed jar (j.installFile) so that the wrapper doesn't get executed by
// another build rule before the jar has been installed. // another build rule before the jar has been installed.
ctx.InstallFile(common.PathForModuleInstall(ctx, "bin"), common.PathForModuleSrc(ctx, j.binaryProperties.Wrapper), ctx.InstallFile(android.PathForModuleInstall(ctx, "bin"), android.PathForModuleSrc(ctx, j.binaryProperties.Wrapper),
j.installFile) j.installFile)
} }
@@ -488,13 +488,13 @@ func JavaBinaryFactory() (blueprint.Module, []interface{}) {
module.properties.Dex = true module.properties.Dex = true
return NewJavaBase(&module.javaBase, module, common.HostAndDeviceSupported, &module.binaryProperties) return NewJavaBase(&module.javaBase, module, android.HostAndDeviceSupported, &module.binaryProperties)
} }
func JavaBinaryHostFactory() (blueprint.Module, []interface{}) { func JavaBinaryHostFactory() (blueprint.Module, []interface{}) {
module := &JavaBinary{} module := &JavaBinary{}
return NewJavaBase(&module.javaBase, module, common.HostSupported, &module.binaryProperties) return NewJavaBase(&module.javaBase, module, android.HostSupported, &module.binaryProperties)
} }
// //
@@ -506,32 +506,32 @@ type javaPrebuiltProperties struct {
} }
type JavaPrebuilt struct { type JavaPrebuilt struct {
common.AndroidModuleBase android.ModuleBase
properties javaPrebuiltProperties properties javaPrebuiltProperties
classpathFile common.Path classpathFile android.Path
classJarSpecs, resourceJarSpecs []jarSpec classJarSpecs, resourceJarSpecs []jarSpec
} }
func (j *JavaPrebuilt) GenerateAndroidBuildActions(ctx common.AndroidModuleContext) { func (j *JavaPrebuilt) GenerateAndroidBuildActions(ctx android.ModuleContext) {
if len(j.properties.Srcs) != 1 { if len(j.properties.Srcs) != 1 {
ctx.ModuleErrorf("expected exactly one jar in srcs") ctx.ModuleErrorf("expected exactly one jar in srcs")
return return
} }
prebuilt := common.PathForModuleSrc(ctx, j.properties.Srcs[0]) prebuilt := android.PathForModuleSrc(ctx, j.properties.Srcs[0])
classJarSpec, resourceJarSpec := TransformPrebuiltJarToClasses(ctx, prebuilt) classJarSpec, resourceJarSpec := TransformPrebuiltJarToClasses(ctx, prebuilt)
j.classpathFile = prebuilt j.classpathFile = prebuilt
j.classJarSpecs = []jarSpec{classJarSpec} j.classJarSpecs = []jarSpec{classJarSpec}
j.resourceJarSpecs = []jarSpec{resourceJarSpec} j.resourceJarSpecs = []jarSpec{resourceJarSpec}
ctx.InstallFileName(common.PathForModuleInstall(ctx, "framework"), ctx.ModuleName()+".jar", j.classpathFile) ctx.InstallFileName(android.PathForModuleInstall(ctx, "framework"), ctx.ModuleName()+".jar", j.classpathFile)
} }
var _ JavaDependency = (*JavaPrebuilt)(nil) var _ JavaDependency = (*JavaPrebuilt)(nil)
func (j *JavaPrebuilt) ClasspathFile() common.Path { func (j *JavaPrebuilt) ClasspathFile() android.Path {
return j.classpathFile return j.classpathFile
} }
@@ -543,15 +543,15 @@ func (j *JavaPrebuilt) ResourceJarSpecs() []jarSpec {
return j.resourceJarSpecs return j.resourceJarSpecs
} }
func (j *JavaPrebuilt) AidlIncludeDirs() common.Paths { func (j *JavaPrebuilt) AidlIncludeDirs() android.Paths {
return nil return nil
} }
func JavaPrebuiltFactory() (blueprint.Module, []interface{}) { func JavaPrebuiltFactory() (blueprint.Module, []interface{}) {
module := &JavaPrebuilt{} module := &JavaPrebuilt{}
return common.InitAndroidArchModule(module, common.HostAndDeviceSupported, return android.InitAndroidArchModule(module, android.HostAndDeviceSupported,
common.MultilibCommon, &module.properties) android.MultilibCommon, &module.properties)
} }
// //
@@ -560,7 +560,7 @@ func JavaPrebuiltFactory() (blueprint.Module, []interface{}) {
type sdkDependency interface { type sdkDependency interface {
JavaDependency JavaDependency
AidlPreprocessed() common.OptionalPath AidlPreprocessed() android.OptionalPath
} }
var _ sdkDependency = (*sdkPrebuilt)(nil) var _ sdkDependency = (*sdkPrebuilt)(nil)
@@ -574,24 +574,24 @@ type sdkPrebuilt struct {
sdkProperties sdkPrebuiltProperties sdkProperties sdkPrebuiltProperties
aidlPreprocessed common.OptionalPath aidlPreprocessed android.OptionalPath
} }
func (j *sdkPrebuilt) GenerateAndroidBuildActions(ctx common.AndroidModuleContext) { func (j *sdkPrebuilt) GenerateAndroidBuildActions(ctx android.ModuleContext) {
j.JavaPrebuilt.GenerateAndroidBuildActions(ctx) j.JavaPrebuilt.GenerateAndroidBuildActions(ctx)
j.aidlPreprocessed = common.OptionalPathForModuleSrc(ctx, j.sdkProperties.Aidl_preprocessed) j.aidlPreprocessed = android.OptionalPathForModuleSrc(ctx, j.sdkProperties.Aidl_preprocessed)
} }
func (j *sdkPrebuilt) AidlPreprocessed() common.OptionalPath { func (j *sdkPrebuilt) AidlPreprocessed() android.OptionalPath {
return j.aidlPreprocessed return j.aidlPreprocessed
} }
func SdkPrebuiltFactory() (blueprint.Module, []interface{}) { func SdkPrebuiltFactory() (blueprint.Module, []interface{}) {
module := &sdkPrebuilt{} module := &sdkPrebuilt{}
return common.InitAndroidArchModule(module, common.HostAndDeviceSupported, return android.InitAndroidArchModule(module, android.HostAndDeviceSupported,
common.MultilibCommon, &module.properties, &module.sdkProperties) android.MultilibCommon, &module.properties, &module.sdkProperties)
} }
func inList(s string, l []string) bool { func inList(s string, l []string) bool {

View File

@@ -17,7 +17,7 @@ package java
import ( import (
"path/filepath" "path/filepath"
"android/soong/common" "android/soong/android"
) )
var resourceExcludes = []string{ var resourceExcludes = []string{
@@ -38,11 +38,11 @@ func isStringInSlice(str string, slice []string) bool {
return false return false
} }
func ResourceDirsToJarSpecs(ctx common.AndroidModuleContext, resourceDirs, excludeDirs []string) []jarSpec { func ResourceDirsToJarSpecs(ctx android.ModuleContext, resourceDirs, excludeDirs []string) []jarSpec {
var excludes []string var excludes []string
for _, exclude := range excludeDirs { for _, exclude := range excludeDirs {
excludes = append(excludes, common.PathForModuleSrc(ctx, exclude, "**/*").String()) excludes = append(excludes, android.PathForModuleSrc(ctx, exclude, "**/*").String())
} }
excludes = append(excludes, resourceExcludes...) excludes = append(excludes, resourceExcludes...)
@@ -53,14 +53,14 @@ func ResourceDirsToJarSpecs(ctx common.AndroidModuleContext, resourceDirs, exclu
if isStringInSlice(resourceDir, excludeDirs) { if isStringInSlice(resourceDir, excludeDirs) {
continue continue
} }
resourceDir := common.PathForModuleSrc(ctx, resourceDir) resourceDir := android.PathForModuleSrc(ctx, resourceDir)
dirs := ctx.Glob("java_resources", resourceDir.String(), nil) dirs := ctx.Glob("java_resources", resourceDir.String(), nil)
for _, dir := range dirs { for _, dir := range dirs {
fileListFile := common.ResPathWithName(ctx, dir, "resources.list") fileListFile := android.ResPathWithName(ctx, dir, "resources.list")
depFile := fileListFile.String() + ".d" depFile := fileListFile.String() + ".d"
glob := filepath.Join(dir.String(), "**/*") glob := filepath.Join(dir.String(), "**/*")
common.GlobRule(ctx, glob, excludes, fileListFile.String(), depFile) android.GlobRule(ctx, glob, excludes, fileListFile.String(), depFile)
jarSpecs = append(jarSpecs, jarSpec{fileListFile, dir}) jarSpecs = append(jarSpecs, jarSpec{fileListFile, dir})
} }
} }