diff options
Diffstat (limited to 'rust/library.go')
-rw-r--r-- | rust/library.go | 39 |
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()) |