diff options
author | 2024-10-30 14:28:17 +0000 | |
---|---|---|
committer | 2025-01-10 21:30:53 +0000 | |
commit | 9eaacc824c4e567e2e2c41be3504e8564aad98bf (patch) | |
tree | 97dee64bccf10d20d21d21f219076604be025cd2 /rust/rust.go | |
parent | 14072ed49ed2e9c5df025ae162d1fd27c349a71e (diff) |
Refactor cc/rust to prep for Rust stubs
This CL largely handles this refactoring in preparation for Rust stubs
support.
Rust modules need to be able to communicate stubs information to cc, and
certain bits of cc needs to be exported so rust can reuse them.
A new VersionedLinkableInterface is added to capture most of the
stubs-related interface definitions.
Bug: 203478530
Test: m blueprint_tests
Change-Id: I380225402fa85a3c39e7b18deb657054b3a52fbe
Diffstat (limited to 'rust/rust.go')
-rw-r--r-- | rust/rust.go | 52 |
1 files changed, 47 insertions, 5 deletions
diff --git a/rust/rust.go b/rust/rust.go index ba6e29383..a4c1afd45 100644 --- a/rust/rust.go +++ b/rust/rust.go @@ -406,10 +406,6 @@ func (mod *Module) HasLlndkStubs() bool { return false } -func (mod *Module) StubsVersion() string { - panic(fmt.Errorf("StubsVersion called on non-versioned module: %q", mod.BaseModuleName())) -} - func (mod *Module) SdkVersion() string { return "" } @@ -561,6 +557,9 @@ func (mod *Module) ExportedCrateLinkDirs() []string { func (mod *Module) PreventInstall() bool { return mod.Properties.PreventInstall } +func (c *Module) ForceDisableSanitizers() { + c.sanitize.Properties.ForceDisable = true +} func (mod *Module) MarkAsCoverageVariant(coverage bool) { mod.coverage.Properties.IsCoverageVariant = coverage @@ -743,11 +742,28 @@ func (mod *Module) IsNdk(config android.Config) bool { return false } +func (mod *Module) IsStubs() bool { + return false +} + func (mod *Module) HasStubsVariants() bool { return false } -func (mod *Module) IsStubs() bool { +func (mod *Module) ApexSdkVersion() android.ApiLevel { + panic(fmt.Errorf("ApexSdkVersion called on unsupported Rust module: %q", mod.BaseModuleName())) +} + +func (mod *Module) ImplementationModuleNameForMake(ctx android.BaseModuleContext) string { + return mod.Name() +} + +func (mod *Module) Multilib() string { + return mod.Arch().ArchType.Multilib +} + +func (mod *Module) IsCrt() bool { + // Rust does not currently provide any crt modules. return false } @@ -771,6 +787,7 @@ func (ctx moduleContext) apexVariationName() string { } var _ cc.LinkableInterface = (*Module)(nil) +var _ cc.VersionedLinkableInterface = (*Module)(nil) func (mod *Module) Init() android.Module { mod.AddProperties(&mod.Properties) @@ -881,6 +898,25 @@ func (mod *Module) nativeCoverage() bool { return mod.compiler != nil && mod.compiler.nativeCoverage() } +func (mod *Module) SetStl(s string) { + // STL is a CC concept; do nothing for Rust +} + +func (mod *Module) SetSdkVersion(s string) { + panic(fmt.Errorf("SetSdkVersion called on unsupported Rust module: %q", mod.BaseModuleName())) +} + +func (mod *Module) SetMinSdkVersion(s string) { + mod.Properties.Min_sdk_version = StringPtr(s) +} + +func (mod *Module) VersionedInterface() cc.VersionedInterface { + if _, ok := mod.compiler.(cc.VersionedInterface); ok { + return mod.compiler.(cc.VersionedInterface) + } + return nil +} + func (mod *Module) EverInstallable() bool { return mod.compiler != nil && // Check to see whether the module is actually ever installable. @@ -1064,6 +1100,12 @@ func (mod *Module) GenerateAndroidBuildActions(actx android.ModuleContext) { } android.SetProvider(ctx, RustInfoProvider, rustInfo) + ccInfo := &cc.CcInfo{ + IsPrebuilt: mod.IsPrebuilt(), + } + + android.SetProvider(ctx, cc.CcInfoProvider, ccInfo) + mod.setOutputFiles(ctx) buildComplianceMetadataInfo(ctx, mod, deps) |