Remove -include <file> when compiling stubs. am: 6437995170
am: b24226fdcc
Change-Id: Ie286839df36ba9bd7bf439e233c888d3c1a715cf
This commit is contained in:
@@ -267,6 +267,7 @@ func TestApexWithStubs(t *testing.T) {
|
|||||||
cc_library {
|
cc_library {
|
||||||
name: "mylib2",
|
name: "mylib2",
|
||||||
srcs: ["mylib.cpp"],
|
srcs: ["mylib.cpp"],
|
||||||
|
cflags: ["-include mylib.h"],
|
||||||
system_shared_libs: [],
|
system_shared_libs: [],
|
||||||
stl: "none",
|
stl: "none",
|
||||||
stubs: {
|
stubs: {
|
||||||
@@ -316,6 +317,10 @@ func TestApexWithStubs(t *testing.T) {
|
|||||||
ensureContains(t, mylibLdFlags, "mylib3/android_arm64_armv8-a_shared_myapex/mylib3.so")
|
ensureContains(t, mylibLdFlags, "mylib3/android_arm64_armv8-a_shared_myapex/mylib3.so")
|
||||||
// .. and not linking to the stubs variant of mylib3
|
// .. and not linking to the stubs variant of mylib3
|
||||||
ensureNotContains(t, mylibLdFlags, "mylib3/android_arm64_armv8-a_shared_12_myapex/mylib3.so")
|
ensureNotContains(t, mylibLdFlags, "mylib3/android_arm64_armv8-a_shared_12_myapex/mylib3.so")
|
||||||
|
|
||||||
|
// Ensure that stubs libs are built without -include flags
|
||||||
|
mylib2Cflags := ctx.ModuleForTests("mylib2", "android_arm64_armv8-a_static_myapex").Rule("cc").Args["cFlags"]
|
||||||
|
ensureNotContains(t, mylib2Cflags, "-include ")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestApexWithExplicitStubsDependency(t *testing.T) {
|
func TestApexWithExplicitStubsDependency(t *testing.T) {
|
||||||
|
@@ -351,6 +351,24 @@ func (library *libraryDecorator) compilerFlags(ctx ModuleContext, flags Flags, d
|
|||||||
|
|
||||||
flags = library.baseCompiler.compilerFlags(ctx, flags, deps)
|
flags = library.baseCompiler.compilerFlags(ctx, flags, deps)
|
||||||
if library.buildStubs() {
|
if library.buildStubs() {
|
||||||
|
// Remove -include <file> when compiling stubs. Otherwise, the force included
|
||||||
|
// headers might cause conflicting types error with the symbols in the
|
||||||
|
// generated stubs source code. e.g.
|
||||||
|
// double acos(double); // in header
|
||||||
|
// void acos() {} // in the generated source code
|
||||||
|
removeInclude := func(flags []string) []string {
|
||||||
|
ret := flags[:0]
|
||||||
|
for _, f := range flags {
|
||||||
|
if strings.HasPrefix(f, "-include ") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
ret = append(ret, f)
|
||||||
|
}
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
flags.GlobalFlags = removeInclude(flags.GlobalFlags)
|
||||||
|
flags.CFlags = removeInclude(flags.CFlags)
|
||||||
|
|
||||||
flags = addStubLibraryCompilerFlags(flags)
|
flags = addStubLibraryCompilerFlags(flags)
|
||||||
}
|
}
|
||||||
return flags
|
return flags
|
||||||
|
Reference in New Issue
Block a user