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

View file

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package common
package android
import (
"bytes"
@ -63,10 +63,10 @@ func (c *androidMkSingleton) GenerateBuildActions(ctx blueprint.SingletonContext
ctx.SetNinjaBuildDir(pctx, filepath.Join(config.buildDir, ".."))
var androidMkModulesList []AndroidModule
var androidMkModulesList []Module
ctx.VisitAllModules(func(module blueprint.Module) {
if amod, ok := module.(AndroidModule); ok {
if amod, ok := module.(Module); ok {
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{}
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
}
amod := mod.(AndroidModule).base()
amod := mod.(Module).base()
data, err := provider.AndroidMk()
if err != nil {
return err

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package common
package android
import (
"fmt"
@ -91,18 +91,18 @@ type WritablePath interface {
}
type genPathProvider interface {
genPathWithExt(ctx AndroidModuleContext, ext string) ModuleGenPath
genPathWithExt(ctx ModuleContext, ext string) ModuleGenPath
}
type objPathProvider interface {
objPathWithExt(ctx AndroidModuleContext, subdir, ext string) ModuleObjPath
objPathWithExt(ctx ModuleContext, subdir, ext string) ModuleObjPath
}
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
// 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 {
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
// 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 {
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
// the current path to create the directory name, and the `name` argument for
// 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 {
return path.resPathWithName(ctx, name)
}
@ -174,7 +174,7 @@ type Paths []Path
// PathsForSource returns Paths rooted from SrcDir
func PathsForSource(ctx PathContext, paths []string) Paths {
if pathConfig(ctx).AllowMissingDependencies() {
if modCtx, ok := ctx.(AndroidModuleContext); ok {
if modCtx, ok := ctx.(ModuleContext); ok {
ret := make(Paths, 0, len(paths))
intermediates := filepath.Join(modCtx.ModuleDir(), modCtx.ModuleName(), modCtx.ModuleSubDir(), "missing")
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
// directory
func PathsForModuleSrc(ctx AndroidModuleContext, paths []string) Paths {
func PathsForModuleSrc(ctx ModuleContext, paths []string) Paths {
ret := make(Paths, len(paths))
for i, path := range paths {
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
// source directory, but strip the local source directory from the beginning of
// each string.
func pathsForModuleSrcFromFullPath(ctx AndroidModuleContext, paths []string) Paths {
func pathsForModuleSrcFromFullPath(ctx ModuleContext, paths []string) Paths {
prefix := filepath.Join(ctx.AConfig().srcDir, ctx.ModuleDir()) + "/"
ret := make(Paths, 0, len(paths))
for _, p := range paths {
@ -238,7 +238,7 @@ func pathsForModuleSrcFromFullPath(ctx AndroidModuleContext, paths []string) Pat
// PathsWithOptionalDefaultForModuleSrc returns Paths rooted from the module's
// 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 {
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
// 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
if moduleSrcPath, ok := path.(ModuleSrcPath); ok {
relDir = moduleSrcPath.sourcePath.path
@ -510,14 +510,14 @@ var _ resPathProvider = ModuleSrcPath{}
// PathForModuleSrc returns a ModuleSrcPath representing the paths... under the
// module's local source directory.
func PathForModuleSrc(ctx AndroidModuleContext, paths ...string) ModuleSrcPath {
func PathForModuleSrc(ctx ModuleContext, paths ...string) ModuleSrcPath {
path := validatePath(ctx, paths...)
return ModuleSrcPath{basePath{path, ctx.AConfig()}, PathForSource(ctx, ctx.ModuleDir(), path), ctx.ModuleDir()}
}
// OptionalPathForModuleSrc returns an OptionalPath. The OptionalPath contains a
// valid path if p is non-nil.
func OptionalPathForModuleSrc(ctx AndroidModuleContext, p *string) OptionalPath {
func OptionalPathForModuleSrc(ctx ModuleContext, p *string) OptionalPath {
if p == nil {
return OptionalPath{}
}
@ -528,15 +528,15 @@ func (p ModuleSrcPath) String() 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))
}
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))
}
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?
return PathForModuleRes(ctx, p.path, name)
}
@ -550,7 +550,7 @@ var _ Path = ModuleOutPath{}
// PathForModuleOut returns a Path representing the paths... under the module's
// output directory.
func PathForModuleOut(ctx AndroidModuleContext, paths ...string) ModuleOutPath {
func PathForModuleOut(ctx ModuleContext, paths ...string) ModuleOutPath {
p := validatePath(ctx, paths...)
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
// `gen' directory.
func PathForModuleGen(ctx AndroidModuleContext, paths ...string) ModuleGenPath {
func PathForModuleGen(ctx ModuleContext, paths ...string) ModuleGenPath {
p := validatePath(ctx, paths...)
return ModuleGenPath{
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?
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))
}
@ -595,7 +595,7 @@ var _ Path = ModuleObjPath{}
// PathForModuleObj returns a Path representing the paths... under the module's
// 'obj' directory.
func PathForModuleObj(ctx AndroidModuleContext, paths ...string) ModuleObjPath {
func PathForModuleObj(ctx ModuleContext, paths ...string) ModuleObjPath {
p := validatePath(ctx, paths...)
return ModuleObjPath{PathForModuleOut(ctx, "obj", p)}
}
@ -610,14 +610,14 @@ var _ Path = ModuleResPath{}
// PathForModuleRes returns a Path representing the paths... under the module's
// 'res' directory.
func PathForModuleRes(ctx AndroidModuleContext, paths ...string) ModuleResPath {
func PathForModuleRes(ctx ModuleContext, paths ...string) ModuleResPath {
p := validatePath(ctx, paths...)
return ModuleResPath{PathForModuleOut(ctx, "res", p)}
}
// PathForModuleInstall returns a Path representing the install path for the
// module appended with paths...
func PathForModuleInstall(ctx AndroidModuleContext, paths ...string) OutputPath {
func PathForModuleInstall(ctx ModuleContext, paths ...string) OutputPath {
var outPaths []string
if ctx.Device() {
partition := "system"

View file

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

View file

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

View file

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package common
package android
import (
"fmt"
@ -129,10 +129,10 @@ func (v *productVariables) SetDefaultConfig() {
}
}
func variableMutator(mctx AndroidBottomUpMutatorContext) {
var module AndroidModule
func variableMutator(mctx BottomUpMutatorContext) {
var module Module
var ok bool
if module, ok = mctx.Module().(AndroidModule); !ok {
if module, ok = mctx.Module().(Module); !ok {
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{}) {
printfIntoProperties(productVariablePropertyValue, variableValue)

View file

@ -20,12 +20,12 @@ import (
"path/filepath"
"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.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")
if len(c.Properties.AndroidMkSharedLibs) > 0 {
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{}) {
if obj != nil {
if androidmk, ok := obj.(interface {
AndroidMk(*common.AndroidMkData)
AndroidMk(*android.AndroidMkData)
}); ok {
androidmk.AndroidMk(&ret)
}
@ -56,7 +56,7 @@ func (c *Module) AndroidMk() (ret common.AndroidMkData, err error) {
return ret, nil
}
func (library *baseLinker) AndroidMk(ret *common.AndroidMkData) {
func (library *baseLinker) AndroidMk(ret *android.AndroidMkData) {
if library.static() {
ret.Class = "STATIC_LIBRARIES"
} 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)
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
for _, flag := range library.exportedFlags() {
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 {
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.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_SYSTEM_SHARED_LIBRARIES :=")
return nil
})
}
func (test *testLinker) AndroidMk(ret *common.AndroidMkData) {
func (test *testLinker) AndroidMk(ret *android.AndroidMkData) {
test.binaryLinker.AndroidMk(ret)
if Bool(test.Properties.Test_per_src) {
ret.SubName = test.binaryLinker.Properties.Stem
}
}
func (library *toolchainLibraryLinker) AndroidMk(ret *common.AndroidMkData) {
func (library *toolchainLibraryLinker) AndroidMk(ret *android.AndroidMkData) {
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_CXX_STL := none")
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) {
ret.Extra = append(ret.Extra, func(w io.Writer, outputFile common.Path) error {
func (installer *baseInstaller) AndroidMk(ret *android.AndroidMkData) {
ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) error {
path := installer.path.RelPathString()
dir, file := filepath.Split(path)
stem := strings.TrimSuffix(file, filepath.Ext(file))

View file

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

View file

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

View file

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

300
cc/cc.go
View file

@ -27,7 +27,7 @@ import (
"github.com/google/blueprint/proptools"
"android/soong"
"android/soong/common"
"android/soong/android"
"android/soong/genrule"
)
@ -56,19 +56,19 @@ func init() {
// 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
// functions will run first.
common.RegisterBottomUpMutator("link", linkageMutator)
common.RegisterBottomUpMutator("test_per_src", testPerSrcMutator)
common.RegisterBottomUpMutator("deps", depsMutator)
android.RegisterBottomUpMutator("link", linkageMutator)
android.RegisterBottomUpMutator("test_per_src", testPerSrcMutator)
android.RegisterBottomUpMutator("deps", depsMutator)
common.RegisterTopDownMutator("asan_deps", sanitizerDepsMutator(asan))
common.RegisterBottomUpMutator("asan", sanitizerMutator(asan))
android.RegisterTopDownMutator("asan_deps", sanitizerDepsMutator(asan))
android.RegisterBottomUpMutator("asan", sanitizerMutator(asan))
common.RegisterTopDownMutator("tsan_deps", sanitizerDepsMutator(tsan))
common.RegisterBottomUpMutator("tsan", sanitizerMutator(tsan))
android.RegisterTopDownMutator("tsan_deps", sanitizerDepsMutator(tsan))
android.RegisterBottomUpMutator("tsan", sanitizerMutator(tsan))
}
var (
HostPrebuiltTag = pctx.VariableConfigMethod("HostPrebuiltTag", common.Config.PrebuiltOS)
HostPrebuiltTag = pctx.VariableConfigMethod("HostPrebuiltTag", android.Config.PrebuiltOS)
LibcRoot = pctx.SourcePathVariable("LibcRoot", "bionic/libc")
)
@ -118,7 +118,7 @@ var (
)
func init() {
if common.CurrentHostType() == common.Linux {
if android.CurrentHostType() == android.Linux {
commonGlobalCflags = append(commonGlobalCflags, "-fdebug-prefix-map=/proc/self/cwd=")
}
@ -163,13 +163,13 @@ func init() {
pctx.SourcePathVariable("clangDefaultBase", "prebuilts/clang/host")
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 "${clangDefaultBase}", nil
})
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 "clang-2812033", nil
@ -193,18 +193,18 @@ type Deps struct {
}
type PathDeps struct {
SharedLibs, LateSharedLibs common.Paths
StaticLibs, LateStaticLibs, WholeStaticLibs common.Paths
SharedLibs, LateSharedLibs android.Paths
StaticLibs, LateStaticLibs, WholeStaticLibs android.Paths
ObjFiles common.Paths
WholeStaticLibObjFiles common.Paths
ObjFiles android.Paths
WholeStaticLibObjFiles android.Paths
GeneratedSources common.Paths
GeneratedHeaders common.Paths
GeneratedSources android.Paths
GeneratedHeaders android.Paths
Cflags, ReexportedCflags []string
CrtBegin, CrtEnd common.OptionalPath
CrtBegin, CrtEnd android.OptionalPath
}
type Flags struct {
@ -224,7 +224,7 @@ type Flags struct {
RequiredInstructionSet string
DynamicLinker string
CFlagsDeps common.Paths // Files depended on by compiler flags
CFlagsDeps android.Paths // Files depended on by compiler flags
}
type BaseCompilerProperties struct {
@ -460,12 +460,12 @@ type ModuleContextIntf interface {
}
type ModuleContext interface {
common.AndroidModuleContext
android.ModuleContext
ModuleContextIntf
}
type BaseModuleContext interface {
common.AndroidBaseContext
android.BaseContext
ModuleContextIntf
}
@ -483,18 +483,18 @@ type feature interface {
type compiler interface {
feature
compile(ctx ModuleContext, flags Flags, deps PathDeps) common.Paths
compile(ctx ModuleContext, flags Flags, deps PathDeps) android.Paths
}
type linker interface {
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
}
type installer interface {
props() []interface{}
install(ctx ModuleContext, path common.Path)
install(ctx ModuleContext, path android.Path)
inData() bool
}
@ -522,15 +522,15 @@ var (
// 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
type Module struct {
common.AndroidModuleBase
common.DefaultableModule
android.ModuleBase
android.DefaultableModule
Properties BaseProperties
unused UnusedProperties
// initialize before calling Init
hod common.HostOrDeviceSupported
multilib common.Multilib
hod android.HostOrDeviceSupported
multilib android.Multilib
// delegates, initialize before calling Init
customizer Customizer
@ -543,7 +543,7 @@ type Module struct {
androidMkSharedLibDeps []string
outputFile common.OptionalPath
outputFile android.OptionalPath
cachedToolchain Toolchain
}
@ -572,18 +572,18 @@ func (c *Module) Init() (blueprint.Module, []interface{}) {
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 {
common.AndroidBaseContext
android.BaseContext
moduleContextImpl
}
type moduleContext struct {
common.AndroidModuleContext
android.ModuleContext
moduleContextImpl
}
@ -645,23 +645,23 @@ func (ctx *moduleContextImpl) selectedStl() string {
return ""
}
func newBaseModule(hod common.HostOrDeviceSupported, multilib common.Multilib) *Module {
func newBaseModule(hod android.HostOrDeviceSupported, multilib android.Multilib) *Module {
return &Module{
hod: hod,
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.stl = &stl{}
module.sanitize = &sanitize{}
return module
}
func (c *Module) GenerateAndroidBuildActions(actx common.AndroidModuleContext) {
func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
ctx := &moduleContext{
AndroidModuleContext: actx,
ModuleContext: actx,
moduleContextImpl: moduleContextImpl{
mod: c,
},
@ -711,7 +711,7 @@ func (c *Module) GenerateAndroidBuildActions(actx common.AndroidModuleContext) {
flags.CFlags = append(flags.CFlags, deps.Cflags...)
var objFiles common.Paths
var objFiles android.Paths
if c.compiler != nil {
objFiles = c.compiler.compile(ctx, flags, deps)
if ctx.Failed() {
@ -724,7 +724,7 @@ func (c *Module) GenerateAndroidBuildActions(actx common.AndroidModuleContext) {
if ctx.Failed() {
return
}
c.outputFile = common.OptionalPathForPath(outputFile)
c.outputFile = android.OptionalPathForPath(outputFile)
if c.installer != nil && c.linker.installable() {
c.installer.install(ctx, outputFile)
@ -796,9 +796,9 @@ func (c *Module) deps(ctx BaseModuleContext) Deps {
return deps
}
func (c *Module) depsMutator(actx common.AndroidBottomUpMutatorContext) {
func (c *Module) depsMutator(actx android.BottomUpMutatorContext) {
ctx := &baseModuleContext{
AndroidBaseContext: actx,
BaseContext: actx,
moduleContextImpl: moduleContextImpl{
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 {
c.depsMutator(ctx)
}
@ -870,14 +870,14 @@ func (c *Module) clang(ctx BaseModuleContext) bool {
}
// 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
ctx.VisitDirectDeps(func(m blueprint.Module) {
name := ctx.OtherModuleName(m)
tag := ctx.OtherModuleDependencyTag(m)
a, _ := m.(common.AndroidModule)
a, _ := m.(android.Module)
if a == nil {
ctx.ModuleErrorf("module %q not an android module", name)
return
@ -886,7 +886,7 @@ func (c *Module) depsToPaths(ctx common.AndroidModuleContext) PathDeps {
c, _ := m.(*Module)
if c == nil {
switch tag {
case common.DefaultsDepTag:
case android.DefaultsDepTag:
case genSourceDepTag:
if genRule, ok := m.(genrule.SourceFileGenerator); ok {
depPaths.GeneratedSources = append(depPaths.GeneratedSources,
@ -899,7 +899,7 @@ func (c *Module) depsToPaths(ctx common.AndroidModuleContext) PathDeps {
depPaths.GeneratedHeaders = append(depPaths.GeneratedHeaders,
genRule.GeneratedSourceFiles()...)
depPaths.Cflags = append(depPaths.Cflags,
includeDirsToFlags(common.Paths{genRule.GeneratedHeaderDir()}))
includeDirsToFlags(android.Paths{genRule.GeneratedHeaderDir()}))
} else {
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 {
case sharedDepTag:
@ -1039,14 +1039,14 @@ func (compiler *baseCompiler) flags(ctx ModuleContext, flags Flags) Flags {
flags.YaccFlags = append(flags.YaccFlags, compiler.Properties.Yaccflags...)
// Include dir cflags
rootIncludeDirs := common.PathsForSource(ctx, compiler.Properties.Include_dirs)
localIncludeDirs := common.PathsForModuleSrc(ctx, compiler.Properties.Local_include_dirs)
rootIncludeDirs := android.PathsForSource(ctx, compiler.Properties.Include_dirs)
localIncludeDirs := android.PathsForModuleSrc(ctx, compiler.Properties.Local_include_dirs)
flags.GlobalFlags = append(flags.GlobalFlags,
includeDirsToFlags(localIncludeDirs),
includeDirsToFlags(rootIncludeDirs))
rootIncludeFiles := common.PathsForSource(ctx, compiler.Properties.Include_files)
localIncludeFiles := common.PathsForModuleSrc(ctx, compiler.Properties.Local_include_files)
rootIncludeFiles := android.PathsForSource(ctx, compiler.Properties.Include_files)
localIncludeFiles := android.PathsForModuleSrc(ctx, compiler.Properties.Local_include_files)
flags.GlobalFlags = append(flags.GlobalFlags,
includeFilesToFlags(rootIncludeFiles),
@ -1061,9 +1061,9 @@ func (compiler *baseCompiler) flags(ctx ModuleContext, flags Flags) Flags {
}
flags.GlobalFlags = append(flags.GlobalFlags, []string{
"-I" + common.PathForModuleSrc(ctx).String(),
"-I" + common.PathForModuleOut(ctx).String(),
"-I" + common.PathForModuleGen(ctx).String(),
"-I" + android.PathForModuleSrc(ctx).String(),
"-I" + android.PathForModuleOut(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
// value.
strict := true
if strings.HasPrefix(common.PathForModuleSrc(ctx).String(), "external/") {
if strings.HasPrefix(android.PathForModuleSrc(ctx).String(), "external/") {
strict = false
}
@ -1177,7 +1177,7 @@ func (compiler *baseCompiler) flags(ctx ModuleContext, flags Flags) 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
objFiles := compiler.compileObjs(ctx, flags, "",
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
func (compiler *baseCompiler) compileObjs(ctx common.AndroidModuleContext, flags Flags,
subdir string, srcFiles, excludes []string, extraSrcs, deps common.Paths) common.Paths {
func (compiler *baseCompiler) compileObjs(ctx android.ModuleContext, flags Flags,
subdir string, srcFiles, excludes []string, extraSrcs, deps android.Paths) android.Paths {
buildFlags := flagsToBuilderFlags(flags)
@ -1349,7 +1349,7 @@ type baseInstaller struct {
dir64 string
data bool
path common.OutputPath
path android.OutputPath
}
var _ installer = (*baseInstaller)(nil)
@ -1358,12 +1358,12 @@ func (installer *baseInstaller) props() []interface{} {
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
if ctx.toolchain().Is64Bit() && 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)
}
@ -1382,8 +1382,8 @@ type flagExporter struct {
}
func (f *flagExporter) exportIncludes(ctx ModuleContext, inc string) {
includeDirs := common.PathsForModuleSrc(ctx, f.Properties.Export_include_dirs)
f.flags = append(f.flags, common.JoinWithPrefix(includeDirs.Strings(), inc))
includeDirs := android.PathsForModuleSrc(ctx, f.Properties.Export_include_dirs)
f.flags = append(f.flags, android.JoinWithPrefix(includeDirs.Strings(), inc))
}
func (f *flagExporter) reexportFlags(flags []string) {
@ -1407,7 +1407,7 @@ type libraryCompiler struct {
Properties LibraryCompilerProperties
// For reusing static library objects for shared library
reuseObjFiles common.Paths
reuseObjFiles android.Paths
}
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
// all code is position independent, and then those warnings get promoted to
// errors.
if ctx.HostType() != common.Windows {
if ctx.HostType() != android.Windows {
flags.CFlags = append(flags.CFlags, "-fPIC")
}
@ -1436,18 +1436,18 @@ func (library *libraryCompiler) flags(ctx ModuleContext, flags Flags) Flags {
return flags
}
func (library *libraryCompiler) compile(ctx ModuleContext, flags Flags, deps PathDeps) common.Paths {
var objFiles common.Paths
func (library *libraryCompiler) compile(ctx ModuleContext, flags Flags, deps PathDeps) android.Paths {
var objFiles android.Paths
objFiles = library.baseCompiler.compile(ctx, flags, deps)
library.reuseObjFiles = objFiles
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,
nil, deps.GeneratedHeaders)...)
} 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,
nil, deps.GeneratedHeaders)...)
}
@ -1472,7 +1472,7 @@ type libraryLinker struct {
wholeStaticMissingDeps []string
// For whole_static_libs
objFiles common.Paths
objFiles android.Paths
}
var _ linker = (*libraryLinker)(nil)
@ -1549,12 +1549,12 @@ func (library *libraryLinker) deps(ctx BaseModuleContext, deps Deps) Deps {
}
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...)
outputFile := common.PathForModuleOut(ctx,
outputFile := android.PathForModuleOut(ctx,
ctx.ModuleName()+library.Properties.VariantName+staticLibraryExtension)
if ctx.Darwin() {
@ -1571,14 +1571,14 @@ func (library *libraryLinker) linkStatic(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)
unexportedSymbols := common.OptionalPathForModuleSrc(ctx, library.Properties.Unexported_symbols_list)
forceNotWeakSymbols := common.OptionalPathForModuleSrc(ctx, library.Properties.Force_symbols_not_weak_list)
forceWeakSymbols := common.OptionalPathForModuleSrc(ctx, library.Properties.Force_symbols_weak_list)
versionScript := android.OptionalPathForModuleSrc(ctx, library.Properties.Version_script)
unexportedSymbols := android.OptionalPathForModuleSrc(ctx, library.Properties.Unexported_symbols_list)
forceNotWeakSymbols := android.OptionalPathForModuleSrc(ctx, library.Properties.Force_symbols_not_weak_list)
forceWeakSymbols := android.OptionalPathForModuleSrc(ctx, library.Properties.Force_symbols_weak_list)
if !ctx.Darwin() {
if versionScript.Valid() {
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()
outputFile := common.PathForModuleOut(ctx, fileName)
outputFile := android.PathForModuleOut(ctx, fileName)
ret := outputFile
builderFlags := flagsToBuilderFlags(flags)
if library.stripper.needsStrip(ctx) {
strippedOutputFile := outputFile
outputFile = common.PathForModuleOut(ctx, "unstripped", fileName)
outputFile = android.PathForModuleOut(ctx, "unstripped", fileName)
library.stripper.strip(ctx, outputFile, strippedOutputFile, builderFlags)
}
@ -1634,11 +1634,11 @@ func (library *libraryLinker) linkShared(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...)
var out common.Path
var out android.Path
if library.static() {
out = library.linkStatic(ctx, flags, deps, objFiles)
} else {
@ -1678,7 +1678,7 @@ type libraryInstaller struct {
sanitize *sanitize
}
func (library *libraryInstaller) install(ctx ModuleContext, file common.Path) {
func (library *libraryInstaller) install(ctx ModuleContext, file android.Path) {
if !library.linker.static() {
library.baseInstaller.install(ctx, file)
}
@ -1688,8 +1688,8 @@ func (library *libraryInstaller) inData() bool {
return library.baseInstaller.inData() || library.sanitize.inData()
}
func NewLibrary(hod common.HostOrDeviceSupported, shared, static bool) *Module {
module := newModule(hod, common.MultilibBoth)
func NewLibrary(hod android.HostOrDeviceSupported, shared, static bool) *Module {
module := newModule(hod, android.MultilibBoth)
linker := &libraryLinker{}
linker.dynamicProperties.BuildShared = shared
@ -1712,7 +1712,7 @@ func NewLibrary(hod common.HostOrDeviceSupported, shared, static bool) *Module {
}
func libraryFactory() (blueprint.Module, []interface{}) {
module := NewLibrary(common.HostAndDeviceSupported, true, true)
module := NewLibrary(android.HostAndDeviceSupported, true, true)
return module.Init()
}
@ -1725,7 +1725,7 @@ type objectLinker struct {
}
func objectFactory() (blueprint.Module, []interface{}) {
module := newBaseModule(common.DeviceSupported, common.MultilibBoth)
module := newBaseModule(android.DeviceSupported, android.MultilibBoth)
module.compiler = &baseCompiler{}
module.linker = &objectLinker{}
return module.Init()
@ -1753,15 +1753,15 @@ func (*objectLinker) flags(ctx ModuleContext, flags Flags) Flags {
}
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...)
var outputFile common.Path
var outputFile android.Path
if len(objFiles) == 1 {
outputFile = objFiles[0]
} else {
output := common.PathForModuleOut(ctx, ctx.ModuleName()+objectExtension)
output := android.PathForModuleOut(ctx, ctx.ModuleName()+objectExtension)
TransformObjsToObj(ctx, objFiles, flagsToBuilderFlags(flags), output)
outputFile = output
}
@ -1784,7 +1784,7 @@ type binaryLinker struct {
Properties BinaryLinkerProperties
hostToolPath common.OptionalPath
hostToolPath android.OptionalPath
}
var _ linker = (*binaryLinker)(nil)
@ -1861,8 +1861,8 @@ func (binary *binaryLinker) isDependencyRoot() bool {
return true
}
func NewBinary(hod common.HostOrDeviceSupported) *Module {
module := newModule(hod, common.MultilibFirst)
func NewBinary(hod android.HostOrDeviceSupported) *Module {
module := newModule(hod, android.MultilibFirst)
module.compiler = &baseCompiler{}
module.linker = &binaryLinker{}
module.installer = &baseInstaller{
@ -1872,7 +1872,7 @@ func NewBinary(hod common.HostOrDeviceSupported) *Module {
}
func binaryFactory() (blueprint.Module, []interface{}) {
module := NewBinary(common.HostAndDeviceSupported)
module := NewBinary(android.HostAndDeviceSupported)
return module.Init()
}
@ -1881,7 +1881,7 @@ func (binary *binaryLinker) begin(ctx BaseModuleContext) {
static := Bool(binary.Properties.Static_executable)
if ctx.Host() {
if ctx.HostType() == common.Linux {
if ctx.HostType() == android.Linux {
if binary.Properties.Static_executable == nil && Bool(ctx.AConfig().ProductVariables.HostStaticBinaries) {
static = true
}
@ -1901,7 +1901,7 @@ func (binary *binaryLinker) flags(ctx ModuleContext, flags Flags) Flags {
if ctx.Host() && !binary.staticBinary() {
flags.LdFlags = append(flags.LdFlags, "-pie")
if ctx.HostType() == common.Windows {
if ctx.HostType() == android.Windows {
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
// all code is position independent, and then those warnings get promoted to
// errors.
if ctx.HostType() != common.Windows {
if ctx.HostType() != android.Windows {
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,
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()
outputFile := common.PathForModuleOut(ctx, fileName)
outputFile := android.PathForModuleOut(ctx, fileName)
ret := outputFile
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 = append(sharedLibs, deps.LateSharedLibs...)
@ -1980,13 +1980,13 @@ func (binary *binaryLinker) link(ctx ModuleContext,
if binary.stripper.needsStrip(ctx) {
strippedOutputFile := outputFile
outputFile = common.PathForModuleOut(ctx, "unstripped", fileName)
outputFile = android.PathForModuleOut(ctx, "unstripped", fileName)
binary.stripper.strip(ctx, outputFile, strippedOutputFile, builderFlags)
}
if binary.Properties.Prefix_symbols != "" {
afterPrefixSymbols := outputFile
outputFile = common.PathForModuleOut(ctx, "unprefixed", fileName)
outputFile = android.PathForModuleOut(ctx, "unprefixed", fileName)
TransformBinaryPrefixSymbols(ctx, binary.Properties.Prefix_symbols, outputFile,
flagsToBuilderFlags(flags), afterPrefixSymbols)
}
@ -1998,7 +1998,7 @@ func (binary *binaryLinker) link(ctx ModuleContext,
return ret
}
func (binary *binaryLinker) HostToolPath() common.OptionalPath {
func (binary *binaryLinker) HostToolPath() android.OptionalPath {
return binary.hostToolPath
}
@ -2010,7 +2010,7 @@ func (stripper *stripper) needsStrip(ctx ModuleContext) bool {
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) {
if ctx.Darwin() {
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 test, ok := m.linker.(*testLinker); ok {
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")
switch ctx.HostType() {
case common.Windows:
case android.Windows:
flags.CFlags = append(flags.CFlags, "-DGTEST_OS_WINDOWS")
case common.Linux:
case android.Linux:
flags.CFlags = append(flags.CFlags, "-DGTEST_OS_LINUX")
flags.LdFlags = append(flags.LdFlags, "-lpthread")
case common.Darwin:
case android.Darwin:
flags.CFlags = append(flags.CFlags, "-DGTEST_OS_MAC")
flags.LdFlags = append(flags.LdFlags, "-lpthread")
}
@ -2110,14 +2110,14 @@ type testInstaller struct {
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.dir64 = filepath.Join(installer.dir64, ctx.ModuleName())
installer.baseInstaller.install(ctx, file)
}
func NewTest(hod common.HostOrDeviceSupported) *Module {
module := newModule(hod, common.MultilibBoth)
func NewTest(hod android.HostOrDeviceSupported) *Module {
module := newModule(hod, android.MultilibBoth)
module.compiler = &baseCompiler{}
linker := &testLinker{}
linker.Properties.Gtest = true
@ -2133,7 +2133,7 @@ func NewTest(hod common.HostOrDeviceSupported) *Module {
}
func testFactory() (blueprint.Module, []interface{}) {
module := NewTest(common.HostAndDeviceSupported)
module := NewTest(android.HostAndDeviceSupported)
return module.Init()
}
@ -2147,8 +2147,8 @@ func (benchmark *benchmarkLinker) deps(ctx BaseModuleContext, deps Deps) Deps {
return deps
}
func NewBenchmark(hod common.HostOrDeviceSupported) *Module {
module := newModule(hod, common.MultilibFirst)
func NewBenchmark(hod android.HostOrDeviceSupported) *Module {
module := newModule(hod, android.MultilibFirst)
module.compiler = &baseCompiler{}
module.linker = &benchmarkLinker{}
module.installer = &baseInstaller{
@ -2160,7 +2160,7 @@ func NewBenchmark(hod common.HostOrDeviceSupported) *Module {
}
func benchmarkFactory() (blueprint.Module, []interface{}) {
module := NewBenchmark(common.HostAndDeviceSupported)
module := NewBenchmark(android.HostAndDeviceSupported)
return module.Init()
}
@ -2169,7 +2169,7 @@ func benchmarkFactory() (blueprint.Module, []interface{}) {
//
func libraryStaticFactory() (blueprint.Module, []interface{}) {
module := NewLibrary(common.HostAndDeviceSupported, false, true)
module := NewLibrary(android.HostAndDeviceSupported, false, true)
return module.Init()
}
@ -2178,7 +2178,7 @@ func libraryStaticFactory() (blueprint.Module, []interface{}) {
//
func librarySharedFactory() (blueprint.Module, []interface{}) {
module := NewLibrary(common.HostAndDeviceSupported, true, false)
module := NewLibrary(android.HostAndDeviceSupported, true, false)
return module.Init()
}
@ -2187,7 +2187,7 @@ func librarySharedFactory() (blueprint.Module, []interface{}) {
//
func libraryHostStaticFactory() (blueprint.Module, []interface{}) {
module := NewLibrary(common.HostSupported, false, true)
module := NewLibrary(android.HostSupported, false, true)
return module.Init()
}
@ -2196,7 +2196,7 @@ func libraryHostStaticFactory() (blueprint.Module, []interface{}) {
//
func libraryHostSharedFactory() (blueprint.Module, []interface{}) {
module := NewLibrary(common.HostSupported, true, false)
module := NewLibrary(android.HostSupported, true, false)
return module.Init()
}
@ -2205,7 +2205,7 @@ func libraryHostSharedFactory() (blueprint.Module, []interface{}) {
//
func binaryHostFactory() (blueprint.Module, []interface{}) {
module := NewBinary(common.HostSupported)
module := NewBinary(android.HostSupported)
return module.Init()
}
@ -2214,7 +2214,7 @@ func binaryHostFactory() (blueprint.Module, []interface{}) {
//
func testHostFactory() (blueprint.Module, []interface{}) {
module := NewTest(common.HostSupported)
module := NewTest(android.HostSupported)
return module.Init()
}
@ -2223,7 +2223,7 @@ func testHostFactory() (blueprint.Module, []interface{}) {
//
func benchmarkHostFactory() (blueprint.Module, []interface{}) {
module := NewBenchmark(common.HostSupported)
module := NewBenchmark(android.HostSupported)
return module.Init()
}
@ -2231,11 +2231,11 @@ func benchmarkHostFactory() (blueprint.Module, []interface{}) {
// Defaults
//
type Defaults struct {
common.AndroidModuleBase
common.DefaultsModule
android.ModuleBase
android.DefaultsModule
}
func (*Defaults) GenerateAndroidBuildActions(ctx common.AndroidModuleContext) {
func (*Defaults) GenerateAndroidBuildActions(ctx android.ModuleContext) {
}
func defaultsFactory() (blueprint.Module, []interface{}) {
@ -2256,10 +2256,10 @@ func defaultsFactory() (blueprint.Module, []interface{}) {
&StripProperties{},
}
_, propertyStructs = common.InitAndroidArchModule(module, common.HostAndDeviceDefault,
common.MultilibDefault, propertyStructs...)
_, propertyStructs = android.InitAndroidArchModule(module, android.HostAndDeviceDefault,
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{}) {
module := newBaseModule(common.DeviceSupported, common.MultilibBoth)
module := newBaseModule(android.DeviceSupported, android.MultilibBoth)
module.compiler = &baseCompiler{}
module.linker = &toolchainLibraryLinker{}
module.Properties.Clang = proptools.BoolPtr(false)
@ -2294,10 +2294,10 @@ func toolchainLibraryFactory() (blueprint.Module, []interface{}) {
}
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
outputFile := common.PathForModuleOut(ctx, libName)
outputFile := android.PathForModuleOut(ctx, libName)
if flags.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
// 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 := ""
// Most 64-bit NDK prebuilts store libraries in "lib64", except for arm64 which is not a
// 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"
}
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))
}
func ndkPrebuiltModuleToPath(ctx common.AndroidModuleContext, toolchain Toolchain,
ext string, version string) common.Path {
func ndkPrebuiltModuleToPath(ctx android.ModuleContext, toolchain Toolchain,
ext string, version string) android.Path {
// NDK prebuilts are named like: ndk_NAME.EXT.SDK_VERSION.
// 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{}) {
module := newBaseModule(common.DeviceSupported, common.MultilibBoth)
module := newBaseModule(android.DeviceSupported, android.MultilibBoth)
module.linker = &ndkPrebuiltObjectLinker{}
return module.Init()
}
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.
if !strings.HasPrefix(ctx.ModuleName(), "ndk_crt") {
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{}) {
module := newBaseModule(common.DeviceSupported, common.MultilibBoth)
module := newBaseModule(android.DeviceSupported, android.MultilibBoth)
linker := &ndkPrebuiltLibraryLinker{}
linker.dynamicProperties.BuildShared = true
module.linker = linker
@ -2391,7 +2391,7 @@ func ndkPrebuiltLibraryFactory() (blueprint.Module, []interface{}) {
}
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.
if !strings.HasPrefix(ctx.ModuleName(), "ndk_lib") {
ctx.ModuleErrorf("NDK prebuilts must have an ndk_lib prefixed name")
@ -2412,7 +2412,7 @@ type ndkPrebuiltStlLinker struct {
}
func ndkPrebuiltSharedStlFactory() (blueprint.Module, []interface{}) {
module := newBaseModule(common.DeviceSupported, common.MultilibBoth)
module := newBaseModule(android.DeviceSupported, android.MultilibBoth)
linker := &ndkPrebuiltStlLinker{}
linker.dynamicProperties.BuildShared = true
module.linker = linker
@ -2420,14 +2420,14 @@ func ndkPrebuiltSharedStlFactory() (blueprint.Module, []interface{}) {
}
func ndkPrebuiltStaticStlFactory() (blueprint.Module, []interface{}) {
module := newBaseModule(common.DeviceSupported, common.MultilibBoth)
module := newBaseModule(android.DeviceSupported, android.MultilibBoth)
linker := &ndkPrebuiltStlLinker{}
linker.dynamicProperties.BuildStatic = true
module.linker = linker
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()
var libDir string
switch stl {
@ -2441,15 +2441,15 @@ func getNdkStlLibDir(ctx common.AndroidModuleContext, toolchain Toolchain, stl s
if libDir != "" {
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)
return common.PathForSource(ctx, "")
return android.PathForSource(ctx, "")
}
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.
if !strings.HasPrefix(ctx.ModuleName(), "ndk_lib") {
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)
}
func linkageMutator(mctx common.AndroidBottomUpMutatorContext) {
func linkageMutator(mctx android.BottomUpMutatorContext) {
if m, ok := mctx.Module().(*Module); ok {
if m.linker != nil {
if linker, ok := m.linker.(baseLinkerInterface); ok {

View file

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

View file

@ -19,14 +19,14 @@ import (
"path/filepath"
"strings"
"android/soong/common"
"android/soong/android"
)
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_BASE", "${clangBase}")
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_LINK", "${clangBin}/llvm-link")
hostType := common.CurrentHostType()
hostType := android.CurrentHostType()
arches := ctx.Config().HostArches[hostType]
makeVarsToolchain(ctx, "", common.Host, hostType, arches[0])
makeVarsToolchain(ctx, "", android.Host, hostType, arches[0])
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 {
makeVarsToolchain(ctx, "", common.Host, common.Windows, winArches[0])
if winArches, ok := ctx.Config().HostArches[android.Windows]; ok {
makeVarsToolchain(ctx, "", android.Host, android.Windows, winArches[0])
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
makeVarsToolchain(ctx, "", common.Device, common.NoHostType, arches[0])
makeVarsToolchain(ctx, "", android.Device, android.NoHostType, arches[0])
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,
hod common.HostOrDevice, ht common.HostType, arch common.Arch) {
func makeVarsToolchain(ctx android.MakeVarsContext, secondPrefix string,
hod android.HostOrDevice, ht android.HostType, arch android.Arch) {
var typePrefix string
if hod.Host() {
if ht == common.Windows {
if ht == android.Windows {
typePrefix = "HOST_CROSS_"
} else {
typePrefix = "HOST_"
@ -102,7 +102,7 @@ func makeVarsToolchain(ctx common.MakeVarsContext, secondPrefix string,
if toolchain.ClangSupported() {
clangPrefix := secondPrefix + "CLANG_" + typePrefix
clangExtras := "-target " + toolchain.ClangTriple()
if ht != common.Darwin {
if ht != android.Darwin {
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+"CXX", gccCmd(toolchain, "g++"))
if ht == common.Darwin {
if ht == android.Darwin {
ctx.Strict(makePrefix+"AR", "${macArPath}")
} else {
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"))
}
if ht == common.Windows {
if ht == android.Windows {
ctx.Strict(makePrefix+"OBJDUMP", gccCmd(toolchain, "objdump"))
}

View file

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

View file

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

View file

@ -20,7 +20,7 @@ import (
"github.com/google/blueprint"
"android/soong/common"
"android/soong/android"
)
type sanitizerType int
@ -213,7 +213,7 @@ func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags) Flags {
}
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.
// TODO: put in flags?
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() {
flags.CFlags = append(flags.CFlags, "-fsanitize-blacklist="+blacklist.String())
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
func sanitizerDepsMutator(t sanitizerType) func(common.AndroidTopDownMutatorContext) {
return func(mctx common.AndroidTopDownMutatorContext) {
func sanitizerDepsMutator(t sanitizerType) func(android.TopDownMutatorContext) {
return func(mctx android.TopDownMutatorContext) {
if c, ok := mctx.Module().(*Module); ok && c.sanitize.Sanitizer(t) {
mctx.VisitDepsDepthFirst(func(module blueprint.Module) {
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
func sanitizerMutator(t sanitizerType) func(common.AndroidBottomUpMutatorContext) {
return func(mctx common.AndroidBottomUpMutatorContext) {
func sanitizerMutator(t sanitizerType) func(android.BottomUpMutatorContext) {
return func(mctx android.BottomUpMutatorContext) {
if c, ok := mctx.Module().(*Module); ok && c.sanitize != nil {
if d, ok := c.linker.(baseLinkerInterface); ok && d.isDependencyRoot() && c.sanitize.Sanitizer(t) {
modules := mctx.CreateVariations(t.String())

View file

@ -15,7 +15,7 @@
package cc
import (
"android/soong/common"
"android/soong/android"
"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)
return ""
}
} else if ctx.HostType() == common.Windows {
} else if ctx.HostType() == android.Windows {
switch stl.Properties.Stl {
case "libc++", "libc++_static", "libstdc++", "":
// 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)
}
if ctx.Device() {
if ctx.Arch().ArchType == common.Arm {
if ctx.Arch().ArchType == android.Arm {
deps.StaticLibs = append(deps.StaticLibs, "libunwind_llvm")
}
if ctx.staticBinary() {
@ -138,7 +138,7 @@ func (stl *stl) flags(ctx ModuleContext, flags Flags) Flags {
flags.LdFlags = append(flags.LdFlags, hostDynamicGccLibs[ctx.HostType()]...)
}
} else {
if ctx.Arch().ArchType == common.Arm {
if ctx.Arch().ArchType == android.Arm {
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.
// Host builds will use GNU libstdc++.
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 {
// Host builds will use the system C++. libc++ on Darwin, GNU libstdc++ everywhere else
flags.CppFlags = append(flags.CppFlags, flags.Toolchain.SystemCppCppflags())
flags.LdFlags = append(flags.LdFlags, flags.Toolchain.SystemCppLdflags())
}
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())
case "ndk_libc++_shared", "ndk_libc++_static":
// TODO(danalbert): This really shouldn't be here...
@ -179,20 +179,20 @@ func (stl *stl) flags(ctx ModuleContext, flags Flags) Flags {
return flags
}
var hostDynamicGccLibs, hostStaticGccLibs map[common.HostType][]string
var hostDynamicGccLibs, hostStaticGccLibs map[android.HostType][]string
func init() {
hostDynamicGccLibs = map[common.HostType][]string{
common.Linux: []string{"-lgcc_s", "-lgcc", "-lc", "-lgcc_s", "-lgcc"},
common.Darwin: []string{"-lc", "-lSystem"},
common.Windows: []string{"-lmsvcr110", "-lmingw32", "-lgcc", "-lmoldname",
hostDynamicGccLibs = map[android.HostType][]string{
android.Linux: []string{"-lgcc_s", "-lgcc", "-lc", "-lgcc_s", "-lgcc"},
android.Darwin: []string{"-lc", "-lSystem"},
android.Windows: []string{"-lmsvcr110", "-lmingw32", "-lgcc", "-lmoldname",
"-lmingwex", "-lmsvcrt", "-ladvapi32", "-lshell32", "-luser32",
"-lkernel32", "-lmingw32", "-lgcc", "-lmoldname", "-lmingwex",
"-lmsvcrt"},
}
hostStaticGccLibs = map[common.HostType][]string{
common.Linux: []string{"-Wl,--start-group", "-lgcc", "-lgcc_eh", "-lc", "-Wl,--end-group"},
common.Darwin: []string{"NO_STATIC_HOST_BINARIES_ON_DARWIN"},
common.Windows: []string{"NO_STATIC_HOST_BINARIES_ON_WINDOWS"},
hostStaticGccLibs = map[android.HostType][]string{
android.Linux: []string{"-Wl,--start-group", "-lgcc", "-lgcc_eh", "-lc", "-Wl,--end-group"},
android.Darwin: []string{"NO_STATIC_HOST_BINARIES_ON_DARWIN"},
android.Windows: []string{"NO_STATIC_HOST_BINARIES_ON_WINDOWS"},
}
}

View file

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

View file

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

View file

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

View file

@ -5,7 +5,7 @@ import (
"os/exec"
"strings"
"android/soong/common"
"android/soong/android"
)
var (
@ -97,7 +97,7 @@ func init() {
})
pctx.StaticVariable("macToolchainRoot", "${macSdkPath}/Toolchains/XcodeDefault.xctoolchain")
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.VariableFunc("macArPath", func(config interface{}) (string, error) {
@ -138,7 +138,7 @@ func init() {
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 !inList(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 toolchainDarwinX8664Singleton Toolchain = &toolchainDarwinX8664{}
func darwinX86ToolchainFactory(arch common.Arch) Toolchain {
func darwinX86ToolchainFactory(arch android.Arch) Toolchain {
return toolchainDarwinX86Singleton
}
func darwinX8664ToolchainFactory(arch common.Arch) Toolchain {
func darwinX8664ToolchainFactory(arch android.Arch) Toolchain {
return toolchainDarwinX8664Singleton
}
func init() {
registerHostToolchainFactory(common.Darwin, common.X86, darwinX86ToolchainFactory)
registerHostToolchainFactory(common.Darwin, common.X86_64, darwinX8664ToolchainFactory)
registerHostToolchainFactory(android.Darwin, android.X86, darwinX86ToolchainFactory)
registerHostToolchainFactory(android.Darwin, android.X86_64, darwinX8664ToolchainFactory)
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -22,7 +22,7 @@ import (
"github.com/google/blueprint"
"android/soong/common"
"android/soong/android"
)
// AAR prebuilts
@ -61,8 +61,8 @@ type AndroidApp struct {
appProperties androidAppProperties
aaptJavaFileList common.Path
exportPackage common.Path
aaptJavaFileList android.Path
exportPackage android.Path
}
func (a *AndroidApp) JavaDependencies(ctx AndroidJavaModuleContext) []string {
@ -80,7 +80,7 @@ func (a *AndroidApp) JavaDependencies(ctx AndroidJavaModuleContext) []string {
return deps
}
func (a *AndroidApp) GenerateJavaBuildActions(ctx common.AndroidModuleContext) {
func (a *AndroidApp) GenerateJavaBuildActions(ctx android.ModuleContext) {
aaptFlags, aaptDeps, hasResources := a.aaptFlags(ctx)
if hasResources {
@ -143,16 +143,16 @@ func (a *AndroidApp) GenerateJavaBuildActions(ctx common.AndroidModuleContext) {
} else if dir, _ := filepath.Split(certificate); dir == "" {
certificate = filepath.Join(ctx.AConfig().DefaultAppCertificateDir(ctx).String(), certificate)
} else {
certificate = filepath.Join(common.PathForSource(ctx).String(), certificate)
certificate = filepath.Join(android.PathForSource(ctx).String(), certificate)
}
certificates := []string{certificate}
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)
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{
@ -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
hasVersionCode := false
hasVersionName := false
@ -183,10 +183,10 @@ func (a *AndroidApp) aaptFlags(ctx common.AndroidModuleContext) ([]string, commo
aaptFlags = append(aaptFlags, "-z")
}
assetDirs := common.PathsWithOptionalDefaultForModuleSrc(ctx, a.appProperties.Asset_dirs, "assets")
resourceDirs := common.PathsWithOptionalDefaultForModuleSrc(ctx, a.appProperties.Android_resource_dirs, "res")
assetDirs := android.PathsWithOptionalDefaultForModuleSrc(ctx, a.appProperties.Asset_dirs, "assets")
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.
// If found, it will be prepended to the list of resource directories.
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,
// use glob to create a filelist.
var aaptDeps common.Paths
var aaptDeps android.Paths
var hasResources bool
for _, d := range resourceDirs {
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
}
manifestPath := common.PathForModuleSrc(ctx, manifestFile)
manifestPath := android.PathForModuleSrc(ctx, manifestFile)
aaptDeps = append(aaptDeps, manifestPath)
aaptFlags = append(aaptFlags, "-M "+manifestPath.String())
aaptFlags = append(aaptFlags, common.JoinWithPrefix(assetDirs.Strings(), "-A "))
aaptFlags = append(aaptFlags, common.JoinWithPrefix(resourceDirs.Strings(), "-S "))
aaptFlags = append(aaptFlags, android.JoinWithPrefix(assetDirs.Strings(), "-A "))
aaptFlags = append(aaptFlags, android.JoinWithPrefix(resourceDirs.Strings(), "-S "))
ctx.VisitDirectDeps(func(module blueprint.Module) {
var depFile common.OptionalPath
var depFile android.OptionalPath
if sdkDep, ok := module.(sdkDependency); ok {
depFile = common.OptionalPathForPath(sdkDep.ClasspathFile())
depFile = android.OptionalPathForPath(sdkDep.ClasspathFile())
} else if javaDep, ok := module.(JavaDependency); ok {
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() {
@ -278,5 +278,5 @@ func AndroidAppFactory() (blueprint.Module, []interface{}) {
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"
"android/soong/common"
"android/soong/android"
)
var (
@ -79,16 +79,16 @@ func init() {
pctx.HostJavaToolVariable("signapkCmd", "signapk.jar")
}
func CreateResourceJavaFiles(ctx common.AndroidModuleContext, flags []string,
deps common.Paths) (common.Path, common.Path, common.Path) {
javaDir := common.PathForModuleGen(ctx, "R")
javaFileList := common.PathForModuleOut(ctx, "R.filelist")
publicResourcesFile := common.PathForModuleOut(ctx, "public_resources.xml")
proguardOptionsFile := common.PathForModuleOut(ctx, "proguard.options")
func CreateResourceJavaFiles(ctx android.ModuleContext, flags []string,
deps android.Paths) (android.Path, android.Path, android.Path) {
javaDir := android.PathForModuleGen(ctx, "R")
javaFileList := android.PathForModuleOut(ctx, "R.filelist")
publicResourcesFile := android.PathForModuleOut(ctx, "public_resources.xml")
proguardOptionsFile := android.PathForModuleOut(ctx, "proguard.options")
ctx.ModuleBuild(pctx, common.ModuleBuildParams{
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
Rule: aaptCreateResourceJavaFile,
Outputs: common.WritablePaths{publicResourcesFile, proguardOptionsFile, javaFileList},
Outputs: android.WritablePaths{publicResourcesFile, proguardOptionsFile, javaFileList},
Implicits: deps,
Args: map[string]string{
"aaptFlags": strings.Join(flags, " "),
@ -102,10 +102,10 @@ func CreateResourceJavaFiles(ctx common.AndroidModuleContext, flags []string,
return publicResourcesFile, proguardOptionsFile, javaFileList
}
func CreateExportPackage(ctx common.AndroidModuleContext, flags []string, deps common.Paths) common.ModuleOutPath {
outputFile := common.PathForModuleOut(ctx, "package-export.apk")
func CreateExportPackage(ctx android.ModuleContext, flags []string, deps android.Paths) android.ModuleOutPath {
outputFile := android.PathForModuleOut(ctx, "package-export.apk")
ctx.ModuleBuild(pctx, common.ModuleBuildParams{
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
Rule: aaptCreateAssetsPackage,
Output: outputFile,
Implicits: deps,
@ -117,12 +117,12 @@ func CreateExportPackage(ctx common.AndroidModuleContext, flags []string, deps c
return outputFile
}
func CreateAppPackage(ctx common.AndroidModuleContext, flags []string, jarFile common.Path,
certificates []string) common.Path {
func CreateAppPackage(ctx android.ModuleContext, flags []string, jarFile android.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,
Output: resourceApk,
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
for _, c := range certificates {
certificateArgs = append(certificateArgs, c+".x509.pem", c+".pk8")
}
ctx.ModuleBuild(pctx, common.ModuleBuildParams{
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
Rule: signapk,
Output: outputFile,
Input: resourceApk,

View file

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

View file

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

View file

@ -25,7 +25,7 @@ import (
"github.com/google/blueprint"
"android/soong"
"android/soong/common"
"android/soong/android"
"android/soong/genrule"
)
@ -114,16 +114,16 @@ type javaBaseProperties struct {
// javaBase contains the properties and members used by all java module types, and implements
// the blueprint.Module interface.
type javaBase struct {
common.AndroidModuleBase
android.ModuleBase
module JavaModuleType
properties javaBaseProperties
// output file suitable for inserting into the classpath of another compile
classpathFile common.Path
classpathFile android.Path
// 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
classJarSpecs []jarSpec
@ -131,43 +131,43 @@ type javaBase struct {
// jarSpecs suitable for inserting resources from a static library into another jar
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,
// for example R.java generated by aapt for android apps
ExtraSrcLists common.Paths
ExtraSrcLists android.Paths
// installed file for binary dependency
installFile common.Path
installFile android.Path
}
type AndroidJavaModuleContext common.AndroidBaseContext
type AndroidJavaModuleContext android.BaseContext
type JavaModuleType interface {
GenerateJavaBuildActions(ctx common.AndroidModuleContext)
GenerateJavaBuildActions(ctx android.ModuleContext)
JavaDependencies(ctx AndroidJavaModuleContext) []string
}
type JavaDependency interface {
ClasspathFile() common.Path
ClasspathFile() android.Path
ClassJarSpecs() []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{}) {
base.module = module
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 j.properties.Sdk_version == "" {
return "core-libart"
@ -191,7 +191,7 @@ func (j *javaBase) BootClasspath(ctx common.AndroidBaseContext) string {
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 {
ctx.AddDependency(ctx.Module(), nil, j.JavaDependencies(ctx)...)
}
@ -215,35 +215,35 @@ func (j *javaBase) JavaDependencies(ctx AndroidJavaModuleContext) []string {
return deps
}
func (j *javaBase) aidlFlags(ctx common.AndroidModuleContext, aidlPreprocess common.OptionalPath,
aidlIncludeDirs common.Paths) []string {
func (j *javaBase) aidlFlags(ctx android.ModuleContext, aidlPreprocess android.OptionalPath,
aidlIncludeDirs android.Paths) []string {
localAidlIncludes := common.PathsForModuleSrc(ctx, j.properties.Aidl_includes)
localAidlIncludes := android.PathsForModuleSrc(ctx, j.properties.Aidl_includes)
var flags []string
if aidlPreprocess.Valid() {
flags = append(flags, "-p"+aidlPreprocess.String())
} 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, common.JoinWithPrefix(localAidlIncludes.Strings(), "-I"))
flags = append(flags, "-I"+common.PathForModuleSrc(ctx).String())
flags = append(flags, "-I"+common.PathForModuleSrc(ctx, "src").String())
flags = append(flags, android.JoinWithPrefix(j.exportAidlIncludeDirs.Strings(), "-I"))
flags = append(flags, android.JoinWithPrefix(localAidlIncludes.Strings(), "-I"))
flags = append(flags, "-I"+android.PathForModuleSrc(ctx).String())
flags = append(flags, "-I"+android.PathForModuleSrc(ctx, "src").String())
return flags
}
func (j *javaBase) collectDeps(ctx common.AndroidModuleContext) (classpath common.Paths,
bootClasspath common.OptionalPath, classJarSpecs, resourceJarSpecs []jarSpec, aidlPreprocess common.OptionalPath,
aidlIncludeDirs common.Paths, srcFileLists common.Paths) {
func (j *javaBase) collectDeps(ctx android.ModuleContext) (classpath android.Paths,
bootClasspath android.OptionalPath, classJarSpecs, resourceJarSpecs []jarSpec, aidlPreprocess android.OptionalPath,
aidlIncludeDirs android.Paths, srcFileLists android.Paths) {
ctx.VisitDirectDeps(func(module blueprint.Module) {
otherName := ctx.OtherModuleName(module)
if javaDep, ok := module.(JavaDependency); ok {
if otherName == j.BootClasspath(ctx) {
bootClasspath = common.OptionalPathForPath(javaDep.ClasspathFile())
bootClasspath = android.OptionalPathForPath(javaDep.ClasspathFile())
} else if inList(otherName, defaultJavaLibraries) {
classpath = append(classpath, javaDep.ClasspathFile())
} else if inList(otherName, j.properties.Java_libs) {
@ -279,13 +279,13 @@ func (j *javaBase) collectDeps(ctx common.AndroidModuleContext) (classpath commo
aidlIncludeDirs, srcFileLists
}
func (j *javaBase) GenerateAndroidBuildActions(ctx common.AndroidModuleContext) {
func (j *javaBase) GenerateAndroidBuildActions(ctx android.ModuleContext) {
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,
aidlIncludeDirs, srcFileLists := j.collectDeps(ctx)
@ -304,7 +304,7 @@ func (j *javaBase) GenerateJavaBuildActions(ctx common.AndroidModuleContext) {
flags.aidlFlags = "$aidlFlags"
}
var javacDeps common.Paths
var javacDeps android.Paths
if bootClasspath.Valid() {
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...)
manifest := common.OptionalPathForModuleSrc(ctx, j.properties.Manifest)
manifest := android.OptionalPathForModuleSrc(ctx, j.properties.Manifest)
allJarSpecs := append([]jarSpec(nil), classJarSpecs...)
allJarSpecs = append(allJarSpecs, resourceJarSpecs...)
@ -353,7 +353,7 @@ func (j *javaBase) GenerateJavaBuildActions(ctx common.AndroidModuleContext) {
}
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
outputFile = TransformJarJar(ctx, outputFile, jarjar_rules)
if ctx.Failed() {
@ -388,7 +388,7 @@ func (j *javaBase) GenerateJavaBuildActions(ctx common.AndroidModuleContext) {
dxFlags = append(dxFlags,
"--debug",
"--verbose",
"--dump-to="+common.PathForModuleOut(ctx, "classes.lst").String(),
"--dump-to="+android.PathForModuleOut(ctx, "classes.lst").String(),
"--dump-width=1000")
}
@ -409,7 +409,7 @@ func (j *javaBase) GenerateJavaBuildActions(ctx common.AndroidModuleContext) {
var _ JavaDependency = (*JavaLibrary)(nil)
func (j *javaBase) ClasspathFile() common.Path {
func (j *javaBase) ClasspathFile() android.Path {
return j.classpathFile
}
@ -421,13 +421,13 @@ func (j *javaBase) ResourceJarSpecs() []jarSpec {
return j.resourceJarSpecs
}
func (j *javaBase) AidlIncludeDirs() common.Paths {
func (j *javaBase) AidlIncludeDirs() android.Paths {
return j.exportAidlIncludeDirs
}
var _ logtagsProducer = (*javaBase)(nil)
func (j *javaBase) logtags() common.Paths {
func (j *javaBase) logtags() android.Paths {
return j.logtagsSrcs
}
@ -439,10 +439,10 @@ type JavaLibrary struct {
javaBase
}
func (j *JavaLibrary) GenerateJavaBuildActions(ctx common.AndroidModuleContext) {
func (j *JavaLibrary) GenerateJavaBuildActions(ctx android.ModuleContext) {
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{}) {
@ -450,13 +450,13 @@ func JavaLibraryFactory() (blueprint.Module, []interface{}) {
module.properties.Dex = true
return NewJavaBase(&module.javaBase, module, common.HostAndDeviceSupported)
return NewJavaBase(&module.javaBase, module, android.HostAndDeviceSupported)
}
func JavaLibraryHostFactory() (blueprint.Module, []interface{}) {
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
}
func (j *JavaBinary) GenerateJavaBuildActions(ctx common.AndroidModuleContext) {
func (j *JavaBinary) GenerateJavaBuildActions(ctx android.ModuleContext) {
j.JavaLibrary.GenerateJavaBuildActions(ctx)
// 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.
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)
}
@ -488,13 +488,13 @@ func JavaBinaryFactory() (blueprint.Module, []interface{}) {
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{}) {
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 {
common.AndroidModuleBase
android.ModuleBase
properties javaPrebuiltProperties
classpathFile common.Path
classpathFile android.Path
classJarSpecs, resourceJarSpecs []jarSpec
}
func (j *JavaPrebuilt) GenerateAndroidBuildActions(ctx common.AndroidModuleContext) {
func (j *JavaPrebuilt) GenerateAndroidBuildActions(ctx android.ModuleContext) {
if len(j.properties.Srcs) != 1 {
ctx.ModuleErrorf("expected exactly one jar in srcs")
return
}
prebuilt := common.PathForModuleSrc(ctx, j.properties.Srcs[0])
prebuilt := android.PathForModuleSrc(ctx, j.properties.Srcs[0])
classJarSpec, resourceJarSpec := TransformPrebuiltJarToClasses(ctx, prebuilt)
j.classpathFile = prebuilt
j.classJarSpecs = []jarSpec{classJarSpec}
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)
func (j *JavaPrebuilt) ClasspathFile() common.Path {
func (j *JavaPrebuilt) ClasspathFile() android.Path {
return j.classpathFile
}
@ -543,15 +543,15 @@ func (j *JavaPrebuilt) ResourceJarSpecs() []jarSpec {
return j.resourceJarSpecs
}
func (j *JavaPrebuilt) AidlIncludeDirs() common.Paths {
func (j *JavaPrebuilt) AidlIncludeDirs() android.Paths {
return nil
}
func JavaPrebuiltFactory() (blueprint.Module, []interface{}) {
module := &JavaPrebuilt{}
return common.InitAndroidArchModule(module, common.HostAndDeviceSupported,
common.MultilibCommon, &module.properties)
return android.InitAndroidArchModule(module, android.HostAndDeviceSupported,
android.MultilibCommon, &module.properties)
}
//
@ -560,7 +560,7 @@ func JavaPrebuiltFactory() (blueprint.Module, []interface{}) {
type sdkDependency interface {
JavaDependency
AidlPreprocessed() common.OptionalPath
AidlPreprocessed() android.OptionalPath
}
var _ sdkDependency = (*sdkPrebuilt)(nil)
@ -574,24 +574,24 @@ type sdkPrebuilt struct {
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.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
}
func SdkPrebuiltFactory() (blueprint.Module, []interface{}) {
module := &sdkPrebuilt{}
return common.InitAndroidArchModule(module, common.HostAndDeviceSupported,
common.MultilibCommon, &module.properties, &module.sdkProperties)
return android.InitAndroidArchModule(module, android.HostAndDeviceSupported,
android.MultilibCommon, &module.properties, &module.sdkProperties)
}
func inList(s string, l []string) bool {

View file

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