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

Commit 8bce3818 authored by Jihoon Kang's avatar Jihoon Kang
Browse files

Remove the java property `exclude_static_libs`

All usages of the property has been converted to using select syntax.

Test: m nothing --no-skip-soong-tests
Bug: 368127911
Change-Id: I130f15d8524b56b6905c4dd3e7283731f437f88d
parent 46694ccb
Loading
Loading
Loading
Loading
+0 −9
Original line number Original line Diff line number Diff line
@@ -58,7 +58,6 @@ func init() {
	AddNeverAllowRules(createInitFirstStageRules()...)
	AddNeverAllowRules(createInitFirstStageRules()...)
	AddNeverAllowRules(createProhibitFrameworkAccessRules()...)
	AddNeverAllowRules(createProhibitFrameworkAccessRules()...)
	AddNeverAllowRules(createCcStubsRule())
	AddNeverAllowRules(createCcStubsRule())
	AddNeverAllowRules(createJavaExcludeStaticLibsRule())
	AddNeverAllowRules(createProhibitHeaderOnlyRule())
	AddNeverAllowRules(createProhibitHeaderOnlyRule())
	AddNeverAllowRules(createLimitNdkExportRule()...)
	AddNeverAllowRules(createLimitNdkExportRule()...)
}
}
@@ -253,14 +252,6 @@ func createProhibitFrameworkAccessRules() []Rule {
	}
	}
}
}


func createJavaExcludeStaticLibsRule() Rule {
	return NeverAllow().
		NotIn("build/soong", "libcore", "frameworks/base/api").
		ModuleType("java_library").
		WithMatcher("exclude_static_libs", isSetMatcherInstance).
		Because("exclude_static_libs property is only allowed for java modules defined in build/soong, libcore, and frameworks/base/api")
}

func createProhibitHeaderOnlyRule() Rule {
func createProhibitHeaderOnlyRule() Rule {
	return NeverAllow().
	return NeverAllow().
		Without("name", "framework-minus-apex-headers").
		Without("name", "framework-minus-apex-headers").
+0 −17
Original line number Original line Diff line number Diff line
@@ -344,23 +344,6 @@ var neverallowTests = []struct {
			`module "outside_allowed_list": violates neverallow`,
			`module "outside_allowed_list": violates neverallow`,
		},
		},
	},
	},
	// Test for the rule restricting use of exclude_static_libs
	{
		name: `"exclude_static_libs" outside allowed directory`,
		fs: map[string][]byte{
			"a/b/Android.bp": []byte(`
				java_library {
					name: "baz",
					exclude_static_libs: [
						"bar",
					],
				}
			`),
		},
		expectedErrors: []string{
			`exclude_static_libs property is only allowed for java modules defined in build/soong, libcore, and frameworks/base/api`,
		},
	},
	// Test for only allowing headers_only for framework-minus-apex-headers
	// Test for only allowing headers_only for framework-minus-apex-headers
	{
	{
		name: `"headers_only" outside framework-minus-apex-headers modules`,
		name: `"headers_only" outside framework-minus-apex-headers modules`,
+1 −4
Original line number Original line Diff line number Diff line
@@ -83,9 +83,6 @@ type CommonProperties struct {
	// list of java libraries that will be compiled into the resulting jar
	// list of java libraries that will be compiled into the resulting jar
	Static_libs proptools.Configurable[[]string] `android:"arch_variant"`
	Static_libs proptools.Configurable[[]string] `android:"arch_variant"`


	// list of java libraries that should not be used to build this module
	Exclude_static_libs []string `android:"arch_variant"`

	// manifest file to be included in resulting jar
	// manifest file to be included in resulting jar
	Manifest *string `android:"path"`
	Manifest *string `android:"path"`


@@ -827,7 +824,7 @@ func (j *Module) AvailableFor(what string) bool {
}
}


func (j *Module) staticLibs(ctx android.BaseModuleContext) []string {
func (j *Module) staticLibs(ctx android.BaseModuleContext) []string {
	return android.RemoveListFromList(j.properties.Static_libs.GetOrDefault(ctx, nil), j.properties.Exclude_static_libs)
	return j.properties.Static_libs.GetOrDefault(ctx, nil)
}
}


func (j *Module) deps(ctx android.BottomUpMutatorContext) {
func (j *Module) deps(ctx android.BottomUpMutatorContext) {
+0 −31
Original line number Original line Diff line number Diff line
@@ -2454,37 +2454,6 @@ java_test_host {
	}
	}
}
}


func TestJavaExcludeStaticLib(t *testing.T) {
	ctx, _ := testJava(t, `
	java_library {
		name: "bar",
	}
	java_library {
		name: "foo",
	}
	java_library {
		name: "baz",
		static_libs: [
			"foo",
			"bar",
		],
		exclude_static_libs: [
			"bar",
		],
	}
	`)

	// "bar" not included as dependency of "baz"
	CheckModuleDependencies(t, ctx, "baz", "android_common", []string{
		`core-lambda-stubs`,
		`ext`,
		`foo`,
		`framework`,
		`stable-core-platform-api-stubs-system-modules`,
		`stable.core.platform.api.stubs`,
	})
}

func TestJavaLibraryWithResourcesStem(t *testing.T) {
func TestJavaLibraryWithResourcesStem(t *testing.T) {
	ctx, _ := testJavaWithFS(t, `
	ctx, _ := testJavaWithFS(t, `
    java_library {
    java_library {