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

Commit 788f6972 authored by Spandan Das's avatar Spandan Das Committed by Gerrit Code Review
Browse files

Merge changes Iab6efe78,I73affae8 into main

* changes:
  Register versioned sdk dependency in module_bp_java_deps.json
  Add IdeInfo for java module types
parents fbe57803 6e8bd1cc
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -2229,6 +2229,11 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps {
			deps.classpath = append(deps.classpath, sdkDep.jars...)
			deps.dexClasspath = append(deps.dexClasspath, sdkDep.jars...)
			deps.aidlPreprocess = sdkDep.aidl
			// Add the sdk module dependency to `compileDepNames`.
			// This ensures that the dependency is reported in `module_bp_java_deps.json`
			// TODO (b/358608607): Move this to decodeSdkDep
			sdkSpec := android.SdkContext(j).SdkVersion(ctx)
			j.compileDepNames = append(j.compileDepNames, fmt.Sprintf("sdk_%s_%s_android", sdkSpec.Kind.String(), sdkSpec.ApiLevel.String()))
		} else {
			deps.aidlPreprocess = sdkDep.aidl
		}
+8 −0
Original line number Diff line number Diff line
@@ -188,3 +188,11 @@ func (d *DeviceHostConverter) AndroidMk() android.AndroidMkData {
		},
	}
}

// implement the following interface for IDE completion.
var _ android.IDEInfo = (*DeviceHostConverter)(nil)

func (d *DeviceHostConverter) IDEInfo(ideInfo *android.IdeInfo) {
	ideInfo.Deps = append(ideInfo.Deps, d.properties.Libs...)
	ideInfo.Libs = append(ideInfo.Libs, d.properties.Libs...)
}
+20 −0
Original line number Diff line number Diff line
@@ -103,3 +103,23 @@ func TestCollectJavaLibraryPropertiesAddJarjarRules(t *testing.T) {
		t.Errorf("Library.IDEInfo() Jarjar_rules = %v, want %v", dpInfo.Jarjar_rules[0], expected)
	}
}

func TestCollectJavaLibraryLinkingAgainstVersionedSdk(t *testing.T) {
	ctx := android.GroupFixturePreparers(
		prepareForJavaTest,
		FixtureWithPrebuiltApis(map[string][]string{
			"29": {},
		})).RunTestWithBp(t,
		`
		java_library {
			name: "javalib",
			srcs: ["foo.java"],
			sdk_version: "29",
		}
	`)
	module := ctx.ModuleForTests("javalib", "android_common").Module().(*Library)
	dpInfo := &android.IdeInfo{}

	module.IDEInfo(dpInfo)
	android.AssertStringListContains(t, "IdeInfo.Deps should contain versioned sdk module", dpInfo.Deps, "sdk_public_29_android")
}
+8 −0
Original line number Diff line number Diff line
@@ -311,3 +311,11 @@ func (p *systemModulesInfoProperties) AddToPropertySet(ctx android.SdkMemberCont
		propertySet.AddPropertyWithTag("libs", p.Libs, ctx.SnapshotBuilder().SdkMemberReferencePropertyTag(true))
	}
}

// implement the following interface for IDE completion.
var _ android.IDEInfo = (*SystemModules)(nil)

func (s *SystemModules) IDEInfo(ideInfo *android.IdeInfo) {
	ideInfo.Deps = append(ideInfo.Deps, s.properties.Libs...)
	ideInfo.Libs = append(ideInfo.Libs, s.properties.Libs...)
}