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

Commit 61d7def3 authored by Liz Kammer's avatar Liz Kammer Committed by Automerger Merge Worker
Browse files

Merge "Change openjdk9 specific props in bp2build/Soong" into main am:...

Merge "Change openjdk9 specific props in bp2build/Soong" into main am: c723757d am: b29d829e am: 91d416a7

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2776469



Change-Id: I9889092917e5eff47d39b62ad3cbeb6fa7390187
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 0332a212 91d416a7
Loading
Loading
Loading
Loading
+39 −0
Original line number Diff line number Diff line
@@ -192,6 +192,45 @@ func TestJavaLibraryJavaVersion(t *testing.T) {
	})
}

func TestJavaLibraryOpenjdk9(t *testing.T) {
	runJavaLibraryTestCase(t, Bp2buildTestCase{
		Blueprint: `java_library {
			name: "java-lib-1",
		srcs: ["a.java"],
		exclude_srcs: ["b.java"],
		javacflags: ["flag"],
		target: {
			android: {
				srcs: ["android.java"],
			},
		},
		openjdk9: {
			srcs: ["b.java", "foo.java"],
			javacflags: ["extraflag"],
		},
		sdk_version: "current",
}`,
		ExpectedBazelTargets: []string{
			MakeBazelTarget("java_library", "java-lib-1", AttrNameToString{
				"srcs": `[
        "a.java",
        "foo.java",
    ] + select({
        "//build/bazel_common_rules/platforms/os:android": ["android.java"],
        "//conditions:default": [],
    })`,
				"sdk_version": `"current"`,
				"javacopts": `[
        "flag",
        "extraflag",
    ]`,
			}),
			MakeNeverlinkDuplicateTarget("java_library", "java-lib-1"),
		},
	})

}

func TestJavaLibraryErrorproneEnabledManually(t *testing.T) {
	runJavaLibraryTestCaseWithRegistrationCtxFunc(t, Bp2buildTestCase{
		StubbedBuildDefinitions: []string{"plugin2"},
+8 −0
Original line number Diff line number Diff line
@@ -1024,7 +1024,12 @@ func (j *Module) collectJavacFlags(

	if flags.javaVersion.usesJavaModules() {
		javacFlags = append(javacFlags, j.properties.Openjdk9.Javacflags...)
	} else if len(j.properties.Openjdk9.Javacflags) > 0 {
		// java version defaults higher than openjdk 9, these conditionals should no longer be necessary
		ctx.PropertyErrorf("openjdk9.javacflags", "JDK version defaults to higher than 9")
	}

	if flags.javaVersion.usesJavaModules() {
		if j.properties.Patch_module != nil {
			// Manually specify build directory in case it is not under the repo root.
			// (javac doesn't seem to expand into symbolic links when searching for patch-module targets, so
@@ -1101,6 +1106,9 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath

	if flags.javaVersion.usesJavaModules() {
		j.properties.Srcs = append(j.properties.Srcs, j.properties.Openjdk9.Srcs...)
	} else if len(j.properties.Openjdk9.Javacflags) > 0 {
		// java version defaults higher than openjdk 9, these conditionals should no longer be necessary
		ctx.PropertyErrorf("openjdk9.srcs", "JDK version defaults to higher than 9")
	}

	srcFiles := android.PathsForModuleSrcExcludes(ctx, j.properties.Srcs, j.properties.Exclude_srcs)
+10 −4
Original line number Diff line number Diff line
@@ -2935,8 +2935,8 @@ func (m *Library) convertLibraryAttrsBp2Build(ctx android.Bp2buildMutatorContext

	archVariantProps := m.GetArchVariantProperties(ctx, &CommonProperties{})
	for axis, configToProps := range archVariantProps {
		for config, _props := range configToProps {
			if archProps, ok := _props.(*CommonProperties); ok {
		for config, p := range configToProps {
			if archProps, ok := p.(*CommonProperties); ok {
				archSrcs := android.BazelLabelForModuleSrcExcludes(ctx, archProps.Srcs, archProps.Exclude_srcs)
				srcs.SetSelectValue(axis, config, archSrcs)
				if archProps.Jarjar_rules != nil {
@@ -2946,6 +2946,11 @@ func (m *Library) convertLibraryAttrsBp2Build(ctx android.Bp2buildMutatorContext
			}
		}
	}
	srcs.Append(
		bazel.MakeLabelListAttribute(
			android.BazelLabelForModuleSrcExcludes(ctx,
				m.properties.Openjdk9.Srcs,
				m.properties.Exclude_srcs)))
	srcs.ResolveExcludes()

	javaSrcPartition := "java"
@@ -3029,8 +3034,9 @@ func (m *Library) convertLibraryAttrsBp2Build(ctx android.Bp2buildMutatorContext
	plugins := bazel.MakeLabelListAttribute(
		android.BazelLabelForModuleDeps(ctx, m.properties.Plugins),
	)
	if m.properties.Javacflags != nil {
		javacopts = bazel.MakeStringListAttribute(m.properties.Javacflags)
	if m.properties.Javacflags != nil || m.properties.Openjdk9.Javacflags != nil {
		javacopts = bazel.MakeStringListAttribute(
			append(append([]string{}, m.properties.Javacflags...), m.properties.Openjdk9.Javacflags...))
	}

	epEnabled := m.properties.Errorprone.Enabled