Merge "Revert "Prohibit static executable in APEX"" am: 2fe71a5165
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1784474 Change-Id: Id7deac26695420aeaf2ec952326b3df9835d97c8
This commit is contained in:
30
apex/apex.go
30
apex/apex.go
@@ -1696,7 +1696,6 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
a.checkUpdatable(ctx)
|
a.checkUpdatable(ctx)
|
||||||
a.checkMinSdkVersion(ctx)
|
a.checkMinSdkVersion(ctx)
|
||||||
a.checkStaticLinkingToStubLibraries(ctx)
|
a.checkStaticLinkingToStubLibraries(ctx)
|
||||||
a.checkStaticExecutables(ctx)
|
|
||||||
if len(a.properties.Tests) > 0 && !a.testApex {
|
if len(a.properties.Tests) > 0 && !a.testApex {
|
||||||
ctx.PropertyErrorf("tests", "property allowed only in apex_test module type")
|
ctx.PropertyErrorf("tests", "property allowed only in apex_test module type")
|
||||||
return
|
return
|
||||||
@@ -2488,35 +2487,6 @@ func (a *apexBundle) checkApexAvailability(ctx android.ModuleContext) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// checkStaticExecutable ensures that executables in an APEX are not static.
|
|
||||||
func (a *apexBundle) checkStaticExecutables(ctx android.ModuleContext) {
|
|
||||||
ctx.VisitDirectDepsBlueprint(func(module blueprint.Module) {
|
|
||||||
if ctx.OtherModuleDependencyTag(module) != executableTag {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if cc, ok := module.(*cc.Module); ok && cc.StaticExecutable() {
|
|
||||||
apex := a.ApexVariationName()
|
|
||||||
exec := ctx.OtherModuleName(module)
|
|
||||||
if isStaticExecutableAllowed(apex, exec) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
ctx.ModuleErrorf("executable %s is static", ctx.OtherModuleName(module))
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// A small list of exceptions where static executables are allowed in APEXes.
|
|
||||||
func isStaticExecutableAllowed(apex string, exec string) bool {
|
|
||||||
m := map[string][]string{
|
|
||||||
"com.android.runtime": []string{
|
|
||||||
"linker",
|
|
||||||
"linkerconfig",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
execNames, ok := m[apex]
|
|
||||||
return ok && android.InList(exec, execNames)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Collect information for opening IDE project files in java/jdeps.go.
|
// Collect information for opening IDE project files in java/jdeps.go.
|
||||||
func (a *apexBundle) IDEInfo(dpInfo *android.IdeInfo) {
|
func (a *apexBundle) IDEInfo(dpInfo *android.IdeInfo) {
|
||||||
dpInfo.Deps = append(dpInfo.Deps, a.properties.Java_libs...)
|
dpInfo.Deps = append(dpInfo.Deps, a.properties.Java_libs...)
|
||||||
|
@@ -374,6 +374,7 @@ func TestBasicApex(t *testing.T) {
|
|||||||
symlinks: ["foo_link_"],
|
symlinks: ["foo_link_"],
|
||||||
symlink_preferred_arch: true,
|
symlink_preferred_arch: true,
|
||||||
system_shared_libs: [],
|
system_shared_libs: [],
|
||||||
|
static_executable: true,
|
||||||
stl: "none",
|
stl: "none",
|
||||||
apex_available: [ "myapex", "com.android.gki.*" ],
|
apex_available: [ "myapex", "com.android.gki.*" ],
|
||||||
}
|
}
|
||||||
@@ -2493,6 +2494,7 @@ func TestFilesInSubDir(t *testing.T) {
|
|||||||
srcs: ["mylib.cpp"],
|
srcs: ["mylib.cpp"],
|
||||||
relative_install_path: "foo/bar",
|
relative_install_path: "foo/bar",
|
||||||
system_shared_libs: [],
|
system_shared_libs: [],
|
||||||
|
static_executable: true,
|
||||||
stl: "none",
|
stl: "none",
|
||||||
apex_available: [ "myapex" ],
|
apex_available: [ "myapex" ],
|
||||||
}
|
}
|
||||||
@@ -2552,6 +2554,7 @@ func TestFilesInSubDirWhenNativeBridgeEnabled(t *testing.T) {
|
|||||||
name: "mybin",
|
name: "mybin",
|
||||||
relative_install_path: "foo/bar",
|
relative_install_path: "foo/bar",
|
||||||
system_shared_libs: [],
|
system_shared_libs: [],
|
||||||
|
static_executable: true,
|
||||||
stl: "none",
|
stl: "none",
|
||||||
apex_available: [ "myapex" ],
|
apex_available: [ "myapex" ],
|
||||||
native_bridge_supported: true,
|
native_bridge_supported: true,
|
||||||
@@ -8185,33 +8188,6 @@ func TestApexJavaCoverage(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestProhibitStaticExecutable(t *testing.T) {
|
|
||||||
testApexError(t, `executable mybin is static`, `
|
|
||||||
apex {
|
|
||||||
name: "myapex",
|
|
||||||
key: "myapex.key",
|
|
||||||
binaries: ["mybin"],
|
|
||||||
min_sdk_version: "29",
|
|
||||||
}
|
|
||||||
|
|
||||||
apex_key {
|
|
||||||
name: "myapex.key",
|
|
||||||
public_key: "testkey.avbpubkey",
|
|
||||||
private_key: "testkey.pem",
|
|
||||||
}
|
|
||||||
|
|
||||||
cc_binary {
|
|
||||||
name: "mybin",
|
|
||||||
srcs: ["mylib.cpp"],
|
|
||||||
relative_install_path: "foo/bar",
|
|
||||||
static_executable: true,
|
|
||||||
system_shared_libs: [],
|
|
||||||
stl: "none",
|
|
||||||
apex_available: [ "myapex" ],
|
|
||||||
}
|
|
||||||
`)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
os.Exit(m.Run())
|
os.Exit(m.Run())
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user