Revert "Revert "Revert "Revert "Export static libraries.""""

This reverts commit 555c114283.

Reason for revert: The namespace issue in the pi-dev-plus-aosp-without-vendor branch is now fixed.

Change-Id: I26ed591447797a8ee505f43bdd209162418b6c5e
This commit is contained in:
Jaewoong Jung 2018-11-16 01:19:56 +00:00
parent c508121448
commit 16c7d3d263
5 changed files with 60 additions and 7 deletions

View File

@ -435,6 +435,7 @@ toolchain_library {
src: "prebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8/x86_64-w64-mingw32/lib/libwinpthread.a",
},
},
notice: "../../prebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8/licenses/mingw-w64-svn-r5861/mingw-w64-libraries/winpthreads/COPYING",
}
toolchain_library {

View File

@ -275,9 +275,10 @@ func translateAndroidModule(ctx SingletonContext, w io.Writer, mod blueprint.Mod
if amod.commonProperties.Owner != nil {
fmt.Fprintln(&data.preamble, "LOCAL_MODULE_OWNER :=", *amod.commonProperties.Owner)
}
if amod.commonProperties.Notice != nil {
fmt.Fprintln(&data.preamble, "LOCAL_NOTICE_FILE :=", "$(LOCAL_PATH)/"+*amod.commonProperties.Notice)
}
}
if amod.commonProperties.Notice != nil {
fmt.Fprintln(&data.preamble, "LOCAL_NOTICE_FILE :=", "$(LOCAL_PATH)/"+*amod.commonProperties.Notice)
}
if host {

View File

@ -70,6 +70,12 @@ func (c *Module) AndroidMk() android.AndroidMkData {
if len(c.Properties.AndroidMkSharedLibs) > 0 {
fmt.Fprintln(w, "LOCAL_SHARED_LIBRARIES := "+strings.Join(c.Properties.AndroidMkSharedLibs, " "))
}
if len(c.Properties.AndroidMkStaticLibs) > 0 {
fmt.Fprintln(w, "LOCAL_STATIC_LIBRARIES := "+strings.Join(c.Properties.AndroidMkStaticLibs, " "))
}
if len(c.Properties.AndroidMkWholeStaticLibs) > 0 {
fmt.Fprintln(w, "LOCAL_WHOLE_STATIC_LIBRARIES := "+strings.Join(c.Properties.AndroidMkWholeStaticLibs, " "))
}
fmt.Fprintln(w, "LOCAL_SOONG_LINK_TYPE :=", c.getMakeLinkType())
if c.useVndk() {
fmt.Fprintln(w, "LOCAL_USE_VNDK := true")

View File

@ -175,10 +175,12 @@ type BaseProperties struct {
// Minimum sdk version supported when compiling against the ndk
Sdk_version *string
AndroidMkSharedLibs []string `blueprint:"mutated"`
AndroidMkRuntimeLibs []string `blueprint:"mutated"`
HideFromMake bool `blueprint:"mutated"`
PreventInstall bool `blueprint:"mutated"`
AndroidMkSharedLibs []string `blueprint:"mutated"`
AndroidMkStaticLibs []string `blueprint:"mutated"`
AndroidMkRuntimeLibs []string `blueprint:"mutated"`
AndroidMkWholeStaticLibs []string `blueprint:"mutated"`
HideFromMake bool `blueprint:"mutated"`
PreventInstall bool `blueprint:"mutated"`
UseVndk bool `blueprint:"mutated"`
@ -1478,9 +1480,15 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
// they merely serve as Make dependencies and do not affect this lib itself.
c.Properties.AndroidMkSharedLibs = append(
c.Properties.AndroidMkSharedLibs, makeLibName(depName))
case staticDepTag, staticExportDepTag, lateStaticDepTag:
c.Properties.AndroidMkStaticLibs = append(
c.Properties.AndroidMkStaticLibs, makeLibName(depName))
case runtimeDepTag:
c.Properties.AndroidMkRuntimeLibs = append(
c.Properties.AndroidMkRuntimeLibs, makeLibName(depName))
case wholeStaticDepTag:
c.Properties.AndroidMkWholeStaticLibs = append(
c.Properties.AndroidMkWholeStaticLibs, makeLibName(depName))
}
})

View File

@ -1545,6 +1545,43 @@ func TestRuntimeLibsNoVndk(t *testing.T) {
checkRuntimeLibs(t, []string{"libvendor_available1", "libvendor1"}, module)
}
func checkStaticLibs(t *testing.T, expected []string, module *Module) {
actual := module.Properties.AndroidMkStaticLibs
if !reflect.DeepEqual(actual, expected) {
t.Errorf("incorrect static_libs"+
"\nactual: %v"+
"\nexpected: %v",
actual,
expected,
)
}
}
const staticLibAndroidBp = `
cc_library {
name: "lib1",
}
cc_library {
name: "lib2",
static_libs: ["lib1"],
}
`
func TestStaticLibDepExport(t *testing.T) {
ctx := testCc(t, staticLibAndroidBp)
// Check the shared version of lib2.
variant := "android_arm64_armv8-a_core_shared"
module := ctx.ModuleForTests("lib2", variant).Module().(*Module)
checkStaticLibs(t, []string{"lib1", "libclang_rt.builtins-aarch64-android", "libatomic", "libgcc"}, module)
// Check the static version of lib2.
variant = "android_arm64_armv8-a_core_static"
module = ctx.ModuleForTests("lib2", variant).Module().(*Module)
// libc++_static is linked additionally.
checkStaticLibs(t, []string{"lib1", "libc++_static", "libclang_rt.builtins-aarch64-android", "libatomic", "libgcc"}, module)
}
var compilerFlagsTestCases = []struct {
in string
out bool