Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4c48f724 authored by Jiyong Park's avatar Jiyong Park
Browse files

install *.so in different paths for their types

Shared libraries are now installed to different directories depending on
their types.

* NDK libraries: /system/lib/ndk
* VNDK libraries: /system/lib/vndk
* VNDK-ext libraries: /system/lib/vndk-ext
* Framework-only libraries: /system/lib
* Vendor-only libraries: /vendor/lib
* Same-process HALs: /vendor/lib/sameprocess

In addition, a new module type vndk_ext_library is added. It is almost
identical to cc_shared_library but it introduces another attribute
'extends'. This is use to reference the vndk library that this vndk-ext
library is extending.

For example, in order to extend a vndk library libFoo:

cc_library {
  name: "libFoo",
  srcs: [...]
}
---------------------
vndk_ext_library {
  name: "libFoo-extended",
  srcs: [...]
  extends: "libFoo"
}

Then, libFoo will be installed as /system/lib/vndk/libFoo.so and
libFoo-extended will be installed as /system/lib/vndk-ext/libFoo.so.
Note that file name of the latter is libFoo.so, not libFoo-extended.so:
file name of an extending module is automatically set to that of the
extended module.

Bug: 33681361
Test: build & run. Libraries must be in the correct directories.
Change-Id: Ia1eb3940605d582a252c78da0f3a5b36fdab062b
parent 300151ba
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -145,6 +145,8 @@ bootstrap_go_package {
        "cc/ndk_headers.go",
        "cc/ndk_library.go",
        "cc/ndk_sysroot.go",

        "cc/vndk_library.go",
    ],
    testSrcs: [
        "cc/cc_test.go",
+4 −0
Original line number Diff line number Diff line
@@ -496,3 +496,7 @@ func (c *deviceConfig) CoverageEnabledForPath(path string) bool {
	}
	return coverage
}

func (c *deviceConfig) SameProcessHalDeps() []string {
	return append([]string(nil), c.config.ProductVariables.SameProcessHalDeps...)
}
+2 −0
Original line number Diff line number Diff line
@@ -135,6 +135,8 @@ type productVariables struct {
	ArtUseReadBarrier *bool `json:",omitempty"`

	BtConfigIncludeDir *string `json:",omitempty"`

	SameProcessHalDeps []string `json:",omitempty"`
}

func boolPtr(v bool) *bool {
+8 −0
Original line number Diff line number Diff line
@@ -156,6 +156,14 @@ func (library *libraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.An
	}
}

func (vndkLibrary *vndkExtLibraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
	ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) error {
		fmt.Fprintln(w, "LOCAL_EXTENDS_MODULE := ", vndkLibrary.properties.Extends)
		return nil
	})
	vndkLibrary.libraryDecorator.AndroidMk(ctx, ret)
}

func (object *objectLinker) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
	ret.Custom = func(w io.Writer, name, prefix, moduleDir string) error {
		out := ret.OutputFile.Path()
+15 −0
Original line number Diff line number Diff line
@@ -162,6 +162,9 @@ type ModuleContextIntf interface {
	vndk() bool
	selectedStl() string
	baseModuleName() string
	isNdk() bool
	isVndk() bool
	isSameProcessHal() bool
}

type ModuleContext interface {
@@ -404,6 +407,18 @@ func (ctx *moduleContextImpl) baseModuleName() string {
	return ctx.mod.ModuleBase.BaseModuleName()
}

func (ctx *moduleContextImpl) isNdk() bool {
	return inList(ctx.baseModuleName(), ndkPrebuiltSharedLibraries)
}

func (ctx *moduleContextImpl) isVndk() bool {
	return config.IsVndkLibrary(ctx.baseModuleName())
}

func (ctx *moduleContextImpl) isSameProcessHal() bool {
	return inList(ctx.baseModuleName(), ctx.ctx.DeviceConfig().SameProcessHalDeps())
}

func newBaseModule(hod android.HostOrDeviceSupported, multilib android.Multilib) *Module {
	return &Module{
		hod:      hod,
Loading