NDK library: collect NDK headers for ABI monitoring
Collect all NDK exported headers paths into a file that is used to
detect public types that should be ABI monitored.
Assume that we have the following code in exported header:
typedef struct Context Context;
typedef struct Output {
...
} Output;
void DoSomething(Context* ctx, Output* output);
If none of public headers exported to end-users contain definition of
"struct Context", then "struct Context" layout and members shouldn't be
monitored. However we use DWARF information from a real library, which
may have access to the definition of "string Context" from
implementation headers, and it will leak to ABI.
STG tool doesn't access source and header files, only DWARF information
from compiled library. And the DWARF contains file name where a type is
defined. So we need a rule to build a list of paths to public headers,
so STG can distinguish private types from public and do not monitor
private types that are not accessible to library users.
Bug: 156513478
Test: development/tools/ndk/update_ndk_abi.sh with enabled canDumpAbi
Change-Id: I9fa41e73450a41379638debb3dc56f421e0fb870
Signed-off-by: Aleksei Vetrov <vvvvvv@google.com>
diff --git a/cc/ndk_headers.go b/cc/ndk_headers.go
index d0ae4a5..1a8e90f 100644
--- a/cc/ndk_headers.go
+++ b/cc/ndk_headers.go
@@ -82,6 +82,7 @@
properties headerProperties
+ srcPaths android.Paths
installPaths android.Paths
licensePath android.Path
}
@@ -125,8 +126,8 @@
m.licensePath = android.PathForModuleSrc(ctx, String(m.properties.License))
- srcFiles := android.PathsForModuleSrcExcludes(ctx, m.properties.Srcs, m.properties.Exclude_srcs)
- for _, header := range srcFiles {
+ m.srcPaths = android.PathsForModuleSrcExcludes(ctx, m.properties.Srcs, m.properties.Exclude_srcs)
+ for _, header := range m.srcPaths {
installDir := getHeaderInstallDir(ctx, header, String(m.properties.From),
String(m.properties.To))
installedPath := ctx.InstallFile(installDir, header.Base(), header)
@@ -193,6 +194,7 @@
properties versionedHeaderProperties
+ srcPaths android.Paths
installPaths android.Paths
licensePath android.Path
}
@@ -211,9 +213,9 @@
fromSrcPath := android.PathForModuleSrc(ctx, String(m.properties.From))
toOutputPath := getCurrentIncludePath(ctx).Join(ctx, String(m.properties.To))
- srcFiles := ctx.GlobFiles(headerGlobPattern(fromSrcPath.String()), nil)
+ m.srcPaths = ctx.GlobFiles(headerGlobPattern(fromSrcPath.String()), nil)
var installPaths []android.WritablePath
- for _, header := range srcFiles {
+ for _, header := range m.srcPaths {
installDir := getHeaderInstallDir(ctx, header, String(m.properties.From), String(m.properties.To))
installPath := installDir.Join(ctx, header.Base())
installPaths = append(installPaths, installPath)
@@ -224,11 +226,11 @@
ctx.ModuleErrorf("glob %q matched zero files", String(m.properties.From))
}
- processHeadersWithVersioner(ctx, fromSrcPath, toOutputPath, srcFiles, installPaths)
+ processHeadersWithVersioner(ctx, fromSrcPath, toOutputPath, m.srcPaths, installPaths)
}
func processHeadersWithVersioner(ctx android.ModuleContext, srcDir, outDir android.Path,
- srcFiles android.Paths, installPaths []android.WritablePath) android.Path {
+ srcPaths android.Paths, installPaths []android.WritablePath) android.Path {
// The versioner depends on a dependencies directory to simplify determining include paths
// when parsing headers. This directory contains architecture specific directories as well
// as a common directory, each of which contains symlinks to the actually directories to
@@ -253,7 +255,7 @@
Rule: versionBionicHeaders,
Description: "versioner preprocess " + srcDir.Rel(),
Output: timestampFile,
- Implicits: append(srcFiles, depsGlob...),
+ Implicits: append(srcPaths, depsGlob...),
ImplicitOutputs: installPaths,
Args: map[string]string{
"depsPath": depsPath.String(),
@@ -317,6 +319,7 @@
properties preprocessedHeadersProperties
+ srcPaths android.Paths
installPaths android.Paths
licensePath android.Path
}
@@ -329,9 +332,9 @@
preprocessor := android.PathForModuleSrc(ctx, String(m.properties.Preprocessor))
m.licensePath = android.PathForModuleSrc(ctx, String(m.properties.License))
- srcFiles := android.PathsForModuleSrcExcludes(ctx, m.properties.Srcs, m.properties.Exclude_srcs)
+ m.srcPaths = android.PathsForModuleSrcExcludes(ctx, m.properties.Srcs, m.properties.Exclude_srcs)
installDir := getCurrentIncludePath(ctx).Join(ctx, String(m.properties.To))
- for _, src := range srcFiles {
+ for _, src := range m.srcPaths {
installPath := installDir.Join(ctx, src.Base())
m.installPaths = append(m.installPaths, installPath)