Pass library kind when linking native libraries.
When linking native libraries with rustc, be explicit about the kind of native library being linked. This prevents confusion when two kinds of one library (e.g. static/dynamic) are available in the library search paths. Bug: 147140513 Test: The correct prebuilt is selected when linking native prebuilts. Change-Id: I37975bcd284e6c33ce3dd45fab8a3b5011b0803b
This commit is contained in:
parent
026ffecb9d
commit
6aa660218e
13
rust/rust.go
13
rust/rust.go
|
@ -623,21 +623,24 @@ func (mod *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
|
|||
linkFile := ccDep.OutputFile()
|
||||
linkPath := linkPathFromFilePath(linkFile.Path())
|
||||
libName := libNameFromFilePath(linkFile.Path())
|
||||
depFlag := "-l" + libName
|
||||
|
||||
if !linkFile.Valid() {
|
||||
ctx.ModuleErrorf("Invalid output file when adding dep %q to %q", depName, ctx.ModuleName())
|
||||
}
|
||||
|
||||
exportDep := false
|
||||
|
||||
switch depTag {
|
||||
case cc.StaticDepTag:
|
||||
depFlag = "-lstatic=" + libName
|
||||
depPaths.linkDirs = append(depPaths.linkDirs, linkPath)
|
||||
depPaths.depFlags = append(depPaths.depFlags, "-l"+libName)
|
||||
depPaths.depFlags = append(depPaths.depFlags, depFlag)
|
||||
directStaticLibDeps = append(directStaticLibDeps, ccDep)
|
||||
mod.Properties.AndroidMkStaticLibs = append(mod.Properties.AndroidMkStaticLibs, depName)
|
||||
case cc.SharedDepTag:
|
||||
depFlag = "-ldylib=" + libName
|
||||
depPaths.linkDirs = append(depPaths.linkDirs, linkPath)
|
||||
depPaths.depFlags = append(depPaths.depFlags, "-l"+libName)
|
||||
depPaths.depFlags = append(depPaths.depFlags, depFlag)
|
||||
directSharedLibDeps = append(directSharedLibDeps, ccDep)
|
||||
mod.Properties.AndroidMkSharedLibs = append(mod.Properties.AndroidMkSharedLibs, depName)
|
||||
exportDep = true
|
||||
|
@ -650,10 +653,10 @@ func (mod *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
|
|||
// Make sure these dependencies are propagated
|
||||
if lib, ok := mod.compiler.(*libraryDecorator); ok && exportDep {
|
||||
lib.linkDirs = append(lib.linkDirs, linkPath)
|
||||
lib.depFlags = append(lib.depFlags, "-l"+libName)
|
||||
lib.depFlags = append(lib.depFlags, depFlag)
|
||||
} else if procMacro, ok := mod.compiler.(*procMacroDecorator); ok && exportDep {
|
||||
procMacro.linkDirs = append(procMacro.linkDirs, linkPath)
|
||||
procMacro.depFlags = append(procMacro.depFlags, "-l"+libName)
|
||||
procMacro.depFlags = append(procMacro.depFlags, depFlag)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue