From 45901edb9a6ba7b42136a3ead126f94f76363eb7 Mon Sep 17 00:00:00 2001 From: Ivan Lozano Date: Fri, 24 Jul 2020 16:05:01 -0400 Subject: Ensure hermetic device rust_bindgen. rust_bindgen was not hermetic previously as it would pull in host headers for device targets. This fixes that by using the same flags we use when compiling with Clang. This also makes sure our rust_bindgen headers are built as similar as possible to their respective cc_libraries. This also pulls in the bionic dependencies as well, which provide the headers required for device targets. Bug: 162007475 Test: device rust_bindgen deps file does not reference host headers. Change-Id: I4efdf333e011a6c6d73a0345e5485823f166d17a --- rust/rust.go | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'rust/rust.go') diff --git a/rust/rust.go b/rust/rust.go index 28f8e1a62..8ebd39dcc 100644 --- a/rust/rust.go +++ b/rust/rust.go @@ -256,6 +256,11 @@ type PathDeps struct { depFlags []string //ReexportedDeps android.Paths + // Used by bindgen modules which call clang + depClangFlags []string + depIncludePaths android.Paths + depSystemIncludePaths android.Paths + coverageFiles android.Paths CrtBegin android.OptionalPath @@ -671,7 +676,7 @@ func (mod *Module) GenerateAndroidBuildActions(actx android.ModuleContext) { mod.compiler.install(ctx, mod.outputFile.Path()) } } else if mod.sourceProvider != nil { - outputFile := mod.sourceProvider.generateSource(ctx) + outputFile := mod.sourceProvider.generateSource(ctx, deps) mod.outputFile = android.OptionalPathForPath(outputFile) mod.subName = ctx.ModuleSubDir() } @@ -821,6 +826,11 @@ func (mod *Module) depsToPaths(ctx android.ModuleContext) PathDeps { depFlag = "-lstatic=" + libName depPaths.linkDirs = append(depPaths.linkDirs, linkPath) depPaths.depFlags = append(depPaths.depFlags, depFlag) + depPaths.depIncludePaths = append(depPaths.depIncludePaths, ccDep.IncludeDirs()...) + if mod, ok := ccDep.(*cc.Module); ok { + depPaths.depSystemIncludePaths = append(depPaths.depSystemIncludePaths, mod.ExportedSystemIncludeDirs()...) + depPaths.depClangFlags = append(depPaths.depClangFlags, mod.ExportedFlags()...) + } depPaths.coverageFiles = append(depPaths.coverageFiles, ccDep.CoverageFiles()...) directStaticLibDeps = append(directStaticLibDeps, ccDep) mod.Properties.AndroidMkStaticLibs = append(mod.Properties.AndroidMkStaticLibs, depName) @@ -828,6 +838,11 @@ func (mod *Module) depsToPaths(ctx android.ModuleContext) PathDeps { depFlag = "-ldylib=" + libName depPaths.linkDirs = append(depPaths.linkDirs, linkPath) depPaths.depFlags = append(depPaths.depFlags, depFlag) + depPaths.depIncludePaths = append(depPaths.depIncludePaths, ccDep.IncludeDirs()...) + if mod, ok := ccDep.(*cc.Module); ok { + depPaths.depSystemIncludePaths = append(depPaths.depSystemIncludePaths, mod.ExportedSystemIncludeDirs()...) + depPaths.depClangFlags = append(depPaths.depClangFlags, mod.ExportedFlags()...) + } directSharedLibDeps = append(directSharedLibDeps, ccDep) mod.Properties.AndroidMkSharedLibs = append(mod.Properties.AndroidMkSharedLibs, depName) exportDep = true @@ -877,6 +892,9 @@ func (mod *Module) depsToPaths(ctx android.ModuleContext) PathDeps { // Dedup exported flags from dependencies depPaths.linkDirs = android.FirstUniqueStrings(depPaths.linkDirs) depPaths.depFlags = android.FirstUniqueStrings(depPaths.depFlags) + depPaths.depClangFlags = android.FirstUniqueStrings(depPaths.depClangFlags) + depPaths.depIncludePaths = android.FirstUniquePaths(depPaths.depIncludePaths) + depPaths.depSystemIncludePaths = android.FirstUniquePaths(depPaths.depSystemIncludePaths) return depPaths } -- cgit v1.2.3-59-g8ed1b