summaryrefslogtreecommitdiff
path: root/rust/rust.go
diff options
context:
space:
mode:
Diffstat (limited to 'rust/rust.go')
-rw-r--r--rust/rust.go56
1 files changed, 52 insertions, 4 deletions
diff --git a/rust/rust.go b/rust/rust.go
index c4fd14859..d5d492971 100644
--- a/rust/rust.go
+++ b/rust/rust.go
@@ -15,6 +15,7 @@
package rust
import (
+ "android/soong/bloaty"
"fmt"
"strings"
@@ -22,7 +23,6 @@ import (
"github.com/google/blueprint/proptools"
"android/soong/android"
- "android/soong/bloaty"
"android/soong/cc"
cc_config "android/soong/cc/config"
"android/soong/fuzz"
@@ -52,6 +52,7 @@ func init() {
})
pctx.Import("android/soong/rust/config")
pctx.ImportAs("cc_config", "android/soong/cc/config")
+ android.InitRegistrationContext.RegisterSingletonType("kythe_rust_extract", kytheExtractRustFactory)
}
type Flags struct {
@@ -64,6 +65,7 @@ type Flags struct {
Toolchain config.Toolchain
Coverage bool
Clippy bool
+ EmitXrefs bool // If true, emit rules to aid cross-referencing
}
type BaseProperties struct {
@@ -161,6 +163,9 @@ type Module struct {
// Output file to be installed, may be stripped or unstripped.
outputFile android.OptionalPath
+ // Cross-reference input file
+ kytheFiles android.Paths
+
docTimestampFile android.OptionalPath
hideApexVariantFromMake bool
@@ -394,6 +399,10 @@ func (mod *Module) SplitPerApiLevel() bool {
return false
}
+func (mod *Module) XrefRustFiles() android.Paths {
+ return mod.kytheFiles
+}
+
type Deps struct {
Dylibs []string
Rlibs []string
@@ -457,7 +466,7 @@ type compiler interface {
cfgFlags(ctx ModuleContext, flags Flags) Flags
featureFlags(ctx ModuleContext, flags Flags) Flags
compilerProps() []interface{}
- compile(ctx ModuleContext, flags Flags, deps PathDeps) android.Path
+ compile(ctx ModuleContext, flags Flags, deps PathDeps) buildOutput
compilerDeps(ctx DepsContext, deps Deps) Deps
crateName() string
rustdoc(ctx ModuleContext, flags Flags, deps PathDeps) android.OptionalPath
@@ -493,6 +502,10 @@ type exportedFlagsProducer interface {
exportLinkObjects(...string)
}
+type xref interface {
+ XrefRustFiles() android.Paths
+}
+
type flagExporter struct {
linkDirs []string
linkObjects []string
@@ -682,6 +695,19 @@ func (mod *Module) CoverageFiles() android.Paths {
panic(fmt.Errorf("CoverageFiles called on non-library module: %q", mod.BaseModuleName()))
}
+// Rust does not produce gcno files, and therefore does not produce a coverage archive.
+func (mod *Module) CoverageOutputFile() android.OptionalPath {
+ return android.OptionalPath{}
+}
+
+func (mod *Module) IsNdk(config android.Config) bool {
+ return false
+}
+
+func (mod *Module) IsStubs() bool {
+ return false
+}
+
func (mod *Module) installable(apexInfo android.ApexInfo) bool {
if !proptools.BoolDefault(mod.Installable(), mod.EverInstallable()) {
return false
@@ -904,11 +930,14 @@ func (mod *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
if mod.compiler != nil && !mod.compiler.Disabled() {
mod.compiler.initialize(ctx)
- outputFile := mod.compiler.compile(ctx, flags, deps)
+ buildOutput := mod.compiler.compile(ctx, flags, deps)
if ctx.Failed() {
return
}
- mod.outputFile = android.OptionalPathForPath(outputFile)
+ mod.outputFile = android.OptionalPathForPath(buildOutput.outputFile)
+ if buildOutput.kytheFile != nil {
+ mod.kytheFiles = append(mod.kytheFiles, buildOutput.kytheFile)
+ }
bloaty.MeasureSizeForPaths(ctx, mod.compiler.strippedOutputFilePath(), android.OptionalPathForPath(mod.compiler.unstrippedOutputFilePath()))
mod.docTimestampFile = mod.compiler.rustdoc(ctx, flags, deps)
@@ -1618,6 +1647,25 @@ func libNameFromFilePath(filepath android.Path) (string, bool) {
return "", false
}
+func kytheExtractRustFactory() android.Singleton {
+ return &kytheExtractRustSingleton{}
+}
+
+type kytheExtractRustSingleton struct {
+}
+
+func (k kytheExtractRustSingleton) GenerateBuildActions(ctx android.SingletonContext) {
+ var xrefTargets android.Paths
+ ctx.VisitAllModules(func(module android.Module) {
+ if rustModule, ok := module.(xref); ok {
+ xrefTargets = append(xrefTargets, rustModule.XrefRustFiles()...)
+ }
+ })
+ if len(xrefTargets) > 0 {
+ ctx.Phony("xref_rust", xrefTargets...)
+ }
+}
+
var Bool = proptools.Bool
var BoolDefault = proptools.BoolDefault
var String = proptools.String