From 9357f4aeda5ff904984a7e03dec22d67b450784a Mon Sep 17 00:00:00 2001 From: Justin Yun Date: Wed, 28 Nov 2018 15:14:47 +0900 Subject: [PATCH] VNDK lib must not have `product_specific: true` VNDK libs are system defined libraries. They must not be product specific. Adding sanity check and a test to prevent setting `product_specific: true` on VNDK libs. Bug: 119575107 Test: building a vndk lib with 'product_specific: true,' must return error. Change-Id: Ie0326540a692573f076ee08baf5d2e2f09d1007e --- cc/cc.go | 6 ++++++ cc/cc_test.go | 15 +++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/cc/cc.go b/cc/cc.go index 4d06c6096..8a0bf71b7 100644 --- a/cc/cc.go +++ b/cc/cc.go @@ -1757,6 +1757,7 @@ func imageMutator(mctx android.BottomUpMutatorContext) { // Sanity check vendorSpecific := mctx.SocSpecific() || mctx.DeviceSpecific() + productSpecific := mctx.ProductSpecific() if m.VendorProperties.Vendor_available != nil && vendorSpecific { mctx.PropertyErrorf("vendor_available", @@ -1766,6 +1767,11 @@ func imageMutator(mctx android.BottomUpMutatorContext) { if vndkdep := m.vndkdep; vndkdep != nil { if vndkdep.isVndk() { + if productSpecific { + mctx.PropertyErrorf("product_specific", + "product_specific must not be true when `vndk: {enabled: true}`") + return + } if vendorSpecific { if !vndkdep.isVndkExt() { mctx.PropertyErrorf("vndk", diff --git a/cc/cc_test.go b/cc/cc_test.go index 3e78ec789..41f633a97 100644 --- a/cc/cc_test.go +++ b/cc/cc_test.go @@ -492,6 +492,21 @@ func TestVndkDepError(t *testing.T) { `) } +func TestVndkMustNotBeProductSpecific(t *testing.T) { + // Check whether an error is emitted when a vndk lib has 'product_specific: true'. + testCcError(t, "product_specific must not be true when `vndk: {enabled: true}`", ` + cc_library { + name: "libvndk", + product_specific: true, // Cause error + vendor_available: true, + vndk: { + enabled: true, + }, + nocrt: true, + } + `) +} + func TestVndkExt(t *testing.T) { // This test checks the VNDK-Ext properties. ctx := testCc(t, `