Revert "Verify that ndk_headers headers are valid C."
Revert submission 3207854-ensure-c-ndk-headers Reason for revert: Droidmonitor created revert due to b/358445530. Reverted changes: /q/submissionid:3207854-ensure-c-ndk-headers Change-Id: I649941a4d063d76a1c6a8e58fb885da2c44331c0
This commit is contained in:
committed by
Gerrit Code Review
parent
a866829885
commit
181934cc26
@@ -18,7 +18,6 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
|
|
||||||
"github.com/google/blueprint"
|
"github.com/google/blueprint"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -45,7 +44,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Returns the NDK base include path for use with sdk_version current. Usable with -I.
|
// Returns the NDK base include path for use with sdk_version current. Usable with -I.
|
||||||
func getCurrentIncludePath(ctx android.PathContext) android.OutputPath {
|
func getCurrentIncludePath(ctx android.ModuleContext) android.OutputPath {
|
||||||
return getNdkSysrootBase(ctx).Join(ctx, "usr/include")
|
return getNdkSysrootBase(ctx).Join(ctx, "usr/include")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,13 +73,6 @@ type headerProperties struct {
|
|||||||
|
|
||||||
// Path to the NOTICE file associated with the headers.
|
// Path to the NOTICE file associated with the headers.
|
||||||
License *string `android:"path"`
|
License *string `android:"path"`
|
||||||
|
|
||||||
// Set to true if the headers installed by this module should skip
|
|
||||||
// verification. This step ensures that each header is self-contained (can
|
|
||||||
// be #included alone) and is valid C. This should not be disabled except in
|
|
||||||
// rare cases. Outside bionic and external, if you're using this option
|
|
||||||
// you've probably made a mistake.
|
|
||||||
Skip_verification *bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type headerModule struct {
|
type headerModule struct {
|
||||||
@@ -317,13 +309,6 @@ type preprocessedHeadersProperties struct {
|
|||||||
|
|
||||||
// Path to the NOTICE file associated with the headers.
|
// Path to the NOTICE file associated with the headers.
|
||||||
License *string
|
License *string
|
||||||
|
|
||||||
// Set to true if the headers installed by this module should skip
|
|
||||||
// verification. This step ensures that each header is self-contained (can
|
|
||||||
// be #included alone) and is valid C. This should not be disabled except in
|
|
||||||
// rare cases. Outside bionic and external, if you're using this option
|
|
||||||
// you've probably made a mistake.
|
|
||||||
Skip_verification *bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type preprocessedHeadersModule struct {
|
type preprocessedHeadersModule struct {
|
||||||
|
@@ -54,22 +54,7 @@ package cc
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
"fmt"
|
|
||||||
"path/filepath"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/google/blueprint"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
verifyCCompat = pctx.AndroidStaticRule("verifyCCompat",
|
|
||||||
blueprint.RuleParams{
|
|
||||||
Command: "$ccCmd -x c -fsyntax-only $flags $in && touch $out",
|
|
||||||
CommandDeps: []string{"$ccCmd"},
|
|
||||||
},
|
|
||||||
"ccCmd",
|
|
||||||
"flags",
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@@ -118,45 +103,6 @@ func getNdkABIHeadersFile(ctx android.PathContext) android.WritablePath {
|
|||||||
return android.PathForOutput(ctx, "ndk_abi_headers.txt")
|
return android.PathForOutput(ctx, "ndk_abi_headers.txt")
|
||||||
}
|
}
|
||||||
|
|
||||||
func verifyNdkHeaderIsCCompatible(ctx android.SingletonContext,
|
|
||||||
src android.Path, dest android.Path) android.Path {
|
|
||||||
sysrootInclude := getCurrentIncludePath(ctx)
|
|
||||||
baseOutputDir := android.PathForOutput(ctx, "c-compat-verification")
|
|
||||||
installRelPath, err := filepath.Rel(sysrootInclude.String(), dest.String())
|
|
||||||
if err != nil {
|
|
||||||
ctx.Errorf("filepath.Rel(%q, %q) failed: %s", dest, sysrootInclude, err)
|
|
||||||
}
|
|
||||||
output := baseOutputDir.Join(ctx, installRelPath)
|
|
||||||
ctx.Build(pctx, android.BuildParams{
|
|
||||||
Rule: verifyCCompat,
|
|
||||||
Description: fmt.Sprintf("Verifying C compatibility of %s", src),
|
|
||||||
Output: output,
|
|
||||||
Input: dest,
|
|
||||||
// Ensures that all the headers in the sysroot are already installed
|
|
||||||
// before testing any of the headers for C compatibility, and also that
|
|
||||||
// the check will be re-run whenever the sysroot changes. This is
|
|
||||||
// necessary because many of the NDK headers depend on other NDK
|
|
||||||
// headers, but we don't have explicit dependency tracking for that.
|
|
||||||
Implicits: []android.Path{getNdkHeadersTimestampFile(ctx)},
|
|
||||||
Args: map[string]string{
|
|
||||||
"ccCmd": "${config.ClangBin}/clang",
|
|
||||||
"flags": fmt.Sprintf(
|
|
||||||
// Ideally we'd check each ABI, multiple API levels,
|
|
||||||
// fortify/non-fortify, and a handful of other variations. It's
|
|
||||||
// a lot more difficult to do that though, and would eat up more
|
|
||||||
// build time. All the problems we've seen so far that this
|
|
||||||
// check would catch have been in arch-generic and
|
|
||||||
// minSdkVersion-generic code in frameworks though, so this is a
|
|
||||||
// good place to start.
|
|
||||||
"-target aarch64-linux-android%d --sysroot %s",
|
|
||||||
android.FutureApiLevel.FinalOrFutureInt(),
|
|
||||||
getNdkSysrootBase(ctx).String(),
|
|
||||||
),
|
|
||||||
},
|
|
||||||
})
|
|
||||||
return output
|
|
||||||
}
|
|
||||||
|
|
||||||
func NdkSingleton() android.Singleton {
|
func NdkSingleton() android.Singleton {
|
||||||
return &ndkSingleton{}
|
return &ndkSingleton{}
|
||||||
}
|
}
|
||||||
@@ -197,17 +143,10 @@ func writeNdkAbiSrcFilter(ctx android.BuilderContext,
|
|||||||
|
|
||||||
type ndkSingleton struct{}
|
type ndkSingleton struct{}
|
||||||
|
|
||||||
type srcDestPair struct {
|
|
||||||
src android.Path
|
|
||||||
dest android.Path
|
|
||||||
}
|
|
||||||
|
|
||||||
func (n *ndkSingleton) GenerateBuildActions(ctx android.SingletonContext) {
|
func (n *ndkSingleton) GenerateBuildActions(ctx android.SingletonContext) {
|
||||||
var staticLibInstallPaths android.Paths
|
var staticLibInstallPaths android.Paths
|
||||||
var headerSrcPaths android.Paths
|
var headerSrcPaths android.Paths
|
||||||
var headerInstallPaths android.Paths
|
var headerInstallPaths android.Paths
|
||||||
var headersToVerify []srcDestPair
|
|
||||||
var headerCCompatVerificationTimestampPaths android.Paths
|
|
||||||
var installPaths android.Paths
|
var installPaths android.Paths
|
||||||
var licensePaths android.Paths
|
var licensePaths android.Paths
|
||||||
ctx.VisitAllModules(func(module android.Module) {
|
ctx.VisitAllModules(func(module android.Module) {
|
||||||
@@ -218,14 +157,6 @@ func (n *ndkSingleton) GenerateBuildActions(ctx android.SingletonContext) {
|
|||||||
if m, ok := module.(*headerModule); ok {
|
if m, ok := module.(*headerModule); ok {
|
||||||
headerSrcPaths = append(headerSrcPaths, m.srcPaths...)
|
headerSrcPaths = append(headerSrcPaths, m.srcPaths...)
|
||||||
headerInstallPaths = append(headerInstallPaths, m.installPaths...)
|
headerInstallPaths = append(headerInstallPaths, m.installPaths...)
|
||||||
if !Bool(m.properties.Skip_verification) {
|
|
||||||
for i, installPath := range m.installPaths {
|
|
||||||
headersToVerify = append(headersToVerify, srcDestPair{
|
|
||||||
src: m.srcPaths[i],
|
|
||||||
dest: installPath,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
installPaths = append(installPaths, m.installPaths...)
|
installPaths = append(installPaths, m.installPaths...)
|
||||||
licensePaths = append(licensePaths, m.licensePath)
|
licensePaths = append(licensePaths, m.licensePath)
|
||||||
}
|
}
|
||||||
@@ -233,10 +164,6 @@ func (n *ndkSingleton) GenerateBuildActions(ctx android.SingletonContext) {
|
|||||||
if m, ok := module.(*versionedHeaderModule); ok {
|
if m, ok := module.(*versionedHeaderModule); ok {
|
||||||
headerSrcPaths = append(headerSrcPaths, m.srcPaths...)
|
headerSrcPaths = append(headerSrcPaths, m.srcPaths...)
|
||||||
headerInstallPaths = append(headerInstallPaths, m.installPaths...)
|
headerInstallPaths = append(headerInstallPaths, m.installPaths...)
|
||||||
// Verification intentionally not done for headers that go through
|
|
||||||
// versioner. It'd be nice to have, but the only user is bionic, and
|
|
||||||
// that one module would also need to use skip_verification, so it
|
|
||||||
// wouldn't help at all.
|
|
||||||
installPaths = append(installPaths, m.installPaths...)
|
installPaths = append(installPaths, m.installPaths...)
|
||||||
licensePaths = append(licensePaths, m.licensePath)
|
licensePaths = append(licensePaths, m.licensePath)
|
||||||
}
|
}
|
||||||
@@ -244,14 +171,6 @@ func (n *ndkSingleton) GenerateBuildActions(ctx android.SingletonContext) {
|
|||||||
if m, ok := module.(*preprocessedHeadersModule); ok {
|
if m, ok := module.(*preprocessedHeadersModule); ok {
|
||||||
headerSrcPaths = append(headerSrcPaths, m.srcPaths...)
|
headerSrcPaths = append(headerSrcPaths, m.srcPaths...)
|
||||||
headerInstallPaths = append(headerInstallPaths, m.installPaths...)
|
headerInstallPaths = append(headerInstallPaths, m.installPaths...)
|
||||||
if !Bool(m.properties.Skip_verification) {
|
|
||||||
for i, installPath := range m.installPaths {
|
|
||||||
headersToVerify = append(headersToVerify, srcDestPair{
|
|
||||||
src: m.srcPaths[i],
|
|
||||||
dest: installPath,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
installPaths = append(installPaths, m.installPaths...)
|
installPaths = append(installPaths, m.installPaths...)
|
||||||
licensePaths = append(licensePaths, m.licensePath)
|
licensePaths = append(licensePaths, m.licensePath)
|
||||||
}
|
}
|
||||||
@@ -304,12 +223,6 @@ func (n *ndkSingleton) GenerateBuildActions(ctx android.SingletonContext) {
|
|||||||
Implicits: headerInstallPaths,
|
Implicits: headerInstallPaths,
|
||||||
})
|
})
|
||||||
|
|
||||||
for _, srcDestPair := range headersToVerify {
|
|
||||||
headerCCompatVerificationTimestampPaths = append(
|
|
||||||
headerCCompatVerificationTimestampPaths,
|
|
||||||
verifyNdkHeaderIsCCompatible(ctx, srcDestPair.src, srcDestPair.dest))
|
|
||||||
}
|
|
||||||
|
|
||||||
writeNdkAbiSrcFilter(ctx, headerSrcPaths, getNdkABIHeadersFile(ctx))
|
writeNdkAbiSrcFilter(ctx, headerSrcPaths, getNdkABIHeadersFile(ctx))
|
||||||
|
|
||||||
fullDepPaths := append(staticLibInstallPaths, getNdkBaseTimestampFile(ctx))
|
fullDepPaths := append(staticLibInstallPaths, getNdkBaseTimestampFile(ctx))
|
||||||
@@ -322,6 +235,6 @@ func (n *ndkSingleton) GenerateBuildActions(ctx android.SingletonContext) {
|
|||||||
ctx.Build(pctx, android.BuildParams{
|
ctx.Build(pctx, android.BuildParams{
|
||||||
Rule: android.Touch,
|
Rule: android.Touch,
|
||||||
Output: getNdkFullTimestampFile(ctx),
|
Output: getNdkFullTimestampFile(ctx),
|
||||||
Implicits: append(fullDepPaths, headerCCompatVerificationTimestampPaths...),
|
Implicits: fullDepPaths,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user