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

Commit 1f086e2f authored by Inseob Kim's avatar Inseob Kim
Browse files

Generate VNDK snapshot with Soong except configs

This is the first commit to generate VNDK snapshot with Soong: .so
files, some txt files, and notice files are captured with Soong. As
ld.config.txt is currently in Android.mk and will be deprecated soon,
configs files (and zipping all of artifacts) are still handled with
Makefile.

Bug: 131564934
Test: 1) DIST_DIR=out/dist development/vndk/snapshot/build.sh
Test: 2) try installing vndk snapshot with:
     development/vndk/snapshot/update.py

Change-Id: I8629e1e25bfc461fd495565bb4872c9af176cf92
parent 0967b34d
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -288,6 +288,10 @@ func TestArchConfig(buildDir string, env map[string]string) Config {

	config.BuildOsVariant = config.Targets[BuildOs][0].String()
	config.BuildOsCommonVariant = getCommonTargets(config.Targets[BuildOs])[0].String()
	config.TestProductVariables.DeviceArch = proptools.StringPtr("arm64")
	config.TestProductVariables.DeviceArchVariant = proptools.StringPtr("armv8-a")
	config.TestProductVariables.DeviceSecondaryArch = proptools.StringPtr("arm")
	config.TestProductVariables.DeviceSecondaryArchVariant = proptools.StringPtr("armv7-a-neon")

	return testConfig
}
@@ -1100,3 +1104,23 @@ func (c *config) ProductPrivateSepolicyDirs() []string {
func (c *config) ProductCompatibleProperty() bool {
	return Bool(c.productVariables.ProductCompatibleProperty)
}

func (c *deviceConfig) BoardVndkRuntimeDisable() bool {
	return Bool(c.config.productVariables.BoardVndkRuntimeDisable)
}

func (c *deviceConfig) DeviceArch() string {
	return String(c.config.productVariables.DeviceArch)
}

func (c *deviceConfig) DeviceArchVariant() string {
	return String(c.config.productVariables.DeviceArchVariant)
}

func (c *deviceConfig) DeviceSecondaryArch() string {
	return String(c.config.productVariables.DeviceSecondaryArch)
}

func (c *deviceConfig) DeviceSecondaryArchVariant() string {
	return String(c.config.productVariables.DeviceSecondaryArchVariant)
}
+25 −0
Original line number Diff line number Diff line
@@ -52,6 +52,31 @@ func JoinWithPrefix(strs []string, prefix string) string {
	return string(ret)
}

func JoinWithSuffix(strs []string, suffix string, separator string) string {
	if len(strs) == 0 {
		return ""
	}

	if len(strs) == 1 {
		return strs[0] + suffix
	}

	n := len(" ") * (len(strs) - 1)
	for _, s := range strs {
		n += len(suffix) + len(s)
	}

	ret := make([]byte, 0, n)
	for i, s := range strs {
		if i != 0 {
			ret = append(ret, separator...)
		}
		ret = append(ret, s...)
		ret = append(ret, suffix...)
	}
	return string(ret)
}

func sortedKeys(m map[string][]string) []string {
	s := make([]string, 0, len(m))
	for k := range m {
+2 −0
Original line number Diff line number Diff line
@@ -279,6 +279,8 @@ type productVariables struct {
	BoardPlatPrivateSepolicyDirs []string `json:",omitempty"`
	BoardSepolicyM4Defs          []string `json:",omitempty"`

	BoardVndkRuntimeDisable *bool `json:",omitempty"`

	VendorVars map[string]map[string]string `json:",omitempty"`

	Ndk_abis               *bool `json:",omitempty"`
+5 −1
Original line number Diff line number Diff line
@@ -1011,7 +1011,7 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
		}
	}

	if c.installer != nil && !c.Properties.PreventInstall && c.IsForPlatform() && c.outputFile.Valid() {
	if c.installable() {
		c.installer.install(ctx, c.outputFile.Path())
		if ctx.Failed() {
			return
@@ -1968,6 +1968,10 @@ func (c *Module) IsInstallableToApex() bool {
	return false
}

func (c *Module) installable() bool {
	return c.installer != nil && !c.Properties.PreventInstall && c.IsForPlatform() && c.outputFile.Valid()
}

func (c *Module) imageVariation() string {
	variation := "core"
	if c.useVndk() {
+47 −2
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import (
	"fmt"
	"io/ioutil"
	"os"
	"path/filepath"
	"reflect"
	"sort"
	"strings"
@@ -75,6 +76,7 @@ func createTestContext(t *testing.T, config android.Config, bp string, os androi
	ctx.PostDepsMutators(func(ctx android.RegisterMutatorsContext) {
		ctx.TopDown("double_loadable", checkDoubleLoadableLibraries).Parallel()
	})
	ctx.RegisterSingletonType("vndk-snapshot", android.SingletonFactoryAdaptor(VndkSnapshotSingleton))
	ctx.Register()

	// add some modules that are required by the compiler and/or linker
@@ -286,8 +288,28 @@ func checkVndkModule(t *testing.T, ctx *android.TestContext, name, subDir string
	}
}

func checkVndkSnapshot(t *testing.T, ctx *android.TestContext, name, subDir, variant string) {
	vndkSnapshot := ctx.SingletonForTests("vndk-snapshot")

	snapshotPath := filepath.Join(subDir, name+".so")
	mod := ctx.ModuleForTests(name, variant).Module().(*Module)
	if !mod.outputFile.Valid() {
		t.Errorf("%q must have output\n", name)
		return
	}

	out := vndkSnapshot.Output(snapshotPath)
	if out.Input != mod.outputFile.Path() {
		t.Errorf("The input of VNDK snapshot must be %q, but %q", out.Input.String(), mod.outputFile.String())
	}
}

func TestVndk(t *testing.T) {
	ctx := testCc(t, `
	config := android.TestArchConfig(buildDir, nil)
	config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
	config.TestProductVariables.Platform_vndk_version = StringPtr("VER")

	ctx := testCcWithConfig(t, `
		cc_library {
			name: "libvndk",
			vendor_available: true,
@@ -325,12 +347,35 @@ func TestVndk(t *testing.T) {
			},
			nocrt: true,
		}
	`)
	`, config)

	checkVndkModule(t, ctx, "libvndk", "vndk-VER", false, "")
	checkVndkModule(t, ctx, "libvndk_private", "vndk-VER", false, "")
	checkVndkModule(t, ctx, "libvndk_sp", "vndk-sp-VER", true, "")
	checkVndkModule(t, ctx, "libvndk_sp_private", "vndk-sp-VER", true, "")

	// Check VNDK snapshot output.

	snapshotDir := "vndk-snapshot"
	snapshotVariantPath := filepath.Join(buildDir, snapshotDir, "arm64")

	vndkLibPath := filepath.Join(snapshotVariantPath, fmt.Sprintf("arch-%s-%s",
		"arm64", "armv8-a"))
	vndkLib2ndPath := filepath.Join(snapshotVariantPath, fmt.Sprintf("arch-%s-%s",
		"arm", "armv7-a-neon"))

	vndkCoreLibPath := filepath.Join(vndkLibPath, "shared", "vndk-core")
	vndkSpLibPath := filepath.Join(vndkLibPath, "shared", "vndk-sp")
	vndkCoreLib2ndPath := filepath.Join(vndkLib2ndPath, "shared", "vndk-core")
	vndkSpLib2ndPath := filepath.Join(vndkLib2ndPath, "shared", "vndk-sp")

	variant := "android_arm64_armv8-a_vendor_shared"
	variant2nd := "android_arm_armv7-a-neon_vendor_shared"

	checkVndkSnapshot(t, ctx, "libvndk", vndkCoreLibPath, variant)
	checkVndkSnapshot(t, ctx, "libvndk", vndkCoreLib2ndPath, variant2nd)
	checkVndkSnapshot(t, ctx, "libvndk_sp", vndkSpLibPath, variant)
	checkVndkSnapshot(t, ctx, "libvndk_sp", vndkSpLib2ndPath, variant2nd)
}

func TestVndkDepError(t *testing.T) {
Loading