Loading android/config.go +4 −0 Original line number Diff line number Diff line Loading @@ -1272,6 +1272,10 @@ func (c *config) FlattenApex() bool { return Bool(c.productVariables.Flatten_apex) } func (c *config) CompressedApex() bool { return Bool(c.productVariables.CompressedApex) } func (c *config) EnforceSystemCertificate() bool { return Bool(c.productVariables.EnforceSystemCertificate) } Loading android/variable.go +3 −2 Original line number Diff line number Diff line Loading @@ -320,6 +320,7 @@ type productVariables struct { Exclude_draft_ndk_apis *bool `json:",omitempty"` Flatten_apex *bool `json:",omitempty"` CompressedApex *bool `json:",omitempty"` Aml_abis *bool `json:",omitempty"` DexpreoptGlobalConfig *string `json:",omitempty"` Loading apex/androidmk.go +5 −1 Original line number Diff line number Diff line Loading @@ -360,7 +360,11 @@ func (a *apexBundle) androidMkForType() android.AndroidMkData { fmt.Fprintln(w, "LOCAL_MODULE_CLASS := ETC") // do we need a new class? fmt.Fprintln(w, "LOCAL_PREBUILT_MODULE_FILE :=", a.outputFile.String()) fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", a.installDir.ToMakePath().String()) fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", name+apexType.suffix()) stemSuffix := apexType.suffix() if a.isCompressed { stemSuffix = ".capex" } fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", name+stemSuffix) fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE :=", !a.installable()) // Because apex writes .mk with Custom(), we need to write manually some common properties Loading apex/apex.go +8 −0 Original line number Diff line number Diff line Loading @@ -120,6 +120,12 @@ type apexBundleProperties struct { // Default: true. Installable *bool // Whether this APEX can be compressed or not. Setting this property to false means this // APEX will never be compressed. When set to true, APEX will be compressed if other // conditions, e.g, target device needs to support APEX compression, are also fulfilled. // Default: true. Compressible *bool // For native libraries and binaries, use the vendor variant instead of the core (platform) // variant. Default is false. DO NOT use this for APEXes that are installed to the system or // system_ext partition. Loading Loading @@ -354,6 +360,8 @@ type apexBundle struct { prebuiltFileToDelete string isCompressed bool // Path of API coverage generate file coverageOutputPath android.ModuleOutPath } Loading apex/apex_test.go +41 −0 Original line number Diff line number Diff line Loading @@ -346,6 +346,13 @@ func ensureListEmpty(t *testing.T, result []string) { } } func ensureListNotEmpty(t *testing.T, result []string) { t.Helper() if len(result) == 0 { t.Errorf("%q is expected to be not empty", result) } } // Minimal test func TestBasicApex(t *testing.T) { ctx, config := testApex(t, ` Loading Loading @@ -6186,6 +6193,40 @@ func TestNonPreferredPrebuiltDependency(t *testing.T) { `) } func TestCompressedApex(t *testing.T) { ctx, config := testApex(t, ` apex { name: "myapex", key: "myapex.key", compressible: true, } apex_key { name: "myapex.key", public_key: "testkey.avbpubkey", private_key: "testkey.pem", } `, func(fs map[string][]byte, config android.Config) { config.TestProductVariables.CompressedApex = proptools.BoolPtr(true) }) compressRule := ctx.ModuleForTests("myapex", "android_common_myapex_image").Rule("compressRule") ensureContains(t, compressRule.Output.String(), "myapex.capex.unsigned") signApkRule := ctx.ModuleForTests("myapex", "android_common_myapex_image").Description("sign compressedApex") ensureEquals(t, signApkRule.Input.String(), compressRule.Output.String()) // Make sure output of bundle is .capex ab := ctx.ModuleForTests("myapex", "android_common_myapex_image").Module().(*apexBundle) ensureContains(t, ab.outputFile.String(), "myapex.capex") // Verify android.mk rules data := android.AndroidMkDataForTest(t, config, "", ab) var builder strings.Builder data.Custom(&builder, ab.BaseModuleName(), "TARGET_", "", data) androidMk := builder.String() ensureContains(t, androidMk, "LOCAL_MODULE_STEM := myapex.capex\n") } func TestPreferredPrebuiltSharedLibDep(t *testing.T) { ctx, config := testApex(t, ` apex { Loading Loading
android/config.go +4 −0 Original line number Diff line number Diff line Loading @@ -1272,6 +1272,10 @@ func (c *config) FlattenApex() bool { return Bool(c.productVariables.Flatten_apex) } func (c *config) CompressedApex() bool { return Bool(c.productVariables.CompressedApex) } func (c *config) EnforceSystemCertificate() bool { return Bool(c.productVariables.EnforceSystemCertificate) } Loading
android/variable.go +3 −2 Original line number Diff line number Diff line Loading @@ -320,6 +320,7 @@ type productVariables struct { Exclude_draft_ndk_apis *bool `json:",omitempty"` Flatten_apex *bool `json:",omitempty"` CompressedApex *bool `json:",omitempty"` Aml_abis *bool `json:",omitempty"` DexpreoptGlobalConfig *string `json:",omitempty"` Loading
apex/androidmk.go +5 −1 Original line number Diff line number Diff line Loading @@ -360,7 +360,11 @@ func (a *apexBundle) androidMkForType() android.AndroidMkData { fmt.Fprintln(w, "LOCAL_MODULE_CLASS := ETC") // do we need a new class? fmt.Fprintln(w, "LOCAL_PREBUILT_MODULE_FILE :=", a.outputFile.String()) fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", a.installDir.ToMakePath().String()) fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", name+apexType.suffix()) stemSuffix := apexType.suffix() if a.isCompressed { stemSuffix = ".capex" } fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", name+stemSuffix) fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE :=", !a.installable()) // Because apex writes .mk with Custom(), we need to write manually some common properties Loading
apex/apex.go +8 −0 Original line number Diff line number Diff line Loading @@ -120,6 +120,12 @@ type apexBundleProperties struct { // Default: true. Installable *bool // Whether this APEX can be compressed or not. Setting this property to false means this // APEX will never be compressed. When set to true, APEX will be compressed if other // conditions, e.g, target device needs to support APEX compression, are also fulfilled. // Default: true. Compressible *bool // For native libraries and binaries, use the vendor variant instead of the core (platform) // variant. Default is false. DO NOT use this for APEXes that are installed to the system or // system_ext partition. Loading Loading @@ -354,6 +360,8 @@ type apexBundle struct { prebuiltFileToDelete string isCompressed bool // Path of API coverage generate file coverageOutputPath android.ModuleOutPath } Loading
apex/apex_test.go +41 −0 Original line number Diff line number Diff line Loading @@ -346,6 +346,13 @@ func ensureListEmpty(t *testing.T, result []string) { } } func ensureListNotEmpty(t *testing.T, result []string) { t.Helper() if len(result) == 0 { t.Errorf("%q is expected to be not empty", result) } } // Minimal test func TestBasicApex(t *testing.T) { ctx, config := testApex(t, ` Loading Loading @@ -6186,6 +6193,40 @@ func TestNonPreferredPrebuiltDependency(t *testing.T) { `) } func TestCompressedApex(t *testing.T) { ctx, config := testApex(t, ` apex { name: "myapex", key: "myapex.key", compressible: true, } apex_key { name: "myapex.key", public_key: "testkey.avbpubkey", private_key: "testkey.pem", } `, func(fs map[string][]byte, config android.Config) { config.TestProductVariables.CompressedApex = proptools.BoolPtr(true) }) compressRule := ctx.ModuleForTests("myapex", "android_common_myapex_image").Rule("compressRule") ensureContains(t, compressRule.Output.String(), "myapex.capex.unsigned") signApkRule := ctx.ModuleForTests("myapex", "android_common_myapex_image").Description("sign compressedApex") ensureEquals(t, signApkRule.Input.String(), compressRule.Output.String()) // Make sure output of bundle is .capex ab := ctx.ModuleForTests("myapex", "android_common_myapex_image").Module().(*apexBundle) ensureContains(t, ab.outputFile.String(), "myapex.capex") // Verify android.mk rules data := android.AndroidMkDataForTest(t, config, "", ab) var builder strings.Builder data.Custom(&builder, ab.BaseModuleName(), "TARGET_", "", data) androidMk := builder.String() ensureContains(t, androidMk, "LOCAL_MODULE_STEM := myapex.capex\n") } func TestPreferredPrebuiltSharedLibDep(t *testing.T) { ctx, config := testApex(t, ` apex { Loading