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

Commit e8cb9178 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge changes I5645ddb9,Ib3d50f15,Ib4c5815a,If3b63706 into main

* changes:
  Revert "Revert^2 "Always embed jni libs and store uncompressed""
  Revert "Revert "Revert "Collect transitve deps of jni libs only for bund...""
  Revert "Add SkipToTransitiveDepsTag interface for dependency tags"
  Revert "Install transitive deps of jni libs, but not the jni libs themselves"
parents 635e1218 d044bb40
Loading
Loading
Loading
Loading
+0 −15
Original line number Diff line number Diff line
@@ -44,21 +44,6 @@ func IsInstallDepNeededTag(tag blueprint.DependencyTag) bool {
	return false
}

// Dependency tags can implement this interface and return true from SkipToTransitiveDeps to
// annotate that this dependency isn't installed, but its transitive dependencies are. This is
// useful when a module is built into another module (ex: static linking) but the module still has
// runtime dependencies.
type SkipToTransitiveDepsTag interface {
	SkipToTransitiveDeps() bool
}

func IsSkipToTransitiveDepsTag(tag blueprint.DependencyTag) bool {
	if i, ok := tag.(SkipToTransitiveDepsTag); ok {
		return i.SkipToTransitiveDeps()
	}
	return false
}

type PropagateAconfigValidationDependencyTag interface {
	PropagateAconfigValidation() bool
}
+3 −15
Original line number Diff line number Diff line
@@ -1474,28 +1474,16 @@ func (m *ModuleBase) computeInstallDeps(ctx ModuleContext) ([]*DepSet[InstallPat
	var installDeps []*DepSet[InstallPath]
	var packagingSpecs []*DepSet[PackagingSpec]
	ctx.VisitDirectDeps(func(dep Module) {
		depTag := ctx.OtherModuleDependencyTag(dep)
		// If this is true, the direct outputs from the module is not gathered, but its
		// transitive deps are still gathered.
		skipToTransitive := IsSkipToTransitiveDepsTag(depTag)
		if isInstallDepNeeded(dep, depTag) || skipToTransitive {
		if isInstallDepNeeded(dep, ctx.OtherModuleDependencyTag(dep)) {
			// Installation is still handled by Make, so anything hidden from Make is not
			// installable.
			if !dep.IsHideFromMake() && !dep.IsSkipInstall() {
				if skipToTransitive {
					installDeps = append(installDeps, dep.base().installFilesDepSet.transitive...)
				} else {
				installDeps = append(installDeps, dep.base().installFilesDepSet)
			}
			}
			// Add packaging deps even when the dependency is not installed so that uninstallable
			// modules can still be packaged.  Often the package will be installed instead.
			if skipToTransitive {
				packagingSpecs = append(packagingSpecs, dep.base().packagingSpecsDepSet.transitive...)
			} else {
			packagingSpecs = append(packagingSpecs, dep.base().packagingSpecsDepSet)
		}
		}
	})

	return installDeps, packagingSpecs
+2 −43
Original line number Diff line number Diff line
@@ -26,7 +26,6 @@ type componentTestModule struct {
	ModuleBase
	props struct {
		Deps         []string
		Build_only_deps []string
		Skip_install *bool
	}
}
@@ -37,18 +36,6 @@ type installDepTag struct {
	InstallAlwaysNeededDependencyTag
}

// dep tag for build_only_deps
type buildOnlyDepTag struct {
	blueprint.BaseDependencyTag
	InstallAlwaysNeededDependencyTag
}

var _ SkipToTransitiveDepsTag = (*buildOnlyDepTag)(nil)

func (tag buildOnlyDepTag) SkipToTransitiveDeps() bool {
	return true
}

func componentTestModuleFactory() Module {
	m := &componentTestModule{}
	m.AddProperties(&m.props)
@@ -58,7 +45,6 @@ func componentTestModuleFactory() Module {

func (m *componentTestModule) DepsMutator(ctx BottomUpMutatorContext) {
	ctx.AddDependency(ctx.Module(), installDepTag{}, m.props.Deps...)
	ctx.AddDependency(ctx.Module(), buildOnlyDepTag{}, m.props.Build_only_deps...)
}

func (m *componentTestModule) GenerateAndroidBuildActions(ctx ModuleContext) {
@@ -412,30 +398,3 @@ func TestPackagingWithSkipInstallDeps(t *testing.T) {
		}
		`, []string{"lib64/foo", "lib64/bar", "lib64/baz"})
}

func TestPackagingWithSkipToTransitvDeps(t *testing.T) {
	// packag -[deps]-> foo -[build_only_deps]-> bar -[deps]-> baz
	// bar isn't installed, but it brings baz to its parent.
	multiTarget := false
	runPackagingTest(t, multiTarget,
		`
		component {
			name: "foo",
			build_only_deps: ["bar"],
		}

		component {
			name: "bar",
			deps: ["baz"],
		}

		component {
			name: "baz",
		}

		package_module {
			name: "package",
			deps: ["foo"],
		}
		`, []string{"lib64/foo", "lib64/baz"})
}
+18 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ package java
import (
	"fmt"
	"io"
	"strings"

	"android/soong/android"

@@ -412,6 +413,23 @@ func (app *AndroidApp) AndroidMkEntries() []android.AndroidMkEntries {
				if app.embeddedJniLibs {
					jniSymbols := app.JNISymbolsInstalls(app.installPathForJNISymbols.String())
					entries.SetString("LOCAL_SOONG_JNI_LIBS_SYMBOLS", jniSymbols.String())
				} else {
					for _, jniLib := range app.jniLibs {
						entries.AddStrings("LOCAL_SOONG_JNI_LIBS_"+jniLib.target.Arch.ArchType.String(), jniLib.name)
						var partitionTag string

						// Mimic the creation of partition_tag in build/make,
						// which defaults to an empty string when the partition is system.
						// Otherwise, capitalize with a leading _
						if jniLib.partition == "system" {
							partitionTag = ""
						} else {
							split := strings.Split(jniLib.partition, "/")
							partitionTag = "_" + strings.ToUpper(split[len(split)-1])
						}
						entries.AddStrings("LOCAL_SOONG_JNI_LIBS_PARTITION_"+jniLib.target.Arch.ArchType.String(),
							jniLib.name+":"+partitionTag)
					}
				}

				if len(app.jniCoverageOutputs) > 0 {
+149 −0
Original line number Diff line number Diff line
@@ -19,6 +19,9 @@ import (
	"testing"

	"android/soong/android"
	"android/soong/cc"

	"github.com/google/blueprint/proptools"
)

func TestRequired(t *testing.T) {
@@ -252,3 +255,149 @@ func TestGetOverriddenPackages(t *testing.T) {
		android.AssertDeepEquals(t, "overrides property", expected.overrides, actual)
	}
}

func TestJniPartition(t *testing.T) {
	bp := `
		cc_library {
			name: "libjni_system",
			system_shared_libs: [],
			sdk_version: "current",
			stl: "none",
		}

		cc_library {
			name: "libjni_system_ext",
			system_shared_libs: [],
			sdk_version: "current",
			stl: "none",
			system_ext_specific: true,
		}

		cc_library {
			name: "libjni_odm",
			system_shared_libs: [],
			sdk_version: "current",
			stl: "none",
			device_specific: true,
		}

		cc_library {
			name: "libjni_product",
			system_shared_libs: [],
			sdk_version: "current",
			stl: "none",
			product_specific: true,
		}

		cc_library {
			name: "libjni_vendor",
			system_shared_libs: [],
			sdk_version: "current",
			stl: "none",
			soc_specific: true,
		}

		android_app {
			name: "test_app_system_jni_system",
			privileged: true,
			platform_apis: true,
			certificate: "platform",
			jni_libs: ["libjni_system"],
		}

		android_app {
			name: "test_app_system_jni_system_ext",
			privileged: true,
			platform_apis: true,
			certificate: "platform",
			jni_libs: ["libjni_system_ext"],
		}

		android_app {
			name: "test_app_system_ext_jni_system",
			privileged: true,
			platform_apis: true,
			certificate: "platform",
			jni_libs: ["libjni_system"],
			system_ext_specific: true
		}

		android_app {
			name: "test_app_system_ext_jni_system_ext",
			sdk_version: "core_platform",
			jni_libs: ["libjni_system_ext"],
			system_ext_specific: true
		}

		android_app {
			name: "test_app_product_jni_product",
			sdk_version: "core_platform",
			jni_libs: ["libjni_product"],
			product_specific: true
		}

		android_app {
			name: "test_app_vendor_jni_odm",
			sdk_version: "core_platform",
			jni_libs: ["libjni_odm"],
			soc_specific: true
		}

		android_app {
			name: "test_app_odm_jni_vendor",
			sdk_version: "core_platform",
			jni_libs: ["libjni_vendor"],
			device_specific: true
		}
		android_app {
			name: "test_app_system_jni_multiple",
			privileged: true,
			platform_apis: true,
			certificate: "platform",
			jni_libs: ["libjni_system", "libjni_system_ext"],
		}
		android_app {
			name: "test_app_vendor_jni_multiple",
			sdk_version: "core_platform",
			jni_libs: ["libjni_odm", "libjni_vendor"],
			soc_specific: true
		}
		`
	arch := "arm64"
	ctx := android.GroupFixturePreparers(
		PrepareForTestWithJavaDefaultModules,
		cc.PrepareForTestWithCcDefaultModules,
		android.PrepareForTestWithAndroidMk,
		android.FixtureModifyConfig(func(config android.Config) {
			config.TestProductVariables.DeviceArch = proptools.StringPtr(arch)
		}),
	).
		RunTestWithBp(t, bp)
	testCases := []struct {
		name           string
		partitionNames []string
		partitionTags  []string
	}{
		{"test_app_system_jni_system", []string{"libjni_system"}, []string{""}},
		{"test_app_system_jni_system_ext", []string{"libjni_system_ext"}, []string{"_SYSTEM_EXT"}},
		{"test_app_system_ext_jni_system", []string{"libjni_system"}, []string{""}},
		{"test_app_system_ext_jni_system_ext", []string{"libjni_system_ext"}, []string{"_SYSTEM_EXT"}},
		{"test_app_product_jni_product", []string{"libjni_product"}, []string{"_PRODUCT"}},
		{"test_app_vendor_jni_odm", []string{"libjni_odm"}, []string{"_ODM"}},
		{"test_app_odm_jni_vendor", []string{"libjni_vendor"}, []string{"_VENDOR"}},
		{"test_app_system_jni_multiple", []string{"libjni_system", "libjni_system_ext"}, []string{"", "_SYSTEM_EXT"}},
		{"test_app_vendor_jni_multiple", []string{"libjni_odm", "libjni_vendor"}, []string{"_ODM", "_VENDOR"}},
	}

	for _, test := range testCases {
		t.Run(test.name, func(t *testing.T) {
			mod := ctx.ModuleForTests(test.name, "android_common").Module()
			entry := android.AndroidMkEntriesForTest(t, ctx.TestContext, mod)[0]
			for i := range test.partitionNames {
				actual := entry.EntryMap["LOCAL_SOONG_JNI_LIBS_PARTITION_"+arch][i]
				expected := test.partitionNames[i] + ":" + test.partitionTags[i]
				android.AssertStringEquals(t, "Expected and actual differ", expected, actual)
			}
		})
	}
}
Loading