summaryrefslogtreecommitdiff
path: root/rust/library.go
diff options
context:
space:
mode:
author Treehugger Robot <treehugger-gerrit@google.com> 2021-04-19 19:40:18 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2021-04-19 19:40:18 +0000
commit9bd39fe80dd25f0ea0638caca67384f2c076d618 (patch)
tree5f155467198bc827bf9865292f6193278846b4cf /rust/library.go
parent46b938485a393167b7a14c9129562d1ffd3ca9a3 (diff)
parent06feee9352b80ebd2a2a3f186ac746f5d1d7026e (diff)
Merge "Rustdoc support."
Diffstat (limited to 'rust/library.go')
-rw-r--r--rust/library.go39
1 files changed, 30 insertions, 9 deletions
diff --git a/rust/library.go b/rust/library.go
index 052fb3a63..1bdf83a43 100644
--- a/rust/library.go
+++ b/rust/library.go
@@ -432,14 +432,10 @@ func (library *libraryDecorator) compilerFlags(ctx ModuleContext, flags Flags) F
func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) android.Path {
var outputFile android.ModuleOutPath
var fileName string
- var srcPath android.Path
+ srcPath := library.srcPath(ctx, deps)
if library.sourceProvider != nil {
- // Assume the first source from the source provider is the library entry point.
- srcPath = library.sourceProvider.Srcs()[0]
deps.srcProviderFiles = append(deps.srcProviderFiles, library.sourceProvider.Srcs()...)
- } else {
- srcPath, _ = srcPathFromModuleSrcs(ctx, library.baseCompiler.Properties.Srcs)
}
flags.RustFlags = append(flags.RustFlags, deps.depFlags...)
@@ -457,22 +453,22 @@ func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps Pa
fileName = library.getStem(ctx) + ctx.toolchain().RlibSuffix()
outputFile = android.PathForModuleOut(ctx, fileName)
- TransformSrctoRlib(ctx, srcPath, deps, flags, outputFile, deps.linkDirs)
+ TransformSrctoRlib(ctx, srcPath, deps, flags, outputFile)
} else if library.dylib() {
fileName = library.getStem(ctx) + ctx.toolchain().DylibSuffix()
outputFile = android.PathForModuleOut(ctx, fileName)
- TransformSrctoDylib(ctx, srcPath, deps, flags, outputFile, deps.linkDirs)
+ TransformSrctoDylib(ctx, srcPath, deps, flags, outputFile)
} else if library.static() {
fileName = library.getStem(ctx) + ctx.toolchain().StaticLibSuffix()
outputFile = android.PathForModuleOut(ctx, fileName)
- TransformSrctoStatic(ctx, srcPath, deps, flags, outputFile, deps.linkDirs)
+ TransformSrctoStatic(ctx, srcPath, deps, flags, outputFile)
} else if library.shared() {
fileName = library.sharedLibFilename(ctx)
outputFile = android.PathForModuleOut(ctx, fileName)
- TransformSrctoShared(ctx, srcPath, deps, flags, outputFile, deps.linkDirs)
+ TransformSrctoShared(ctx, srcPath, deps, flags, outputFile)
}
if !library.rlib() && !library.static() && library.stripper.NeedsStrip(ctx) {
@@ -514,6 +510,31 @@ func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps Pa
return outputFile
}
+func (library *libraryDecorator) srcPath(ctx ModuleContext, deps PathDeps) android.Path {
+ if library.sourceProvider != nil {
+ // Assume the first source from the source provider is the library entry point.
+ return library.sourceProvider.Srcs()[0]
+ } else {
+ path, _ := srcPathFromModuleSrcs(ctx, library.baseCompiler.Properties.Srcs)
+ return path
+ }
+}
+
+func (library *libraryDecorator) rustdoc(ctx ModuleContext, flags Flags,
+ deps PathDeps) android.OptionalPath {
+ // rustdoc has builtin support for documenting config specific information
+ // regardless of the actual config it was given
+ // (https://doc.rust-lang.org/rustdoc/advanced-features.html#cfgdoc-documenting-platform-specific-or-feature-specific-information),
+ // so we generate the rustdoc for only the primary module so that we have a
+ // single set of docs to refer to.
+ if ctx.Module() != ctx.PrimaryModule() {
+ return android.OptionalPath{}
+ }
+
+ return android.OptionalPathForPath(Rustdoc(ctx, library.srcPath(ctx, deps),
+ deps, flags))
+}
+
func (library *libraryDecorator) getStem(ctx ModuleContext) string {
stem := library.baseCompiler.getStemWithoutSuffix(ctx)
validateLibraryStem(ctx, stem, library.crateName())