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

Commit d12979d0 authored by Jiyong Park's avatar Jiyong Park
Browse files

static rust binaries are also prohibited in APEXes

Also fixes a bug that the test runs for host APEXes like
com.android.art.host.

Bug: 185971244
Test: m
Test: build mainline_modules target on aosp-master
Change-Id: Ie2012adbf2f4eda5454d5eaa30f128fb1e20ad37
parent 192600a7
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -2490,11 +2490,17 @@ func (a *apexBundle) checkApexAvailability(ctx android.ModuleContext) {

// checkStaticExecutable ensures that executables in an APEX are not static.
func (a *apexBundle) checkStaticExecutables(ctx android.ModuleContext) {
	// No need to run this for host APEXes
	if ctx.Host() {
		return
	}

	ctx.VisitDirectDepsBlueprint(func(module blueprint.Module) {
		if ctx.OtherModuleDependencyTag(module) != executableTag {
			return
		}
		if cc, ok := module.(*cc.Module); ok && cc.StaticExecutable() {

		if l, ok := module.(cc.LinkableInterface); ok && l.StaticExecutable() {
			apex := a.ApexVariationName()
			exec := ctx.OtherModuleName(module)
			if isStaticExecutableAllowed(apex, exec) {
+24 −0
Original line number Diff line number Diff line
@@ -8208,6 +8208,30 @@ func TestProhibitStaticExecutable(t *testing.T) {
			system_shared_libs: [],
			stl: "none",
			apex_available: [ "myapex" ],
			min_sdk_version: "29",
		}
	`)

	testApexError(t, `executable mybin.rust is static`, `
		apex {
			name: "myapex",
			key: "myapex.key",
			binaries: ["mybin.rust"],
			min_sdk_version: "29",
		}

		apex_key {
			name: "myapex.key",
			public_key: "testkey.avbpubkey",
			private_key: "testkey.pem",
		}

		rust_binary {
			name: "mybin.rust",
			srcs: ["foo.rs"],
			static_executable: true,
			apex_available: ["myapex"],
			min_sdk_version: "29",
		}
	`)
}