rust: Emit android vndk cfg flag.

Pass an "android_vndk" cfg flag that indicates this code
targets the vndk. This can be useful in instances where code
might need to behave differently.

This also includes a fix to make sure our vendor Soong tests
are correctly configured.

Bug: 179907868
Test: Soong tests pass.
Test: Example module emits new cfg flags.
Change-Id: I01cdf91f6f9d42cd8a759266d5170479664bf4bc
This commit is contained in:
Ivan Lozano
2021-02-12 09:55:06 -05:00
parent 81314ff2e6
commit f76cdf7c20
3 changed files with 43 additions and 3 deletions

View File

@@ -64,6 +64,14 @@ func testRust(t *testing.T, bp string) *android.TestContext {
return tctx.parse(t)
}
func testRustVndk(t *testing.T, bp string) *android.TestContext {
tctx := newTestRustCtx(t, bp)
tctx.useMockedFs()
tctx.generateConfig()
tctx.setVndk(t)
return tctx.parse(t)
}
// testRustCov returns a TestContext in which a basic environment has been
// setup. This environment explicitly enables coverage.
func testRustCov(t *testing.T, bp string) *android.TestContext {
@@ -140,6 +148,15 @@ func (tctx *testRustCtx) enableCoverage(t *testing.T) {
tctx.config.TestProductVariables.NativeCoveragePaths = []string{"*"}
}
func (tctx *testRustCtx) setVndk(t *testing.T) {
if tctx.config == nil {
t.Fatalf("tctx.config not been generated yet. Please call generateConfig first.")
}
tctx.config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
tctx.config.TestProductVariables.ProductVndkVersion = StringPtr("current")
tctx.config.TestProductVariables.Platform_vndk_version = StringPtr("VER")
}
// parse validates the configuration and parses the Blueprint file. It returns
// a TestContext which can be used to retrieve the generated modules via
// ModuleForTests.