summaryrefslogtreecommitdiff
path: root/rust/library.go
diff options
context:
space:
mode:
Diffstat (limited to 'rust/library.go')
-rw-r--r--rust/library.go18
1 files changed, 10 insertions, 8 deletions
diff --git a/rust/library.go b/rust/library.go
index 18bf0a05b..c0ff741db 100644
--- a/rust/library.go
+++ b/rust/library.go
@@ -15,6 +15,7 @@
package rust
import (
+ "errors"
"fmt"
"regexp"
"strings"
@@ -489,7 +490,7 @@ func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps Pa
var outputFile android.ModuleOutPath
var ret buildOutput
var fileName string
- crateRootPath := library.crateRootPath(ctx, deps)
+ crateRootPath := crateRootPath(ctx, library)
if library.sourceProvider != nil {
deps.srcProviderFiles = append(deps.srcProviderFiles, library.sourceProvider.Srcs()...)
@@ -584,15 +585,16 @@ func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps Pa
return ret
}
-func (library *libraryDecorator) crateRootPath(ctx ModuleContext, _ PathDeps) android.Path {
+func (library *libraryDecorator) checkedCrateRootPath() (android.Path, error) {
if library.sourceProvider != nil {
+ srcs := library.sourceProvider.Srcs()
+ if len(srcs) == 0 {
+ return nil, errors.New("Source provider generated 0 sources")
+ }
// Assume the first source from the source provider is the library entry point.
- return library.sourceProvider.Srcs()[0]
- } else if library.baseCompiler.Properties.Crate_root == nil {
- path, _ := srcPathFromModuleSrcs(ctx, library.baseCompiler.Properties.Srcs)
- return path
+ return srcs[0], nil
} else {
- return android.PathForModuleSrc(ctx, *library.baseCompiler.Properties.Crate_root)
+ return library.baseCompiler.checkedCrateRootPath()
}
}
@@ -607,7 +609,7 @@ func (library *libraryDecorator) rustdoc(ctx ModuleContext, flags Flags,
return android.OptionalPath{}
}
- return android.OptionalPathForPath(Rustdoc(ctx, library.crateRootPath(ctx, deps),
+ return android.OptionalPathForPath(Rustdoc(ctx, crateRootPath(ctx, library),
deps, flags))
}