diff options
author | 2023-11-22 20:37:27 +0000 | |
---|---|---|
committer | 2023-11-22 20:37:27 +0000 | |
commit | b103659c0b9e883401d482168731d194b2c6657c (patch) | |
tree | 9561013968ca2af25b30e9bf8dd1e4de5416912d /rust/library.go | |
parent | f7474880a152b8423231b70d597c8a949ae2ab01 (diff) | |
parent | db72f7ed803df370951f7a03bd6f6fcad1b357e2 (diff) |
Merge changes I0caddbf6,Iee20b060,I6c92580b,I45028945,Ia7dd5220, ... into main
* changes:
rust: Resolve crate roots outside rust-project
rust: Cache crateRootPath to avoid ctx
rust: internalize srcPathFromModuleSrcs
rust: move crateRootPath to compiler
rust: Privatize Cargo* methods on compiler
rust: Move compiler interface to compiler.go
Diffstat (limited to 'rust/library.go')
-rw-r--r-- | rust/library.go | 18 |
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)) } |