Merge changes Ied267053,Ica29c649 am: eca59f3dee
am: ee02ef9bd8
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1906612 Change-Id: Ie336ff4b58882364b1a6a90ed614a650f815bbdb
This commit is contained in:
@@ -16,7 +16,6 @@ package cc
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
@@ -25,44 +24,37 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestLibraryHeaders(t *testing.T) {
|
func TestLibraryHeaders(t *testing.T) {
|
||||||
ctx := testCc(t, `
|
bp := `
|
||||||
cc_library_headers {
|
%s {
|
||||||
name: "headers",
|
name: "headers",
|
||||||
export_include_dirs: ["my_include"],
|
export_include_dirs: ["my_include"],
|
||||||
}
|
}
|
||||||
cc_library_static {
|
cc_library_static {
|
||||||
name: "lib",
|
name: "lib",
|
||||||
srcs: ["foo.c"],
|
srcs: ["foo.c"],
|
||||||
header_libs: ["headers"],
|
header_libs: ["headers"],
|
||||||
}
|
}
|
||||||
`)
|
`
|
||||||
|
|
||||||
// test if header search paths are correctly added
|
for _, headerModule := range []string{"cc_library_headers", "cc_prebuilt_library_headers"} {
|
||||||
cc := ctx.ModuleForTests("lib", "android_arm64_armv8-a_static").Rule("cc")
|
t.Run(headerModule, func(t *testing.T) {
|
||||||
cflags := cc.Args["cFlags"]
|
ctx := testCc(t, fmt.Sprintf(bp, headerModule))
|
||||||
if !strings.Contains(cflags, " -Imy_include ") {
|
|
||||||
t.Errorf("cflags for libsystem must contain -Imy_include, but was %#v.", cflags)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestPrebuiltLibraryHeaders(t *testing.T) {
|
// test if header search paths are correctly added
|
||||||
ctx := testCc(t, `
|
cc := ctx.ModuleForTests("lib", "android_arm64_armv8-a_static").Rule("cc")
|
||||||
cc_prebuilt_library_headers {
|
android.AssertStringDoesContain(t, "cFlags for lib module", cc.Args["cFlags"], " -Imy_include ")
|
||||||
name: "headers",
|
|
||||||
export_include_dirs: ["my_include"],
|
|
||||||
}
|
|
||||||
cc_library_static {
|
|
||||||
name: "lib",
|
|
||||||
srcs: ["foo.c"],
|
|
||||||
header_libs: ["headers"],
|
|
||||||
}
|
|
||||||
`)
|
|
||||||
|
|
||||||
// test if header search paths are correctly added
|
// Test that there's a valid AndroidMk entry.
|
||||||
cc := ctx.ModuleForTests("lib", "android_arm64_armv8-a_static").Rule("cc")
|
headers := ctx.ModuleForTests("headers", "android_arm64_armv8-a").Module()
|
||||||
cflags := cc.Args["cFlags"]
|
e := android.AndroidMkEntriesForTest(t, ctx, headers)[0]
|
||||||
if !strings.Contains(cflags, " -Imy_include ") {
|
|
||||||
t.Errorf("cflags for libsystem must contain -Imy_include, but was %#v.", cflags)
|
// This duplicates the tests done in AndroidMkEntries.write. It would be
|
||||||
|
// better to test its output, but there are no test functions that capture that.
|
||||||
|
android.AssertBoolEquals(t, "AndroidMkEntries.Disabled", false, e.Disabled)
|
||||||
|
android.AssertBoolEquals(t, "AndroidMkEntries.OutputFile.Valid()", true, e.OutputFile.Valid())
|
||||||
|
|
||||||
|
android.AssertStringListContains(t, "LOCAL_EXPORT_CFLAGS for headers module", e.EntryMap["LOCAL_EXPORT_CFLAGS"], "-Imy_include")
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -197,7 +197,13 @@ func (p *prebuiltLibraryLinker) link(ctx ModuleContext,
|
|||||||
if p.header() {
|
if p.header() {
|
||||||
ctx.SetProvider(HeaderLibraryInfoProvider, HeaderLibraryInfo{})
|
ctx.SetProvider(HeaderLibraryInfoProvider, HeaderLibraryInfo{})
|
||||||
|
|
||||||
return nil
|
// Need to return an output path so that the AndroidMk logic doesn't skip
|
||||||
|
// the prebuilt header. For compatibility, in case Android.mk files use a
|
||||||
|
// header lib in LOCAL_STATIC_LIBRARIES, create an empty ar file as
|
||||||
|
// placeholder, just like non-prebuilt header modules do in linkStatic().
|
||||||
|
ph := android.PathForModuleOut(ctx, ctx.ModuleName()+staticLibraryExtension)
|
||||||
|
transformObjToStaticLib(ctx, nil, nil, builderFlags{}, ph, nil, nil)
|
||||||
|
return ph
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
Reference in New Issue
Block a user