Merge "rust modules can be included in apex"
This commit is contained in:
@@ -43,7 +43,7 @@ func (mod *Module) SubAndroidMk(data *android.AndroidMkEntries, obj interface{})
|
||||
}
|
||||
|
||||
func (mod *Module) AndroidMkEntries() []android.AndroidMkEntries {
|
||||
if mod.Properties.HideFromMake {
|
||||
if mod.Properties.HideFromMake || mod.hideApexVariantFromMake {
|
||||
|
||||
return []android.AndroidMkEntries{android.AndroidMkEntries{Disabled: true}}
|
||||
}
|
||||
|
@@ -18,6 +18,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"android/soong/android"
|
||||
"android/soong/cc"
|
||||
)
|
||||
|
||||
func TestClippy(t *testing.T) {
|
||||
@@ -45,6 +46,7 @@ func TestClippy(t *testing.T) {
|
||||
}`
|
||||
|
||||
bp = bp + GatherRequiredDepsForTest()
|
||||
bp = bp + cc.GatherRequiredDepsForTest(android.NoOsType)
|
||||
|
||||
fs := map[string][]byte{
|
||||
// Reuse the same blueprint file for subdirectories.
|
||||
|
@@ -19,6 +19,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"android/soong/android"
|
||||
"android/soong/cc"
|
||||
)
|
||||
|
||||
// Test that feature flags are being correctly generated.
|
||||
@@ -132,6 +133,7 @@ func TestLints(t *testing.T) {
|
||||
}`
|
||||
|
||||
bp = bp + GatherRequiredDepsForTest()
|
||||
bp = bp + cc.GatherRequiredDepsForTest(android.NoOsType)
|
||||
|
||||
fs := map[string][]byte{
|
||||
// Reuse the same blueprint file for subdirectories.
|
||||
|
66
rust/rust.go
66
rust/rust.go
@@ -74,6 +74,7 @@ type BaseProperties struct {
|
||||
type Module struct {
|
||||
android.ModuleBase
|
||||
android.DefaultableModuleBase
|
||||
android.ApexModuleBase
|
||||
|
||||
Properties BaseProperties
|
||||
|
||||
@@ -88,6 +89,8 @@ type Module struct {
|
||||
subAndroidMkOnce map[SubAndroidMkProvider]bool
|
||||
|
||||
outputFile android.OptionalPath
|
||||
|
||||
hideApexVariantFromMake bool
|
||||
}
|
||||
|
||||
func (mod *Module) OutputFiles(tag string) (android.Paths, error) {
|
||||
@@ -508,6 +511,7 @@ func (mod *Module) Init() android.Module {
|
||||
}
|
||||
|
||||
android.InitAndroidArchModule(mod, mod.hod, mod.multilib)
|
||||
android.InitApexModule(mod)
|
||||
|
||||
android.InitDefaultableModule(mod)
|
||||
return mod
|
||||
@@ -605,6 +609,11 @@ func (mod *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
|
||||
ModuleContext: actx,
|
||||
}
|
||||
|
||||
apexInfo := actx.Provider(android.ApexInfoProvider).(android.ApexInfo)
|
||||
if !apexInfo.IsForPlatform() {
|
||||
mod.hideApexVariantFromMake = true
|
||||
}
|
||||
|
||||
toolchain := mod.toolchain(ctx)
|
||||
|
||||
if !toolchain.Supported() {
|
||||
@@ -694,6 +703,11 @@ var (
|
||||
sourceDepTag = dependencyTag{name: "source"}
|
||||
)
|
||||
|
||||
func IsDylibDepTag(depTag blueprint.DependencyTag) bool {
|
||||
tag, ok := depTag.(dependencyTag)
|
||||
return ok && tag == dylibDepTag
|
||||
}
|
||||
|
||||
type autoDep struct {
|
||||
variation string
|
||||
depTag dependencyTag
|
||||
@@ -1052,6 +1066,58 @@ func (mod *Module) HostToolPath() android.OptionalPath {
|
||||
return android.OptionalPath{}
|
||||
}
|
||||
|
||||
var _ android.ApexModule = (*Module)(nil)
|
||||
|
||||
func (mod *Module) ShouldSupportSdkVersion(ctx android.BaseModuleContext, sdkVersion android.ApiLevel) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (mod *Module) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool {
|
||||
depTag := ctx.OtherModuleDependencyTag(dep)
|
||||
|
||||
if ccm, ok := dep.(*cc.Module); ok {
|
||||
if ccm.HasStubsVariants() {
|
||||
if cc.IsSharedDepTag(depTag) {
|
||||
// dynamic dep to a stubs lib crosses APEX boundary
|
||||
return false
|
||||
}
|
||||
if cc.IsRuntimeDepTag(depTag) {
|
||||
// runtime dep to a stubs lib also crosses APEX boundary
|
||||
return false
|
||||
}
|
||||
|
||||
if cc.IsHeaderDepTag(depTag) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
if mod.Static() && cc.IsSharedDepTag(depTag) {
|
||||
// shared_lib dependency from a static lib is considered as crossing
|
||||
// the APEX boundary because the dependency doesn't actually is
|
||||
// linked; the dependency is used only during the compilation phase.
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
if depTag == procMacroDepTag {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// Overrides ApexModule.IsInstallabeToApex()
|
||||
func (mod *Module) IsInstallableToApex() bool {
|
||||
if mod.compiler != nil {
|
||||
if lib, ok := mod.compiler.(*libraryDecorator); ok && (lib.shared() || lib.dylib()) {
|
||||
return true
|
||||
}
|
||||
if _, ok := mod.compiler.(*binaryDecorator); ok {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
var Bool = proptools.Bool
|
||||
var BoolDefault = proptools.BoolDefault
|
||||
var String = proptools.String
|
||||
|
@@ -120,6 +120,7 @@ func (tctx *testRustCtx) useMockedFs() {
|
||||
// attributes of the testRustCtx.
|
||||
func (tctx *testRustCtx) generateConfig() {
|
||||
tctx.bp = tctx.bp + GatherRequiredDepsForTest()
|
||||
tctx.bp = tctx.bp + cc.GatherRequiredDepsForTest(android.NoOsType)
|
||||
cc.GatherRequiredFilesForTest(tctx.fs)
|
||||
config := android.TestArchConfig(buildDir, tctx.env, tctx.bp, tctx.fs)
|
||||
tctx.config = &config
|
||||
|
@@ -77,6 +77,7 @@ func GatherRequiredDepsForTest() string {
|
||||
no_libcrt: true,
|
||||
nocrt: true,
|
||||
system_shared_libs: [],
|
||||
apex_available: ["//apex_available:platform", "//apex_available:anyapex"],
|
||||
}
|
||||
cc_library {
|
||||
name: "libprotobuf-cpp-full",
|
||||
@@ -93,6 +94,7 @@ func GatherRequiredDepsForTest() string {
|
||||
host_supported: true,
|
||||
native_coverage: false,
|
||||
sysroot: true,
|
||||
apex_available: ["//apex_available:platform", "//apex_available:anyapex"],
|
||||
}
|
||||
rust_library {
|
||||
name: "libtest",
|
||||
@@ -102,6 +104,7 @@ func GatherRequiredDepsForTest() string {
|
||||
host_supported: true,
|
||||
native_coverage: false,
|
||||
sysroot: true,
|
||||
apex_available: ["//apex_available:platform", "//apex_available:anyapex"],
|
||||
}
|
||||
rust_library {
|
||||
name: "libprotobuf",
|
||||
@@ -122,15 +125,11 @@ func GatherRequiredDepsForTest() string {
|
||||
host_supported: true,
|
||||
}
|
||||
|
||||
` + cc.GatherRequiredDepsForTest(android.NoOsType)
|
||||
`
|
||||
return bp
|
||||
}
|
||||
|
||||
func CreateTestContext(config android.Config) *android.TestContext {
|
||||
ctx := android.NewTestArchContext(config)
|
||||
android.RegisterPrebuiltMutators(ctx)
|
||||
ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
|
||||
cc.RegisterRequiredBuildComponentsForTest(ctx)
|
||||
func RegisterRequiredBuildComponentsForTest(ctx android.RegistrationContext) {
|
||||
ctx.RegisterModuleType("rust_binary", RustBinaryFactory)
|
||||
ctx.RegisterModuleType("rust_binary_host", RustBinaryHostFactory)
|
||||
ctx.RegisterModuleType("rust_bindgen", RustBindgenFactory)
|
||||
@@ -164,6 +163,14 @@ func CreateTestContext(config android.Config) *android.TestContext {
|
||||
ctx.BottomUp("rust_begin", BeginMutator).Parallel()
|
||||
})
|
||||
ctx.RegisterSingletonType("rust_project_generator", rustProjectGeneratorSingleton)
|
||||
}
|
||||
|
||||
func CreateTestContext(config android.Config) *android.TestContext {
|
||||
ctx := android.NewTestArchContext(config)
|
||||
android.RegisterPrebuiltMutators(ctx)
|
||||
ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
|
||||
cc.RegisterRequiredBuildComponentsForTest(ctx)
|
||||
RegisterRequiredBuildComponentsForTest(ctx)
|
||||
|
||||
return ctx
|
||||
}
|
||||
|
Reference in New Issue
Block a user