diff options
| author | 2020-07-10 18:57:44 +0000 | |
|---|---|---|
| committer | 2020-07-10 18:57:44 +0000 | |
| commit | c76b0fd5f3676fce8c4417f6c1d40cb63eb0bee0 (patch) | |
| tree | 7f21e811bf0226b6170857a755f82b1b1d4d5ad4 /rust/compiler.go | |
| parent | fd1e267e409556b77735f7c88802806243e7cad8 (diff) | |
| parent | 9c3f56a3aa5dd0f92155a8d5e137e79318b76a0e (diff) | |
Merge "Specify module dependency in the srcs list" am: 21143a601c am: 9c3f56a3aa
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1356365
Change-Id: I5e4cbd9d86ee9f99d2bbc08fce40dd4b56d9dcbc
Diffstat (limited to 'rust/compiler.go')
| -rw-r--r-- | rust/compiler.go | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/rust/compiler.go b/rust/compiler.go index 92a3b07f2..c20179bd0 100644 --- a/rust/compiler.go +++ b/rust/compiler.go @@ -253,10 +253,24 @@ func (compiler *baseCompiler) relativeInstallPath() string { return String(compiler.Properties.Relative_install_path) } -func srcPathFromModuleSrcs(ctx ModuleContext, srcs []string) android.Path { - srcPaths := android.PathsForModuleSrc(ctx, srcs) - if len(srcPaths) != 1 { - ctx.PropertyErrorf("srcs", "srcs can only contain one path for rust modules") +func srcPathFromModuleSrcs(ctx ModuleContext, srcs []string) (android.Path, android.Paths) { + // The srcs can contain strings with prefix ":". + // They are dependent modules of this module, with android.SourceDepTag. + // They are not the main source file compiled by rustc. + numSrcs := 0 + srcIndex := 0 + for i, s := range srcs { + if android.SrcIsModule(s) == "" { + numSrcs++ + srcIndex = i + } + } + if numSrcs != 1 { + ctx.PropertyErrorf("srcs", "srcs can only contain one path for a rust file") + } + if srcIndex != 0 { + ctx.PropertyErrorf("srcs", "main source file must be the first in srcs") } - return srcPaths[0] + paths := android.PathsForModuleSrc(ctx, srcs) + return paths[srcIndex], paths } |